8.3
Networking & Protocols

TCP Flow Control

Explore TCP's sliding window, slow start, congestion avoidance, and fast retransmit mechanisms. Watch segments travel between sender and receiver with realistic timing.

Sender BufferWindow: [1..4] Size: 4
[
1
2
3
4
]
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
Acked
Sent (unacked)
In window
Outside window
Lost
Retransmitted
Segment Transfer
tick 0 | RTT ~4 ticks
SenderReceiver
TCP Metrics
cwnd
4.0
ssthresh
16
Segments Sent
0
Acknowledged
0
Retransmitted
0
RTT
4 ticks
Window Start
1
Window Size
4
Transfer Progress0/32
Sliding Window

The sliding window protocol allows the sender to transmit multiple segments before receiving acknowledgments. The window slides right as ACKs arrive.

Green segments are acknowledged
Amber segments are sent but unacknowledged
Cyan segments are within the window but unsent
Status
sending
Tick: 0 | In-flight: 0 packets
1.0x
Key Concepts
Sliding Window

Allows multiple segments in-flight without individual ACKs. Window size controls throughput.

effective_window = min(cwnd, rwnd)
Slow Start

Exponential cwnd growth from 1 MSS. Probes network capacity quickly but carefully.

cwnd += 1 MSS per ACK
Congestion Avoidance

Linear cwnd growth after ssthresh. Additive increase, multiplicative decrease (AIMD).

cwnd += 1/cwnd per ACK
Fast Retransmit

3 duplicate ACKs trigger immediate retransmission, bypassing expensive timeout recovery.

ssthresh = cwnd/2
TCP Segment Header
0
4
8
12
16
20
24
28
31
Source Port (16 bits)
Destination Port (16 bits)
Sequence Number (32 bits)
Acknowledgment Number (32 bits)
Offset
Rsv
URG
ACK
PSH
RST
SYN
FIN
Window Size
Checksum (16 bits)
Urgent Pointer (16 bits)
Congestion Control Algorithms
PhaseTriggercwnd Changessthresh ChangeGrowth Pattern
Slow StartConnection open+1 per ACKUnchangedExponential
Congestion Avoidancecwnd >= ssthresh+1/cwnd per ACKUnchangedLinear
Fast Retransmit3 dup ACKsssthresh + 3cwnd / 2Step down
TimeoutRTO expires1 MSScwnd / 2Reset to SS
TCP vs UDP
TCP (Transmission Control Protocol)
  • Connection-oriented (3-way handshake)
  • Reliable delivery with ACKs
  • Flow control via sliding window
  • Congestion control (slow start, AIMD)
  • Ordered delivery guaranteed
  • Use: HTTP, FTP, SSH, Email
UDP (User Datagram Protocol)
  • Connectionless (fire and forget)
  • Unreliable, no acknowledgments
  • No flow or congestion control
  • Minimal overhead (8-byte header)
  • No ordering guarantee
  • Use: DNS, Video, VoIP, Gaming