UDP

Overview
The UDP (User Datagram Protocol) is one of the core transport layer protocols of the Internet Protocol Suite, defined by RFC 768.

UDP can send datagrams (messages) to other hosts without requiring the various hand-shaking and setup methods used by many other transport protocols such as TCP. However, there is no guarantee messages will arrive, and likewise messages may be late or out of order. At the same time, UDP does not incur the overheads associated with the various hand-shaking methods. UDP is best suited for time-sensitive data where transfer speed is more important than data integrity. Also, due to forgoing the various error-checking protocols, UDP supports multicasting.

Technical Details
UDP is a minimalistic transport layer protocol, and offers no guarantee that a message will arrive, arrive on time, or arrive in order is exchange for speed. However, UDP does support checksums to verify data integrity and multiplexing over multiple ports.

Header
UDP heavers consist of 4, two-byte fields, two fo which are optional (Source Port Number and Checksum). This has been changed when using IPv6 where the checksum is not optional.

Source port number The Source Port Number identifies the sending port number. However, this field is optional, and does not necessarily contain the actual sending port, but is more often used to indicate the port a reply should be send to is desired.

Destination port number This field is required, and indentifies the reciever's port.

Length This field specifies the combined length of the entire datagram, including both the header and data. The minimum length is 8-bytes (the size of the header itself), with a maximum of 65535 bytes. However, IPv4 limits the size to 65,507 bytes.

Checksum The checksum is used to verify data integrity and considered optional except under IPv6. If no checksum is to be used, the checksum should consist of all zeros.

Checksum
As defined by RFC 768:

"Checksum is the 16-bit one's complement of the one's complement sum of a pseudo header of information from the IP header, the UDP header, and the data, padded with zero octets at the end (if necessary) to make a multiple of two octets."

UDP uses different checksum methods for IPv4 and IPv6. These checksums are computed using "pseudo-headers" that contain some of the information from the IPv4/IPv6 headers.

IPv4

IPv6

Links

 * RFC 768