Stop and Wait protocol, its problems and solutions
It is the simplest flow control method in which the sender will send the packet and then wait for the acknowledgement by the receiver that it has received the packet then it will send the next packet.
Stop and wait protocol is very easy to implement.
Attention reader! Don’t stop learning now. Practice GATE exam well before the actual exam with the subject-wise and overall quizzes available in GATE Test Series Course.
Learn all GATE CS concepts with Free Live Classes on our youtube channel.
Total time taken to send is,
Ttotal = Tt(data) + Tp + Tq + Tprocess + Tt(ack) + Tp ( since, Tq and Tprocess = 0) Ttotal = Tt(data) + 2Tp + Tt(ack) Ttotal = Tt(data) + 2Tp (when Tt(ack) is negligible)
Efficiency = useful time / total cycle time = Tt / (Tt+2Tp) = 1 / (1+2a) [a = Tp/Tt]
Note: Stop and wait is better for less distance. Hence it is a good protocol for LAN. Stop and wait is favorable for bigger packets.
What if the data packet is lost in between ?
- According to sender, receiver is busy but actually data is lost.
- Receiver will assume, no packet has been sent by sender.
- Both will be waiting for each other and there will be a deadlock.
Need for timeout timer:
A timer is applied and the receiver will wait till the timeout timer for the data after that it will confirm that the data has been lost.
What if the data packet has been lost ?
After timeout timer expires, sender will assume that the data is lost but actually the acknowledgement is lost. By assuming this it will send the data packet again but according to receiver it is a new data packet, hence it will give rise to duplicate packet problem.
To eliminate duplicate packet problem sequence number is added to the data packet. So using packet numbers it can easily determine the duplicate packets.
What if there is a delay in receiving acknowledgement ?
According to sender, the acknowledgement of packet 1 is delayed and packet 2 has been lost. But the receiver assumes that the acknowledgement that has been received was of packet 2. This problem is called missing packet problem.
Missing packet problem can be solved if acknowledgements also have numbers.