Skip to main content

What is a sliding window?

A sliding window is a TCP mechanism that lets a sender send several segments in a row without waiting for each one to be acknowledged, while not overloading the receiver.

Simply put: a sliding window is a limit on how much data can be sent "ahead" without waiting for an ACK.


Why a sliding window is needed

Without a window, TCP would work like this:

  • send a segment
  • wait for an acknowledgment
  • send the next one

This would be very slow.

A sliding window allows:

  • transferring data as a stream
  • using the network's bandwidth efficiently

How a sliding window works

1. The receiver announces the window size

In every ACK, the receiver reports:

  • Window Size - how many bytes it is ready to accept

This protects the receiver from being overloaded.


2. The sender can send data within the window

The sender:

  • can send several segments
  • as long as their total size does not exceed the window size

Not every segment needs to be acknowledged immediately.


3. The window "slides"

When the receiver:

  • acknowledges part of the data

the window:

  • shifts forward
  • freeing up space for new data

Hence the name - sliding window.


An example to understand it

  • Window size: 10 bytes
  • The sender can send bytes 1-10
  • The receiver acknowledges bytes 1-5
  • The window shifts forward → now bytes 11-15 can be sent

Transmission continues without stopping.


What a sliding window actually controls

Important. A sliding window in TCP is responsible for:

  • flow control
  • not for routing
  • not for correcting errors directly

Loss is handled separately, through:

  • ACKs
  • timeouts
  • retransmissions

Relationship to network congestion

TCP has two limits:

  1. The receiver window
  • how much the receiver can accept
  1. The congestion window
  • how much the network allows

In practice, the sender uses:

the minimum of these two values


Why this matters for applications

A sliding window:

  • increases transmission speed
  • makes TCP scalable
  • lets it work equally well:
    • on a local network
    • and over the Internet

Short Answer

Interview ready
Premium

A concise answer to help you respond confidently on this topic during an interview.