Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Improving UDP reliability

I am building a small UDP based server. the server is based on .Net and uses the Socket class it self. I'm using completion ports through ReceiveMessageFromAsync, and the async send.

My problem is I'm loosing around 5%-10% of my traffic. Now i understand this is normal, but is there any way of improving this statistic?

like image 381
AK_ Avatar asked May 04 '26 09:05

AK_


2 Answers

You might want to look at the answers to this question before rolling your own reliability layer on top of UDP... What do you use when you need reliable UDP?

Alternatively you can try and increase the amount of data that gets through by making the socket's send and recv buffers as large as possible by setting the appropriate socket options before you start to recv.

like image 148
Len Holgate Avatar answered May 05 '26 23:05

Len Holgate


Ensure that you do not send UDP datagrams larger than the path MTU (which is typically no more than ~1400 bytes, and sometimes less). Such packets will be fragmented into multiple IP packets and reassembled at the destination - and if any one of those fragments is lost, then the entire UDP datagram will be discarded.

This has an amplification effect on the packet loss rate - this table shows how the UDP datagram loss rate goes up dramatically as the number of fragments used to carry it increases:

Underlying Fragment Loss Rate: 1.00%

Fragments   UDP Datagram Loss Rate
--------------------------------------
1           1.00%
2           1.99%
3           2.97%
4           3.94%
5           4.90%
6           5.85%
7           6.79%
8           7.73%
9           8.65%
10          9.56%
15          13.99%
20          18.21%
30          26.03%
40          33.10%
like image 44
caf Avatar answered May 05 '26 21:05

caf



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!