D48 of 10
0 XP
  1. Hook
  2. Play
  3. Predict
  4. Name it
  5. Check
  6. Explain

D4 · Lesson 8 · Error-correcting codes

Adding redundant bits so the receiver can find and fix errors, code rate and minimum distance, how many errors a code corrects, the repetition code that does worse than nothing, the Hamming (7,4) code, Reed–Solomon codes for bursts, and the modern codes that approach Shannon's limit

In 1947 Richard Hamming, frustrated that a relay computer at Bell Labs kept stopping over the weekend at the first error it detected, asked why it couldn't find and fix the error itself. His answer, a few extra parity bits computed so that any single flipped bit leaves a unique signature, began coding theory. Codes are now everywhere: in every disk, memory chip, QR code and radio link. They're how real systems approach the Shannon limit of lesson 6, by spending a little of the bandwidth on redundancy that lets the receiver correct what noise breaks.

  • Bit error rates against Eb/N0 for uncoded BPSK, a 3× repetition code with majority vote, and the Hamming (7,4) code, all with hard decisions.
  • Coded bits get less energy each, since the same energy per information bit is shared among more transmitted bits, so the raw error rate p rises before decoding repairs it.
  • The repetition code repairs too little to pay for its 3× overhead and stays worse than sending nothing extra. Hamming's code wins at high Eb/N0.

Predict

Each bit is sent three times and the receiver takes a majority vote. At the same energy per information bit, is this better or worse than sending each bit once?

Name it

Rate and distance

An (n, k) block code turns k information bits into n coded bits: its rate is r=k/n, and the link's data rate falls by that factor. The minimum distance dmin⁡ is the fewest bits in which two codewords differ. A code can

  • detect up to dmin⁡−1 errors, and
  • correct up to t=⌊(dmin⁡−1)/2⌋ errors, by choosing the nearest codeword.

Energy per coded bit

At a fixed energy per information bit, each coded bit gets rEb, so with BPSK the raw error rate before decoding is p=Q(2rEb/N0). A code helps only if its correction more than makes up for that.

Hamming codes

With m parity bits, n=2m−1 and k=n−m: (7,4), (15,11), (31,26). Each corrects one error (dmin⁡ = 3): the parity checks that fail, read as a binary number, point to the flipped bit. For small p, the (7,4) code's decoded bit error rate is about 9p2.

Stronger codes

  • Reed–Solomon codes work on bytes and fix bursts: RS(255,223) corrects any 16 wrong bytes in 255. CDs, QR codes and deep-space links use them.
  • Convolutional codes with Viterbi decoding, and soft decisions that pass the receiver's confidence along with each bit, gain about 2 dB more.
  • Turbo and LDPC codes, decoded iteratively, operate within a decibel of Shannon's limit; LDPC codes are in Wi-Fi, 5G and DVB-S2.

Worked example

At Eb/N0 = 10 dB, compare uncoded BPSK with the Hamming (7,4) code.

Show the solution
  1. Uncoded. The bit error rate is 3.9×10−6.
  2. Coded bits. They get 4/7 of the energy: p=Q(2×4/7×10)=3.6×10−4
  3. After decoding. 9p2=1.2×10−6
  4. Compare. That's three times better, at the cost of sending 7 bits for every 4.

Answer the Hamming code gives 1.2 × 10⁻⁶ against 3.9 × 10⁻⁶ uncoded.

Worked example

How many errors can a code with dmin⁡ = 7 correct? What's the rate of RS(255,223)?

Show the solution
  1. Errors corrected. ⌊6/2⌋=3 errors, or 6 detected.
  2. Rate of RS(255,223). 223/255=0.875
  3. What RS(255,223) corrects. (255−223)/2=16 byte errors.

Answer it corrects 3 errors (or detects 6), and RS(255,223) has rate 0.875 and corrects 16 byte errors.

Worked example

A CRC-16 checks every frame. If 1000 frames a day arrive with random errors, how often does a bad frame slip through undetected?

Show the solution
  1. Chance a bad frame passes. A good 16-bit CRC passes a random error pattern with probability about 2−16=1.5×10−5
  2. Per day. That's 0.015 bad frames a day, about one every 66 days.
  3. A 32-bit CRC. With 2−32 in place of 2−16, a bad frame slips through about once in 12,000 years.

Answer about one bad frame every 66 days.

Check

A code has minimum distance 5. How many errors per codeword can it always correct?

Check

A Hamming code has 4 parity bits. What's its rate?

Check

Each copy of a bit sent three times flips with probability 0.05. How often does the majority vote come out wrong?

Check

A rate-0.75 code sends BPSK at Eb/N0 = 4 dB per information bit. What's the raw error rate of each coded bit before decoding?

Check

A block code has minimum distance 5.

(a)

How many errors can it correct?

(b)

How many can it detect, if it corrects none?

Check

A CRC of 16 bits checks frames; 100 frames a day arrive with random errors.

(a)

What fraction of bad frames slip through?

(b)

How many undetected bad frames is that per day?

Explain why

Why can a repetition code make a link worse, while a well-designed code makes it better?

Practice

Keep practicing

8 kinds of problem on this topic, dealt one at a time with new numbers every time, for as long as you like.