UDP
From bildr
Contents |
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.
| bits | 0-15 | 16-31 |
| 0 | Source Port Number | Destination Port Number |
| 32 | Length | Checksum |
| 64 | Data | |
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
| bits | 0 – 7 | 8 – 15 | 16 – 23 | 24 – 31 |
| 0 | Source address | |||
| 32 | Destination address | |||
| 64 | Zeros | Protocol | UDP length | |
| 96 | Source Port | Destination Port | ||
| 128 | Length | Checksum | ||
| 160 | Data | |||
IPv6
| bits | 0 – 7 | 8 – 15 | 16 – 23 | 24 – 31 |
| 0 | Source address | |||
| 32 | ||||
| 64 | ||||
| 96 | ||||
| 128 | Destination address | |||
| 160 | ||||
| 192 | ||||
| 224 | ||||
| 256 | UDP length | |||
| 288 | Zeros | Next Header | ||
| 320 | Source Port | Destination Port | ||
| 352 | Length | Checksum | ||
| 384 | Data | |||
Links
This page is an Article on bildr. Articles are pages that define or explain a concept, method, or generic item.