It’s known as the IP of the transport layer, or “IP between applications.”
Like IP, it is:
UDP is used for applications that just send messages back and forth, not streams.
There are no sequence numbers. If an application wants to sequence messages, then the application has to put sequence numbers in the packet body and the application has to do the reordering and re-transmission.
Applications that might use UDP:
If you need streams, reliability, and all that, use TCP instead.
So why might UDP be good? Well, it’s really fast as there’s very little overhead.
UDP is a transport layer protocol, so it only cares about port numbers, not about networks and hosts. As a message-based protocol, there is no notion of sequence numbers, fragments, or really anything else. The packet format is just this:
0 0 | 0 1 | 0 2 | 0 3 | 0 4 | 0 5 | 0 6 | 0 7 | 0 8 | 0 9 | 1 0 | 1 1 | 1 2 | 1 3 | 1 4 | 1 5 | 1 6 | 1 7 | 1 8 | 1 9 | 2 0 | 2 1 | 2 2 | 2 3 | 2 4 | 2 5 | 2 6 | 2 7 | 2 8 | 2 9 | 3 0 | 3 1 |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Source Port | Destination Port | ||||||||||||||||||||||||||||||
Message Length | Checksum | ||||||||||||||||||||||||||||||
Body |
Discussion:
Choose message sizes wiselyAlthough messages can be up to 64K in size, if you make them too big they will get fragmented at the IP layer. Remember that IP fragments in order to fit its packets in the source and destination’s networks’ frames, so generally keep the UDP messages around 1400-1450 bytes (leaving room for the IP header, etc.)
UDP applications may be client-server or peer-to-peer.
TODO
TODO
TODO
We’ve covered: