Skip to content
DenseChip
Learn
PracticeCode labInterview

DenseChip

Navigate

Menu

LearnPracticeCode labInterview

Tools

All toolsSV editorCode repoResume
DenseChip

Practice, courses, and chip-design tools in one focused workspace.

LearnPracticeCode labInterviewToolsLearning paths

© 2026 DenseChip

AboutContactPrivacyTerms
Skip to lesson

Course contents

  • How to Use This Course
  • Reading Paths
  • Concept Map
  • How to Read the Diagrams
  • Part 0: What Is a Protocol?10
  • Part 1: Timing and Clocking11
  • Part 2: Encoding and Framing12
  • Part 3: Handshakes13
  • Part 4: Flow Control17
    • Why Flow Control
    • On/Off Flow Control
    • Credit-Based Flow Control
    • Credit Initialisation
    • The Credit Loop and Buffer Sizing
    • Credit Classes and Pools
    • Credit Return Latency and Batching
    • Credit Bugs
    • Window Flow Control
    • Rate-Based Shaping
    • Hop-by-Hop or End-to-End
    • Lossless or Lossy
    • Switching Modes
    • Head-of-Line Blocking
    • Choosing Flow Control
    • Protocols Compared: Flow Control
    • Drills: Flow Control
  • Part 5: Transactions19
  • Part 6: Concurrency and Performance17
  • Part 7: Ordering13
  • Part 8: Sharing and Arbitration12
  • Part 9: Deadlock and Liveness13
  • Part 10: Reliability and Recovery20
  • Part 11: Bring-Up and Link Management10
  • Part 12: Power8
  • Part 13: Shared State and Coherence9
  • Part 14: Security and Isolation7
  • Part 15: Specifying and Verifying11
  • Part 16: Protocols Dissected17
  • Part 17: Capstones5
  • Part 18: Interview Preparation6
Loading lesson

‹Part 4: Flow Control
  1. Topics
  2. First Principles of Hardware Protocols
  3. Part 4: Flow Control
  4. Window Flow Control

Part 4 · Flow Control · Working (W)

Window Flow Control

A sliding window limits how much data may be sent but not yet acknowledged. How it differs from credits, why the same bandwidth-delay law sizes it, and where each is used.

On this page

    Note

    Level: Working (W) · Answers: How much may I send before I hear back?

    Before this: The Credit Loop and Buffer Sizing

    Two engineers argue about whether a link "uses credits" or "uses a window". Both describe a sender that may send a limited amount ahead and must then wait to hear back. They are describing two different mechanisms that obey the same law, and the difference matters as soon as a packet is lost.

    What is a sliding window, and how is it different from credits?

    The obvious answer, and why it breaks

    It is tempting to treat "window" and "credits" as two names for one idea, since both cap the data in flight. But they count different things and are freed by different events. Credits count free slots in the receiver's buffer and come back when a slot empties. A window counts data sent but not yet acknowledged and slides forward when acknowledgements arrive. Conflating them leads to systems that either overflow (a window that slides on acknowledgements while the receiver's buffer is still full) or stall (credits withheld for data that was lost and will never arrive).

    The idea: limit what is unacknowledged

    In window flow control the sender may have at most W units sent but not yet acknowledged. Each acknowledgement covers some data and lets the window slide forward, allowing that much new data. The receiver acknowledges data when it has received it correctly, which is why windows sit naturally alongside reliability (Part 10): the same acknowledgements that confirm delivery also release the window.

    The throughput law is the same as for credits. Each unit of window can be used at most once per acknowledgement round trip:

    throughput≤RTTack​W​,W≥bandwidth×RTTack​ for full rate
    A window caps unacknowledged data; acknowledgements, not freed buffer slots, let it slide.

    Try it

    Set the window and the acknowledgement round trip, then step through 32 packets. To see what a window does when a packet is lost, pick a packet to lose: its acknowledgement never arrives, the window fills and stops, and after a timeout the sender goes back and resends from the lost packet (go-back-N, lesson 10.12).

    Sliding window

    Loading sliding window…

    A window of 4 against an 8-cycle round trip sends at 50%. Raise the window to 8 for full rate, then lose packet 5 and watch the window stall.

    Credits and windows side by side

    Credits

    Window

    Counts

    Free slots in the receiver's buffer

    Data sent but not yet acknowledged

    Released when

    A slot empties (the consumer took the data)

    An acknowledgement arrives (the data was received)

    Protects against

    Receiver buffer overflow

    Too much data outstanding (for replay buffers, sequence numbers, or the network)

    Usual scope

    One hop

    End to end, or one link's reliability layer

    If data is lost

    Its credit is never returned unless the protocol handles it

    It is never acknowledged; a timeout or NAK replays it, and the window waits

    Sizing law

    B ≥ bandwidth × credit RTT

    W ≥ bandwidth × acknowledgement RTT

    Many links use both. A reliable link layer has a window (bounded by its replay buffer and sequence numbers, lesson 10.10), and the receiver's buffers are protected by credits. The window answers "how much might I have to resend?"; the credits answer "how much room does the receiver have?".

    The design space

    Use

    Choose

    Because

    Protect a receiver's buffer on a lossless hop

    Credits

    Exact, and released by the event that matters (a slot freeing)

    Bound data that might need resending

    A window

    Released by acknowledgements, which reliability needs anyway

    End-to-end flow over a lossy network

    A window, with the receiver advertising how much it can take

    No per-hop control is available end to end

    How real protocols chose

    Protocol

    Window or credits

    PCI Express

    Both, at different layers: credits at the transaction layer protect receiver buffers; the data link layer's replay mechanism limits unacknowledged packets with its sequence numbers and replay buffer (lesson 10.11).

    TCP over Ethernet

    An end-to-end window: the receiver advertises how much it can accept, and the sender keeps no more than that unacknowledged.

    What breaks

    A link sizes its replay window for the acknowledgement round trip but forgets that the receiver's buffers are smaller than the window (illustrative). The receiver acknowledges each packet when it arrives intact, but its buffer is full because its consumer is slow. The window keeps sliding on acknowledgements, packets keep arriving, and the receiver must drop them, which triggers replays, which arrive at a still-full buffer. Acknowledging correct receipt is not the same as having room; the fix was credits on the receive buffer alongside the window.

    Why this matters

    Senior lens. Whenever a design says "the sender may send N ahead", ask what N counts and what event frees it. Slots freed by consumption are credits; data freed by acknowledgement is a window. Each needs its own sizing from its own round trip, and a robust link usually needs both. Mixing them up is how designs end up dropping data on a lossless link or stalling forever on a lossy one.

    Interview

    Asked: "How is a sliding window different from credits?"

    Weak answer: They are the same thing.

    Strong answer: Both cap data in flight and both need about bandwidth times round trip to reach full rate, but they count different things. Credits count free slots in the receiver's buffer and come back when a slot empties; they protect the buffer. A window counts data sent but not yet acknowledged and slides when acknowledgements arrive; it bounds what might need resending. A reliable link often uses both: a window in its replay layer and credits on its receive buffers.

    Follow-ups: (1) What happens to each when a packet is lost? (2) Why can acknowledging receipt still overflow a buffer?

    Check yourself A window of 32 packets and an acknowledgement round trip of 64 packet times. What is the best throughput?

    32/64 = 50% of the link.

    Check yourself Why does a window naturally sit alongside reliability?

    Its window is released by acknowledgements, which a reliable protocol sends anyway to confirm delivery; and the unacknowledged data is exactly what must be kept for possible replay.

    Check yourself A receiver acknowledges packets as they arrive intact but has a full buffer. What protects it?

    Not the window, which slides on acknowledgement. The receive buffer needs its own flow control, such as credits.

    Key takeaways

    • A window limits data sent but not yet acknowledged; acknowledgements slide it forward.

    • Credits count receiver slots freed by consumption; windows count data freed by acknowledgement. Both obey throughput ≤ amount / round trip.

    • Reliable links often need both: a window for replay, credits for the receiver's buffers.

    Keep going

    Next: Lesson 4.10, Rate-Based Shaping. Flow control with no feedback at all: agree a rate and a burst size, and enforce them with a token bucket.

    Related topics

    • Part 4 overview: Flow Control

    • Lesson 10.11: Replay Buffers

    Previous

    59 / 234

    Next: Rate-Based Shaping

    Up next

    Up nextRate-Based Shaping

    Sign in to save progress

    Practice this lessonReport an error

    See also

    • Why Flow Control
    • On/Off Flow Control
    • Credit-Based Flow Control