Internet checksum of a short header — parity and checksum
exam standardone's-complement sum, then complement
Answer
3A7B
Why this example is worth doing
The RFC 1071 checksum: sum the 16-bit words with end-around carry, then complement the result. Its useful property is that summing the whole header including the checksum field yields all ones, so the receiver's check is a comparison against a constant. The page shows the verification pass as well as the computation, since that is the half usually omitted.
Try your own input in the Parity & checksum. Even and odd parity, one’s-complement sums and the Internet checksum, step by step.
How the answer is reached
Internet checksum (RFC 1071) over 10 bytes
Adjacent octets are paired into big-endian 16-bit integers and added with end-around carry.
| Word | Running sum | + word | End-around carry | New running sum |
|---|---|---|---|---|
| 0x4500 | 0x0000 | 0x4500 | no | 0x4500 |
| 0x0073 | 0x4500 | 0x4573 | no | 0x4573 |
| 0x0000 | 0x4573 | 0x4573 | no | 0x4573 |
| 0x4000 | 0x4573 | 0x8573 | no | 0x8573 |
| 0x4011 | 0x8573 | 0xC584 | no | 0xC584 |
One's-complement sum0xC584— RFC 1071 prints this value in its example
Checksum0x3A7B— the complement of the sum — this is what goes in the packet
Verification0xC584 — not 0xFFFF— summing the octets *including* the checksum field must give 0xFFFF
The transmitted checksum is the complement of the sum. RFC 1071’s worked example prints 0xDDF2, which is the sum, not the checksum (that is 0x220D). In UDP a computed value of 0x0000 is transmitted as 0xFFFF, which comes from RFC 768 rather than RFC 1071.
Source: RFC 1071, "Computing the Internet Checksum"