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

Check the bits, guard the data

Week 23 · 3.3 Parity checks and network security · 3 lessons
1

Make the count even

Computing 9: Topic 3.3, pp. 284–298
GoalWork out the parity bit for seven data bits with even and odd parity, and check whether a received byte passes.
New words
parity bit · an extra bit added to the data so that the number of 1s follows an agreed ruleeven parity · the rule that the total number of 1s in the byte must be evenodd parity · the rule that the total number of 1s in the byte must be oddparity check · an error-detection method that counts the 1s in a received byte and compares the count with the rule
Explanation

Bits can change on their way along a cable or through the air, for example because of interference, crosstalk between cables or a power surge. A parity check can notice some of these changes. The sender adds one extra bit, the parity bit, to seven data bits, so that the 8 bits follow an agreed rule: with even parity the number of 1s must be even, and with odd parity it must be odd. To find the parity bit, count the 1s in the data bits. With even parity the bit is 1 if the count is odd and 0 if it is even, and with odd parity it is the other way round. Both devices must agree on even or odd before sending, for example during a handshake. Another method you met earlier is the echo check: the data is sent back and compared with what was sent, which detects an error but does not fix it. In this course the parity bit is written first, on the left. The receiver counts the 1s in all 8 bits, and if the count breaks the rule, the byte fails and something has changed.

1s in the 7 data bitsEven parity bitOdd parity bit
an odd number (1, 3, 5, 7)10
an even number (0, 2, 4, 6)01
Worked examples
Parity bitData bits1s in dataByte sent1s in byte
101101003101101004
Even parity. The data bits are 0110100. There are 3 ones, which is odd. To make the total even, the parity bit must be 1. The byte sent is 10110100, which has 4 ones.
Parity bitData bits1s in dataByte sent1s in byte
001101003001101003
Odd parity. The same data bits 0110100 already have 3 ones, which is odd. The parity bit must not change this, so it is 0. The byte sent is 00110100, which has 3 ones.
Byte received1s countedEven or odd?Result
110100115oddfail
011011004evenpass
100010002evenpass
Checking at the receiver. Both devices agreed on even parity. Three bytes arrive. The receiver counts the 1s in each whole byte. An odd count means a fail, and the receiver knows that at least one bit changed on the way.
Class activity

Bit cards (no computer). Make eight cards: write 1 on one side and 0 on the other. Partner A lays out seven data bits in a row and says ‘even’ or ‘odd’. Partner B counts the 1s and puts the eighth card, the parity bit, on the left. Partner A checks the count of the whole byte. Then swap roles. For a challenge, B turns the cards face down, A turns one card over in secret, and B counts the 1s again and says ‘pass’ or ‘fail’.

Practice
1
The sender uses even parity. Work out the parity bit for each row, and write the byte that is sent.
Data bitsParity bitByte sent
1000101??
0011110??
0000111??
1100110??
2
The sender uses odd parity. Work out the parity bit for each row.
Data bitsNumber of 1sParity bit
1010100??
0111111??
0000000??
1111111??
3
Both devices use odd parity. Count the 1s in each received byte and say whether it passes or fails.
Byte received1s countedPass or fail?
10110110??
01001100??
11001100??
4
A learner says: ‘The data bits 1011000 have three 1s, which is an odd number, so with even parity the parity bit is 0.’ Find the mistake and give the correct byte.