The Transmission Control Protocol (TCP) is a fundamental transport layer protocol in the Internet protocol suite. It provides reliable, ordered, and error-checked delivery of data between applications running on hosts communicating over an IP network.
| Field | Size (bits) | Description |
|---|---|---|
| Source Port | 16 | Sender's port number |
| Destination Port | 16 | Receiver's port number |
| Sequence Number | 32 | Byte stream position |
| Acknowledgment Number | 32 | Next expected byte |
| Data Offset | 4 | Header length in 32-bit words |
| Flags (SYN, ACK, FIN, etc.) | 6 | Control bits |
| Window Size | 16 | Receive buffer space available |
| Checksum | 16 | Error detection |
| Urgent Pointer | 16 | Priority data indicator |
Master the three-way handshake process for connection establishment and the four-way handshake for connection termination.
Investigate how TCP uses sliding windows for flow control and efficient data transmission.
Examine slow start, congestion avoidance, fast retransmit, and fast recovery mechanisms.
Calculate throughput, RTT, window sizes, and analyze the sawtooth pattern of congestion windows.
Before data transmission begins, TCP establishes a connection using a three-way handshake to synchronize sequence numbers and acknowledge each other's readiness.
SYN=1, SEQ=x
SYN=1, ACK=1, SEQ=y, ACK=x+1
ACK=1, SEQ=x+1, ACK=y+1
TCP uses a four-way handshake to gracefully close connections, allowing both sides to finish transmitting data independently.
FIN=1, SEQ=u (Client wants to close)
ACK=1, SEQ=v, ACK=u+1 (Server acknowledges)
FIN=1, SEQ=v, ACK=u+1 (Server wants to close)
ACK=1, SEQ=u+1, ACK=v+1 (Client acknowledges)
TCP uses a sliding window mechanism for flow control, allowing the sender to transmit multiple packets before requiring an acknowledgment, thus improving network utilization and throughput.
Congestion control prevents network overload by dynamically adjusting the transmission rate based on perceived network conditions. TCP uses the AIMD (Additive Increase Multiplicative Decrease) algorithm combined with Slow Start.
Exponential growth phase at connection start or after timeout.
Window doubles every RTT until ssthresh is reached or loss occurs.
Linear growth phase to probe for available bandwidth.
Window increases by 1 MSS per RTT (linear growth).
Triggered by 3 duplicate ACKs. Retransmit lost segment immediately without waiting for timeout.
After fast retransmit, inflate cwnd and continue with congestion avoidance (Reno) or slow start (Tahoe).
This integrated simulation demonstrates the complete TCP lifecycle including connection establishment, data transfer with sliding windows, and congestion control mechanisms.
Open the 3-Way Handshake tab. Set the initial sequence numbers for both client and server (ISN). Observe the default values (typically random 32-bit values).
Click "Simulate Handshake" and observe the packet exchange. Record the SEQ and ACK numbers at each step in your observation table.
Note the state changes: CLOSED → SYN_SENT → ESTABLISHED (client) and LISTEN → SYN_RCVD → ESTABLISHED (server).
Study the 4-way termination process. Understand the TIME_WAIT state and its purpose (2×MSL wait).
Set different window sizes (1, 4, 8 packets). Observe how the number of outstanding packets affects throughput.
Simulate packet loss by selecting a packet to drop. Observe Go-Back-N behavior vs Selective Repeat concepts.
Observe how the receive window advertisement limits the sender's transmission rate.
Set ssthresh to 16 MSS. Start simulation and observe exponential growth of cwnd (1, 2, 4, 8, 16).
Continue simulation beyond ssthresh. Observe linear growth (16, 17, 18, 19...) until packet loss.
Compare Tahoe (cwnd → 1 on loss) vs Reno (cwnd → ssthresh on 3 dup ACKs) behavior.
Plot the congestion window over time. Identify the characteristic "sawtooth" pattern of TCP.
| Step | Direction | Flags | Sequence Number | Ack Number | Client State | Server State |
|---|---|---|---|---|---|---|
| 1 | Client → Server | SYN=1 | x | 0 | SYN_SENT | LISTEN |
| 2 | Server → Client | SYN=1, ACK=1 | y | x+1 | SYN_SENT | SYN_RCVD |
| 3 | Client → Server | ACK=1 | x+1 | y+1 | ESTABLISHED | ESTABLISHED |
| RTT # | Phase | cwnd (MSS) | ssthresh (MSS) | Segments Sent | Event |
|---|---|---|---|---|---|
| 0 | Slow Start | 1 | 16 | 1 | Connection start |
| 1 | Slow Start | 2 | 16 | 2 | - |