Sliding Window Protocol in Computer Networks: Working, Types, and Examples
TL;DR: The sliding window protocol is a flow-control technique that lets a sender transmit multiple frames before waiting for an acknowledgment, instead of sending one frame at a time like Stop-and-Wait. The "window" is the set of frames the sender can have in transit at once, and it slides forward as acknowledgments arrive. The three main types are One-Bit Sliding Window, Go-Back-N ARQ, and Selective Repeat ARQ.

Sending one frame and waiting for its acknowledgment before sending the next frame wastes time, especially over networks with significant round-trip delay. The sliding window protocol addresses this problem by allowing a sender to send multiple frames, up to a system-defined limit (the window size), before waiting for acknowledgments. The purpose of this article is to discuss the sliding window protocol by describing what it is, how it works in computer networks, what the three types are, how the window size is related to the sequence numbers using a mathematical formula, the throughput calculation compared to the Stop-and-Wait protocol, and the advantages, disadvantages, and applications of sliding window protocols.

What Is Sliding Window Protocol in Computer Networks?

The sliding window protocol is a flow-control and reliable-delivery mechanism used at the data link and transport layers, most notably in TCP, that lets a sender transmit multiple frames before requiring an acknowledgment for each one. Both the sender and receiver maintain a "window," a range of sequence numbers currently valid for sending or accepting frames. As acknowledgments come in, the window slides forward to cover the next set of frames, which is where the protocol gets its name.

Core Concepts

  • Window size: It determines how many frames or bytes the transmitting side can send before it stops and waits for a reply.
  • Sender window and receiver window: The sliding window protocol uses these to track frames. The sender's window stores sequence numbers the sender can send, while the receiver's window stores sequence numbers it expects to receive.
  • Acknowledgments: ACKs tell the sender that frames arrived at the receiver. Sliding window can use either cumulative ACKs (sending a cumulative ACK for all frames up to a given one) or SACKs / Selective ACKs (telling the sender which frames were received individually).
  • Timers: Each sent frame has a timer, and if it runs out because the receiver didn't reply, the sender must retransmit the frame.
  • Sequence numbers: Every frame sent needs a unique sequence number so that the receiver can detect duplicates, out-of-order frames, and missing frames.

Cyber Security Expert Master's ProgramExplore Program
Learn from Top Cyber Security Mentors!

How Sliding Window Works

Sliding Window Protocol

  1. Begin with the initial sequence numbers. Both the sender and the receiver start with the same sequence number and window size.
  2. Transmit many segments. Here, the sender transmits several frames equal to the window size without receiving any acknowledgment.
  3. Receiver acknowledges what it gets. The receiver sends ACKs (cumulative or selective) for the frames it successfully receives.
  4. Update the sender's window on ACKs. As acknowledgments arrive, the sender's window slides forward, freeing up room to send new frames.
  5. Handle lost or delayed segments. If an expected ACK doesn't arrive before the timer expires, the sender retransmits, with the exact retransmission behavior depending on the protocol type (see below).

Types of Sliding Window Protocol

There are three classic types of sliding window protocols, distinguished mainly by window size and how they recover from lost or corrupted frames.

One-Bit Sliding Window Protocol

The simplest form, where the window size is fixed at exactly 1 for both sender and receiver, using only a single bit (0 or 1) for the sequence number. The sender transmits one frame and waits for its acknowledgment before sending the next, alternating the sequence bit between 0 and 1 each time. This makes it functionally equivalent to Stop-and-Wait, and it exists mainly as the conceptual starting point before scaling up to larger windows: it guarantees reliable, in-order delivery, but with none of the throughput benefit a larger window provides.

Go-Back-N ARQ

The sender can have multiple frames in transit (window size > 1), but the receiver only accepts frames in strict order and discards anything that arrives out of sequence. If an error occurs or a frame is lost, the sender retransmits that frame and every frame sent after it, even ones the receiver already received correctly.

Selective Repeat ARQ

Like Go-Back-N, the sender can have multiple frames in transit, but the receiver buffers out-of-order frames instead of discarding them. When an error occurs, only the specific frame(s) with errors are re-sent, not everything after them. This is more bandwidth-efficient but requires more buffer memory at the receiver.

Protocol

Window Size

Retransmission Behavior

Buffer Needs

One-Bit / Stop-and-Wait

Always 1

Resends the single lost frame

Minimal

Go-Back-N

Can be > 1

Retransmits the lost frame and all subsequent frames

Receiver discards out-of-order frames

Selective Repeat

Can be > 1

Only the frame(s) with errors are re-sent

Buffers out-of-order frames

Window Size and Sequence Number Limits

The maximum usable window size isn't arbitrary—it's constrained by how many sequence numbers are available, which depends on how many bits represent them.

  • Go-Back-N: maximum window size = 2^n − 1, where n is the number of bits used for the sequence number.
  • Selective Repeat: maximum window size = 2^(n−1), exactly half of Go-Back-N's limit for the same number of bits.

Worked example (n = 3 bits): With 3 bits, sequence numbers range from 0 to 7 (8 possible values).

  • Go-Back-N's maximum window size = 2³ − 1 = 7.
  • Selective Repeat's maximum window size = 2^(3−1) = 4.

Selective Repeat needs a smaller window than Go-Back-N because it buffers out-of-order frames. If its window were as large as Go-Back-N's, the receiver could no longer reliably distinguish a retransmitted old frame from a new one carrying the same sequence number, since sequence numbers wrap around and get reused.

Cyber Security Expert Master's ProgramLearn Now
Master In-Demand Cyber Security Skills!

Sliding Window Protocol vs. Stop-and-Wait Protocol

In Stop-and-Wait, the sender transmits one frame and waits for an acknowledgment before sending the next. This waiting introduces idle time, reducing effective throughput, especially on high-latency networks. Sliding window protocols allow the sender to send multiple frames before receiving acknowledgments, keeping the network busier and improving throughput.

Stop-and-Wait throughput:

Throughput = Frame time / (Frame time + RTT)

Example: with a 10 ms frame time and 100 ms round-trip time, throughput ≈ 10 / (10 + 100) ≈ 0.09 frames per unit time.

Sliding window throughput:

Throughput = (Window size × Frame time) / (Frame time + RTT)

Example: with the same 10 ms frame time and 100 ms RTT, and a window size of 4, throughput ≈ (4 × 10) / (10 + 100) ≈ 0.36 frames per unit time, a 4x improvement over Stop-and-Wait.

Important caveat: this scaling only holds up to the bandwidth-delay product, the point where the window is just large enough to keep the link continuously busy. That point is roughly ⌈(Frame time + RTT) / Frame time⌉, which in this example is ⌈110/10⌉ = 11. Once the window size reaches that point, the link is fully utilized, and increasing the window further does not increase throughput, since the sender can't transmit faster than one frame per frame time regardless of how many frames it's allowed to have outstanding.

Advantages of Sliding Window Protocol

  • Reduces idle waiting time compared to Stop-and-Wait, since the sender doesn't pause after every single frame.
  • Improves throughput, especially on high-latency or high-bandwidth-delay-product links.
  • Maintains ordered, reliable delivery through sequence numbers and acknowledgments.
  • Adapts to network conditions when paired with dynamic window sizing (as in TCP's congestion window).
Learn 21+ in-demand cybersecurity skills, including ethical hacking, system penetration testing, AI-powered threat detection, network packet analysis, and much more with Masters in Cyber Security.

Disadvantages of Sliding Window Protocol

  • Go-Back-N wastes bandwidth by retransmitting already-received frames whenever an earlier one is lost.
  • Selective Repeat avoids that waste but needs more receiver buffer memory to hold out-of-order frames.
  • More complex to implement and debug than Stop-and-Wait, since both sender and receiver must track window state, timers, and sequence numbers.
  • Choosing the wrong window size (too small underuses available bandwidth; too large can overwhelm the receiver or the network) requires tuning to the specific link's bandwidth-delay product.

Applications of Sliding Window Protocol

  • Data link layer communication: Used in protocols like HDLC to manage reliable frame delivery over a single physical link.
  • TCP at the transport layer: TCP's sliding window (paired with rwnd and cwnd) governs how much unacknowledged data can be in flight across an entire connection.
  • High-bandwidth, high-latency networks: Satellite links and long-distance WAN connections benefit the most, since Stop-and-Wait would waste most of the link's capacity waiting on round-trip delay.
  • Error-prone links: Selective Repeat in particular is used where retransmitting everything after a lost frame (as Go-Back-N does) would be too costly in wasted bandwidth.

Common Mistakes and Quick Fixes

  • Wrong assumptions about ACKs: Assuming every single frame needs its own individual, immediate acknowledgment. Fix: understand that cumulative ACKs confirm multiple frames at once, which is part of what makes sliding window more efficient than Stop-and-Wait.
  • Incorrect buffering expectations: Assuming all sliding window variants handle out-of-order frames the same way. Fix: remember that Go-Back-N discards out-of-order frames while Selective Repeat buffers them; this single difference drives most of the retransmission and buffering trade-offs between the two.
  • Improper handling of retransmissions: Resending all unacknowledged frames when only one segment was actually lost. Fix: check which protocol is in use first; that behavior is correct for Go-Back-N, but wrong (and wasteful) for Selective Repeat, where only the specific lost frame should be resent.

CEH v13 - Certified Ethical Hacking CourseExplore Program
Build Your Network Security Skill Set Now!

Conclusion

The sliding window protocol is a foundational mechanism for reliable and efficient data transmission in computer networks. By letting multiple frames stay in transit at once, up to a size dictated by the sequence-number formula and tuned to the link's bandwidth-delay product, it reduces idle time. It improves throughput over Stop-and-Wait while still guaranteeing ordered, reliable delivery. Understanding this protocol, and how One-Bit, Go-Back-N, and Selective Repeat trade off simplicity, bandwidth, and buffer memory, is essential groundwork for learning network and cybersecurity. To deepen your knowledge of sliding window protocol and other network security fundamentals, explore Simplilearn's Masters in Cybersecurity.

Key Takeaways

  • Sliding window protocol lets a sender transmit multiple frames before waiting for acknowledgment, unlike Stop-and-Wait.
  • The three types are One-Bit (window size 1), Go-Back-N (discards out-of-order frames, resends everything after a loss), and Selective Repeat (buffers out-of-order frames, resends only the lost frame).
  • Maximum window size is capped by sequence number bits: 2^n − 1 for Go-Back-N, 2^(n−1) for Selective Repeat.
  • Throughput scales with window size only up to the bandwidth-delay product; beyond that, the link is already saturated.
  • TCP uses a sliding window bounded by the smaller of the receive window (rwnd) and congestion window (cwnd).
The step-by-step Security Engineer Roadmap is designed for professionals seeking to understand the full scope of the profession. Explore the skills, tools, salary potential, and career roadmap needed to build a successful career in cybersecurity.

FAQs

1. What is one-bit sliding window protocol?

One-bit sliding window protocol uses a window size of exactly 1, with a single sequence-number bit that alternates between 0 and 1. It sends one frame, waits for its acknowledgment, then sends the next, making it functionally identical to Stop-and-Wait rather than offering the throughput benefit of a larger window.

2. What is the maximum window size for Go-Back-N versus Selective Repeat with the same sequence-number bits?

With n sequence-number bits, Go-Back-N's maximum window size is 2^n − 1, while Selective Repeat's is 2^(n−1), exactly half. Selective Repeat needs the smaller limit because it buffers out-of-order frames, and a larger window would make it impossible to reliably tell a retransmitted old frame apart from a new one reusing the same sequence number.

3. What is the difference between rwnd and cwnd in TCP?

In TCP, rwnd (receive window) and cwnd (congestion window) both control how much data a sender can transmit, but they solve different problems. The receiver sets rwnd to tell the sender how much data it can accept without overflowing its buffer. The sender manages cwnd based on current network conditions to avoid causing congestion.

4. What is TCP window scaling, and when is it needed?

TCP window scaling is an option that lets TCP use a much larger window than the default field size allows. The need for a large receive window is most significant in high-speed networks or networks with very long delays. Because such networks offer huge bandwidth, small window sizes would underutilize the available bandwidth.

5. What is sequence number wrap in sliding window protocol?

Sequence number wrap occurs when the sequence number reaches the maximum value that can be stored in a set number of bits and wraps around to zero. The window size must be small enough relative to the sequence-number space to ensure that any frame still in transit has a unique sequence number.

About the Author

Bharani DharanBharani Dharan

Bharanidharan serves as the Data Protection Officer at Simplilearn, leading data governance, cybersecurity, and global privacy compliance. He connects innovation with accountability, building privacy-first systems and ensuring security remains central to every digital service and user interaction.

View More
  • Acknowledgement
  • PMP, PMI, PMBOK, CAPM, PgMP, PfMP, ACP, PBA, RMP, SP, OPM3 and the PMI ATP seal are the registered marks of the Project Management Institute, Inc.
  • *All trademarks are the property of their respective owners and their inclusion does not imply endorsement or affiliation.
  • Career Impact Results vary based on experience and numerous factors.