UDP: Datagrams, Headers, and Checksums
Connectionless Transport: UDP
With UDP, the sender's and receiver's transport entities do not perform a handshake before sending segments. This is why UDP is called connectionless.
UDP makes a best effort to deliver packets to the destination host but guarantees neither reliability nor order, bandwidth, or delay requirements. Compared with TCP, UDP offers no connection establishment, no connection state, and small packet-header overhead.
The UDP header has only four fields, each two bytes long. Ports deliver application data to the appropriate process on the destination end system. The length field indicates the segment's byte count, including its header. The checksum can detect errors in the segment.
Build a UDP datagram
Unlock the complete interactive lab, deeper explanations, and curated reference answers.
KNOWLEDGE QUIZ
Checksum
As a UDP segment travels from source to destination, noise or storage in routers can change its bits. The UDP checksum provides error detection. The sender treats the segment contents as 16-bit integers and adds them, wrapping any overflow around, then complements the sum and places the result in the checksum field.
For example, add two 16-bit integers:
Wrap the overflow bit around:
Complementing the result gives the checksum 0100010001000011.
The receiver adds all 16-bit integers, including the checksum. If the packet has no errors, the sum is 1111111111111111; otherwise, a different sum indicates an error.
A failing checksum means the packet is erroneous and will be discarded. A passing checksum does not guarantee that the packet is entirely correct. UDP detects errors but cannot recover from them.
Flip bits and inspect the checksum
Unlock the complete interactive lab, deeper explanations, and curated reference answers.
KNOWLEDGE QUIZ
Compute and test a one's-complement checksum
For 16-bit words E666 and D555 (hex), show binary addition, end-around carry, checksum, and receiver verification. Then change the words to E667 and D554 and explain the result. Also find UDP length for a 40-byte payload. This exercise sums the listed words only; a real UDP checksum additionally covers its IP pseudo-header, UDP header, and padded payload.