Why can't I get all UDP packets?

My program uses UdpClient to try to get 27 responses from 27 hosts. The response size is 10 KB. My broadband inbound bandwidth is 150KB / s.

27 responses are sent from hosts almost simultaneously and every 10 seconds.

However, I can only get 8 to 17 responses each time. The number of answers I can get is quite dynamic, but within the range.

Can someone tell me why? why can't i get everything?

I understand that UDP is not reliable. but I tried to get 5 to 10 answers at the same time, it worked. I think network links are not so bad.

The code is very simple. On 27 hosts, I just use UdpClient to send 10K to my machine.

On my machine, I have one UdpClient that receives datagrams. Every time I get data, I create a stream to process it (basically processing means just printing "I got 10 KB", but it works in the stream).

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 response size to 3 KB, the situation will be much better than about 25 answers.

Any other idea? UDP buffer issues

+4
source share
3 answers

As you said yourself, UDP is not reliable. Thus, the likelihood that the packets fell somewhere.

Note that packet drops are caused by overloaded switches / routers / network cards as well as bad links. If someone sends you 27 responses to 10Kb "at the same time". it is possible that the buffers on your network card or the nearest switch are full and packets fall.

As long as you have some code to display, most likely there is nothing to say.

+5
source

10kb packages are probably fragmented. If even one of the fragments is removed, the package cannot be reassembled. Depending on your network, 3kb packets may not be fragmented, but in any case they will be fragmented less, increasing the chances of them passing. You can run the PMTU discovery tool to find out the largest packet size supported by links.

+1
source

I think UDP is not reliable at all, so I think this problem occurs because you get a bottleneck (how typical is the call) UDP sends everything except disordered and without checking so I think you should to create a view of this protocol using UDP, I say that I already made this key is trying to send all packets with identifier. thus, the receiver knows which packets are missing and can request them from the transmitter, for example, TCP usually executes

0
source

Source: https://habr.com/ru/post/1303470/


All Articles