Methods of Error Detection
Data can change on its way. Parity checks, checksums and echo checks find errors after transmission, ARQ sends damaged data again, and check digits find mistakes made when data is entered.
WATCH IT EXPLAINED
EXPLORE IT IN 3D
Errors on the link
Data crosses a satellite link, and a noise generator strikes it on the way. Catch what it breaks: parity bits, a parity block, a checksum, an echo, a barcode's check digit, and ARQ.
Why data arrives wrong
Data can be lost, gained or changed on the way, so the sender adds extra information for checking.
When data is sent, interference, such as electrical noise, can change it on the way. Three kinds of error can happen.
| Kind of error | What happens |
|---|---|
| Data loss | some bits never arrive |
| Data gain | extra bits appear |
| Data change | bits are flipped: a 0 arrives as a 1, or a 1 as a 0 |
The receiver never sees the original data, so it cannot simply compare the two.
That is why the sender adds extra information to the data. The receiver uses it to check what arrived.
Parity check
A parity bit makes the number of 1s in each byte even or odd, so the receiver can count and check.
- Before sending, the sender and the receiver agree to use even parity or odd parity.
- One bit of each byte, here the left-most, is the parity bit.
- The sender sets the parity bit so that the total number of 1s in the byte is even (even parity) or odd (odd parity).
- The receiver counts the 1s in each byte it receives.
- If the count does not match the agreed parity, an error has happened, and the data is sent again.
Example:The data bits below have 4 ones. For even parity the sender adds a 0. For odd parity it adds a 1, to make 5 ones.
data bits 1011001 (4 ones)
even parity 0 1011001 (4 ones: even)
odd parity 1 1011001 (5 ones: odd)What parity cannot catch
Parity misses an even number of flipped bits, and it cannot say which bit is wrong.
A parity check finds any odd number of flipped bits: one, three, five and so on.
Watch out:If two bits flip, or any even number, the count of 1s stays even (or stays odd). The error is not noticed. Try it in the figure above.
Parity also cannot say which bit is wrong. So the whole byte has to be sent again.
A parity block check, in the next note, helps with both problems. But it does not solve them completely.
Parity block check and the parity byte
A parity byte checks every column of a block, so one flipped bit can be found and fixed.
Data can be sent as a block of bytes, each with its own parity bit. After the block, the sender adds a parity byte. Each of its bits is the parity bit for one column of the block.
If one bit is flipped on the way:
- The row that holds it fails the check.
- The column that holds it fails the check too.
- The wrong bit is where the row and the column cross.
- The receiver corrects it by flipping it back.
Watch out:Some errors still slip through. If four bits flip at the corners of a rectangle, every row and every column still has the right parity.
even parity, parity bit on the left
P data (7-bit ASCII)
C 1 1000011
O 1 1001111
D 0 1000100
E 1 1000101
1 0001101 parity byteChecksum
A checksum is a value calculated from a block; the receiver calculates it again and compares.
A checksum works on a whole block of data.
- The sender uses an agreed algorithm to calculate a value from the data.
- It sends this value, the checksum, with the block.
- The receiver uses the same algorithm on the data it received.
- It compares its answer with the checksum that arrived.
- If they are different, there has been an error, and the block is requested again.
Exam:There are many checksum algorithms. So an exam question gives you the algorithm when it asks you to calculate one.
algorithm: add the values, then keep the
remainder after dividing by 256
H E L L O
72 + 69 + 76 + 76 + 79 = 372
372 ÷ 256 leaves remainder 116
checksum sent with the block: 116Echo check
In an echo check, the receiver sends the data straight back, and the sender compares the two.
An echo check works like this:
- The receiver sends a copy of the data it received straight back to the sender.
- The sender compares the returned copy with the data it sent.
- If they are different, an error has happened, and the data is sent again.
The method is simple, but it has two problems:
- It doubles the amount of data sent.
- It cannot show where the error happened.
Watch out:A mismatch might come from the way back. The copy the receiver got might have been correct.
Check digits
A check digit is calculated from the other digits, and it catches mistakes when a number is entered.
A check digit is an extra digit at the end of a number. It is calculated from the other digits using an algorithm. Check digits are used in ISBNs on books and in barcodes on products.
- The number is entered: typed by a person, or scanned from a barcode.
- The computer calculates the check digit again.
- It compares it with the check digit that was entered.
- If they differ, the number was entered wrongly.
The ISBN-13 method catches any single wrong digit. It also catches most swaps of two neighbouring digits, called transposition errors.
Remember:An ISBN-13 always has 13 digits. So a missing or extra digit shows up as the wrong length.
Calculating a check digit
Each check-digit system has its own algorithm, and the question tells you which one to use.
Different systems use different algorithms, and a question will say which one to use.
| ISBN-13 | Modulo-11 (the older ISBN-10) | |
|---|---|---|
| Weights | 1 and 3 in turn, on the first 12 digits | count down from 10 to 2 |
| Step 1 | multiply each digit by its weight, and add the results | the same |
| Step 2 | find the remainder after dividing by 10 | find the remainder after dividing by 11 |
| Step 3 | take it away from 10 | take it away from 11 |
| Special results | 10 becomes 0 | 10 is written X, and 11 is written 0 |
Remember:Modulo-11 catches every swap of two different digits.
ISBN-13 978680316760?
weights 1 3 1 3 1 3 1 3 1 3 1 3
sum of digit × weight = 103
103 ÷ 10 leaves remainder 3
10 − 3 = 7, so the check digit is 7
(a remainder of 0 gives
a check digit of 0)
modulo-11 680316760?
weights 10 9 8 7 6 5 4 3 2
sum of digit × weight = 235
235 ÷ 11 leaves remainder 4
11 − 4 = 7, so the check digit is 7
(10 is written X, and 11 is written 0)ARQ: automatic repeat query
ARQ sends a packet again and again until the receiver says it arrived without errors.
ARQ (automatic repeat query) uses acknowledgements and a timeout to make sure that data arrives without errors. An acknowledgement is a short reply from the receiver. A timeout is a time limit.
- The sender sends a packet and starts a timer.
- The receiver checks the packet with an error check, such as a checksum.
- Packet correct: the receiver sends back a positive acknowledgement.
- Packet has an error: it sends back a negative acknowledgement, which asks for the packet again.
- No acknowledgement before the timeout: the sender sends the packet again automatically.
This repeats until the packet is acknowledged, or until a set number of attempts has been made.
Which check does what
Most checks find errors after sending; a check digit finds mistakes when data is entered.
| Method | When | How | Weakness |
|---|---|---|---|
| Parity check | after transmission | a parity bit makes the count of 1s even or odd | misses an even number of flipped bits |
| Parity block check | after transmission | a parity bit on each row, a parity byte for the columns | misses some patterns, such as four corners |
| Checksum | after transmission | a value from the data, recalculated and compared | misses errors that cancel out |
| Echo check | after transmission | the data is sent back and compared | doubles the traffic; which journey failed? |
| ARQ | after transmission | an error check, ACK or NAK, and a timeout | needs its error check to notice the error |
| Check digit | data entry | a digit from the other digits, recalculated | misses some swaps (ISBN-13: neighbours that differ by 5) |
ARQ uses a check such as a checksum, with acknowledgements (ACK: positive, NAK: negative) and a timeout. So damaged data is sent again automatically.
A check digit catches mistakes made when data is entered, by a person typing it or a scanner reading it.
Watch out:None of these methods is certain to catch every error.
This byte uses even parity. What must the parity bit be?
KEY TERMS
CHECK YOURSELF
1.Why can a single parity check MISS an error?
2.One bit has flipped. Which check can find WHICH bit is wrong?
3.In ARQ, what does the sender do when no acknowledgement arrives before the timeout?
4.What kind of error is a check digit designed to catch?
5.An echo check finds a mismatch. Why can the sender not be sure the receiver's copy was wrong?