AdvertisementYour brand could be hereYour brand hereOn every Darslab page · students, parents and teachersinfo@darslab.comAsk for pricesPricesinfo@darslab.com
☰ Year plan · Computing

Errors, search and a coding project

Week 15 · Unit 7.3: Connections are made · 3 lessons
1

When bits flip

Computing 7: Unit 7.3, pp. 82–111
GoalExplain why errors happen when data is sent and use a parity bit to check a byte.
New words
byte · a group of 8 bitscorrupted · damaged or changed by an error, so that it is no longer correctpower surge · a sudden rise in electrical power that can damage equipment or dataparity bit · an extra bit added so that the number of 1s in a byte is always even
Explanation

Computers send data as bits, which are 0s and 1s, and a group of 8 bits is a byte. Sometimes the signal is damaged on its way, so a 1 flips into a 0 or a 0 into a 1, and the data is corrupted, as in the picture, where the top row is the byte sent and the bottom row is the byte received. Causes include a broken cable, electrical interference, a power surge and hacking. One flipped bit can change a letter, a number or a pixel, so the receiver needs a way to notice errors. One simple check is a parity bit: the sender adds an extra bit so that the number of 1s in the byte is always even. If the receiver counts an odd number of 1s, it knows that something went wrong and asks for the data to be sent again. The check cannot see an error where two bits flip, so real systems use stronger checks as well.

1100101011001110
Worked examples
Data bitsNumber of 1sParity bitByte sent
11000103 (odd)111000101
Adding a parity bit. The seven data bits 1100010 contain three 1s, which is odd. The sender adds a parity bit of 1, so the byte now holds four 1s, which is even. The byte sent is 11000101.
Byte receivedNumber of 1sEven?Result
100110115noerror: ask for it again
011001104yeslooks correct
Checking at the receiver. The receiver counts the 1s in every byte that arrives. An odd count means an error.
1100010110000111
A limit of the check. The byte 11000101 had four 1s. Two bits flipped (the bottom row), so it arrived as 10000111, which still has four 1s. The receiver thinks it is fine, but the data is wrong.
Class activity

Flip detective (no computer): you need eight coins. Heads means 1 and tails means 0. A partner lays out seven coins to make any pattern, counts the heads and adds an eighth coin so that the number of heads is even. Turn your back. Your partner secretly turns over one coin. Turn round and count the heads: an odd number means an error, but you cannot say which coin changed. Now let your partner turn over two coins. Does the count catch it? Write what you found.

Practice
1
Add an even parity bit to each group of seven bits and write the whole byte.
Data bitsNumber of 1sParity bitByte sent
1001110???
0110100???
1111000???
2
These bytes arrived using even parity. Which ones must contain an error?
Byte receivedHas an error?
11100101?
00111100?
00010000?
3
Name three things that can cause errors when data is sent, and say which could affect a wireless link.
4
The byte 10100110 was sent (top row) and arrived as 10100010 (bottom row). (a) Which bit flipped? (b) Does the parity check find the error?
1010011010100010