Data Link Layer and Medium Access Sub Layer · Computer Networks

Sliding Window

Watch lectures

The Sliding Window Concept and Flow Control


1. Fundamentals of the Sliding Window Technique

The Sliding Window is a foundational abstract mechanism in computer networks used for simultaneous flow control and reliable in-order data transmission.

Rather than sending a single frame and halting (as in Stop-and-Wait), the sliding window allows the sender to transmit multiple consecutive packets before receiving an acknowledgment, treating the communication channel as a continuous pipeline:

  Data Pipeline (Bandwidth-Delay Product):
  [ Sender ] ===== [ F0 ] [ F1 ] [ F2 ] [ F3 ] [ F4 ] =====> [ Receiver ]
                   |<------- In-Flight Frames ------->|

2. Mathematical Model of the Sending Window

The sending window is an imaginary box covering the sequence numbers of frames that are either in transit (unacknowledged) or eligible to be transmitted immediately.

       0    1   [  2    3    4    5    6    7  ]   8    9   10 ...
  <-- Acked --> |<------- Window Size Ws ------>| <-- Cannot send yet -->
                ^                             ^
                |                             |
             Sf (First unacked)            Sn (Next to send)

Three Window Pointers & State Variables:

  1. SfS_f (Send Window, First): Sequence number of the oldest transmitted frame that has not yet received an ACK.
  2. SnS_n (Send Window, Next): Sequence number assigned to the next new frame to be transmitted.
  3. SsizeS_{\text{size}} (Window Size): Maximum number of frames the sender can transmit without receiving an ACK.

Dynamic Movement of the Window Walls:

  • Expansion / Transmission: When a new frame is sent, pointer SnS_n advances to the right (Sn←Sn+1S_n \leftarrow S_n + 1).
  • Transmission Condition: The sender can transmit a new frame only while:
(Sn−Sf)<Ssize(S_n - S_f) < S_{\text{size}}
  • Sliding / Shrinking: When a valid acknowledgment arrives confirming frames up to kk, pointer SfS_f advances to the right (Sf←k+1S_f \leftarrow k + 1), sliding the window forward across the sequence circle and opening up room to transmit fresh frames!

3. Sequence Number Space Modulo 2m2^m

Sequence numbers are bounded by an mm-bit field in the frame header, wrapping around in a modular circle from 00 to 2m−12^m - 1:

                         0
                   7           1
                 6       O       2    Modulo 8 Circle (m = 3 bits)
                   5           3
                         4
  • When the count reaches 2m−12^m - 1, the next frame receives sequence number 00.
  • Sequence arithmetic is performed modulo 2m2^m:
Seq No=(Current No+1)(mod2m)\text{Seq No} = (\text{Current No} + 1) \pmod{2^m}

4. Bandwidth-Delay Product (BDP) and Optimal Window Sizing

The capacity of a network pipe is measured by the Bandwidth-Delay Product (BDP):

BDP=Bandwidth×Round-Trip Time (RTT)=B×2⋅Tp\text{BDP} = \text{Bandwidth} \times \text{Round-Trip Time (RTT)} = B \times 2 \cdot T_p
  Pipe Capacity = Volume of Bits in Flight
  +-----------------------------------------------------------+
  | Sender ====> [ Bit Pipe Volume = Bandwidth * RTT ] ====> Receiver |
  +-----------------------------------------------------------+

Window Sizing Implications:

  1. Under-buffered (Ws<BDPW_s < \text{BDP}):
    • The sender window empties before the first ACK returns. The sender stalls into idle wait states, causing channel underutilization (η<100%\eta < 100\%).
  2. Optimal (Ws=BDPW_s = \text{BDP}):
    • The sender continuously transmits at full line rate. The exact moment the sender finishes transmitting the WsW_s-th frame, the ACK for the 1st frame arrives, keeping the channel 100%100\% saturated.
  3. Over-buffered (Ws>BDPW_s > \text{BDP}):
    • Excess packets queue in router intermediate buffers, creating buffer bloat and unnecessary queueing latency.

5. Sliding Window: Data Link Layer vs. Transport Layer

Dimension Data Link Layer (DLL) Transport Layer (TCP)
Basic Unit Discrete Frames (Packets) Stream of Bytes
Window Metric Count of frames (WsW_s frames) Count of bytes (e.g., 65,535 bytes65{,}535\text{ bytes})
Scope Single physical hop (node-to-node) Global end-to-end across internetwork
Window Dynamism Fixed static window configuration Dynamic: adjusts via Receiver Window (rwnd) and Congestion Window (cwnd)
Implementation Hardware NICs and firmware Operating system network stack kernel

6. Key Exam Questions & Numericals

  1. A channel has a bandwidth of 10 Mbps10\text{ Mbps} and propagation delay Tp=20 msT_p = 20\text{ ms}. If frame size is 1,000 bytes1{,}000\text{ bytes}, calculate the minimum window size required for 100%100\% link efficiency.
    • Tt=8,000 bits10×106 bps=0.8 msT_t = \frac{8{,}000\text{ bits}}{10 \times 10^6\text{ bps}} = 0.8\text{ ms}.
    • RTT≈2⋅Tp=40 ms\text{RTT} \approx 2 \cdot T_p = 40\text{ ms}.
    • Optimal Window:
Ws≥1+2⋅TpTt=1+40 ms0.8 ms=1+50=51 framesW_s \geq 1 + \frac{2 \cdot T_p}{T_t} = 1 + \frac{40\text{ ms}}{0.8\text{ ms}} = 1 + 50 = \mathbf{51\text{ frames}}
  1. What occurs when the sender's sliding window is full?
    • The sender must cease transmission and wait for acknowledgments to arrive from the receiver. As ACKs arrive, the left edge of the window slides forward (SfS_f advances), allowing new frames to be transmitted.
  2. Explain how the sliding window mechanism prevents buffer overflow at the receiver.
    • The receiver only advertises a window size equal to its available buffer space. The sender is never permitted to transmit more unacknowledged data than the advertised receive window, guaranteeing that arriving packets always find free buffer slots.
Budget AppAndroid App

Pocketly on Android

Log daily food, travel, and hostel expenses instantly. Set monthly spending limits and see where your money goes without complex spreadsheets.

← All Computer Networks modules