GOAT EngineerPreparing your learning space…

System Design · Concept Library · Free article

TCP & the Handshake

How TCP opens a reliable, ordered byte stream for HTTP/1.1 and HTTP/2, while HTTP/3 uses QUIC over UDP.

TCP provides a reliable, in-order byte stream. It normally starts with a three-message handshake and retransmits lost data. Connection establishment costs one round trip before the server can answer ordinary application data, so reuse is valuable. HTTP/1.1 and HTTP/2 use TCP; HTTP/3 provides reliable streams over QUIC and UDP instead.

A connection you can trust

IP packets can be lost, duplicated, or delivered out of order. TCP handles those conditions and presents the application with a reliable, ordered byte stream.

The peers first establish a connection. TCP then uses sequence numbers, acknowledgements, retransmission, and flow and congestion control while data moves.

The three-step greeting

Normally, both sides exchange a quick greeting before application data. It takes three messages, written SYN → SYN-ACK → ACK. TCP Fast Open is a specialised exception that can carry data during setup. Step through the ordinary case:

The interactive version of this example is available when JavaScript loads.

What TCP does for you

  • Reliable delivery: TCP retransmits lost bytes and presents received data in order. If recovery fails, the connection reports an error; TCP does not guarantee that a higher-level message completes.
  • Ordering: bytes arrive in the order you sent them, even if the underlying packets took different paths.
  • Flow control: it slows down so a fast sender does not overwhelm a slower receiver.
  • Congestion control: it backs off when the network is busy, so the whole network does not collapse under load.

TCP vs UDP

UDP is a smaller transport with no built-in connection setup, retransmission, or ordering. An application can accept those semantics, or build richer behaviour above UDP. QUIC, for example, adds reliable ordered streams, congestion control, and security for HTTP/3.

TCPUDP
ConnectionYes: greeting firstNo: just send
Reliable?Yes, re-sends lost dataNo, may drop silently
Ordered?YesNo
OverheadHigherLower
Good forHTTP/1.1, HTTP/2, APIs, filesLive media, games, DNS, and transports such as QUIC

Why reusing the connection matters

Every new TCP connection normally spends a round trip on the handshake before ordinary application data can receive a response. Opening a fresh connection for each image, script, and stylesheet repeats that cost.

Keeping a connection open lets later requests avoid the handshake. HTTP/2 can also carry several streams over one TCP connection.

Where TCP sits

TCP is the transport layer, often called Layer 4. It sits above IP and below applications such as HTTP. A Layer 4 load balancer can route using the connection’s source and destination addresses, ports, and protocol without reading the HTTP request. See network layers.

What to remember

Sources and further reading

By GOAT Engineer. Back to Concept Library. Privacy Policy · Contact.