Lesson 55: Checksum
Did the data arrive safely?
- Data can change on the way: noise can flip a bit.
- The sender works out a checksum from the data and sends it with the data.
- The receiver works out the checksum again. Same number: OK. Different number: error, so it asks for the data again.
Words for this lesson
| Word | Meaning |
|---|---|
| checksum | a value calculated from the data, sent with it |
| ASCII code | the number for a character, e.g. H = 72 |
| acknowledgement | a message back: "I got it, no errors" |
| ARQ | automatic repeat query: resend until it arrives correctly |
The checksum steps
| Step | Who | What |
|---|---|---|
| 1 | sender | calculates the checksum from the data |
| 2 | sender | sends the data and the checksum |
| 3 | receiver | calculates the checksum again |
| 4 | receiver | compares: same → ACK; different → ask to resend |
In the exam
- 0478/11/M/J/25 Q4(b)(i): describe the checksum process. Mark scheme: the checksum is calculated from the data with an algorithm; it is transmitted with the data; it is recalculated by the receiver; if the values do not match, an error is detected and the data is resent.
- 0478/13/O/N/23 Q5(c): how an ARQ works. Mark scheme: the receiver checks the packet for errors and sends an acknowledgement; if the sender gets no acknowledgement before a timeout, it resends the packet.
Dificuldade 3/5 · Moedas 200 + pequeno bônus na primeira conclusão hoje
Before data is sent, the sender works out a checksum from it. Finish checksum(data): add up the ASCII codes of all the characters (data[i] is a code), then return the remainder after dividing by 256, so it fits in one byte. Type HELLO: the checksum is 116.
Clique em Executar para ver a saída aqui.
Dificuldade 4/5 · Moedas 280 + pequeno bônus na primeira conclusão hoje
Now be the receiver. A packet arrives as the data, a comma and the checksum the sender worked out, for example HELLO,116. Recalculate the checksum. If it matches, light the green LED (pin 12) and send back ACK. If not, light the red LED (pin 13) and print Error: please resend.
Clique em Executar para ver a saída aqui.