Stop and Wait Protocol
Overview
To maintain the rate of data transmission between sender and receiver, it is required to use flow control protocol. The data link layer provides us with the protocol for controlling the data transmission rate. So here we are going to discuss one of the flow control protocols named stop and wait protocol.
The stop-and-wait protocol is a simple protocol that allows the sender to send the next packet when the acknowledgment of the previous packet is received from the receiver.
What is the Stop and Wait Protocol?
- While transmitting data from sender to receiver, the flow of data is required to be controlled.
- It uses a link between sender and receiver as a half-duplex link.
- Suppose there is a situation where the sender is sending the data at a rate higher than the rate of the receiver to process and receive the data. Flow Control protocol ensures that the data does not get lost.
- The flow control protocols ensure that the sender sends the data only at a rate that the receiver can receive and process it.
- This is a flow control protocol that works in a noiseless channel.
- Noiseless channel is an idealistic channel in which no data frames are lost, corrupted, or duplicated.
- After sending the data, the sender will stop and wait until he receives an acknowledgment from the receiver.
- Flow control service is provided by the data link layer of the OSI suite.
Refer to the below image to see various flow control protocols of the data link layer
Note: In the stop-and-wait protocol, the sender will send the data and wait for an acknowledgment from the receiver.
Primitives of Stop and Wait Protocol
Sender Side
Rule 1: Sender will send one packet at a time Rule 2: Sender will send the next packet to the receiver only when it receives the acknowledgment of the previous packet from the receiver. So, in the stop-and-wait protocol, the sender-side process is very simple.
Note: The sender sends one packet at a time and does not send the next packet until it receives an acknowledgment of the previous packet from the receiver.
Receiver Side
Rule 1: The receiver receives the data packet and then consumes the data packet. Rule 2: The receiver sends acknowledgment when the data packet is consumed. So, in this protocol, the receiver-side process is also very simple.
Working of Stop and Wait Protocol
- If there is a communication between sender and receiver, then the sender sends the packet to the receiver, and the packet is called a data packet.
- The sender will not send the second packet to the receiver until acknowledgment of the first packet is received.
- The receiver will send the acknowledgment for the packet that the receiver has received.
- When the sender receives the acknowledgment, it sends the next packet to the receiver.
- This process of sending data and receiving acknowledgment continues until all the packets are not sent.
- The main benefit of stop and wait protocol is its simplicity
- But this protocol has some disadvantages, too; for example, if the sender wants to send 10,000 data packets, and the sender can not send all 10,000 packets at a time in this protocol, one packet is allowed to be sent at a time.
Refer to the below image to see the working of data transmission in the stop-and-wait protocol
Advantages of Stop and Wait Protocol
- This protocol provides flow control.
- One of the main advantages of the stop-and-wait protocol is its simplicity.
- Stop and wait protocol is useful in LAN as its efficiency decreases with the increasing distance between sender and receiver.
- If we increase the data packet size, the efficiency is going to increase. Hence, it is suitable for transmitting big data packets.
- Stop & wait protocol is accurate as the sender sends the next frame to the receiver only when the acknowledgment of the previous packet is received. So there is less chance of the frame being lost.
Disadvantages of Stop and Wait Protocol
Problems Occur Due to Lost Data
Suppose the sender sends the data packet, but the data packet is lost due to some reason. Since the receiver has not received the packet for a long time, the sender does not receive any acknowledgment from the receiver, so it will not send the next packet.
In this case, two problems occur in data transmission:
- For an acknowledgment, the sender has to wait for an infinite amount of time.
- The receiver will also have to wait for an infinite amount of time to receive the data.
Refer to the below image to see data loss in the stop-and-wait protocol
Problems Occur Due to Lost Acknowledgment
Suppose the sender sends the packet, and the receiver will send an acknowledgment. But the acknowledgment sent by the receiver will be lost in the network, therefore sender will not send the next packet as the acknowledgment is not received In this case, one problem occurs in data transmission:
- The sender has to wait for an infinite amount of time due to acknowledgment loss in the network.
Refer to the below image to see acknowledgment loss in the stop-and-wait protocol
Problem Due to the Delay in Data or Acknowledgment
Suppose the sender sends the data packet, and the receiver will also send the acknowledgment, but the acknowledgment is received by the sender after the timeout period. So sender will not consider this acknowledgement as there may be a situation that the sender will retransmit the packet after time out.
Refer to the below image to see delayed data and acknowledgment in the stop-and-wait protocol
Enroll in our Free Computer Networking course specially curated by industry experts. Sign up today and get certified for free!
Conclusion
- Stop and wait protocol is a simple and reliable protocol for flow control.
- Stop and wait protocol is a data link layer protocol.
- In this protocol, the sender will not send the next packet to the receiver until the acknowledgment of the previous packet is received.
- One of the disadvantages of stop and wait protocol is that its efficiency is low.