Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

The "unreliable" in UDP doesn't mean "expect this to fail", it just means "things are not guaranteed to arrive, and if they do they might not arrive in the right order".

So "make sure you can handle (where "handle" could simply be "safely ignore") failed/unordered transmission" rather than "expect failed/unordered transmission".

If you can't cope with or ignore missed/unordered reception, wrap your comms in a stream based protocol (TCP, one of the other existing ones, or some contraption of your own) that manages reordering and retransmission as needed.

Maybe there is a better word to cover that then "unreliable" which sounds quite definite, but I can't think of one off the top of my head.



Arguably "expect this to fail X% of the time" is a more robust approach - because in-order delivery or zero-loss situations are then simply best cases that "just work".

But you can not make work what you can't test.

So anyone embarking on making their own transport protocol should test how their app works with various amounts of packet loss (1%, 5% and 20% are three reasonable marks to try which may happen in real world - especially in the wireless links case), as well as jitter, and variable delay.

To do such testing, it's handy to use a Linux module called "netem" which allows to simulate the delay, jitter and loss:

   http://www.linuxfoundation.org/collaborate/workgroups/networking/netem
   https://calomel.org/network_loss_emulation.html


You also need vary the pattern of packet loss as well as the overall frequency: You could lose 20% of your packets over a short period in roughly even distribution (perhaps due to "constant" background noise), or you could lose a sequence of packets amounting to that much (due to a sudden burst of interference on a particular hop of a route).




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: