IP Header Fields in the UDP Pseudo-Header
The UDP pseudo-header is a conceptual data structure used exclusively during the calculation of the UDP checksum. Rather than transmitting this data across the network, both the sender and receiver construct it in memory to verify that a datagram has reached its correct destination without corruption. This article provides a straightforward breakdown of the specific Internet Protocol (IP) header fields borrowed to construct the UDP pseudo-header for both IPv4 and IPv6 networks.
Purpose of the Pseudo-Header
The User Datagram Protocol (UDP) operates at the transport layer, while the Internet Protocol operates at the network layer. To protect against misrouted packets—such as those delivered to the wrong host due to routing table corruption or bit errors—the UDP checksum includes key addressing and protocol information from the IP header.
IPv4 Header Fields in the UDP Pseudo-Header
When calculating the UDP checksum over an IPv4 network, the pseudo-header is 12 bytes (96 bits) long and includes the following fields directly from the IPv4 header:
- Source IP Address (32 bits / 4 bytes): Copied directly from the IPv4 header’s Source Address field, representing the sender’s IP address.
- Destination IP Address (32 bits / 4 bytes): Copied directly from the IPv4 header’s Destination Address field, representing the recipient’s IP address.
- Protocol (8 bits / 1 byte): Copied directly from
the IPv4 header’s Protocol field. For UDP, this value is fixed at
17(or0x11in hexadecimal).
Additional IPv4 Pseudo-Header Fields
Along with the fields taken from the IPv4 header, the pseudo-header contains: * Zero Padding (8 bits / 1 byte): A byte set entirely to zeros placed immediately before the Protocol field to align the structure to 16-bit boundaries. * UDP Length (16 bits / 2 bytes): The total length of the UDP header plus the UDP data (copied from the UDP header itself, not the IPv4 Total Length field).
IPv6 Header Fields in the UDP Pseudo-Header
In IPv6, calculating the UDP checksum is mandatory. The IPv6 pseudo-header is 40 bytes long and extracts the following fields from the IPv6 base and extension headers:
- Source IPv6 Address (128 bits / 16 bytes): The original source IP address. If a Routing extension header is present, this reflects the final source.
- Destination IPv6 Address (128 bits / 16 bytes): The final destination IP address. If a Routing extension header is present, this is updated to reflect the final destination rather than an intermediate hop.
- Next Header (8 bits / 1 byte): Copied from the
Next Headerfield in the IPv6 header (or the preceding extension header). For UDP, this value is17(0x11).
Additional IPv6 Pseudo-Header Fields
- UDP Length (32 bits / 4 bytes): The total length of the UDP header and its payload, represented as a 32-bit integer.
- Zero Padding (24 bits / 3 bytes): A 3-byte block of zeros placed before the 8-bit Next Header field to ensure 32-bit alignment.
Summary
The IP fields included in the UDP pseudo-header are the Source IP Address, the Destination IP Address, and the Protocol / Next Header field. These network-layer fields, combined with the transport layer’s UDP Length, ensure that any error in addressing or transport identification invalidates the checksum and causes the corrupted datagram to be discarded.