The length field defines the length of the datagram. This consists of the length of the header (8 bytes) and the size of the user data (theoretical maximum: 65,535 bytes). When using IPv4, the actual limit for the user data is 65,507 bytes – after deducting IP and UDP headers. In IPv6, packets (so-called jumbograms) that exceed the maximum are also possible. According to RFC 2675, the value of the length field is set to "0" in such a case.
The UDP header is terminated by the checksum, which is used for error detection during transmission. In this way, any manipulations of the transmitted data can be detected – however, corresponding packets are discarded without a new request. To generate the sum, parts of the
- UDP header,
- the user data,
- as well as the so-called pseudo-header (contains IP header information)
are included.
The checksum is optional in IPv4, but is used by most applications by default. If you omit it, this field will also take the value "0." If UDP is used in combination with IPv6, the checksum is mandatory.