Transport, chapter 20 of 36
UDP: Eight Bytes of Header
Since 1980 nobody has found anything to fix in RFC 768, three pages that still define UDP.
Before the SYN, the laptop sends the ISP's resolver a 75-byte frame. Behind the IPv4 header sit eight bytes of transport header (two port numbers, a length, and a checksum) and then a question about www.example.net. No handshake announced the frame and nothing will acknowledge it. If it is lost, the only thing that notices is a timer in the resolver library, which asks again.
- 1980
- the date of RFC 768, three pages by Jon Postel that were never obsoleted
- 0x8920
- our query's checksum, which also covers 12 octets that never cross the wire
- 51,200
- amplification that Cloudflare reported in February 2018, from 15-byte memcached requests to responses of about 750 kB
Twelve octets that never travel
The checksum of our DNS query, summed in 16-bit words with the field taken as zero, once at the sender and once at the receiver. Change the network, the sender, the receiving host, or one octet of the message, and watch the verdict.
Why has RFC 768 never been replaced?
RFC 768 is three pages by Jon Postel, dated 28 August 1980, and nobody has found anything in it to fix. When the host requirements of 1989 went through the protocols one by one, the UDP walk-through took one sentence: "There are no known errors in the specification of UDP" (RFC 1122, Section 4.1.2).
The debugging had happened before the RFC. IEN 88 of May 1979 still gave the minimum length as four for a header of eight octets, and of the IP header its checksum covered only the two addresses. RFC 768 corrected the minimum to eight and added the protocol and the UDP length to the pseudo-header.
What does the pseudo-header protect?
The checksum covers twelve octets that never cross the wire, the eight octets of header, and the data. The pseudo-header carries both addresses and the protocol number, which RFC 768 justifies as "protection against misrouted datagrams". A datagram that reaches the wrong host fails the check. The length enters the sum twice, and RFC 8085, Section 3.4 adds that it catches truncation and padding.
IPv4 already has a header checksum, but every router writes a new one, and a router that computes it afresh hides a header it damaged itself. The price is a layer violation: a NAT that rewrites an address must patch the UDP checksum as well.
May a sender switch the checksum off?
Over IPv4 it may, because RFC 768 reserves the zero value for a sender that generated no checksum. RFC 1122, Section 4.1.3.4 tightened this in 1989. Generation must be on by default, and a datagram with a nonzero, wrong checksum must be discarded silently.
IPv6 has no header checksum, so a receiver must discard a datagram whose UDP checksum is zero (RFC 8200, Section 8.1). Tunnel builders objected that an outer checksum over packets with their own inner checksums looked like "an unwarranted burden" (RFC 6935, Section 1). RFC 6935 and RFC 6936 (April 2013) allow a zero-checksum mode for tunnel encapsulations, enabled per port and never globally.
How did the laptop pick port 53124?
An off-path attacker who wants to inject a forged answer must match the five values of the transport tuple, and of those the client's port is the only one to guess (RFC 6056, Section 1). A DNS answer must also match the 16-bit query ID and the question (RFC 5452, Section 9.1).
If the resolver library leaves the choice to the kernel, Linux binds the socket when the library first calls connect() or sends, before it looks at the destination, and udp_lib_get_port() starts at a random point in 32768 to 60999 [Linux2026]. Port 53124 is then one of 28,232 equally likely values, about 14.8 bits. Chromium's own DNS client binds a random port from 1024 to 65535 instead [Chromium2026].
What stops a datagram from lying about its sender?
UDP has no defense of its own, and a server answers the source address of the request. A request with a forged source sends the reply to the owner of that address, and if the reply is larger than the request, the attacker has an amplifier. In 2014 Christian Rossow measured an average factor of 556.9 for NTP [Rossow2014].
RFC 4732, Section 3.2 draws the design rule: no significantly larger responses without a handshake that validates the client's address. The transport side answers with that handshake. QUIC sends at most three times the bytes it has received to an unvalidated address (RFC 9000, Section 8).
Can eight bytes grow options?
RFC 9868 (October 2025), by Joe Touch, finds the room in a redundancy. The UDP length usually equals the IP payload length, but nothing requires it to. If it is smaller, the octets between the end of the UDP data and the end of the IP payload form a surplus area for options (RFC 9868, Section 7).
A legacy receiver must deliver exactly the UDP data and ignore the rest, and Linux does: udp_rcv() trims the packet to the UDP length before it verifies the checksum [Linux2026]. As for why UDP has its own length field at all, RFC 9868, Section 4 says that "the real reason remains unknown".
The book keeps asking
This chapter has 5,733 words and 12 questions. These 6 are answered only in the book and the audiobook.
- What does the laptop send?
- What happened to UDP-Lite?
- Who decides what port 53 means?
- Why do new transports travel inside UDP?
- How does an application read the ECN bits?
- What does a datagram cost the kernel?
Open the sources
- RFC 768 User Datagram Protocol
- RFC 1122 Requirements for Internet Hosts - Communication Layers
- RFC 6335 Internet Assigned Numbers Authority (IANA) Procedures for the Management of the Service Name and Transport Protocol Port Number Registry
- RFC 6056 Recommendations for Transport-Protocol Port Randomization
- RFC 8085 UDP Usage Guidelines
- RFC 6936 Applicability Statement for the Use of IPv6 UDP Datagrams with Zero Checksums
- RFC 9868 Transport Options for UDP
- [Linux2026] Linux kernel source tree, v7.4-rc1 (commit 6628e7d4c6b2, 1 November 2026)
All 51 documents this chapter cites, each with a link to its publisher and a copy kept here.
