---
title: Reed–Solomon, concatenated and modern codes
heading: Symbol-oriented Reed–Solomon codes and burst errors, interleaving, concatenation, and the iterative turbo and LDPC codes that reach within a fraction of a decibel of capacity
eyebrow: S8 · Lesson 36 · Reed–Solomon, concatenated and modern codes
xp: 50
---

::: hook
For forty years after Shannon, practical codes stayed several decibels short of capacity. Reed–Solomon codes, correcting whole bytes at a time, cleaned up the bursts of errors that Viterbi decoders and scratched CDs produce, and concatenating the two brought deep-space links to within about 2.5 dB of the limit. Then in 1993 Berrou and Glavieux announced turbo codes working at 0.7 dB, a result so good that many listeners assumed a mistake, and Gallager's long-forgotten low-density parity-check codes were rediscovered a few years later. Both decode iteratively, passing soft beliefs back and forth, and they now carry the data in 4G, 5G, Wi-Fi and satellite TV.
:::

::: play
- Approximate Eb/N0 needed for a bit error rate near 10⁻⁵ by rate-1/2 (or similar-rate) schemes against the year they appeared, with the Shannon limit for rate 1/2 and binary inputs, 0.19 dB, as the floor.
- Uncoded BPSK needs 9.6 dB; the K = 7 convolutional code about 4.4; Reed–Solomon concatenated with it about 2.5; turbo codes 0.7; long LDPC codes within a few hundredths of a decibel of the limit.
- Each step closed more of the gap with more decoding effort, until the gap was essentially gone.
:::
:::

```sim plot
view: graph
x: y = 1945..2005
y: E = -1..11 dB
plot: 0.19 | dashed | color: ch3 | label: Shannon limit, rate 1/2, binary inputs
point: 1948, 9.6 | label: uncoded BPSK
point: 1967, 4.4 | label: K = 7 convolutional, Viterbi
point: 1977, 2.5 | label: RS + convolutional (Voyager)
point: 1993, 0.7 | label: turbo code
point: 2001, 0.2 | label: long LDPC code
```

::: predict
## The Reed–Solomon (255, 223) code works on 8-bit symbols. How many corrupted bytes per codeword can it correct, wherever they fall?

- [ ] 1
- [ ] 8
- [x] 16
- [ ] 32

::: reveal
16. Its 32 check symbols give $d_\text{min}$ = n − k + 1 = 33, so it corrects (n − k)/2 = 16 symbol errors, and a symbol counts as one error whether one bit or all eight are wrong. That makes it ideal for bursts: any run of up to 121 bad bits (15 full bytes plus one more bit) touches at most 16 bytes.
:::
:::

::: nameit
## Reed–Solomon codes

Codes over symbols of m bits, with length $n = 2^m - 1$ symbols (255 for bytes). Any (n, k) RS code has $d_\text{min} = n - k + 1$, the most possible (it's **maximum-distance separable**), so it corrects

$$t = \frac{n - k}{2}\text{ symbol errors}$$

or twice as many erasures. A burst of up to $(t - 1)m + 1$ bits always lands in at most t symbols. CDs, DVDs, QR codes, DSL and deep-space links use RS codes.

## Interleaving

Writing codewords into the rows of an array and sending its columns spreads a burst across many codewords. With depth D, a burst of B symbols puts at most ⌈B/D⌉ errors in any codeword.

## Concatenation

An inner code (often convolutional, soft-decoded) cleans up random errors; its occasional failures come out in bursts, which an interleaved outer RS code removes. Voyager's RS(255, 223) over the K = 7 code needed about 2.5 dB for very low error rates.

## Iterative codes

- **Turbo codes**: two simple recursive convolutional encoders, the second fed an interleaved copy of the data. Two soft-in soft-out decoders exchange extrinsic information for several iterations.
- **LDPC codes**: block codes whose parity-check matrix is sparse; **belief propagation** passes probability messages between bit nodes and check nodes on the code's graph.
- **Polar codes** (Arıkan, 2009) provably reach capacity and carry 5G's control channels.
- Iterative codes show a steep **waterfall** a fraction of a dB above the limit, and sometimes an **error floor** at very low error rates.
:::

::: example
## A burst of 100 consecutive bit errors hits a stream protected by RS(255, 223). Is it corrected?

::: solution
1. **Bytes touched.** 100 bits span at most
   $$\lceil 100/8 \rceil + 1 = 14\ \text{bytes}$$
   if they straddle a boundary.
2. **Against the code.** That's fewer than 16, so yes, it's corrected.
3. **Guaranteed limit.**
   $$(16 - 1) \times 8 + 1 = 121\ \text{bits}$$
4. **Against a binary code.** A binary code correcting 100 random bit errors per 2040 bits would need far more redundancy than RS's 12.5%.

**Answer:** yes: the burst touches at most 14 bytes, fewer than the 16 the code corrects.
:::
:::

::: example
## How far from capacity were the schemes on the chart?

::: solution
1. **The limit.** At rate 1/2 with binary inputs it's 0.19 dB.
2. **Each scheme's distance.** Subtracting that from what each scheme needs:

| Scheme | Distance from the limit |
|---|---|
| Uncoded BPSK, at 9.6 dB | 9.4 dB |
| The K = 7 code | about 4.2 dB |
| Concatenated RS | about 2.3 dB |
| The first turbo code | 0.5 dB |
| Chung, Forney, Richardson and Urbanke's 2001 LDPC code, at very long block lengths | within 0.0045 dB |

**Answer:** from 9.4 dB away for uncoded BPSK down to within 0.0045 dB for the 2001 LDPC code.
:::
:::

::: example
## A burst of 300 byte errors hits RS(255, 223) codewords interleaved to depth 8. Is it corrected? What depth would be needed?

::: solution
1. **What each codeword corrects.** t = 16 symbols.
2. **Depth 8.** It spreads the burst so that some codeword gets
   $$\lceil 300/8 \rceil = 38$$
   errors: decoding fails.
3. **Depth needed.** A depth of
   $$\lceil 300/16 \rceil = 19$$
   or more keeps every codeword at 16 or fewer (depth 20 gives at most 15).
4. **The cost.** Buffering 19 or more codewords at each end.

**Answer:** no, some codeword gets 38 errors at depth 8; a depth of 19 or more is needed.
:::
:::

::: check
given: n = 255 | 127 | 63; t = 2 | 8 | 16; let k = n - 2*t
answer: (n - k)/2
tolerance: 0

## A Reed–Solomon code has n = {n} and k = {k} symbols. How many symbol errors can it correct?

::: right
Right. (n − k)/2 = {answer}.
:::

::: misses
- [n - k] That's how many erasures it can fill in; errors cost twice as much.
- [any] Not yet. $d_\text{min} = n - k + 1$, so t = (n − k)/2.
:::
:::

::: check
given: t = 8 | 16 | 32; m = 4 | 8
answer: (t - 1)*m + 1
unit: bits
tolerance: 0

## An RS code with {m}-bit symbols corrects t = {t} symbols. What's the longest bit burst it always corrects?

::: right
Right. $(t - 1)m + 1$ = {answer}: a burst that long can touch at most t symbols.
:::

::: misses
- [t*m] A burst of tm bits that starts mid-symbol can touch t + 1 symbols.
- [any] Not yet. A burst straddling symbol boundaries spreads into one extra symbol.
:::
:::

::: check
given: m = 3 | 4 | 6 | 8 | 10
answer: 2^m - 1
tolerance: 0

## How many symbols long is a standard Reed–Solomon codeword with {m}-bit symbols?

::: right
Right. $2^m - 1$ = {answer}.
:::

::: misses
- [2^m] RS codes over GF(2^m) have length $2^m - 1$.
- [any] Not yet. $n = 2^m - 1$.
:::
:::

::: check
given: B = 21 | 53 | 123; D = 4 | 8 | 16
answer: ceil(B/D - 0.0001)
tolerance: 0

## An interleaver of depth {D} spreads a burst of {B} symbol errors across codewords. At most how many land in any one codeword?

::: right
Right. ⌈B/D⌉ = {answer}.
:::

::: misses
- [floor(B/D + 0.0001)] Round up: the remainder lands somewhere.
- [any] Not yet. The burst is dealt out across D codewords in turn.
:::
:::

::: check
given: E = 0.7 | 2.5 | 4.4 | 9.6; L = 0.19
answer: E - L
unit: dB
tolerance: 0.05

## A rate-1/2 scheme needs {E} dB. How far is it from the binary-input Shannon limit of {L} dB?

::: right
Right. {answer} dB.
:::

::: misses
- [E + 1.59] The relevant limit for rate 1/2 with binary inputs is {L} dB, not −1.59 dB.
- [any] Not yet. Subtract the limit.
:::
:::

::: check
given: n = 255 | 63; t = 4 | 8; let k = n - 2*t
answer: 100*k/n
unit: %
tolerance: 0.5%

## What's the rate of an RS({n}, {k}) code?

::: right
Right. k/n = {answer}%.
:::

::: misses
- [any] Not yet. Data symbols over total symbols.
:::
:::

::: check
kind: parts
given: t = 8 | 16; B = 100 | 300 | 1000; D = 4 | 16

## Interleaved RS codewords correct t = {t} symbols each; a burst of {B} symbols hits an interleaver of depth {D}.

::: part
answer: ceil(B/D - 1e-9)
unit: symbols
tolerance: 0

### At most how many errors land in one codeword?

::: misses
- [any] ⌈B/D⌉.
:::
:::

::: part
answer: ceil(B/t - 1e-9)
tolerance: 0

### What is the least depth that would correct the burst?

::: misses
- [any] ⌈B/t⌉.
:::
:::
:::

::: check
kind: derivation
vars: m = 3..16, k = 1..60000

## A Reed–Solomon code has m-bit symbols, full length n = 2^m − 1 and k data symbols (k < n).

::: step
answer: (2^m - 1 - k)/2

### How many symbol errors can it correct?
:::

::: step
answer: k/(2^m - 1)

### What is its rate?
:::

::: step
answer: ((2^m - 1 - k)/2 - 1)*m + 1

### What is the longest bit burst it always corrects?
:::

::: right
Right. Long symbols make RS codes natural burst correctors.
:::
:::

::: explain
## Why do turbo and LDPC decoders pass soft information back and forth instead of making hard decisions?

::: model
Each component of a turbo or LDPC code is weak on its own: a single parity check or a short convolutional code can say only a little about each bit. But each one gives evidence about the bits that the others can use. A soft decision carries not just a guess but its confidence, so one decoder can tell the other which bits it's sure of and which are shaky, and the other can use that to resolve its own uncertainties, sending back refined beliefs. Repeating the exchange lets weak, local evidence accumulate across the whole code until nearly every bit is confidently decided. A hard decision would throw away the confidence and end the conversation after one round, which is why iterative soft decoding is what lets these codes approach capacity.
:::
:::

::: practice

::: check
given: n = 255 | 127; t = 6 | 10; let k = n - 2*t
answer: (n - k)/2
tolerance: 0

## RS({n}, {k}) symbol errors corrected?

::: misses
- [any] (n − k)/2.
:::
:::

::: check
given: t = 4 | 10; m = 6 | 8
answer: (t - 1)*m + 1
unit: bits
tolerance: 0

## Guaranteed burst for t = {t}, {m}-bit symbols?

::: misses
- [any] $(t - 1)m + 1$.
:::
:::

::: check
given: B = 30 | 75; D = 6 | 10
answer: ceil(B/D - 0.0001)
tolerance: 0

## Worst codeword's share of a {B}-symbol burst at depth {D}?

::: misses
- [any] ⌈B/D⌉.
:::
:::
:::
