2. Sliding Window
<aside>
đź“– Features
- Generalization of stop-and-wait: allow multiple un-acked segments
 
- Bound on number of un-acked segments, called window
 
- Can keep pipe full
</aside>
 
<aside>
đź“– Flow Control
- Allow a “window” of unacknowledged packets in flight
 
- When acknowledgment arrives, advance window
 
- Required sequence number space size depends on window sizes
</aside>
 
2.1 Sliding Window Sender
- Every segment has a sequence number (SeqNo)
 
- Maintain 3 variables
- Send window size (SWS)
 
- Last acknowledgment received (LAR)
 
- Last segment sent (LSS)
 
 
- Maintain invariant: $\text{(LSS - LAR) ≤ SWS}$
 
- Advance LAR on new acknowledgment
 
- Buffer up to SWS segments
 
2.2 Sliding Window Receiver
- Maintain 3 variables
- Receive window size (RWS)
 
- Last acceptable segment (LAS)
 
- Last segment received (LSR)
 
 
- Maintain invariant: $\text{(LAS - LSR) ≤ RWS}$
 
- If received packet is < LAS, send acknowledgment
- Send cumulative acks
 
- NOTE:TCP acks are next expected data
 
 
2.3 RWS, SWS, and Sequence Space
- $\text{RWS≥1, SWS ≥1, RWS≤SWS}$
 
- Generally need RWS+SWS sequence numbers
- RWS packets in unknown state (ACK may/may not be lost)
 
- SWS packets in flight must not overflow sequence number space
 
 
2.4 TCP Flow Control

- Receiver advertises RWS using window field
 
- Sender can only send data up to LAR + window