O Level Computer Science 2210 · Area 1 · Computer systems

Error detection: parity, checksums and check digits

Interference on a link can lose, add or change bits, so a receiver needs a way of telling that something went wrong. This page covers the checks used after transmission, the check digit used at data entry, and the acknowledgement system that gets the data sent again. The commonest lost mark is describing what is added without saying what the receiver does with it.

Not started

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.

Three ways to catch a corrupted transmissionA parity bit catches an odd number of changed bits; two changes leave the parity unchanged.A checksum, a check digit or a repeat request covers what a single parity bit cannot.Odd parity: each byte is sent with a parity bit1011 001011100 111010110 10010If one bit flips, the count of 1s no longer matches the parity bit.If two bits flip, the parity is unchanged and the error is missed.Checksumdata blocksent to the receiverchecksum valuecalculated from the blockThe receiver recalculatesand compares. Any changethat alters the total is found.
A block of data bytes laid out as rows with a parity bit column down the right-hand side and a parity byte along the bottom, and beside it a checksum value calculated at the sender and the same calculation being repeated at the receiver, with the two values compared and shown as matching or not matching.

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.

Learn the three error types by name with an example each: a bit never arrives is data loss, extra bits appear is data gain, and a bit flips is data change. Questions ask for the names, not a description of noise.

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 byteNumber of 1sParity bit for even parityParity bit for odd parity
0 1 1 0 1 0 0 140, so the total stays 41, so the total becomes 5
1 1 0 0 0 1 1 040, so the total stays 41, so the total becomes 5
1 0 0 1 1 1 1 051, so the total becomes 60, so the total stays 5
0 0 1 1 0 1 0 031, so the total becomes 40, so the total stays 3
Even parity means the total number of 1s is even once the parity bit is included. Count the 1s in the data first, then decide the bit; do not try to remember a table of examples.

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.

The two marks in a checksum answer are almost always (1) a value calculated from the data and sent with it, and (1) the receiver recalculates and compares, rejecting the data if the values differ. Say both halves.

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.

Check digit = errors in data entry. Parity, checksum and echo check = errors after transmission. Writing about a check digit in a transmission question, or the reverse, is the single most common way to lose these marks.

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 receiverResponseWhat the sender does
Block arrives and passes the checkPositive acknowledgement (ACK)Sends the next block
Block arrives but fails the checkNegative acknowledgement (NAK)Re-transmits the same block automatically
Nothing arrives, or the acknowledgement is lostNo responseTimeout expires and the block is re-transmitted automatically
Three things earn marks in ARQ: positive acknowledgement, negative acknowledgement leading to re-transmission, and timeout leading to re-transmission. Students routinely forget the timeout, which is worth a mark on its own.

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.

In a message sent over a mobile network

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.

In a library issuing a book

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.

At a supermarket self-checkout

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.

In a file transfer between two computers

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.

In a serial link inside a machine

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.

Q1Name the three ways data can be corrupted during transmission.
Data loss, where bits never arrive; data gain, where extra bits appear; and data change, where a bit flips from 0 to 1 or 1 to 0.
Q2How is the parity bit set for even parity?
So that the total number of 1s in the byte, including the parity bit, is an even number.
Q3How is the parity bit set for odd parity?
So that the total number of 1s in the byte, including the parity bit, is an odd number.
Q4What kind of error can a parity check not detect?
An even number of errors in the same byte, because two flipped bits change the count of 1s by two, so the parity still matches.
Q5What does a parity block check add to a simple parity check?
A parity bit for each byte plus a parity byte for each column, so that a single corrupted bit is located at the intersection of the failing row and column.
Q6How does a checksum detect an error?
A value is calculated from the data and sent with it; the receiver recalculates it and compares the two, and a difference means the data changed in transmission.
Q7How does an echo check work?
The receiver sends the data back to the sender, which compares it with the original. It is slow because the data travels twice.
Q8What is a check digit and what does it detect?
An extra digit calculated from the other digits of a number and appended to it. It detects errors in data entry, such as a digit mistyped or a bar code misread.
Q9Where are check digits used?
In international standard book numbers (ISBNs), in the bar codes on products, and in account and identity numbers.
Q10What is a positive acknowledgement?
A signal from the receiver confirming that a block of data arrived and passed its error check.
Q11What happens after a negative acknowledgement?
The sender automatically re-transmits the block that failed the check.
Q12Why does ARQ need a timeout?
Because the data or the acknowledgement may be lost entirely, so no reply of either kind arrives. The timer expires and the sender re-transmits the block automatically.
0 of 12 marked as known

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.

IdentifyAO11 mark
A byte arrives at a receiver with an extra bit that was never sent by the sender. Identify the type of transmission error that has occurred.

Mark scheme — tick each point you actually made

Examiner tip: Data gain means something has been added. Data loss is something missing, and data change is a bit flipping value.
DescribeAO12 marks
Describe how odd parity is used to detect an error in a transmitted byte.

Mark scheme — tick each point you actually made

Examiner tip: Two sentences, one for the sender and one for the receiver. Say 'odd' explicitly, because the mark scheme is written for the parity named in the question.
ExplainAO23 marks
A data byte 1 0 1 1 0 0 1 1 is to be transmitted using even parity. Explain how the parity bit is determined, and state what the receiver will do with the byte when it arrives.

Mark scheme — tick each point you actually made

Examiner tip: Count the 1s before you write anything, and show the count. A bare answer of 'the parity bit is 1' gains nothing without the reasoning that produced it.
DescribeAO14 marks
Describe how a checksum is used to detect an error after a block of data has been transmitted.

Mark scheme — tick each point you actually made

Examiner tip: Four stages: calculate, send, recalculate, compare. Keep them in that order and the four marks follow.
ExplainAO23 marks
A library system asks staff to type the ISBN of each book. Explain how a check digit in the ISBN helps to prevent an incorrect record being created.

Mark scheme — tick each point you actually made

Examiner tip: This is about data entry, not transmission. Do not mention parity or checksums here; the marks are for calculating, comparing and rejecting at the point of entry.
ExplainAO24 marks
Explain how automatic repeat query (ARQ) is used to make sure that data is received without error.

Mark scheme — tick each point you actually made

Examiner tip: Cover all three branches. The timeout is a separate mark from the acknowledgements, and it is the one most often left out.
CompareAO14 marks
Compare a parity check and an echo check as methods of detecting errors after transmission.

Mark scheme — tick each point you actually made

Examiner tip: Compare means both methods on the same points, side by side: what is sent, the cost, what is detected, and what the sender learns. Do not describe one fully and then the other.

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

A student wroteA student wrote: 'A parity check will find any error in a transmitted byte, because the parity bit is recalculated and compared with the original.'
Why it loses marksParity only detects an odd number of bit errors. If two bits change, the count of 1s is unchanged, the parity still matches and the byte is accepted. The parity bit is also not 'recalculated and compared': the receiver counts the 1s in the byte it has received.
The answer that scoresA parity bit is added to each byte so that the total number of 1s is always odd (odd parity) or always even (even parity). The receiver counts the 1s in the received byte, including the parity bit, and if the total is not the expected odd or even number it knows a bit has changed and the byte is rejected. Because two flipped bits change the count by two and restore the parity, an even number of errors is not detected.
A student wroteA student wrote: 'A check digit is added to a packet so that the receiver can detect errors caused by interference during transmission.'
Why it loses marksThe method has been described correctly but attached to the wrong context. A check digit guards data entry, when a number is typed or scanned, and it is checked by the computer before the number is used. Errors after transmission are caught by parity, a checksum or an echo check.
The answer that scoresA check digit is an extra digit calculated from the other digits of a number and appended to it. When the number is entered by hand or read by a scanner, the computer applies the same rule to the digits it has received and compares the result with the check digit. If they differ, a digit was entered incorrectly and the entry is rejected. It is used for ISBNs and for the bar codes on products. Errors caused by interference during transmission are detected by a parity check, a checksum or an echo check.
A student wroteA student wrote: 'ARQ works because the receiver sends a negative acknowledgement, and that is how the sender knows the data arrived.'
Why it loses marksA negative acknowledgement says the opposite: the data arrived but failed its check. The statement also leaves out the positive acknowledgement and the timeout, so it describes only one of the three branches of ARQ and misstates what that one means.
The answer that scoresWith ARQ the receiver sends a positive acknowledgement when a block arrives and passes its error check, and a negative acknowledgement when it arrives but fails. The sender re-transmits the block after a negative acknowledgement. The sender also starts a timer when it transmits: if no acknowledgement of either kind arrives before the timer expires, a timeout occurs and the block is re-transmitted automatically. Together these cover corrupted, lost and unacknowledged data.
A student wroteA student wrote: 'An echo check is efficient because it sends only a small amount of extra data back to the sender.'
Why it loses marksAn echo check sends the whole of the received data back, not a summary of it. That is exactly why it is slow: the link carries every bit twice, once in each direction.
The answer that scoresIn an echo check the receiving device sends the data it has received back to the sender, and the sender compares the returned copy with the data it originally sent. If the two match, the data is accepted; if not, it is re-sent. The drawback is that the data is transmitted twice, which doubles the traffic and roughly doubles the time taken, and the sender cannot tell which of the two journeys introduced the error.

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.