Checking a checksum at the receiver

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

Checking a checksum at the receiver

Name:
Date:
Class:

Quick Questions

Shade in the A or B circle for each question.

1. After receiving a block of data, what does the receiver do with the checksum?
A It simply reads the sent checksum and assumes the data is correct
B It recalculates the checksum from the received data and compares it with the checksum that was sent
2. The recalculated checksum is 142 and the checksum that was sent is 142. What does this show?
A No error was detected
B An error has definitely occurred
3. The recalculated checksum is 139 but the checksum that was sent is 142. What should happen next?
A The data is accepted because the numbers are close
B An error is detected and the data is requested again
4. Which statement about a matching checksum is correct?
A A match means no error was detected
B A match proves the data is 100% error-free
5. The data arrives correctly, but the checksum itself was changed during transmission. What will the receiver find?
A A mismatch, because the checksum itself was corrupted
B A match, because the data is correct

Match the Pairs

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

Left columnRight column
1calculated == received_checksum AIF calculated != received_checksum THEN request_resend
2calculated != received_checksum BThe checksums differ, so an error has occurred and the data must be requested again
3The receiver works out its own checksum from the data it received, using the same method as the sender CA resend is requested when the checksums match. It should only be requested on a mismatch, because a match means no error was detected.
4A mismatch means an error was found, so the receiver asks the sender to send the data again DThe checksum the receiver worked out matches the one sent, so no error is detected
5IF calculated == received_checksum THEN request_resend Ecalculated = checksum(received_data)
6A mismatch means the checksum is corrupted, so the data must be fine FThe checksum itself can be corrupted in transmission, so a mismatch does not prove which part is wrong. Either way, the data is requested again.

Definitions

recalculate and compare

Fill in the Blanks

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

1.
IF calculated _ sent THEN OUTPUT "No error detected" ENDIF
2.
IF calculated __ sent THEN OUTPUT "Request data again" ENDIF
3.
IF calculated = sent THEN OUTPUT "OK" ____ OUTPUT "Request resend" ENDIF
4.
calculated ← SUM(________) MOD 256 IF calculated = sent THEN OUTPUT "OK" ENDIF
5.
// Data is fine but checksum corrupted IF calculated <> ____ THEN OUTPUT "Resend" ENDIF

Spot the Error

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

Question 1
A calc ← sentChecksum MOD 256
B IF calc = sentChecksum THEN
C OUTPUT "No error detected"
D ELSE
E OUTPUT "Request resend"
F ENDIF
Question 2
A calc ← SUM(received) MOD 256
B IF calc <> sentSum THEN
C OUTPUT "No error detected"
D ELSE
E OUTPUT "No error detected"
Question 3
A INPUT received
B calc ← SUM(received) MOD 256
C IF calc = sentSum THEN
D OUTPUT "No error detected"
Question 4
A sent ← 142
B calc ← LENGTH(data)
C IF calc <> sent THEN
D OUTPUT "Error: resend"
Question 5
A received ← [10, 20, 40]
B sentSum ← 60
C calc ← sentSum
D IF calc <> sentSum THEN
E OUTPUT "Request again"

Answer Key

Checking a checksum at the receiver
Section A: Quick Questions
Q1
B — It recalculates the checksum from the received data and compares it with the checksum that was sent
Q2
A — No error was detected
Q3
B — An error is detected and the data is requested again
Q4
A — A match means no error was detected
Q5
A — A mismatch, because the checksum itself was corrupted
Section B: Match the Pairs
Q1
calculated == received_checksum → The checksum the receiver worked out matches the one sent, so no error is detected
Q2
calculated != received_checksum → The checksums differ, so an error has occurred and the data must be requested again
Q3
The receiver works out its own checksum from the data it received, using the same method as the sender → calculated = checksum(received_data)
Q4
A mismatch means an error was found, so the receiver asks the sender to send the data again → IF calculated != received_checksum THEN request_resend
Q5
IF calculated == received_checksum THEN request_resend → A resend is requested when the checksums match. It should only be requested on a mismatch, because a match means no error was detected.
Q6
A mismatch means the checksum is corrupted, so the data must be fine → The checksum itself can be corrupted in transmission, so a mismatch does not prove which part is wrong. Either way, the data is requested again.
Section C: Definitions
Q1
recalculate and compare — The receiver recalculates the checksum from the received data and compares it with the one sent. Match means no error detected; mismatch means error, so resend is requested.
Section D: Fill in the Blanks
Q1
IF calculated = sent THEN OUTPUT "No error detected" ENDIF
Q2
IF calculated <> sent THEN OUTPUT "Request data again" ENDIF
Q3
IF calculated = sent THEN OUTPUT "OK" ELSE OUTPUT "Request resend" ENDIF
Q4
calculated ← SUM(received) MOD 256 IF calculated = sent THEN OUTPUT "OK" ENDIF
Q5
// Data is fine but checksum corrupted IF calculated <> sent THEN OUTPUT "Resend" ENDIF
Section E: Spot the Error
Q1
A — The receiver must recalculate the checksum from the data it received, not from the checksum that was sent. It should be calc ← SUM(data) MOD 256.
Q2
C — When the two checksums differ, an error has occurred, so the receiver must request the data again. It must not say that no error was detected.
Q3
A — The receiver needs the checksum that was sent as well as the data, otherwise it has nothing to compare with. It should be INPUT received, sentSum.
Q4
B — A checksum is calculated from the values in the data, not by counting how many items there are. It should be calc ← SUM(data) MOD 256, using the same method as the sender.
Q5
C — Copying the sent checksum means the two values always match, so errors are never found. The receiver must recalculate it with calc ← SUM(received).