Code360 powered by Coding Ninjas X Naukri.com. Code360 powered by Coding Ninjas X Naukri.com
Table of contents
1.
Introduction
2.
What is Stop and Wait for ARQ (Automatic Repeat Request)?
3.
Stop and Wait ARQ Protocol
4.
Primitives of Stop and Wait Protocol
4.1.
Sender's side:
4.2.
Receiver's side:
5.
Working of Stop and Wait protocol
6.
Characteristics of Stop and Wait ARQ
7.
Advantages of Stop and Wait Protocol
7.1.
Simple Implementation
7.2.
Error Detection and Correction 
7.3.
Flow Control 
7.4.
Ideal for Short Messages
7.5.
Deterministic Behavior
8.
Disadvantages of Stop and Wait Protocol
8.1.
Problems due to lost data
8.2.
Problems due to lost acknowledgement
8.3.
Problems due to the delayed Acknowledgement/Data
9.
 
10.
Frequently Asked Questions
10.1.
Where is the Stop and Wait protocol used?
10.2.
Which protocol improves the efficiency of stop-and-wait protocol?
10.3.
Why is the stop and wait protocol inefficient?
10.4.
In which type of channel stop and wait protocol is used?
11.
Conclusion
Last Updated: Mar 27, 2024
Medium

Stop and Wait Protocol

gp-icon
Computer networks
Free guided path
11 chapters
46+ problems
gp-badge
Earn badges and level up

Introduction

In this article, we will discuss the Stop and Wait protocol. In this protocol, the sender sends one frame at a time to the receiver and waits for the acknowledgement. Until the acknowledgement is received, the sender sits idle. Upon receiving the acknowledgement, the sender will send the next frame and wait for its acknowledgement. This process will keep going until the sender has transmitted all the frames. 

stop and wait arq

To make sure that we don't lose frames in between, we need flow control which is provided by the Data link layer. Flow control is a speed matching mechanism where the receiver should inform the sender at what speed it can handle the data frames. It is a set of procedures that tells the sender how much data it can transmit before waiting for an acknowledgement from the receiver.

The protocols involved in flow control are shown below:

Protocols flowchart

In the next section, we will learn about the Stop-and-Wait protocols & then move on to the Stop-and-Wait ARQ protocols with their working.

What is Stop and Wait for ARQ (Automatic Repeat Request)?

  • It is a flow control protocol where flow control is one of the data link layer's services.
  • Stop and Wait Protocol is a data link layer protocol for the transmission of frames over noiseless channels.
  • It provides unidirectional data transmission with flow control facilities but without error control facilities.
  • After sending one frame, the sender will not send any other frame, and it waits for an acknowledgement before transmitting the next frame.
Get the tech career you deserve, faster!
Connect with our expert counsellors to understand how to hack your way to success
User rating 4.7/5
1:1 doubt support
95% placement record
Akash Pal
Senior Software Engineer
326% Hike After Job Bootcamp
Himanshu Gusain
Programmer Analyst
32 LPA After Job Bootcamp
After Job
Bootcamp

Stop and Wait ARQ Protocol

After transmitting one frame in the Stop and Wait Protocol, the sender waits for an acknowledgement before transmitting the next frame. There are chances for the frame to be lost or the acknowledgement to be lost. If it happens, the sender and receiver will wait for an infinite amount of time, and there will be no progress in the Stop and Wait Protocol.

The Stop and Wait automatic repeat request (ARQ) protocol differs from the Stop and Wait Protocol. 

  • In this Protocol, if the acknowledgement does not arrive after a certain period of time, the sender times out and retransmits the original frame.
  • If the sender is sending a frame and the receiver receives that and sends an acknowledgement. If that acknowledgement has not reached the sender on time, a timer will run on the sender's side.
  • Once the timer expires or the senders times out immediately, the sender will retransmit the frame again. This retransmission is automatic; we call it Stop and Wait ARQ (automatic repeat request protocol).
  • Stop and Wait ARQ = Stop and Wait + Timeout Timer + Sequence number.

Primitives of Stop and Wait Protocol

Sender's side:

Rule1: Send one data packet at a time.

Rule2: Send the next packet only after receiving the acknowledgement for the previous packet.

Receiver's side:

Rule 1: Receive and consume data packet.

Rule 2: After consuming the packet, acknowledgement needs to be sent (Flow Control).

Working of Stop and Wait protocol

Let's understand the above rules with an example:

Step1: Suppose there is a sender and there is a receiver, and the sender will send exactly one packet, i.e. the data packet. Now, the sender will not send any other data packet before receiving the acknowledgement from the previous packet.     

Data Packet

Step 2: Now the receiver will send an acknowledgement to the sender for the data packet that it has received.

Acknowledgement

 

Step 3:After receiving the acknowledgement, the sender will again send the next packet and so on.

 

next packet sent

 

The main advantage of the Stop and Wait protocol is its simplicity, but the main disadvantage is that if it has 1000 packets, all packets cannot be transmitted simultaneously. So, it has to wait for the acknowledgement before sending the next packet.   

Characteristics of Stop and Wait ARQ

Some of the characteristics of Stop and Wait ARQ include:

  • Simplicity: Stop and Wait ARQ is simple to implement and is used for basic communication systems
     
  • Sequential Transmission: It sends one frame at a time and waits for an acknowledgement before sending the next frame
     
  • Positive Acknowledgment: The sender waits for a positive acknowledgement (ACK) before sending the next transmission from the receiver
     
  • Retransmission: If the sender does not receive an ACK or receives a negative acknowledgement (NACK) in a fixed timeout period,  it again transmits the  frame
     
  • Reliable but Inefficient: It ensures reliable data transfer, but it is inefficient because  it needs to wait for the sender's acknowledgements
     
  • Low Throughput: Stop and Wait ARQ causes low throughput, mainly on high-latency networks

Advantages of Stop and Wait Protocol

Key advantages of Stop and Wait ARQ are:

Simple Implementation

Stop and Wait is easy to implement, which makes it best for basic communication systems with limited resources 

Error Detection and Correction 

It effectively detects and corrects errors in transmitted data via the acknowledgement process

Flow Control 

Stop and Wait helps prevent data congestion as the sender waits for acknowledgement before sending more data

Ideal for Short Messages

It is best for situations where the data payload is small and the overhead of the acknowledgement process is acceptable

Deterministic Behavior

Stop and Wait protocol ensures a deterministic and predictable behaviour, which can be advantageous in real-time systems

Disadvantages of Stop and Wait Protocol

Problems due to lost data

Suppose the sender sends the data, and this data is lost.
→ The sender waits for the acknowledgement for an infinite amount of time. As the data is lost, the receiver has not received any packet from the sender. So it will not send the acknowledgement to the sender.
→ The receiver waits for an infinite time for the data packet as the data is lost.

Data loss

Problems due to lost acknowledgement

In this case, the sender has sent the data to the receiver, and the receiver has sent the acknowledgement, but here the acknowledgement is lost due to some problems in the network. So, in this case, the sender waits for an infinite amount of time for the acknowledgement.

Infinite acknowledgement

Problems due to the delayed Acknowledgement/Data

After a timeout on the sender side, a delayed acknowledgement might be wrongly considered as the acknowledgement of some other data packet.

Time out

 


You can also read about the network models in computer network.

Frequently Asked Questions

Where is the Stop and Wait protocol used?

It is used in relational communication. It allows you to control errors and flows. It can be used in both the Data Link and the transport Layers.

Which protocol improves the efficiency of stop-and-wait protocol?

To improve the efficiency of the stop and wait protocol we can use selective repeat protocol, by using this protocol we don't need to wait for the acknowledgement of each frame when sending multiple frames.

Why is the stop and wait protocol inefficient?

Stop and wait protocol can be considered an inefficient protocol because, we have to wait for the acknowledgment of previous frame before sending the next frames, which leads to more delays and less usage of provided bandwidth.

In which type of channel stop and wait protocol is used?

The stop-and-wait protocol is used in channels where there is a low error rate and relatively low data transfer delay. These can include reliable wireless connections or wired-connected channels.

Conclusion

This article extensively discussed the Stop and Wait protocol and its working in different scenarios with examples for a better understanding.

Recommended Readings:

Check out some of the amazing Guided Paths on topics such as Data Structure and Algorithms, Competitive Programming, Basics of C, Basics of Java, Computer Networks, etc. along with some Contests and Interview Experiences only on Coding Ninjas Studio

Previous article
RIP Protocol
Next article
Routing vs. Routed Protocols
Guided path
Free
gridgp-icon
Computer networks
11 chapters
46+ Problems
gp-badge
Earn badges and level up
Live masterclass