My program use UdpClient to try to receive 27 responses from 27 hosts. The size of the response is 10KB. My broadband incoming bandwidth is 150KB/s.
The 27 responses are sent from the hosts almost at the same time and for every 10 secs.
However, I can only receive 8 – 17 responses each time. The number of responses that I can receive is quite dynamic but within the range.
Can anyone tell me why? why can’t I receive all?
I understand UDP is not reliable. but I tried receiving 5 – 10 responses at the same time, it worked. I guess the network links are not so bad.
The code is very simple. ON the 27 hosts, I just use UdpClient to send 10KB to my machine.
On my machine, I have one UdpClient receive datagrams. Each time I get a data, I create a thread to handle it (basically handling it means just print out “I received 10KB”, but it runs in a thread).
listener = new UDPListener(Port);
listener.Start();
while (true) {
try {
UDPContext context = listener.Accept();
ThreadPool.QueueUserWorkItem(new WaitCallback(HandleMessage), context);
} catch (Exception) { }
}
If I reduce the size of the response down to 3KB, the case gets much better that roughly 25 responses can be received.
Any more idea? UDP buffer problems???
As you said yourself, UDP is not reliable. So chances are packets are dropped somewhere.
Note that packet drop is caused just as much by overloaded switches/routers/network cards as by bad links. If someone sends you 27 10Kb responses “simultaneously”. it might very well be that the buffers of your network card, or a nearby switch are full, and packets get dropped.
Until you have some code to show, there’s probably not much else to say.