The Stop-and-Wait Protocol is one of the simplest and most fundamental protocols used in data communication to ensure reliable data transmission between two devices, typically a sender and a receiver. It is a flow control protocol, meaning that it controls the rate of data transmission between two devices to prevent the sender from overwhelming the receiver.
In this protocol, the sender transmits a data frame and then waits for an acknowledgment (ACK) from the receiver before sending the next frame. The sender is in a “waiting” state until it receives the ACK. If the sender doesn’t receive an acknowledgment within a specified timeout period, it will retransmit the same frame.
Key Characteristics
- Simple and Reliable:
- The protocol ensures that data is reliably delivered by requiring acknowledgment for each frame before sending the next.
- Flow Control:
- It controls the flow of data between the sender and receiver to ensure the receiver isn’t overwhelmed with too many frames at once.
- Synchronization:
- The sender and receiver need to remain synchronized, with the sender waiting for an acknowledgment before proceeding.
- Timeout Mechanism:
- If the sender doesn’t receive the acknowledgment within a given time period (due to network issues or lost frames), it assumes the frame was lost and retransmits it.
Working of the Stop-and-Wait Protocol
- Sender Side:
- The sender sends a data frame to the receiver.
- After sending the frame, the sender waits for an acknowledgment (ACK) from the receiver.
- The sender will not send the next frame until it receives the acknowledgment.
- Receiver Side:
- The receiver receives the data frame and sends an acknowledgment (ACK) back to the sender, indicating successful reception.
- If the receiver detects an error in the received frame, it may discard the frame, and the sender will not receive an acknowledgment, prompting a retransmission.
- Timeout and Retransmission:
- If the sender doesn’t receive an acknowledgment within the timeout period, it will retransmit the same frame.
- This ensures that frames are eventually delivered even in the case of transmission errors or lost packets.
Example of Stop-and-Wait Protocol
Let’s consider an example where a sender wants to transmit data in 3 frames to a receiver using the Stop-and-Wait Protocol.
- Sender: S
- Receiver: R
Scenario:
- S sends Frame 1 to R.
- S sends the first frame (Frame 1) and waits for the acknowledgment (ACK) from R.
- R receives Frame 1 and sends back an ACK for Frame 1.
- The receiver receives the frame correctly and sends back an acknowledgment (ACK1) indicating that Frame 1 was received.
- S receives ACK1 and then sends Frame 2 to R.
- After receiving ACK1, S sends the second frame (Frame 2) and waits for the acknowledgment (ACK) for Frame 2.
- R receives Frame 2 and sends back an ACK for Frame 2.
- R successfully receives Frame 2 and sends back an acknowledgment (ACK2).
- S receives ACK2 and sends Frame 3 to R.
- After receiving ACK2, S sends the third frame (Frame 3).
- R receives Frame 3 and sends back an ACK for Frame 3.
- R successfully receives Frame 3 and sends back the final acknowledgment (ACK3).
- S receives ACK3 and concludes the transmission.
Case of Packet Loss (Retransmission Example):
Now, assume Frame 2 is lost during transmission:
- S sends Frame 1 → R sends ACK1.
- S receives ACK1, sends Frame 2, but it is lost.
- R doesn’t receive Frame 2 and therefore doesn’t send ACK2.
- S waits for ACK2 but doesn’t receive it within the timeout period.
- S retransmits Frame 2.
- R receives Frame 2, sends ACK2.
- S receives ACK2, and the transmission proceeds as usual.
Advantages of Stop-and-Wait Protocol
- Simplicity:
- The protocol is easy to understand and implement due to its simplicity.
- Error Control:
- It ensures reliable delivery by requiring an acknowledgment for each frame and retransmitting lost frames.
- Flow Control:
- It controls the flow of data between sender and receiver, preventing the receiver from being overwhelmed with too many frames.
Disadvantages of Stop-and-Wait Protocol
- Inefficient:
- The protocol is inefficient for high-latency or high-bandwidth networks because the sender spends much of its time waiting for acknowledgments. The sender only sends one frame at a time and cannot send any additional frames until it receives an acknowledgment for the previous one.
- Low Throughput:
- Since only one frame can be sent at a time, the throughput of the communication is limited by the round-trip time (RTT) for the acknowledgments.
- Delay:
- The waiting time for acknowledgment increases the total transmission time, especially for networks with high latency.
Example: Transmission Time Calculation
Assume:
- Frame size = 1000 bytes
- Transmission rate = 1000 bytes per second
- Round-trip time (RTT) = 2 seconds
The total transmission time for sending one frame and waiting for acknowledgment can be calculated as:

Thus, it takes 3 seconds to transmit one frame and receive an acknowledgment in this scenario.
Conclusion
The Stop-and-Wait Protocol is a fundamental protocol used in data communication for ensuring reliable transmission by waiting for an acknowledgment after sending each frame. While simple, it can be inefficient in high-latency networks, and more advanced protocols like Sliding Window and Go-Back-N are often used in practice for higher efficiency. However, it remains a valuable learning tool for understanding the principles of reliable data transmission.