Reliable Data Transfer (Stop & Wait)
These notes are low-effort, due to catching up in this module. See the videos and slides for more detail.
Recovering From Errors
We can use acknowledgements and negative acknowledgements from the client to the sender:
- Acknowledgements (ACKs) - Tells the sender that the packet was received okay.
-
Negative Acknowledgements (NACKs) - Tells the sender that the packet had errors.
This can be removed as the sender can resend the packet if there is a timeout for an ACK.
Corrupted Acknowledgements
If an acknowledgement is lost then the sender will send a duplicate packet. We can add sequence numbers to keep track of if a packet is a duplicate:
- For stop and wait we can alternate between 0 and 1.
- If there is a duplicate the packet is dropped and another acknowledgement is sent.
Packet Loss
A timer can be put on each packet:
- If an ACK is not received in time the packet is re-transmitted.
- If the re-transmission is a duplicate then the sequence numbers will handle this.
Twice the round trip time is a reasonable starting point for the timer.
Stop & Wait Sequence
Sender:
- Sequence number is added to the packet.
- 0 or 1 will do.
- Send the packet and start timer.
- Check if the ACK is corrupt or a NACK, if it is send the same packet.
- Send the next packet if an ACK is received.
- If packet times out, send it again.
Receiver:
- Must check if received packet is duplicate.
- State indicates whether 0 or 1 is expected packet sequence number.
- If packet is duplicate send ACK.
- If packet is in order then send ACK and pass to the application layer.