Stop-and-Wait


Stop-and-Wait
  • Senders keeps a copy of the last frame until it receives an acknowledgement.
  • For identification, both data frames and acknowledgements (ACK) frames are numbered alternatively 0 and 1.
  • Sender has a control variable (S) that holds the number of the recently sent frame. (0 or 1)
  • Receiver has a control variable (R) that holds the number of the next frame expected (0 or 1).
  • Sender starts a timer when it sends a frame. If an ACK is not received within a allocated time period, the sender assumes that the frame was lost or damaged and resends it.
  • Receiver send only positive ACK if the frame is intact.
  • ACK number always defines the number of the next expected frame.

  • When a receiver receives a damaged frame, it discards it and keeps its value of R.
  • After the timer at the sender expires, another copy of frame 1 is sent.

Lost Frame
Lost Frame 2

  • If the sender receives a damaged ACK, it discards it.
  • When the timer of the sender expires, the sender retransmits frame 1.
  • Receiver has already received frame 1 and expecting to receive frame 0 (R=0). Therefore it discards the second copy of frame 1.

  • The ACK can be delayed at the receiver or due to some problem
  • It is received after the timer for frame 0 has expired.
  • Sender retransmitted a copy of frame 0. However, R =1 means receiver expects to see frame 1. Receiver discards the duplicate frame 0.
  • Sender receives 2 ACKs, it discards the second ACK.

Delayed frame
Piggybacking Method

  • A method to combine a data frame with ACK.
  • Station A and B both have data to send.
  • Instead of sending separately, station A sends a data frame that includes an ACK.
  • Station B does the same thing.
  • Piggybacking saves bandwidth.

  • In stop-and-wait, at any point in time, there is only one frame that is sent and waiting to be acknowledged.
  • This is not a good use of transmission medium.
  • To improve efficiency, multiple frames should be in transition while waiting for ACK.