UDP datagrams
One send, one datagram
UDP transports separate messages called datagrams. Unlike TCP, the transport does not combine consecutive messages into a single byte stream. An ordinary UDP receive operation obtains one datagram, subject to buffer and API limits; an undersized buffer can truncate it. Sending a datagram does not require the TCP-style handshake. For a live status display, a new reading may matter more than an old missing one.
Read the header and calculate length
The base UDP header has four 16-bit fields: source port, destination port, length and checksum. The checksum helps detect corruption; it is not cryptographic authentication. In the ordinary example below, with no UDP transport options or IPv6 jumbogram, a 12-byte payload gives UDP length 20. With a 20-byte IPv4 header the IP packet is 40 bytes. A 1500-byte path MTU permits 1472 bytes of UDP user data in this same IPv4 layout without IP fragmentation. With a 40-byte IPv6 base header and no extensions, the corresponding value is 1452. Do not assume every path has MTU 1500.
UDP header = 8 BUser data = 12 BUDP length = 20 BIPv4 header = 20 BIP length = 40 BLoss, duplicates and ordering
UDP itself does not recover lost messages, suppress all duplicates, or put datagrams back in sending order. In this fictional status feed, the receiver observes 41, 43, 43, 42. A display that only wants the latest numbered reading can accept 41 and 43, then ignore the repeated 43 and older 42. The sequence numbers and that policy belong to the application, not UDP. If every message matters, the application needs a suitable reliable protocol rather than merely assuming retries are safe.
Sent: 41 42 43Received: 41 43 43 42Display: 41 43Choosing a transport
UDP has a smaller base header and no built-in connection setup, but this does not guarantee lower application latency. Loss, congestion, encryption and application-level setup or recovery can change the result. UDP applications must handle congestion responsibly and avoid oversize datagrams; where reliability is needed, use an appropriate established protocol. For example, a file transfer can use TCP, while a live measurement feed might discard outdated samples over UDP. QUIC is an example of a protocol built over UDP that supplies additional transport behavior, including reliable streams.
Check the assumptions
The eight-byte base header remains the starting point. RFC 9868 defines optional transport extensions using space beyond ordinary UDP data, and IPv6 jumbograms have special length handling. Our arithmetic excludes those features; their existence does not establish support on a particular operating system. Practice: for a 1200-byte path MTU and a 20-byte IPv4 header, calculate the ordinary UDP data budget: 1200 − 20 − 8 = 1172 bytes.
Check Your Understanding
Solidify your learning with the interactive assessment directly below this lesson.
Concept Quiz & Questions
UDP datagrams — knowledge check
Interpret fictional transport observations and calculate expected results.
How many bytes does the base UDP header contain?
A normal UDP datagram contains 30 data bytes. What is its UDP length?
UDP datagrams 7 and 9 arrive, but 8 is absent. What does UDP itself promise?
A live display needs only its newest reading. Which design can fit?
An ordinary IPv6 packet has MTU budget 1280 B and no extension headers. How much UDP data fits without fragmentation?