Error Detection
Data Transmission
A checksum is a value calculated from the data using an agreed algorithm, sent alongside the data, and re-calculated by the receiver to verify the data was not corrupted.
How it works
- Before transmission, the sender runs every byte of the data through a algorithm. The output is a small fixed-size number (often a single byte or a few bytes).
- The sender transmits the data together with the checksum.
- The receiver re-runs the same checksum algorithm on the received data.
- The receiver compares its calculated checksum with the one that was sent.
- If the two checksums match, no error has been detected. If they differ, the data has been corrupted in transit.
A simple example checksum algorithm
A textbook example: take each byte of the data as a number, add them all up, and keep only the last byte of the sum.
For data bytes 45, 200, 12, 99:
- Sum: 45 + 200 + 12 + 99 = 356
- Last byte (modulo 256): 356 − 256 = 100
- Transmitted checksum: 100
If a single byte changes during transmission, the receiver's sum will be different and the checksums will not match. Real algorithms (CRC, MD5, SHA) use more complex maths to catch a much wider range of corruption patterns.
What checksums can and cannot do
- Detects that an error has occurred.
- Does NOT locate where the error is.
- Does NOT correct the error.
- Can miss carefully crafted changes that happen to give the same checksum (extremely rare with good algorithms).
Exam tip
Why mismatched checksums prove the data changed
A two-mark question told you that the two checksum values did not match and asked why that shows an error. Any two of three points earned the marks: the checksum is calculated from the data itself; the receiver recalculates it with the same algorithm; so different values can only have come from different data. Repeating that the values differ is the question's own premise, so your answer has to say why they differ: the data that arrived is not the data that was sent.
Quick check
4 short questions on this note. See what has stuck, and where to look if something hasn't.