Can UDP datagrams arrive out of order, duplicated, or not at all?
Yes to all three. UDP makes no promises about order, duplicates, or delivery. Each datagram is independent and can take a different route, so the application must tolerate or handle these cases.
Explain it simply
Throwing five tennis balls over a wall one after another. Some may land out of order, one may get stuck in a tree, and a ball could bounce back and be picked up twice. UDP does not catch them for you.
Example
Sender sends datagrams: A B C D
Receiver may see: A C B D (reordered)
A B D (C lost)
A B B C D (B duplicated)Datagram boundaries are preserved, however. If the sender sends one 200-byte datagram, the receiver gets one 200-byte datagram, never two 100-byte halves or two merged. That differs from TCP, which is a byte stream with no message boundaries.
Real-time apps handle this by tagging data with sequence numbers or timestamps (RTP does this for voice and video), keeping a short jitter buffer to reorder, and dropping anything too late to play.
What to say in the interview
"UDP gives no ordering, no duplicate suppression and no delivery guarantee, but it does keep message boundaries. Applications deal with this using sequence numbers, timestamps and jitter buffers."
Common mistakes
- Assuming local networks never reorder or drop UDP. They do under load.