RSystems

Networking

TCP

Also known as: Transmission Control Protocol

TCP (Transmission Control Protocol) is a connection-oriented transport protocol that guarantees reliable, ordered delivery of data between two endpoints. It's the foundation of web, email, and file transfer traffic.

TCP sits at the transport layer of the network stack, above IP and below application protocols like HTTP and SMTP. It takes a stream of data from an application and breaks it into segments, each numbered for reassembly, then transmits them over IP — which doesn't guarantee delivery or order.

Diagram showing the four-layer TCP/IP model: Application, Transport (TCP/UDP), Internet (IP), and Network Access layers

How TCP establishes a connection

Before any data is sent, TCP performs a three-way handshake to establish a connection:

  1. SYN — the client sends a synchronization request
  2. SYN-ACK — the server acknowledges and sends its own sync
  3. ACK — the client acknowledges the server's sync

Only after this handshake does data flow. This setup provides both endpoints with sequence numbers used to detect lost packets and request retransmission.

Diagram showing the TCP three-way handshake: SYN, SYN-ACK, ACK sequence between client and server

TCP vs UDP

TCP's reliability has a cost: latency. The handshake, acknowledgments, and retransmission add overhead. For applications that need every byte delivered correctly — HTTP, HTTPS, email, file transfer, SSH, iSCSI — TCP is the right choice. For applications that prioritize speed over guaranteed delivery (DNS, VoIP, video streaming, gaming), UDP avoids the overhead by dropping the guarantees.

TCP also handles flow control (matching transmission speed to receiver capacity) and congestion control (backing off when the network is congested), which makes it resilient to varying network conditions.