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

Test Your Knowledge

Quick MCQ check on this algorithm

Start Quiz →

AI Summary

Summarize this page in your favorite LLM