What is Stop and Wait protocol?

While sending the data from the sender to the receiver the flow of data needs to be controlled. Suppose a situation where the sender is sending the data at a rate higher than the receiver is able to receive and process it, then the data will get lost. The Flow-control methods will help in ensuring that the data doesn't get lost. The flow control method will keep a check that the senders send the data only at a rate that the receiver is able to receive and process. There are mainly two ways in which this can be achieved i.e. using Stop-and-wait protocol or sliding window protocol. In this blog, we are going to learn about the Stop-and-wait protocol. So, let’s get started.

Stop and Wait Protocol

It is the simplest flow control method. In this, the sender will send one frame at a time to the receiver. The sender will stop and wait for the acknowledgment from the receiver. This time(i.e. the time between message sending and acknowledgement receiving) is the waiting time for the sender and the sender is totally idle during this time. When the sender gets the acknowledgment(ACK), then it will send the next data packet to the receiver and wait for the acknowledgment again and this process will continue as long as the sender has the data to send. This can be understood by the diagram below:

The above diagram explains the normal operation in a stop-and-wait protocol. Now, we will see some situations where the data or acknowledgment is lost and how the stop-and-wait protocol responds to it.

Situation 1

Suppose if any frame sent is not received by the receiver and is lost. So the receiver will not send any acknowledgment as it has not received any frame. Also, the sender will not send the next frame as it will wait for the acknowledgment for the previous frame which it had sent. So a deadlock situation arises here. To avoid any such situation there is a time-out timer. The sender waits for this fixed amount of time for the acknowledgment and if the acknowledgment is not received then it will send the frame again.

Situation 2

Consider a situation where the receiver has received the data and sent the acknowledgment but the ACK is lost. So, again the sender might wait till infinite time if there is no system of time-out timer. So, in this case also, the time-out timer will be used and the sender will wait for a fixed amount of time for the acknowledgment and then send the frame again if the acknowledgement is not received.

There are two types of delays while sending these frames:

  • Transmission Delay: Time taken by the sender to send all the bits of the frame onto the wire is called transmission delay. This is calculated by dividing the data size(D) which has to be sent by the bandwidth(B) of the link.
Td = D / B
  • Propagation Delay: Time taken by the last bit of the frame to reach from one side to the other side is called propagation delay. It is calculated by dividing the distance between the sender and receiver by the wave propagation speed.
Tp = d / s ; where d = distance between sender and receiver, s = wave propagation speed

The propagation delay for sending the data frame and the acknowledgment frame is the same as distance and speed will remain the same for both frames. Hence, the total time required to send a frame is:

Total time= Td(Transmission Delay) + Tp(Propagation Delay for data frame) + Tp(Propagation Delay for acknowledgment frame)
Total time=Td+ 2Tp

The sender is doing work only for Td time (useful time)and for the rest 2Tp time the sender is waiting for the acknowledgment.

Efficiency

Efficiency = Useful Time/ Total Time

η = Td / (Td+2*Tp)
η = 1/(1+2a) →(1)
where a=Tp / Td

Throughput

The number of bits that a receiver can accept in total time duration (i.e. transmission time(Td) + 2 * propagation delay(Tp)). It is also called effective bandwidth or bandwidth utilization.

In Stop and Wait, in the total duration, the receiver can accept only one frame. One frame is of data size D i.e. D bits in one frame.

Therefore, Throughput= D / (Td + 2Tp)

Throughput = D / Td(1+2a) →(2)

where a= Tp / Td

From the definition of Transmission delay,

Td=D/B

Cross multiplying B and Td, we get

B = D/Td → (3)

Now putting the value of equation 3 in equation 2, we get,

Throughput= B /(1+2a) → (4)

Now, putting the value of equation 1 in equation 4, we get,

Throughput= η * B

Advantages of Stop and Wait Protocol

  1. It is very simple to implement.
  2. The main advantage of this protocol is the accuracy. The next frame is sent only when the first frame is acknowledged. So, there is no chance of any frame being lost.

Disadvantages of Stop and Wait Protocol

  1. We can send only one packet at a time.
  2. If the distance between the sender and the receiver is large then the propagation delay would be more than the transmission delay. Hence, efficiency would become very low.
  3. After every transmission, the sender has to wait for the acknowledgment and this time will increase the total transmission time. This makes the transmission process slow .

This is how the flow of data is controlled using the stop-and-wait protocol. Hope you learned something new today.

Do share this blog with your friends to spread the knowledge. Visit our YouTube channel for more content. You can read more blogs from here .

Keep Learning :)

Team AfterAcademy!