2.2Parity and Internet checksum
The idea
To detect errors, the sender adds a few redundant bits. Parity adds one bit; the Internet checksum adds up 16-bit words and sends the complement.
Think of it like this: Counting your change twice: if the two totals differ, something went wrong; if they agree you are probably fine.
Why it exists
IP, TCP and UDP all use the checksum, and parity limits are a classic true-false.
How it works
- Single parity: make the number of 1s even (or odd). It catches any odd number of flipped bits and no even number.
- Internet checksum: add the 16-bit words, fold any carry back into the low bits, take the 1s complement.
- The receiver adds all words plus the checksum and expects ffff.
- A checksum cannot detect errors that cancel (for example two words swapped).
Worked example: Words 4500 0073 0000 4000 4011 0000 c0a8 0001 c0a8 00c7
The folded sum is 479e, so the checksum is its complement b861. The receiver adds all ten words plus b861 and gets ffff.
Now play with it
- →Change one hex digit in a word: the receiver total is no longer ffff.
- →Swap two words: the total stays ffff, so the error is missed.
Add 16-bit words with end-around carry (carries wrap back into the low bits), then take the 1s complement. The default words are a real IPv4 header with the checksum field set to 0000.
| add | running total | after folding the carry |
|---|---|---|
| 4500 | 4500 | 4500 |
| 0073 | 4573 | 4573 |
| 0000 | 4573 | 4573 |
| 4000 | 8573 | 8573 |
| 4011 | c584 | c584 |
| 0000 | c584 | c584 |
| c0a8 | 1862c | 862d |
| 0001 | 862e | 862e |
| c0a8 | 146d6 | 46d7 |
| 00c7 | 479e | 479e |
The receiver gets all-ones (ffff) when nothing was corrupted. The checksum catches most errors but not, for instance, two swapped words.
| Method | Detects | Misses | Corrects? |
|---|---|---|---|
| Single parity bit | any odd number of bit errors | even number of errors | no |
| 2-D parity | all 1, 2, 3-bit errors | some 4-bit patterns | single-bit errors |
| Internet checksum | most errors | errors that cancel out, swapped words | no |
| CRC (degree r) | all bursts ≤ r bits, all odd errors if (x + 1) divides G | few special patterns | no |
Check yourself
A single parity bit can detect
Exam notes (the dense version)
Single parity bit detects every odd number of bit errors and misses even numbers; it detects, never corrects. 2-D parity can correct a single-bit error. The Internet checksum (IP, TCP, UDP) adds 16-bit words with end-around carry and sends the 1s complement; the receiver adds everything including the checksum and expects all ones. It misses errors that cancel out, such as swapped words.
Previous year questions: Framing & Error Control (2)
PYQs are grouped by topic, so this is the full set for Framing & Error Control; try the ones that match this subtopic. Open all 2 on the topic page.