Lesson 67: Wait for the ACK
No reply? Send it again
- In a positive ARQ (automatic repeat query), the receiver sends an acknowledgement (ACK) for each packet that arrives without errors.
- The sender starts a timer when it sends a packet. No ACK before the timeout: it sends the packet again.
millis()is the timer: the time since the board started, in ms.
Words for this lesson
| Word | Meaning |
|---|---|
| acknowledgement | a message back: "I got it" |
| timeout | the time limit for the ACK |
| resend | send the same packet again |
The first program, step by step
| Time (ms) | What happens |
|---|---|
| 0 | send packet 1, timer starts |
| 400 | ACK: packet 1 OK, send packet 2 |
| 1400 | no ACK for 1000 ms: resend packet 2 |
| 1800 | ACK: packet 2 OK, send packet 3 |
| 2200 | ACK: packet 3 OK, all sent |
In the exam
- 0478/11/M/J/24 Q9(b)(i): describe how a parity check and a positive ARQ find errors. Mark scheme points for the ARQ: the packet is sent and a timer is started; if the data is correct, an acknowledgement is sent; the sender then sends the next packet and restarts the timer; if the data has an error, no acknowledgement is sent; if no acknowledgement arrives before the timeout, the packet is resent.
Сложность 4/5 · 280 монет + небольшой бонус за первое завершение сегодня
The Arduino sends 3 packets. You are the receiver: type ACK when a packet arrives. The sender keeps the time it sent the packet in sentAt. Add the таймаут: if no ACK has come after more than 1000 ms, print Timeout: resend packet and the number, and send the packet again with sendPacket().
Нажмите Запустить, чтобы увидеть результат здесь.
Сложность 4/5 · 280 монет + небольшой бонус за первое завершение сегодня
If the link is broken, the sender should not try for ever. Count the tries in tries. After a timeout on the third try, print Link down and stop. Otherwise add 1 to tries, print for example Timeout: resend packet 2 (try 2) and send again. tries goes back to 1 when an ACK arrives.
Нажмите Запустить, чтобы увидеть результат здесь.