Skip to content
PlayOwl
Computers & communication · #349

How can messages survive small transmission errors?

Messages pick up mistakes on their journey. A few extra check squares let the receiver find a flipped square and flip it back.

The big idea: A message is sent with extra check bits worked out from the message itself. If a bit flips on the way, the checks no longer fit, and the receiver can tell where the mistake is.

Start exploring
0 of 5 parts done
How Things Work poster: How can messages survive small transmission errors?
1Watch it

Finding a flipped bit

  1. A space probe sends a picture home. The picture travels as a long stream of bits, each one either on or off, across millions of kilometers.
  2. On the way, a burst of radio noise hits the signal and one bit flips from on to off. Now the picture that arrives has a wrong square.
  3. One fix is to send every bit three times and let the receiver take a vote. If one copy flips, the other two still agree. It works, but the message is three times as long.
  4. A smarter trick adds one check square to each row, set so that the row always has an even number of lit squares. If a square flips, its row turns odd, and the receiver knows something is wrong.
  5. Now add a check square under each column as well. A flipped square makes one row odd and one column odd. Where they cross is the mistake, so the receiver flips it back.
  6. The picture arrives perfect. Cleverer versions of this trick protect QR codes, discs, phone calls and everything saved on a computer.
2Look inside

Look inside a protected message

Tap each part of the message and its journey. Watch what it does.

  • Data squares. These sixteen squares are the real message: here, a tiny picture. Each square is one bit, lit for 1 and dark for 0.
  • Row checks. Each row gets one extra square. It is lit or dark, whichever makes the number of lit squares in that row even.
  • Column checks. Each column gets an extra square as well, so every column also has an even number of lit squares.
  • Corner check. The corner square checks the check squares. If one of them is flipped on the way, the corner helps to show it.
  • Noise. Noise is anything that muddles the signal on its way: a radio crackle, a scratch on a disc, a weak signal. It can flip a bit.
  • Checker. The receiver counts the lit squares in every row and column. An even count shows green. An odd count shows red: something in that line was flipped.
  • Fixer. The flipped square sits where the red row and the red column cross. The receiver flips it back, and the message is right again.
3Try it

Damage the message

Tap any square to flip it, as noise would. Watch the lamps beside the rows and under the columns. Then flip a second square.

Experiment: One square gets flipped on the way. Can the check squares show which one it was?

  1. Tap one square and look at the lamps. Press Check and repair.
  2. Now tap two different squares and press Check and repair again.
  3. Try two squares in the same row. Which lamps turn red?

What we found: One flipped square makes exactly one row and one column odd, and they cross at the mistake, so the receiver can repair it. Two flipped squares make too many lines odd, or hide each other. The receiver can tell that something is wrong but not where, so it has to ask for the message again.

Turn on JavaScript to try it yourself.

4Solve a challenge

Repair three messages

Three messages arrive, each with one flipped square. Use the counts to find the odd row and odd column, then tap the square to repair it.

5Go deeper

How messages fix themselves

Everything a computer sends is made of bits: tiny signals that are either on or off. On the way, a bit can get flipped. A crackle of radio noise, a scratch on a disc or a weak signal can turn an on into an off. One wrong bit might change a letter in a word, or a dot in a picture.

The answer is to send a little extra. The simplest way is to say everything three times and take a vote, but that makes the message three times as long. A smarter way is to add check bits. In the grid on this page, each row gets one extra square, chosen so the row always has an even number of lit squares. Each column gets one as well.

When the message arrives, the receiver counts every row and column. If a square was flipped, its row is now odd and its column is odd. Where the odd row and the odd column cross is the flipped square, so the receiver flips it back. Nobody had to send the message again.

The trick has limits. If two squares flip, the receiver can still tell that something is wrong, but not where, so it asks for the message again. Spelling a name with extra words, B for banana, works the same way, though people choose the words and computers do it with arithmetic. Stronger codes of this kind are why a scratched disc still plays and a torn QR code still scans.

Key words

Bit
The smallest piece of data: on or off, 1 or 0.
Noise
Anything that muddles a signal on its way and can flip a bit.
Check bit (parity bit)
An extra bit added so that a row has an even number of 1s.
Error detection
Noticing that a message was changed on the way, even if you cannot tell where.
Error correction
Finding exactly which bit is wrong and flipping it back, without asking for the message again.
Redundancy
Extra information sent along with a message to keep it safe.

Check your thinking

  1. One row has an odd number of lit squares, and so does one column. Where is the flipped square?

    Show the answer

    Where that row and that column cross. A flipped square upsets its own row and its own column. Only one square is in both.

  2. Why send extra check bits, when they are not part of the message?

    Show the answer

    So the receiver can find and fix a bit that was flipped on the way. Check bits are worked out from the message. If the message changes, they no longer fit, and that shows where the damage is.

  3. Two squares in the same row are flipped. What does the receiver see?

    Show the answer

    The row looks fine, but two columns are odd, so it knows something is wrong but not where. Two flips in one row cancel out in that row, but each upsets its own column. Two red columns and no red row cannot point to one square.

  4. Sending every bit three times also fixes mistakes. Why are check squares usually better?

    Show the answer

    They need far fewer extra bits. Saying everything three times triples the message. A few check squares protect it with much less extra to send.

  5. Four bits at the corners of a rectangle are all flipped. Why does the parity grid miss this?

    Show the answer

    Each affected row and column has two flips, so every parity is still even. Parity only records whether a count is odd or even. Two flips in a line cancel, so this pattern leaves an all-even syndrome. Stronger codes are needed for noisier channels.