Transmission Control Protocol (TCP) is one of the core protocols of the Internet Protocol Suite. It was originally defined in May 1974 by Vint Cerf and Yogen Dalal and has evolved through subsequent RFCs (Request for Comments) to become one of the fundamental technologies that power the modern internet.
TCP operates at the transport layer of the OSI model and provides reliable, ordered, and error-checked delivery of a stream of bytes between applications running on hosts communicating via an IP network. It's designed to handle lost, duplicated, or delayed packets, ensuring complete data transmission regardless of network conditions.
When compared to its transport layer counterpart, User Datagram Protocol (UDP), TCP provides connection-oriented communication, reliability, and flow control but at the cost of lower transport efficiency and higher resource utilization. This makes TCP the protocol of choice for applications where data accuracy is more important than speed, such as web browsing, email, file transfers, and database communications.
TCP uses a three-way handshake to establish a connection between a client and server:
SYN Client sends a SYN (synchronize) packet to the server, initiating a connection.
SYN-ACK Server responds with a SYN-ACK packet, acknowledging the client's request and synchronizing its own sequence numbers.
ACK Client sends an ACK packet to acknowledge the server's response, completing the handshake.
This handshake ensures both parties are ready to communicate and establishes the initial sequence numbers for data transmission. Sequence numbers are critical for tracking data packets and ensuring they are reassembled in the correct order at the destination.
Once a connection is established, TCP manages the data transfer through several key processes:
TCP divides the application data into appropriately sized segments (typically with a maximum segment size of 1460 bytes to fit in Ethernet frames). Each segment includes a TCP header containing information such as source and destination port numbers, sequence numbers, acknowledgment numbers, flags, and a checksum.
TCP ensures reliable delivery through positive acknowledgment with retransmission:
TCP implements flow control using a sliding window mechanism:
TCP employs several algorithms to avoid network congestion:
TCP uses a four-way handshake (also known as the TCP termination sequence) to properly close a connection:
FIN One party sends a FIN packet to indicate it has no more data to send.
ACK The other party acknowledges receipt of the FIN.
FIN The other party sends its own FIN when it has no more data to send.
ACK The first party acknowledges the second FIN, completing the termination.
This process ensures all data in transit is delivered and both sides are ready to terminate the connection. TCP connections can also be reset immediately using a RST (reset) flag, which is typically used when a connection needs to be terminated abnormally due to error conditions.
The TCP header typically contains 20 bytes of mandatory fields and optional fields that can vary in length. Key fields include:
Optional fields may include Maximum Segment Size (MSS), Window Scale, Timestamps, and Selective Acknowledgments (SACK), which enhance TCP functionality.
Over the decades, numerous TCP variants have been developed to address specific network challenges:
TCP has also evolved through various extensions including TCP Fast Open (TFO), which reduces connection establishment latency.
Despite being over four decades old, TCP remains essential to modern internet infrastructure:
TCP continues to evolve to meet modern demands, with ongoing research improving performance in satellite networks, high-speed data center environments, and mobile networks with variable connectivity. The development of QUIC (Quick UDP Internet Connections), which implements TCP-like reliability over UDP, demonstrates both the continued importance of TCP's principles and the need for innovation beyond TCP's limitations.
