What is TCP?
Also known as: Transmission Control Protocol
TCP (Transmission Control Protocol) is a connection-oriented, reliable transport protocol that provides in-order, error-checked delivery of a byte stream between applications running on hosts in an IP network.
TCP, defined in RFC 9293, is the core transport protocol of the Internet Protocol Suite. It operates at the transport layer (Layer 4) of the OSI model, sitting directly above IP. TCP is connection-oriented, meaning a virtual circuit must be established between two endpoints before data can be exchanged. This is done through a three-way handshake: SYN, SYN-ACK, ACK. Once established, the connection supports full-duplex communication.
The protocol breaks application data into segments, assigns sequence numbers to each byte, and ensures that the receiving host reassembles those bytes in the exact order they were sent. TCP provides retransmission of lost segments, detection and removal of duplicate segments, flow control via a sliding window, and congestion control through algorithms like slow start, congestion avoidance, fast retransmit, and fast recovery. The receiver sends cumulative acknowledgments (ACKs) to indicate which bytes have been received successfully. If an ACK is not received within a retransmission timeout (RTO), the segment is resent.
TCP is contrasted with UDP, which is connectionless and unreliable. TCP is used by applications that require guaranteed delivery and ordering, such as HTTP/HTTPS (ports 80, 443), SMTP (25), FTP (21), and SSH (22). It runs on top of IP (IPv4 or IPv6) and does not inherently enforce security. For encryption, protocols like TLS are layered over TCP (e.g., HTTPS = HTTP + TLS + TCP). TCP has evolved through several RFCs, adding features such as selective acknowledgments (SACK, RFC 2018) and timestamps (RFC 7323).
Key facts
- TCP uses a three-way handshake (SYN, SYN-ACK, ACK) to establish a connection.
- Sequence numbers track every byte, enabling in-order delivery and duplicate detection.
- Flow control uses a sliding window to prevent a sender from overwhelming a receiver.
- Congestion control employs slow start and AIMD (additive increase/multiplicative decrease).
- TCP connections are uniquely identified by the tuple (source IP, source port, destination IP, destination port).
How it works in practice
Related terms
References
More in Web Protocols
CORS
CORS (Cross-Origin Resource Sharing) is a browser security mechanism that lets servers explicitly allow web pages from one origin to request resources from a different origin via HTTP response headers.
GraphQL
GraphQL is a query language and runtime for APIs that lets clients request exactly the data they need in a single round trip, reducing over-fetching and under-fetching.
gRPC
gRPC is a high-performance, open-source remote procedure call framework initially developed by Google. It uses HTTP/2 for transport, Protocol Buffers as its interface definition language and message serialization format, and supports bidirectional streaming.
HTTP
HTTP is a text-based request-response protocol that defines how web clients and servers exchange resources, forming the foundation of data communication on the World Wide Web.
HTTP Pipelining
HTTP Pipelining is a technique in HTTP/1.1 that sends multiple requests on a single connection without waiting for each response, now largely replaced by HTTP/2 multiplexing.
HTTP Status Code
A three-digit integer in an HTTP response that indicates the result of the server's attempt to process the request, grouped into five classes (1xx through 5xx).
HTTP/1.1
HTTP/1.1 is the persistent-connection version of the Hypertext Transfer Protocol, defined in RFC 2616 and updated by RFCs 7230-7235, enabling multiple requests and responses over a single TCP connection.
HTTP/2
HTTP/2 is a binary, multiplexed version of HTTP that reduces latency through header compression, stream prioritization, and server push, as defined in RFC 7540.
HTTP/3
HTTP/3 is the third major version of the Hypertext Transfer Protocol, which runs over QUIC instead of TCP to reduce latency, eliminate head-of-line blocking, and improve connection setup time.
HTTPS
HTTPS (HTTP Secure) is HTTP traffic encrypted inside a TLS session, protecting data confidentiality, integrity, and server authenticity between a client and a web server.