Hash Lab

Checksum

Internet checksum

The 16-bit one’s-complement sum that sits in the header of every IPv4 packet, every ICMP packet, and every UDP / TCP segment. Specified in RFC 1071 (1988) by Braden, Borman, and Partridge. Designed for hardware that could not afford to do CRC at line rate; still adequate for the small failures it was built to catch.

How it works

  1. Treat the data as a sequence of 16-bit big-endian integers; pad the last byte with zero if needed.
  2. Sum them with carries wrapped around (one’s-complement addition).
  3. Take the one’s complement of the result. That’s the checksum.

At the receiver, sum everything including the checksum field; a valid packet sums to 0xFFFFin one’s complement (equivalently, 0 after taking the one’s complement of the sum).

At a glance

Output16 bits
StandardRFC 1071 (1988); RFC 1141, 1624 (incremental updates)
ThroughputTrivial; computable in hardware at any line rate
StatusNon-cryptographic; minimum-viable accidental-corruption detector

Where it shows up

Limitations

Incremental updates

Because one’s-complement addition is associative and commutative, you can update an Internet checksum after a small change without rehashing the whole thing , just subtract the old word and add the new one (RFC 1141, 1624). Critical for routers that adjust the TTL field on every hop.

References

Quick quiz

Test yourself on internet-checksum

10 multiple-choice questions. Pick an answer for each, then submit to see explanations.

  1. Q1.Which RFC specifies the Internet checksum?

  2. Q2.Output size of the Internet checksum?

  3. Q3.Which protocol carries an Internet checksum in its header?

  4. Q4.Why did IPv6 drop the header checksum?

  5. Q5.What does TCP cover with its Internet-checksum value?

  6. Q6.RFC 1141 / 1624 contribution:

  7. Q7.Can the Internet checksum detect byte reordering?

  8. Q8.Is the Internet checksum cryptographic?

  9. Q9.Which router operation needs the Internet checksum recomputed?

  10. Q10.ICMP uses the Internet checksum over...

0 of 10 answered