Stop-and-Wait Protocol

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

  1. Simple and Reliable:
    • The protocol ensures that data is reliably delivered by requiring acknowledgment for each frame before sending the next.
  2. 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.
  3. Synchronization:
    • The sender and receiver need to remain synchronized, with the sender waiting for an acknowledgment before proceeding.
  4. 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

  1. 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.
  2. 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.
  3. 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:

  1. S sends Frame 1 to R.
    • S sends the first frame (Frame 1) and waits for the acknowledgment (ACK) from R.
  2. 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.
  3. 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.
  4. R receives Frame 2 and sends back an ACK for Frame 2.
    • R successfully receives Frame 2 and sends back an acknowledgment (ACK2).
  5. S receives ACK2 and sends Frame 3 to R.
    • After receiving ACK2, S sends the third frame (Frame 3).
  6. R receives Frame 3 and sends back an ACK for Frame 3.
    • R successfully receives Frame 3 and sends back the final acknowledgment (ACK3).
  7. S receives ACK3 and concludes the transmission.

Case of Packet Loss (Retransmission Example):

Now, assume Frame 2 is lost during transmission:

  1. S sends Frame 1R sends ACK1.
  2. S receives ACK1, sends Frame 2, but it is lost.
  3. R doesn’t receive Frame 2 and therefore doesn’t send ACK2.
  4. S waits for ACK2 but doesn’t receive it within the timeout period.
  5. S retransmits Frame 2.
  6. R receives Frame 2, sends ACK2.
  7. S receives ACK2, and the transmission proceeds as usual.

Advantages of Stop-and-Wait Protocol

  1. Simplicity:
    • The protocol is easy to understand and implement due to its simplicity.
  2. Error Control:
    • It ensures reliable delivery by requiring an acknowledgment for each frame and retransmitting lost frames.
  3. 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

  1. 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.
  2. 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.
  3. 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.

Comments

No comments yet. Why don’t you start the discussion?

Leave a Reply

Your email address will not be published. Required fields are marked *