The UDP Header

UDP messages consist of header and body parts, just like IP datagrams. The body part contains whatever data was provided by the application in use, while the header contains the fields that tell the destination UDP software what to do with the data.

A UDP message is made up of six fields (counting the data portion of the message). The total size of the message will vary according to the size of the data in the body part. The fields in a UDP message are shown in Table 6.2, along with their size (in bytes) and their usage.

Table 6.2. The Fields in a UDP Message

Field

Bytes

Usage Notes

Source Port

2

Identifies the 16-bit port number in use by the application that is sending the data

Destination Port

2

Identifies the 16-bit target port number of the application that is to receive this data

Length

2

Specifies the size of the total UDP message, including both the header and data segments

Checksum

2

Used to store a checksum of the entire UDP message

Data

varies

The data portion of the UDP message

Notice that the UDP header does not provide any fields for source or destination IP addresses, or for any other services that are not specifically related to UDP. This is because those services are provided by the IP header or by the application-specific protocols (and thus contained within the UDP message’s data segment).

Every UDP message has an eight-byte header, as can be seen from Table 6.2. Thus, the theoretical minimum size of a UDP message is eight bytes, although this would not leave any room ...

Get Internet Core Protocols: The Definitive Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.