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:

Td = D / B

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,