Knowledge graphSettings

Updated: March 24, 2026 at 11:23 AM

TCP protocol

medium

Reliable byte delivery: connection, three‑way handshake, flow and congestion control.

This chapter matters because it makes the cost of reliable delivery visible: connection setup, ordering, flow control, and congestion control are always paid for in latency, memory, and state.

In practice, it helps you design retries, connection pooling, streaming, and backpressure with a clear sense of how the transport layer shapes application latency and throughput.

In interviews and design discussions, it lets you explain transport choices and load behavior through actual TCP mechanisms rather than generic claims about reliability.

Practical value of this chapter

Reliable delivery

Builds understanding of delivery guarantees and their cost to latency and throughput.

Congestion behavior

Encourages explicit congestion-control reasoning in data-flow and retry design.

Connection lifecycle

Shows handshake, keepalive, and queueing impact on request-path performance.

Interview depth

Strengthens transport-layer discussion in reliability-critical design cases.

RFC

RFC 9293 (TCP)

Current TCP standard: segment format, connection states, and protocol behavior.

Перейти на сайт

TCP is a key transport protocol in the TCP/IP stack. It provides reliable, ordered byte-stream delivery and adapts sending pace based on network and receiver feedback.

Core TCP properties

Reliable delivery

TCP provides ordered and verifiable delivery of byte streams between applications.

Connection-oriented

Before any payload transfer, peers establish a connection with a three-way handshake.

Retransmit and ACK

Lost segments are detected and retransmitted until acknowledgments are received.

Flow control

The receiver limits sender pace through receive window updates to protect buffers.

Congestion control

TCP adjusts sending rate when congestion signals appear in the network path.

TCP segment content visualization

Header fields encode reliability, ordering, flow control, and how TCP reacts to packet loss.

TCP Segment Header (base)

20-60 bytes

Source Port

16 bits

Destination Port

16 bits

Sequence Number

32 bits

Acknowledgment Number

32 bits

Data Offset

4 bits

Reserved

3 bits

Flags

9 bits

Window Size

16 bits

Checksum

16 bits

Urgent Pointer

16 bits

Options + Padding (optional)

32 bits

Base header is usually 20 bytes. Options (MSS, Window Scale, SACK Permitted, Timestamps) can extend it to 60 bytes.

TCP connection lifecycle

Connection setup

SYN -> SYN-ACK -> ACK, initial sequence space synchronization and window negotiation.

Data transfer

Stream segmentation, ACK processing, window updates, and retransmissions on loss.

Connection teardown

FIN/ACK exchange in both directions, plus TIME_WAIT to protect from stale segments.

Three-way handshake

TCP establishes connection state through a three-step handshake (SYN -> SYN-ACK -> ACK). After this, peers synchronize sequence space and can exchange data in full duplex mode.

TCP three-way handshake

Click a step or use controls to replay the connection setup

State

Click "Start" to see all TCP connection setup steps.

ClientServer
Client
-
Server
After all three steps the connection becomes established.

Flow and congestion control dynamics

Use step-by-step playback or autoplay across RTT steps to see cwnd/rwnd evolution.

StepRTT 1 (1 of 8)
cwndrwnd

Congestion window (cwnd)

2 MSS

Receive window (rwnd)

18 MSS

Effective window (min)

2 MSS

Queue pressure

8%

Higher queue occupancy increases tail latency even when packet loss is modest.

RTT

18 ms

Loss

0.0%

Estimated throughput

1.3 Mbps

MSS = 1460B

Phase: Slow start

What is happening in this step: Connection just started: sender ramps up cwnd quickly while the path is still uncongested.

Term decoding

  • cwnd = congestion window - Sender-side window: adjusted by congestion signals and limits in-flight data volume.
  • rwnd = receive window - Receiver-advertised window in ACKs that reflects available buffer capacity.
  • send window = min(cwnd, rwnd) - Effective sending limit is always the smaller value of these two windows.

Related chapter

IPv4 and IPv6: evolution of IP addressing

How IP routing properties affect TCP throughput and stability.

Open chapter

How routing and network conditions shape TCP behavior

RTT and BDP

Higher RTT and bandwidth-delay product require larger effective windows for good throughput.

Loss and queueing

Packet loss and queue buildup directly reduce cwnd and increase tail latency.

Asymmetric routing

Different forward/reverse paths can cause reordering and unnecessary duplicate ACK patterns.

MTU and fragmentation

PMTU discovery failures lead to blackhole behavior and heavy retransmission loops.

NAT/LB idle timeout

Middleboxes can terminate long-lived TCP sessions and create false-positive network incidents.

Why this matters in System Design

  • TCP handshake and connection warm-up directly influence p95/p99 request latency.
  • Window sizing, congestion control, and RTT define real throughput beyond nominal bandwidth.
  • Poor timeout/retry policy quickly causes cascading failures under stress.
  • Transport-level telemetry often finds incident root cause faster than app-level debugging alone.

Common mistakes

Assuming transport is always stable and ignoring tail latency in network segments.

Mixing congestion and application timeouts into one metric without layer split.

Ignoring connection pooling/keepalive and overloading systems with excessive handshakes.

Reusing identical timeout/retry settings for intra-DC and inter-region traffic.

Related chapters

Enable tracking in Settings