Octet

What is in a UDP header, and what does UDP leave to the application?

Show the answer

Say this first

Eight bytes: source port, destination port, length (header plus data) and checksum, 16 bits each. UDP leaves everything else to the application: no handshake, no acknowledgment, no retransmission, no ordering, no flow control and no congestion control. The checksum is optional in IPv4 (zero means none) and mandatory in IPv6, apart from narrow tunnel exceptions.

Go deeper

Fields

FieldBitsNotes
Source port16May be 0 if no reply is expected, rarely seen
Destination port16Selects the application
Length16Header plus payload, minimum 8
Checksum16Covers a pseudo-header, the header and the data

Sizes

The largest UDP payload over IPv4 is 65,507 bytes (65,535 minus 20 for IP and 8 for UDP). Anything over the path MTU is fragmented by IP, and losing one fragment loses the whole datagram. That is why DNS over UDP now aims for answers of about 1,232 bytes and QUIC sizes its own packets.

What runs on UDP

DNS 53, DHCP 67 and 68, TFTP 69, NTP 123, SNMP 161 and 162, syslog 514, IKE 500 and NAT-T 4500, RIP 520, BFD 3784, VXLAN 4789, QUIC and HTTP/3 on 443, RTP media on dynamic ports.

What the application must add

Timeouts and retries (DNS, TFTP), sequence numbers (RTP), its own rate control (RFC 8085 sets out guidelines for UDP applications), and keepalives to hold NAT and firewall state open.

Traps

  • Saying UDP has no checksum. It has one; IPv4 lets it be zero, IPv6 normally requires it.
How did you do?Book 5.1 Simple Demultiplexor (UDP)