Internet Checksum Example
  1. Transmitting
    1. Message: This is a message
    2. Hex, ASCII codes, grouped into 16-bit units and padded with zeros
      5468 6973 2069 7320 6120 6d65 7373 6167 6500
    3. Add them up
      5468 + 6973 + 2069 + 7320 + 6120 + 6d65 + 7373 + 6167 + 6500 = 359c3
    4. Add in the carryout:
      59c3 + 0003 = 59c6
    5. Invert the sum: a639
    6. Not zeros, so don't need to replace with ones.
    7. Transmit:
      5468 6973 2069 7320 6120 6d65 7373 6167 6500 a639
  2. Checking
    1. Receive:
      5468 6973 2069 7320 6120 6d65 7373 6167 6500 a639
    2. Add them up
      5468 + 6973 + 2069 + 7320 + 6120 + 6d65 + 7373 + 6167 + 6500 + a639 = 3fffc
    3. Add in the carryout:
      fffc + 0003 = ffff
    4. Invert the sum: 0000
    5. So the message checks.
  3. So why does it work, even if you replace all-zeros with all-ones? (Numbers in this explanation are in hex.)
    1. Call the initial checksum of the message data produced at step D on the transmission side S. (S=59c6 in the above example.)
    2. We then invert S, call that Ŝ. (a639 in the example.)
    3. If Ŝ=0, the checksum is C=ffff, otherwise C=Ŝ.
    4. The verifier will then sum the received data, which is R=S+C, where addition is the odd 16-bit wrap-around-carryout kind.
    5. If C=Ŝ, then R=S+Ŝ=ffff, which is inverted to 0000.
    6. Suppose instead that we used the invert case to force C=ffff.
      1. This happens when Ŝ=0, so S=ffff.
      2. Now R=S+C=ffff+ffff=1fffe=fffe+0001=ffff.
      3. Which is inverted to 0000
    7. So you get zero in either case.