1-bit Sliding Window Protocol
Window size 1. Stop-and-wait. Must get ack before can send next frame.
Both machines are sending and receiving. Combined in one loop here.
Let us assume one goes first.
If both start simultaneously, get problem – see later.
If one goes first, only one of them has the yellow block outside the main loop:
1-bit Sliding Window
Look at section to “handle inbound stream”:
If got frame, inc(expected), then later ack(1-expected) (ack last frame).
Ack always = (1-expected).
Look at section to “handle outbound stream”:
If got ack for what I’m trying to send, go on to next.
Else simply re-send it.
My acks responding to my inbound stream are being piggybacked onto my outbound stream.
Similarly, my inbound stream contains acks relating to my outbound stream.
|Figure (a) below:|
A trying to send its frame 0 to B.
B trying to send its frame 0 to A.
Imagine A’s timeout is too short. A repeatedly times out and sends multiple copies to B, all with seq=0, ack=1.
When first one of these gets to B, it is accepted. Set expected=1. B sends its frame, seq=0, ack=0.
All subsequent copies of A’s frame rejected since seq=0 not equal to expected. All these also have ack=1.
B repeatedly sends its frame, seq=0, ack=0. But A not getting it because it is timing out too soon.
Eventually, A gets one of these frames. A has its ack now (and B’s frame). A sends next frame and acks B’s frame.
Conclusion: Could get wasted time, but provided a frame can eventually make it through, no infinite loop, and no duplicate packets to Network layer. Process will complete.
Notation (seq, ack, packet)
Asterisk – delivered to Network layer.