Replace one word without scanning every word
02An updater knows the old checksum, the old 16-bit word and its replacement. It can remove the old contribution, add the new one and complement the resulting sum.
HC′=~0xFFFF=0x0000. This exactly matches recomputing the edited header from scratch.
Source for this drawing: RFC 1624 · Read RFC section 3 ↗
New to this? Start hereA quick picture + helpful background
A message needs an address.
Think of a packet as a small addressed envelope. Devices pass it onward; transport protocols decide what delivery promises an application gets.
Helpful first, if these ideas are unfamiliar
These pictures are analogies to help you learn. The linked RFC explains the actual rules.
Terms in this drawing
Related RFCs and changes
“Updates” changes part of an earlier RFC. “Obsoletes” replaces it. This list shows selected related documents.
Recover the sum, replace the contribution, then complement once at the end.
- Equation 3 is HC′ = ~(~HC + ~m + m′), with all complements limited to 16 bits and additions performed using one’s-complement arithmetic.
- The complement of m represents its additive inverse in that arithmetic. Restore ~HC first; do not move the outer complement through the sum using an ordinary-algebra shortcut.
- Section 9 recommends either Equation 3 or the equivalent Equation 4, HC′ = HC − ~m − m′, using the specified subtract-with-borrow arithmetic. This walkthrough implements Equation 3, not ordinary machine subtraction.
m is an aligned 16-bit contribution, even when only one byte changes; preserve the other byte. Any protocol-specific checksum coverage and byte order still matter. This bounded update assumes an initially correct checksum and known old/new words; it does not validate a packet or repair unrelated corruption.
Read the RFC section ↗