Protocol Deep Dive

Transmission Control
Protocol

An interactive guide to the backbone of the internet. Explore headers, state machines, and congestion control algorithms.

Reliable

Ensures data delivery via acknowledgments (ACK) and retransmissions.

Ordered

Guarantees byte sequence order using Sequence and Acknowledgment numbers.

Flow Controlled

Prevents sender overflow using the Sliding Window mechanism.

Connection Establishment

The 3-Way Handshake

CLIENT CLOSED
SERVER LISTEN
SYN
SYN-ACK
ACK
> Ready to initiate handshake...

Step 1: SYN

Client sends a SYN (synchronize) packet to the server to request a connection. Indicates the client's initial sequence number (ISN).

Step 2: SYN-ACK

Server responds with SYN-ACK. Acknowledges client's SYN (ISN + 1) and sends its own ISN.

Step 3: ACK

Client sends ACK. Acknowledges server's SYN (Server ISN + 1). Connection is established.

Flow Control

The Sliding Window Mechanism

Receiver Buffer Size: 4
SENDER BUFFER Bytes 0-19
Sent & Acked
Sent, Not Acked
Usable Window
Not Sent
RECEIVER BUFFER Window: 4

How it works

  • The Receiver advertises a Window Size (rwnd) in every ACK.
  • The Sender maintains a "Usable Window" which is the minimum of the Receiver's rwnd and the Congestion Window (cwnd).
  • The Sender can only send bytes that fall within this window.
  • As ACKs arrive, the window slides forward, allowing new data to be sent.
0%
Link Utilization

Increasing the window size allows the sender to "fill the pipe" more effectively, improving throughput on high-latency links.

Congestion Control

AIMD (Additive Increase / Multiplicative Decrease)

Congestion Window (cwnd): 1
Threshold (ssthresh): 16
Slow Start

Slow Start

Exponential growth. Starts with cwnd = 1 MSS. For every ACK received, cwnd increases by 1. Effectively doubles every RTT. Continues until ssthresh is hit or packet loss occurs.

Congestion Avoidance

Linear growth. Once cwnd > ssthresh, cwnd increases by roughly 1 MSS per RTT (Additive Increase). This is cautious probing for available bandwidth.

Fast Retransmit / Recovery

If 3 duplicate ACKs are received, packet loss is inferred. ssthresh is set to cwnd/2, and cwnd is set to ssthresh + 3 (Reno) or 1 (Tahoe).

Timeout

If RTO (Retransmission Timeout) expires, severe congestion is assumed. ssthresh = cwnd/2, and cwnd is reset to 1 MSS. Re-enters Slow Start.