← 🧮 Framing & Error Control
Subtopic 2 of 4

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

  1. Single parity: make the number of 1s even (or odd). It catches any odd number of flipped bits and no even number.
  2. Internet checksum: add the 16-bit words, fold any carry back into the low bits, take the 1s complement.
  3. The receiver adds all words plus the checksum and expects ffff.
  4. 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.

addrunning totalafter folding the carry
450045004500
007345734573
000045734573
400085738573
4011c584c584
0000c584c584
c0a81862c862d
0001862e862e
c0a8146d646d7
00c7479e479e
Sum (folded)479e
Checksum = ~sumb861
Receiver adds everything incl. checksumffff

The receiver gets all-ones (ffff) when nothing was corrupted. The checksum catches most errors but not, for instance, two swapped words.

MethodDetectsMissesCorrects?
Single parity bitany odd number of bit errorseven number of errorsno
2-D parityall 1, 2, 3-bit errorssome 4-bit patternssingle-bit errors
Internet checksummost errorserrors that cancel out, swapped wordsno
CRC (degree r)all bursts ≤ r bits, all odd errors if (x + 1) divides Gfew special patternsno

Check yourself

A single parity bit can detect

Remember: Parity: odd errors only. Checksum: end-around carry, 1s complement, receiver expects all ones.
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.