Sliding window protocols

Sliding Window Protocols are a set of flow control mechanisms used in the Data Link Layer (and sometimes Transport Layer) to efficiently manage data transmission between sender and receiver. Unlike the simple Stop-and-Wait protocol, which sends a single frame and waits for an acknowledgment before sending the next frame, Sliding Window allows the sender to send multiple frames before needing an acknowledgment, improving overall throughput and efficiency.

Key Concepts of Sliding Window Protocol:

  1. Window Size: This refers to the number of frames that the sender can transmit before receiving an acknowledgment. Both the sender and receiver have a “window” that determines how many frames can be sent and received at any given time.
  2. Sliding Mechanism: As the sender receives acknowledgments for frames it has sent, the window “slides” forward, allowing new frames to be sent. This continuous sliding process helps maintain an efficient flow of data.
  3. Frame Numbering: Each frame sent by the sender is given a unique identifier (frame number). These identifiers help the receiver track which frames have been received and which ones are still expected.
  4. Acknowledgments: Acknowledgments are typically sent by the receiver for the next expected frame, indicating which frames have been successfully received. In some cases, the receiver may acknowledge multiple frames at once.

Types of Sliding Window Protocols:

  1. Go-Back-N (GBN):
    • Sender: The sender can send multiple frames within the window size but must wait for an acknowledgment for the first frame in the window. If any frame in the window is lost or corrupted, all subsequent frames need to be resent.
    • Receiver: The receiver only acknowledges the next expected frame. If a frame is lost or out of order, the receiver will ignore it and wait for the correct frame.
    • Example: Suppose the window size is 3, and the sender has sent frames 1, 2, and 3. If frame 2 is lost, the receiver will ignore frame 3 and ask for frame 2 to be resent, along with frames 3, 4, and 5.
    Advantages:
    • Simple to implement.
    • Ensures that all frames are received in order.
    Disadvantages:
    • Inefficient if packets are lost, as the entire window must be resent.
    • Wastes bandwidth by resending frames that have already been successfully received.
  2. Selective Repeat (SR):
    • Sender: The sender can send multiple frames within the window, just like Go-Back-N, but only the frames that are lost or corrupted need to be resent.
    • Receiver: The receiver keeps track of all frames and can store out-of-order frames in its buffer until the missing frames arrive. It only sends an acknowledgment for the frames it has successfully received.
    • Example: If the sender’s window size is 3 and frames 1, 2, and 3 are sent, but frame 2 is lost, the receiver will acknowledge frames 1 and 3. The sender will only resend frame 2.
    Advantages:
    • More efficient than Go-Back-N, as only the lost frames are resent.
    • Reduces the number of redundant transmissions.
    Disadvantages:
    • Requires more memory and buffering at the receiver to store out-of-order frames.
    • More complex to implement than Go-Back-N.

Example of a Sliding Window Protocol (Go-Back-N):

Let’s assume the following:

  • Window size = 3 frames
  • Sender sends frames 1, 2, and 3.
  • Receiver acknowledges the frames received and requests re-transmission of any lost or erroneous frames.

Transmission Process:

  1. Step 1: Sender sends frames 1, 2, and 3. Receiver gets frame 1, but not frame 2 (lost).
  2. Step 2: Receiver sends acknowledgment (ACK) for frame 1, indicating frame 2 is expected next.
  3. Step 3: Sender receives ACK for frame 1, slides window, and sends frames 4, 5, and 6.
  4. Step 4: Receiver gets frame 3, acknowledges frame 3, and sends ACK for frame 2 (which is missing).
  5. Step 5: Sender gets ACK for frame 2, and sends frames 7, 8, and 9.

In this way, the sender slides the window forward, resending only the lost frames and keeping track of the frames acknowledged.


Advantages of Sliding Window Protocol:

  • Efficiency: Sliding window allows multiple frames to be in transit at the same time, maximizing the utilization of the link.
  • Reduced Waiting Time: Unlike Stop-and-Wait, which requires a complete round-trip time (RTT) after each frame, sliding window minimizes idle times.
  • Flexible Buffering: The receiver can buffer out-of-order frames (in the case of Selective Repeat), providing better handling of lost frames.

Disadvantages:

  • Complexity: Sliding window protocols are more complex to implement than simpler methods like Stop-and-Wait.
  • Buffering Requirement: Sliding window requires both the sender and receiver to have enough buffer space to manage multiple frames at once, particularly in the case of Selective Repeat.

Summary of Differences:

FeatureGo-Back-N (GBN)Selective Repeat (SR)
Window SizeSender’s window size (number of frames)Both sender and receiver have their own window sizes
RetransmissionResends all frames from the lost one onwardOnly lost or corrupted frames are resent
Receiver BufferingNo buffering (frame must be received in order)Buffering allowed for out-of-order frames
ComplexitySimpler to implementMore complex due to out-of-order frame handling
EfficiencyLess efficient (redundant retransmissions)More efficient (only lost frames are resent)

Conclusion:

Sliding window protocols (Go-Back-N and Selective Repeat) offer significant improvements in efficiency compared to Stop-and-Wait by allowing multiple frames to be transmitted simultaneously and reducing idle times. Go-Back-N is simpler but less efficient in case of packet loss, while Selective Repeat is more efficient but more complex, as it allows for out-of-order frame reception.

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 *