Skip to content
UoL CS Notes

Reliable Data Transfer (Stop & Wait)

COMP211 Lectures

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:

  1. Sequence number is added to the packet.
    • 0 or 1 will do.
  2. Send the packet and start timer.
  3. Check if the ACK is corrupt or a NACK, if it is send the same packet.
  4. Send the next packet if an ACK is received.
  5. If packet times out, send it again.

Receiver:

  1. Must check if received packet is duplicate.
  2. State indicates whether 0 or 1 is expected packet sequence number.
  3. If packet is duplicate send ACK.
  4. If packet is in order then send ACK and pass to the application layer.