Can UDP retransmit lost data?

edwinNosh picture edwinNosh · Mar 30, 2011 · Viewed 11.8k times · Source

I know the protocol doesn't support this but is it common for clients that require some level of reliability to build into their application a method for requesting retransmission of a packet if found to be corrupt?

Answer

Damon picture Damon · Mar 30, 2011

It is common for clients to implement reliability on top of UDP if they need reliability (or sometimes just some reliability) but not any of the other things that TCP offers, for example strict in-order delivery, and if they want, at the same time, low latency (or multicast, where it works).

In general, you will only want to use reliable UDP if there are urgent reasons (very low latency and high speed needed, e.g. for a twitch game). In every "normal" case, simply using TCP will serve you equally well or better.
Also note that it is easy to implement your own stack on top of UDP that performs worse than TCP.

See enet for an example of a library that implements reliability (and some other features) on top of UDP (Raknet or HawkNL would be other examples).