What a checksum can and cannot detect

Tip: Choose Save as PDF in the print dialog to download. Use A4 paper size.

What a checksum can and cannot detect

Name:
Date:
Class:

Quick Questions

Shade in the A or B circle for each question.

1. Two bytes swap places during transmission. The sum of all the bytes stays the same. Will the checksum spot the error?
A No, the sum is unchanged so the error is missed
B Yes, the checksum always notices a change of order
2. One byte goes UP by 5 and another byte goes DOWN by 5. What happens to the checksum?
A It changes, so the receiver always finds the errors
B It stays the same, so the errors cancel out and are missed
3. A single byte in a block is changed during transmission. Which statement is true?
A The sum changes, so the checksum will normally detect it
B The sum stays the same, so the checksum cannot detect it
4. Which is a strength of a checksum compared with a single parity bit for a whole block?
A It checks every byte's value, so it catches more errors
B It can always find which byte is wrong and fix it
5. The receiver's checksum does not match the one sent. What can the receiver tell?
A Exactly which byte is wrong, so it can correct it
B There is an error somewhere, but not which byte is wrong

Match the Pairs

Draw a line connecting each item on the left to its match on the right.

Left columnRight column
1Sent: 10, 20, 30 | Received: 30, 20, 10 AA checksum cannot show which byte is wrong, so the receiver cannot tell that byte 3 is the problem.
2Sent: 10, 20, 30 | Received: 15, 20, 25 BA matching checksum does not prove the data is correct, because swapped bytes or errors that cancel out give the same sum.
3A checksum is stronger than a single parity bit for a block because it detects most changes, losses and gains in the whole block. COne byte went up by 5 and another down by 5, so the sum is unchanged and the error is missed.
4A checksum cannot show which byte is wrong: a mismatch only tells you that there is an error somewhere in the data. DThe bytes are swapped but the sum is still 60, so the checksum matches and the error is missed.
5Checksums match, so the data must be perfect ESent: 10, 20, 30, sum 60 | Received: 10, 20, sum 60 -> 30 is not 60, error found
6Checksum mismatch at byte 3, so resend byte 3 only FSent sum 60, received sum 65 -> error, but which byte?

Definitions

checksum

Fill in the Blanks

Complete each line of code by filling in the missing parts.

1.
sent ← 4 + 9 + 2 received ← 9 + 4 + 2 IF sent _ received THEN OUTPUT "No error"
2.
sent ← 10 + 20 + 30 received ← 11 + __ + 30 IF sent = received THEN OUTPUT "Missed"
3.
sent ← 8 + 5 + 7 received ← 8 + 5 IF sent ≠ ________ THEN OUTPUT "Error"
4.
IF sent ≠ received THEN errorDetected ← ____ locationKnown ← FALSE
5.
sum1 ← byteA + byteB sum2 ← byteB _ byteA OUTPUT sum1 = sum2

Spot the Error

Shade in the letter of the line that contains an error.

Question 1
A sent ← [10, 20, 30]
B got ← [20, 10, 30]
C IF SUM(sent) = SUM(got) THEN
D OUTPUT "Swap detected"
Question 2
A sent ← [5, 9, 7]
B got ← [6, 8, 6]
C checksum ← 20
D OUTPUT SUM(got) = checksum
Question 3
A sum ← SUM(received)
B IF sum <> checksum THEN
C OUTPUT "Byte 3 is wrong"
D REQUEST RESEND
Question 4
A checksum ← MAX(data) MOD 256
B SEND data, checksum
C received ← RECEIVE()
D calc ← SUM(rx.data) MOD 256
E IF calc <> rx.check THEN
Question 5
A sent ← [8, 3, 4, 5]
B got ← [8, 3, 4, 5]
C IF SUM(got) <> 20 THEN
D OUTPUT "Error found"

Answer Key

What a checksum can and cannot detect
Section A: Quick Questions
Q1
A — No, the sum is unchanged so the error is missed
Q2
B — It stays the same, so the errors cancel out and are missed
Q3
A — The sum changes, so the checksum will normally detect it
Q4
A — It checks every byte's value, so it catches more errors
Q5
B — There is an error somewhere, but not which byte is wrong
Section B: Match the Pairs
Q1
Sent: 10, 20, 30 | Received: 30, 20, 10 → The bytes are swapped but the sum is still 60, so the checksum matches and the error is missed.
Q2
Sent: 10, 20, 30 | Received: 15, 20, 25 → One byte went up by 5 and another down by 5, so the sum is unchanged and the error is missed.
Q3
A checksum is stronger than a single parity bit for a block because it detects most changes, losses and gains in the whole block. → Sent: 10, 20, 30, sum 60 | Received: 10, 20, sum 60 -> 30 is not 60, error found
Q4
A checksum cannot show which byte is wrong: a mismatch only tells you that there is an error somewhere in the data. → Sent sum 60, received sum 65 -> error, but which byte?
Q5
Checksums match, so the data must be perfect → A matching checksum does not prove the data is correct, because swapped bytes or errors that cancel out give the same sum.
Q6
Checksum mismatch at byte 3, so resend byte 3 only → A checksum cannot show which byte is wrong, so the receiver cannot tell that byte 3 is the problem.
Section C: Definitions
Q1
checksum — A sum of the data bytes sent with the data. It catches most changes, losses and gains, but misses swapped bytes or errors that cancel out, and cannot show which byte is wrong.
Section D: Fill in the Blanks
Q1
sent ← 4 + 9 + 2 received ← 9 + 4 + 2 IF sent = received THEN OUTPUT "No error"
Q2
sent ← 10 + 20 + 30 received ← 11 + 19 + 30 IF sent = received THEN OUTPUT "Missed"
Q3
sent ← 8 + 5 + 7 received ← 8 + 5 IF sent ≠ received THEN OUTPUT "Error"
Q4
IF sent ≠ received THEN errorDetected ← TRUE locationKnown ← FALSE
Q5
sum1 ← byteA + byteB sum2 ← byteB + byteA OUTPUT sum1 = sum2
Section E: Spot the Error
Q1
D — Swapping bytes does not change the total, so both sums are 60. The checksum matches and the swap goes unnoticed. The line should say the swap is not detected.
Q2
A — The checksum is 20, so the sent bytes must add up to 20. 5 + 9 + 7 is 21. The line should be sent ← [5, 9, 6].
Q3
C — A checksum only shows that the sum is wrong. It cannot show which byte is wrong. The message should say there is an error somewhere in the data.
Q4
A — A checksum is made by adding the data bytes, not by finding the largest one. The line should use SUM(data).
Q5
B — The example shows a lost byte, so got should be missing the 5, and its sum is then 15, not 20. With all four bytes the sum would be 20 and no error would be found. The line should be got ← [8, 3, 4].