One parity bit says that something is wrong but not where. This lesson shows the parity block check, which can find the wrong bit. Then it shows the checksum, which checks a whole block with one value, and the echo check, which sends the data back.
about 25 min1 simulation1 practice question
Lesson 2 of 3Show all lessonsHide
Try the code and the simulations beside the lesson.
The parity block check
Data is usually sent as a block of several bytes. Each byte has its own parity bit. After the block, the sender adds one more byte, the parity byte. Each bit of the parity byte is the parity bit for one column of the block.
A grid of bits with eight columns, numbered 1 to 8, and five rows: bytes 1 to 4 and the parity byte. Column 1 holds the parity bit of each byte, and the block uses even parity. Row 3 is marked as having an odd number of 1s and column 5 is marked the same way. The bit where row 3 and column 5 cross is circled as the wrong bit.
Now every row and every column can be checked. Suppose one bit flips on the way.
The receiver checks each row (each byte). One row has the wrong parity.
The receiver checks each column, including the parity byte. One column has the wrong parity.
The wrong bit is where that row and that column cross.
In the picture the block uses even parity. Row 3 has an odd number of 1s, and so does column 5. So the bit in row 3, column 5 is wrong. Because a bit can only be 0 or 1, the receiver can even correct it by flipping it back.
A parity block check is stronger than a single parity bit, because it can locate one wrong bit. Some patterns of several errors can still slip through, for example four flipped bits at the corners of a rectangle.
The checksum
A checksum checks a whole block with one value.
Before sending, the sender works out a value from the block of data, using an agreed method. This value is the checksum.
The checksum is sent with the block.
The receiver works out the checksum again from the data it received, using the same method.
If the two checksums match, no error is found. If they are different, an error has occurred, and the receiver asks for the block to be sent again.
There are many checksum methods. The exam question tells you the method when it wants a calculation. In this course we use a simple one: add the bytes, and keep the remainder after dividing the total by 256. A byte holds 0 to 255, so the checksum fits in one byte.
Example: the block is 72, 105, 33 and 200. The total is 410, and 410−256=154. The checksum is 154.
A simple checksum can miss errors. If one byte goes up by 5 and another goes down by 5, the total is the same. Real systems use cleverer methods, but the steps of the check are the same.
The echo check
An echo check works like reading a message back to a friend.
The sender sends the data.
The receiver sends the same data straight back to the sender.
The sender compares the data that came back with the data it sent.
If they are the same, no error is found. If they differ, an error has occurred, and the data is sent again.
The echo check has two drawbacks. Every piece of data crosses the link twice, which takes time. And if the copies differ, the sender cannot tell whether the error happened on the way out or on the way back. The data may have arrived correctly the first time.
Practise with new numbers
Try it in Python
The program works out the checksum of a block of four bytes. One byte changes on the way, and the receiver's checksum no longer matches. Then it runs an echo check on the same data.
Common mistakes
Saying the receiver sends the checksum back. In a checksum, the receiver works the value out again and compares. Sending data back is the echo check.
Saying the echo check is done by the receiver. The sender does the comparing.
Forgetting the parity byte. A parity block check needs the parity bits of the columns as well as of the rows.
Saying a checksum catches everything. Errors that cancel in the total slip through.
Remember these
Parity block: a parity bit for each row and a parity byte for the columns; the wrong bit is where the bad row and the bad column cross.
Checksum: sender works out a value and sends it with the block; receiver works it out again; a difference means an error.
Echo check: receiver returns the data; sender compares; a difference means an error.
Check yourself
Try each one on your own first. If you are stuck, open a hint. Then check with Show the answer.
In a parity block check, what does each bit of the parity byte check?
In an even parity block, row 2 and column 6 both have an odd number of 1s. What does the receiver do?
A block holds the bytes 90, 180 and 40. Use the method of this lesson to find the checksum.
In a checksum method, what happens if the two checksums do not match?
Give one drawback of an echo check.
Enroll free in Detecting Errors in Transmitted Data
Every lesson is open to read. Enrolling also lets you:
Mark lessons done and carry on where you stopped.
Take the tests of this lesson and its course.
Count the course towards the certificate for its chapter.