Syllabus coverage
- Understand the need to check for errors after data transmission and how these errors can occur, including data loss, data gain and data change caused by interference
- Describe the process of a parity check, including odd and even parity, and parity byte and parity block checks
- Describe the process of a checksum and of an echo check in detecting errors after transmission
- Describe how a check digit is used to detect errors in data entry, including in international standard book numbers (ISBN) and bar codes
- Describe how an automatic repeat query (ARQ) can be used to establish that data is received without error, including acknowledgements and timeout
Part of the O Level Computer Science syllabus 2210.
Why transmitted data has to be checked
A signal travelling along a cable or through the air is a physical quantity, and physical quantities pick up noise. Electrical interference from nearby machinery, a poor connection, a long cable or a weak radio signal can all disturb the signal enough that a receiver reads the wrong value. The data that leaves one device is therefore not guaranteed to be the data that arrives at the other.
The syllabus names three effects. Data loss is when a bit, a byte or a whole packet never arrives. Data gain is when extra bits appear that were never sent. Data change is when a bit flips, so a 0 arrives as a 1 or a 1 arrives as a 0. All three make the received data different from the sent data, and a computer cannot tell by looking at the data that it is wrong.
The solution is to send something extra alongside the data, calculated from the data itself, so that the receiver can repeat the calculation and compare. Every method on this page works on that principle: a value is derived from the data before transmission, sent with it, and recomputed on arrival. If the two values disagree, an error has occurred. This is error detection, not error correction: the check tells the receiver that something is wrong, not which bit is wrong, so the usual response is to ask for the data again.
Parity check: odd and even
A parity check adds one extra bit to each byte before it is sent. The parity bit is chosen so that the number of 1s in the nine bits (the eight data bits plus the parity bit) is always the same, either always even or always odd, depending on which parity has been agreed.
With even parity the parity bit is set so that the total number of 1s is an even number. If the data byte already contains an even number of 1s, the parity bit is 0; if it contains an odd number, the parity bit is 1. With odd parity the rule is reversed: the parity bit makes the total number of 1s odd.
The receiver repeats the count. It counts the 1s in each byte it receives, including the parity bit, and checks whether the total is the expected even or odd number. If it is, the byte is accepted. If it is not, the receiver knows that a bit has changed and can request the byte again. The check is cheap: one bit per byte and a simple count.
The limitation is important and examiners like it. Parity detects any odd number of errors in a byte, because one flipped bit changes the count by one and breaks the parity. It cannot detect an even number of errors, because two flipped bits change the count by two, the parity is restored, and the byte passes as correct. It also cannot say which bit was wrong, and if the parity bit itself is corrupted the check may reject a byte that was actually correct.
| Data byte | Number of 1s | Parity bit for even parity | Parity bit for odd parity |
|---|---|---|---|
| 0 1 1 0 1 0 0 1 | 4 | 0, so the total stays 4 | 1, so the total becomes 5 |
| 1 1 0 0 0 1 1 0 | 4 | 0, so the total stays 4 | 1, so the total becomes 5 |
| 1 0 0 1 1 1 1 0 | 5 | 1, so the total becomes 6 | 0, so the total stays 5 |
| 0 0 1 1 0 1 0 0 | 3 | 1, so the total becomes 4 | 0, so the total stays 3 |
Parity byte and parity block check
Parity on single bytes has a weakness that grows with the amount of data: it only checks each byte in isolation, so it cannot tell you which byte in a block was corrupted, only that one was. A parity block check extends the idea to a whole block of data arranged as rows of bytes.
A parity bit is calculated for each byte in the usual way, giving a column of parity bits on the right. Then a parity bit is calculated for each column of the block, giving an extra parity byte at the bottom. The block is sent with both its row parity bits and its column parity byte.
The receiver recalculates every row parity and every column parity. If a single bit has been corrupted, one row check and one column check will both fail, and the intersection of that row and that column points to the exact bit that is wrong. That makes a block check more useful than simple parity, because it can locate the error and even allow it to be corrected by flipping the bit back.
The same limit still applies in each direction: an even number of errors in one row, or in one column, cancels out and is not detected. A block check therefore reduces the chance of an undetected error but does not remove it.
Checksum
A checksum is a value calculated from the whole block of data using arithmetic, and sent alongside it, usually in the packet trailer. The simplest form adds up the byte values of the block, discards any carry beyond the width of the checksum, and sends the total.
The receiver performs the same calculation on the data it has received and compares its result with the checksum that arrived. If the two match, the data is accepted as probably correct. If they differ, at least one byte has changed and the block is rejected and requested again.
A checksum is stronger than parity for large blocks because it is sensitive to changes anywhere in the data, not just within one byte, and a single checksum covers the whole block rather than a bit per byte. It is also cheap to compute, which is why it appears in network protocols and in file transfers.
It is still not a proof. Two errors can cancel out, for example one byte increased by a value and another decreased by the same amount, leaving the total unchanged. A checksum also cannot say which byte is wrong. For these reasons stronger forms such as a cyclic redundancy check are used where the risk matters, but the principle is the same: calculate, send, recalculate, compare.
Echo check
An echo check does not calculate anything from the data. Instead, the receiving device sends the data it has received back to the sender, and the sender compares the returned data with the copy it originally sent. If the two are identical, the transmission is accepted; if they differ, an error occurred and the data is sent again.
The method is simple and needs no arithmetic at either end, which makes it easy to implement on a link between two devices that can both transmit. It is also thorough in one sense: it compares the entire data rather than a summary of it, so a change anywhere will be spotted, provided the return journey is clean.
Its drawbacks are the reason it is used less than checksums. The data is transmitted twice, once out and once back, so the link carries double the traffic and the transfer takes roughly twice as long. The sender also cannot tell which of the two journeys corrupted the data, so it does not know whether to blame the link or the receiver. And the comparison assumes the return path is reliable, which is not guaranteed.
Check digit: catching errors in data entry
Everything so far checks data that has travelled along a link. A check digit checks something different: data that a person has typed or a machine has scanned. The errors it catches are human ones, such as transposing two digits, missing a digit out or pressing the wrong key, and machine ones such as a scanner misreading a bar code.
An extra digit is calculated from the other digits of the number using a fixed rule, and appended to the number. When the number is entered, the computer applies the same rule to the digits that were keyed in and compares its result with the check digit at the end. If the two agree, the number is accepted; if not, at least one digit was entered wrongly and the entry is rejected and re-typed.
The rule is usually a weighted calculation, where each digit is multiplied by a position-dependent weight and the results are combined, often with a division and a remainder. You are not expected to perform the calculation; you are expected to describe the process and name where it is used.
Two named examples are required. An international standard book number (ISBN) ends in a check digit, so a miscopied ISBN is rejected by a bookshop or library system before it is used to order the wrong title. The bar code on a product also ends in a check digit, so a smudged or misread code is rejected at the till instead of being charged as a different product. The same idea protects account numbers and identity numbers.
ARQ: getting the data sent again
Detecting an error is only useful if something is done about it. ARQ (automatic repeat query), sometimes called automatic repeat request, is the set of rules that makes the sender re-transmit data until it is received correctly. It works together with whichever error check the link uses.
When the receiver gets a block of data that passes its check, it sends back a positive acknowledgement (ACK). When it gets a block that fails, it sends a negative acknowledgement (NAK), and the sender automatically re-transmits that block. Each block carries a sequence number so that a duplicate arriving after an acknowledgement was lost can be recognised and discarded rather than added twice.
Acknowledgements alone are not enough, because the failure might be that nothing arrived at all. The sender therefore starts a timer when it transmits. If no acknowledgement of any kind has arrived when the time expires, a timeout occurs, and the sender re-transmits the block automatically. A lost block, a lost acknowledgement and a corrupted block all end in the same recovery: the data is sent again.
ARQ is what turns a detection method into a reliable link. It costs time, because waiting for acknowledgements and re-sending blocks slows the transfer, and the size of the blocks trades efficiency against the amount of data that must be repeated when something goes wrong.
| Event at the receiver | Response | What the sender does |
|---|---|---|
| Block arrives and passes the check | Positive acknowledgement (ACK) | Sends the next block |
| Block arrives but fails the check | Negative acknowledgement (NAK) | Re-transmits the same block automatically |
| Nothing arrives, or the acknowledgement is lost | No response | Timeout expires and the block is re-transmitted automatically |
Matching the method to the job
The methods are not interchangeable, and a question that asks you to choose expects the reason to come from where the error happens.
For errors after transmission, parity is the cheapest and weakest: one bit per byte, detecting only an odd number of bit errors. A parity block check adds the ability to locate a single bad bit. A checksum covers a whole block with one value and is stronger for large transfers. An echo check compares the data itself but doubles the traffic. ARQ then recovers from whichever error was detected.
For errors in data entry, none of those apply, because no transmission has taken place. A check digit is used, and it is validated by the same computer that will store the number, at the moment the number is keyed in or scanned.
A strong system uses more than one. A card payment, for example, carries a check digit in the card number to catch a typing error, a checksum on the network packets to catch corruption in transit, and acknowledgements with timeouts so that anything lost is sent again.
Key terms you must be able to define
- Data loss
- An error in transmission in which a bit, byte or packet never arrives at the receiver.
- Data gain
- An error in transmission in which extra bits appear in the received data that were never sent.
- Data change
- An error in transmission in which a bit flips value, so a 0 arrives as a 1 or a 1 arrives as a 0.
- Parity bit
- An extra bit added to each byte so that the total number of 1s is always even (even parity) or always odd (odd parity).
- Parity block check
- A check on a block of data in which a parity bit is calculated for each byte and a further parity byte for each column, so that a single corrupted bit can be located.
- Checksum
- A value calculated from a block of data and transmitted with it. The receiver recalculates the value and compares the two; a difference means the data has changed.
- Echo check
- An error detection method in which the receiver sends the data back to the sender, which compares it with what it originally sent. It is slow because the data travels twice.
- Check digit
- An extra digit calculated from the other digits of a number and appended to it, used to detect errors when the number is typed or scanned, for example in ISBNs and bar codes.
- Automatic repeat query (ARQ)
- A set of rules that makes the sender re-transmit data until it is received correctly, using positive and negative acknowledgements and a timeout.
- Positive acknowledgement (ACK)
- A signal sent by the receiver to confirm that a block of data arrived and passed its error check.
- Negative acknowledgement (NAK)
- A signal sent by the receiver to say that a block of data arrived but failed its error check, so the sender must re-transmit it.
- Timeout
- The expiry of the sender's timer when no acknowledgement has arrived, which causes the sender to re-transmit the data automatically.
In context
2210 sets its questions inside systems a student already uses - a school network, a phone, a supermarket till, a vending machine, a website. These show how the theory is applied to a context you have not seen before, then you answer for the system you are given.
Each packet carries a checksum in its trailer. The phone's radio link is the least reliable part of the path, so if interference changes a byte the checksum no longer matches at the network end, the packet is discarded, and the transport protocol notices the missing packet and asks for it again. The user sees a short delay rather than a corrupted word.
The librarian types the ISBN from the back cover. The library system recalculates the check digit from the digits entered and compares it with the final digit of the ISBN. If a digit was mistyped, the two do not match and the system refuses the entry, so the loan is not recorded against the wrong title. Correcting a rejected entry takes seconds; tracing a wrong record later can take much longer.
The scanner reads the bar code, whose last digit is a check digit. The till recalculates it from the other digits before looking up the price. A smeared or partly read code fails the check and the till asks for the item again, which prevents a customer being charged for the wrong product. The same number is then transmitted to the stock system, where a checksum protects it in transit.
The sender divides the file into blocks and sends each one; the receiver checks it and answers with an acknowledgement. If a block fails the check it is rejected and a negative acknowledgement is returned, and the sender repeats just that block. If the sender hears nothing at all within its timeout it repeats the block anyway, so a lost block does not stall the transfer.
A simple link between a keyboard controller and the main board may use only odd parity, because each keystroke is a single byte and a single flipped bit is the likely failure. The receiver counts the 1s and rejects the byte if the count is even, and the keypress is discarded rather than the wrong character being displayed.
Flashcards
Click a card to flip it. Mark honestly — the tracker uses this.
Exam-style questions
7 questions, 21 marks. Write your answer and press Mark my answer — it is marked against the scheme and tells you which points you made and what would gain the next mark. You can still reveal the scheme and mark it yourself instead.
Mark scheme — tick each point you actually made
Mark scheme — tick each point you actually made
Mark scheme — tick each point you actually made
Mark scheme — tick each point you actually made
Mark scheme — tick each point you actually made
Mark scheme — tick each point you actually made
Mark scheme — tick each point you actually made
Exam technique for this topic
- Always write what happens at the receiver, not only what the sender adds. 'A parity bit is added' is half an answer; 'the receiver counts the 1s and rejects the byte if the count is wrong' is the other half.
- Name the parity. Write 'odd parity, so the total number of 1s is odd' rather than 'parity is used', because the question usually specifies odd or even and the mark scheme follows it.
- Keep the two contexts apart: parity, checksum and echo check detect errors after transmission; a check digit detects errors in data entry, such as a mistyped ISBN or a misread bar code.
- In an ARQ answer, give all three branches: positive acknowledgement for a good block, negative acknowledgement and re-transmission for a bad block, and timeout and re-transmission when nothing comes back. The timeout is the branch most often omitted.
- If you are asked for a drawback, be specific: parity misses an even number of errors, a checksum can miss two errors that cancel out, and an echo check doubles the amount of data sent.
Why students lose marks here
Where this fits in O Level Computer Science 2210
This page is one topic of Cambridge O Level Computer Science 2210. O Level Computer Science 2210 is the course home: every area and every topic in Cambridge's own order, the papers you sit and what each one tests, and the exam-practice tools. The full topic list, with each topic linked to its revision page, is on the O Level Computer Science 2210 syllabus page.