views:

359

answers:

3

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???

+5  A: 

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.

nos
Ganesh R.
Thanks for your reply. Is it possible that some kind of buffer is not big enough to hold the data? or the data is wiped before I can handle the data in time?
Jack
@Jack Yes, that's what Im saying :) Those buffers could be in your network card, in the windows kernel, or in a nearby ethernet switch. In any case there's little you can do about it - even if you would increase the UDP buffers, theres no guarantee whatsoever that it will help, and it will not help if it's the routers or switches that drop the packets.
nos
+1  A: 

The 10kb packets are probably being fragmented. If even one of the fragments is dropped, the packet can't be reassembled. Depending on your network, the 3kb packets may not be fragmented, but in any case they would be fragmented less, increasing the chances that they make it through. You could run a PMTU discovery tool to find out the largest packet size the links support.

Hugh Brackett
A: 

sorry guys i just screw up

i was trying to comment in another post about guitar effects.

talking about this issue i think that UDP is not reliable at all, so i think this trouble is because you are getting a bottleneck (how tipically it is call) UDP sends everything but disordered and without check so i think you must create kind of this protocol using UDP, i tell this cause i already made it the key is trying to send all the packages with an ID. this way the receiver knows wich packages are missing and could ask for them to the transmitter,

like TCP normally does

in letto tutti sono bello