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.
Worked examples
Data bits
Number of 1s
Parity bit
Byte sent
1100010
3 (odd)
1
11000101
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 received
Number of 1s
Even?
Result
10011011
5
no
error: ask for it again
01100110
4
yes
looks correct
Checking at the receiver. The receiver counts the 1s in every byte that arrives. An odd count means an error.
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 bits
Number of 1s
Parity bit
Byte sent
1001110
?
?
?
0110100
?
?
?
1111000
?
?
?
1001110 has four 1s, so the parity bit is 0 and the byte is 10011100. 0110100 has three 1s, so the parity bit is 1 and the byte is 01101001. 1111000 has four 1s, so the parity bit is 0 and the byte is 11110000.
2
These bytes arrived using even parity. Which ones must contain an error?
Byte received
Has an error?
11100101
?
00111100
?
00010000
?
11100101 has five 1s (odd), so it has an error. 00111100 has four 1s (even), so it looks correct. 00010000 has one 1 (odd), so it has an error.
3
Name three things that can cause errors when data is sent, and say which could affect a wireless link.
Any three of: a broken or damaged cable, electrical interference, a power surge, hacking. Electrical interference can affect a wireless link, and so can hacking. (A broken cable cannot 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?
(a) The 6th bit, counting from the left, flipped from 1 to 0. (b) Yes. The byte sent had four 1s, which is even, and the byte received has three 1s, which is odd, so the receiver finds the error.