SAW Stop and Wait
Stop-and-Wait (SAW) is a flow control protocol used in computer networks to ensure reliable and orderly data transmission between a sender and a receiver. It is a simple and widely used protocol that operates in a half-duplex mode, meaning that data can only be sent in one direction at a time.
The main objective of the Stop-and-Wait protocol is to ensure that the receiver acknowledges each received frame before the sender transmits the next frame. This acknowledgment (ACK) serves as an indication to the sender that the previous frame has been successfully received and that it is safe to send the next frame. If the sender does not receive the ACK within a certain timeout period, it assumes that the frame was lost or damaged and retransmits it.
Here's a step-by-step explanation of how the Stop-and-Wait protocol works:
- Sender transmits a frame: The sender starts by transmitting a frame containing a block of data to the receiver. Once the frame is sent, the sender starts a timer.
- Receiver receives the frame: The receiver receives the frame and checks it for errors. If the frame is error-free, the receiver sends an acknowledgment (ACK) frame back to the sender indicating successful reception.
- Sender receives the ACK: The sender waits for the ACK frame to be received. If the sender receives the ACK within the timeout period, it assumes that the frame was successfully delivered and proceeds to send the next frame. If the timeout expires before receiving the ACK, the sender assumes that the frame was lost or damaged and retransmits it.
- Receiver processes the data: The receiver receives the frame, extracts the data from it, and processes it. Once the data is processed, the receiver sends the ACK frame back to the sender.
- Repeat the process: Steps 1 to 4 are repeated for each frame until all the data has been successfully transmitted and received. The sender only sends the next frame when it receives the ACK for the previous frame.
The Stop-and-Wait protocol provides reliability by ensuring that each frame is acknowledged before sending the next frame. However, it introduces some inefficiencies in the network due to the stop-and-wait behavior, where the sender has to wait for an acknowledgment before sending the next frame. This can result in low network utilization, especially for long propagation delays or high error rates.
Despite its simplicity, the Stop-and-Wait protocol serves as a fundamental building block for more advanced protocols that provide improved efficiency and reliability, such as the sliding window protocols.