UDP checksum step by step

One's complement sum of 16-bit words: the carry that leaves on the left wraps around and is added on the right; at the end every bit is inverted. Then the receiver checks it, also through a channel that flips bits.

Words of the segment

From 2 to 6 words of 16 bits, in hexadecimal (B53D) or binary (16 digits). A bit can also be changed by clicking it on the right.

Scenarios

Channel with errors

On the receiver tabs, click a bit of a received word to change it. Or:

Practice

A new segment with the answers hidden: work out the checksum in hexadecimal and press Check. The hint shows the sum before complementing.

View

Partial sums (hexadecimal)

Model assumptions
  • The words are summed two at a time in one's complement: the carry that leaves on the left (the 17th bit) is not lost; it wraps around and is added to the rightmost bit (end-around carry). Then every bit is inverted: that is the checksum carried in the header (Kurose and Ross §3.3.2; RFC 768 and RFC 1071).
  • Here the words are summed without the pseudo-header, as in the book example. The real UDP checksum is computed over the pseudo-header (source IP, destination IP, 0, protocol 17, UDP length) plus the whole segment, with the checksum field set to 0: you will do that in the lab.
  • With an odd number of bytes a 00 padding byte is added at the end to complete the last word. It takes part in the sum but is not transmitted: the receiver adds it again.
  • The receiver can check in two equivalent ways: sum every word including the received checksum (1111111111111111 = FFFF if no error is detected), or keep the received checksum, set the field to 0, recompute and compare.
  • It detects any one-bit error, but not every multi-bit error: a 0 → 1 in one word and a 1 → 0 in the same column of another word cancel out. That is why the link layer adds a CRC, which is more powerful (Topic 5).
  • In IPv4 the field is optional: 0 means “not computed” (if the computed checksum is 0000 it is sent as FFFF). In IPv6 it is mandatory. When it detects an error, UDP discards the segment or passes it to the application with a warning; the sender is not told.