What is the stop and wait protocol?

Overview

Out of the various flow controlFlow control refers to mechanisms designed to manage the data flow between the user and server. mechanisms, the stop-and-wait protocol is perhaps one of the simplest. This protocol is designed to function on noiseless channelsNoiseless channels are idealistic channels in which no data packets are lost, corrupted, or duplicated. and acts on the Data Link layer. Because of their functioning on noiseless channels, it provides no error control facilities.

The stop-and-wait protocol relies on acknowledgments (ACKs) for the exchange of packets. To elaborate, the sender sends out one packetA parcel of data to send over a network., waits for an acknowledgment of that packet, and then sends out the next packet. This sequence of events leads to the transmission of packets, as illustrated below:

Transmision

Rules

Since the protocol requires a sender to not send a packet without receiving the last packet's acknowledgment, there are a few rules that the protocol entails, as shown below:

Sender side

Receiver side

It send only one packet at a time.

It receives and consumes the received packet.

It sends the next packet if and only if the ACK of the prior packet is received.

It sends an ACK to the sender once a packet is received.

If a timeout occurs (for noisy environments), it sends the current packet again.


Issues

While the stop-and-wait protocol is incredibly simple to implement if assuming a noiseless channel, there are a host of issues when a noisy channel is introduced.

For instance, if a packet gets lost before it reaches the receiver, the receiver waits for an infinite amount of time (or until it's timeout) for the packet. Subsequently, this causes the sender to wait for an infinite amount of time for the ACK, so no further packets are sent. If a timeout is implemented on the sender side, the sender sends out the same packet at timeout.

Packet getting lost during transmission

Additionally, suppose the channel is noisy, and an ACK gets lost before it can reach the sender. In that case, the sender waits for an infinite amount of time (or until timeout) for the ACK and never sends out the next packet, and sends out the same packet at timeout again.

ACK getting lost during transmission

Finally, there also exists the scenario where there's a delay in the ACK reaching the sender. In this case, a timeout occurs on the sender's side, and the sender re-transmits the same packet. The receiver gets two of the same packets (increased redundancy), and the sender gets two of the same ACKs.

Delay in receiving the ACK
Copyright ©2024 Educative, Inc. All rights reserved