Home » Computer Network » Briefly explain the sliding window protocol

Briefly explain the sliding window protocol

Last updated:

Support this post with a reaction:

4,034 views

The sliding window protocol is a fundamental technique used in computer networks to achieve efficient, reliable, and ordered data transmission. It plays a central role in protocols such as TCP on the Internet and in data link layer protocols for point-to-point and wireless links.

By controlling how many frames or packets can be sent before receiving acknowledgments, the sliding window protocol improves throughput, manages flow control, and handles errors caused by losses or corruption.

Understanding this protocol helps students and professionals grasp the essential mechanics behind reliable communication, making it a vital topic for university exams and practical networking.

What is Sliding Window Protocol?

The sliding window protocol is a method of flow control and error control in which a sender may transmit multiple frames or packets without waiting for an acknowledgment for each one. These frames are identified using sequence numbers, and acknowledgments confirm successful reception.

The term “sliding window” refers to a moving range (window) of sequence numbers that the sender is allowed to transmit and that the receiver is prepared to accept.

  • Flow control ensures the sender does not overwhelm the receiver’s buffer.
  • Error control ensures lost or corrupted frames are detected and retransmitted.
  • The sender’s window slides forward when acknowledgments (ACKs) are received, allowing new frames to be sent.

Why Sliding Window Matters?

  • Improves Efficiency: Allows multiple frames to be transmitted without waiting for individual acknowledgments.
  • Better Bandwidth Utilization: Reduces idle time and makes better use of network bandwidth.
  • Provides Flow Control: Prevents the sender from overwhelming the receiver with too much data.
  • Ensures Reliable Communication: Uses acknowledgments and retransmissions to handle lost or damaged frames.
  • Maintains Ordered Delivery: Uses sequence numbers to help deliver frames in the correct order.

Key Components and Terminology

  • Sequence Numbers: Each frame or packet is labeled with a sequence number, typically modulo 2^k for some k.
  • Sender Window (SW): The range of sequence numbers the sender is allowed to transmit but has not yet been acknowledged.
  • Receiver Window (RW): The range of sequence numbers the receiver is willing to accept at a given time.
  • Acknowledgment (ACK): A control message confirming successful receipt. Many systems use cumulative ACKs (ACK n acknowledges all frames up to n−1).
  • Negative Acknowledgment (NAK or NACK): Indicates a specific frame was not correctly received (used in some variants).
  • Timers: Used to detect losses; if an ACK is not received before timeout, retransmissions occur.
  • Window Size (W): The maximum number of unacknowledged frames allowed at once. This is a crucial design parameter.
  • Buffering: Sender buffers unacknowledged frames; receiver buffers out-of-order frames (in selective repeat).

How the Sliding Window Protocol Works: Step-by-Step

The following outlines the generic operation of a sliding window scheme:

  • Initialization:
    • Set sender window to include the next W sequence numbers starting from base (lowest unacknowledged number).
    • Receiver window defines the next acceptable sequence numbers.
  • Sending:
    • As long as the next sequence number is within the sender window, transmit the frame and start (or refresh) the timer associated with it (or a single timer for the oldest outstanding frame, depending on the variant).
  • Receiving:
    • Upon receiving a frame:
      • If it is expected and valid (correct checksum), accept it, deliver in order if possible, and update the receiver window.
      • If out of order and the protocol allows buffering (Selective Repeat), store it and wait for missing frames to fill the gap.
      • Send an ACK (cumulative or selective) as per protocol rules; optionally piggyback ACKs on outgoing data.
  • Sliding:
    • When the sender receives an ACK acknowledging the base of its window, it moves the window forward, freeing buffer space and allowing new frames to be sent.
  • Timeout and Retransmission:
    • If a timer expires for a frame not yet acknowledged, the sender retransmits according to the variant (Go-Back-N or Selective Repeat).

Types of Sliding Window Protocols

Sliding Window Protocol is mainly classified into two types: Go-Back-N ARQ and Selective Repeat ARQ. These protocols provide flow control and error control to ensure reliable data transmission.

1. Go-Back-N ARQ

Go-Back-N ARQ is a sliding window protocol that allows the sender to transmit multiple frames before receiving acknowledgments. If a frame is lost or damaged during transmission, the sender retransmits that frame along with all subsequent unacknowledged frames.

Working of Go-Back-N ARQ

  • Frame Transmission: The sender transmits multiple frames according to the specified window size without waiting for individual acknowledgments.
  • Sequence Numbers: Each frame is assigned a unique sequence number to identify it.
  • Frame Reception: The receiver accepts frames only in the correct order.
  • Error Detection: If a frame is lost or damaged, the receiver identifies the missing frame and discards subsequent out-of-order frames.
  • Acknowledgment: The receiver sends a cumulative acknowledgment indicating the next frame expected.
  • Retransmission: If the sender does not receive the required acknowledgment before the timeout, it retransmits the lost frame and all subsequent unacknowledged frames.
  • Window Movement: After receiving acknowledgments, the sender moves its window forward and continues transmitting new frames.

Example: Suppose the sender transmits frames 0, 1, 2, 3 and frame 1 is lost. The receiver accepts frame 0 but discards frames 2 and 3 because frame 1 is missing. After a timeout, the sender retransmits frames 1, 2 and 3.

Advantages:

  • Allows multiple frames to be transmitted at a time.
  • Requires less receiver buffer memory.
  • Easy to understand and implement.
  • Provides reliable data transmission through acknowledgments and retransmissions.

Disadvantages:

  • Retransmits all subsequent unacknowledged frames even if some were received correctly.
  • Wastes bandwidth when frame errors occur frequently.
  • Performance decreases when network delays or transmission errors are high.

2. Selective Repeat ARQ

Selective Repeat ARQ is an advanced sliding window protocol that retransmits only the specific frames that are lost or damaged. Unlike Go-Back-N, it allows the receiver to accept and temporarily store correctly received frames even when they arrive out of order.

Working of Selective Repeat ARQ

  • Frame Transmission: The sender transmits multiple frames within the specified window size.
  • Sequence Numbers: Each frame is assigned a sequence number for identification.
  • Frame Reception: The receiver checks each incoming frame for errors.
  • Buffering: Correctly received frames are accepted and stored in the receiver’s buffer, even if earlier frames are missing.
  • Acknowledgment: The receiver sends individual acknowledgments for successfully received frames.
  • Retransmission: If a frame is lost or damaged, only that particular frame is retransmitted by the sender.
  • Ordered Delivery: Once the missing frame is received, the receiver arranges the buffered frames in the correct sequence and delivers them to the upper layer.
  • Window Movement: After receiving the required frames and acknowledgments, the sender and receiver windows move forward.

Example: Suppose the sender transmits frames 0, 1, 2, 3 and frame 1 is lost. The receiver accepts frame 0 and temporarily stores frames 2 and 3. The sender retransmits only frame 1. Once frame 1 arrives, the receiver delivers frames 1, 2 and 3 in the correct order.

Advantages:

  • Retransmits only lost or damaged frames.
  • Reduces unnecessary retransmissions.
  • Makes better use of available network bandwidth.
  • Provides better performance in networks with frequent transmission errors.
  • Supports out-of-order frame reception through buffering.

Disadvantages:

  • More complex to implement than Go-Back-N.
  • Requires additional buffer memory at the receiver.
  • Requires separate timers for individual frames.
  • Needs careful sequence number and window size management.

Difference Between Go-Back-N and Selective Repeat ARQ

Go-Back-N ARQSelective Repeat ARQ
Retransmits the lost frame and all subsequent unacknowledged frames.Retransmits only the lost or damaged frames.
Discards out-of-order frames.Accepts and buffers out-of-order frames.
Uses cumulative acknowledgments.Uses individual acknowledgments.
Requires less receiver buffer memory.Requires more receiver buffer memory.
Uses a simpler retransmission mechanism.Uses a more complex retransmission mechanism.
Less efficient when multiple frames are retransmitted unnecessarily.More efficient because unnecessary retransmissions are avoided.
Suitable for relatively reliable communication links.Useful for links where transmission errors occur more frequently.

Window Size in Sliding Window Protocol

Window Size refers to the maximum number of frames that a sender can transmit without waiting for acknowledgments from the receiver. It determines how much data can be sent at a time and plays an important role in controlling data transmission.

How Window Size Works

  • Initial Window: The sender and receiver maintain a window that defines the frames allowed for transmission and reception.
  • Frame Transmission: The sender can transmit frames within the permitted window size without waiting for individual acknowledgments.
  • Acknowledgment: The receiver sends acknowledgments for successfully received frames.
  • Window Movement: When acknowledgments arrive, the sender’s window moves forward, allowing new frames to be transmitted.
  • Window Limitation: If the window becomes full, the sender must wait until acknowledgments are received before sending additional frames.

Types of Window Size

  • Sender Window Size: Defines the maximum number of unacknowledged frames that the sender can transmit at a time.
  • Receiver Window Size: Defines the number of frames that the receiver is prepared to accept.

Importance of Window Size

  • Improves Transmission Efficiency: A larger window allows more frames to be transmitted without waiting for acknowledgments.
  • Controls Data Flow: Prevents the sender from transmitting more data than the receiver can handle.
  • Utilizes Bandwidth: Helps make better use of available network bandwidth.
  • Reduces Waiting Time: Allows continuous data transmission while acknowledgments are travelling back to the sender.
  • Supports Reliable Communication: Helps manage frame transmission and acknowledgment processing.

Sequence Numbers in Sliding Window Protocol

Sequence Numbers are unique numbers assigned to data frames during transmission. They help the sender and receiver identify frames, maintain the correct order of data, and detect missing or duplicate frames.

How Sequence Numbers Work

  • Frame Identification: Each frame is assigned a sequence number so that the receiver can identify it.
  • Maintaining Order: Sequence numbers help the receiver arrange frames in the correct order.
  • Acknowledgment: The receiver uses sequence numbers to indicate which frames have been successfully received.
  • Detecting Lost Frames: If a frame is missing from the sequence, the receiver can identify the missing frame.
  • Retransmission: Sequence numbers help the sender identify which frames need to be retransmitted.
  • Duplicate Detection: They help the receiver recognize and discard duplicate frames.

Advantages of Sliding Window Protocol

Sliding Window Protocol provides several advantages that improve the efficiency and reliability of data transmission in computer networks.

  • High Transmission Efficiency: Allows multiple frames to be transmitted before receiving acknowledgments, reducing waiting time.
  • Better Bandwidth Utilization: Makes effective use of available network bandwidth by allowing continuous data transmission.
  • Flow Control: Prevents the sender from transmitting more data than the receiver can handle.
  • Reliable Data Transmission: Uses acknowledgments and retransmission mechanisms to ensure successful data delivery.
  • Reduced Waiting Time: The sender does not need to wait after transmitting every individual frame.
  • Error Control: Helps detect lost or damaged frames and retransmit them.
  • Ordered Delivery: Uses sequence numbers to maintain the correct order of frames.
  • Improved Throughput: Allows more data to be transmitted within a given period.
  • Supports Multiple Frames: Enables the sender to transmit several frames within the permitted window size.

Disadvantages of Sliding Window Protocol

Although Sliding Window Protocol improves data transmission, it also has some limitations.

  • Complex Implementation: Managing window sizes, sequence numbers, acknowledgments and retransmissions makes the protocol more complex.
  • Buffer Memory Requirement: Requires memory to store unacknowledged frames at the sender and, in some methods, out-of-order frames at the receiver.
  • Acknowledgment Overhead: Requires acknowledgment messages to track successfully received frames.
  • Retransmission Overhead: Lost or damaged frames must be retransmitted, which may consume additional bandwidth.
  • Window Size Management: Selecting an appropriate window size is important for maintaining transmission efficiency.
  • Timer Management: Requires timers to detect missing acknowledgments and initiate retransmissions.
  • Performance Issues: Network delays and frequent transmission errors can reduce overall performance.

Applications of Sliding Window Protocol

Sliding Window Protocol is used in different communication systems to provide efficient and reliable data transmission.

  • TCP Communication: TCP uses a sliding window mechanism to control the amount of data sent before receiving acknowledgments.
  • Wireless Networks: Used in wireless communication systems to manage data transmission and handle transmission errors.
  • File Transfer: Helps transfer files reliably between computers by controlling data flow and retransmitting lost data.
  • Computer Networks: Used in data link layer protocols to provide flow control and error control.
  • Internet Communication: Supports reliable data exchange between devices through protocols such as TCP.
  • Satellite Communication: Helps improve data transmission efficiency over long-distance communication links where delays are high.
  • Point-to-Point Communication: Controls the flow of frames between two directly connected devices.