Minimum Value for the UDP Length Field
The minimum possible value for the User Datagram Protocol (UDP) Length field is 8. This article explains the composition of the UDP header, why the length field cannot legally drop below 8 bytes, and how network stacks handle packets that specify invalid length values.
Understanding the UDP Length Field
The UDP Length field is a 16-bit field in the standard UDP header that specifies the total size of the UDP datagram in bytes. This measurement includes both the UDP header itself and the encapsulated data payload.
Why the Minimum Value is 8
A standard UDP header consists of four mandatory fields, each measuring 2 bytes (16 bits), for a total fixed size of 8 bytes (64 bits):
- Source Port: 2 bytes
- Destination Port: 2 bytes
- Length: 2 bytes
- Checksum: 2 bytes
The formula used to determine the value of the UDP Length field is:
\[\text{UDP Length} = \text{Header Size (8 bytes)} + \text{Payload Size (variable)}\]
When a UDP packet carries no payload data (a 0-byte payload), the datagram consists solely of the 8-byte header. Consequently, the minimum valid value that can be placed in the UDP Length field is 8.
Handling Values Below 8
Because the minimum header size is 8 bytes, any UDP datagram with a Length field value strictly less than 8 is considered malformed. If a network stack or operating system receives a packet with a Length field of 7 or lower, the packet is immediately dropped as invalid to prevent buffer underruns and protocol processing errors.