What is TCP (Transmission Control Protocol)?
A connection-oriented transport-layer protocol. It sets up a connection with a three-way handshake and uses sequence numbers, acknowledgments (ACKs) and retransmission to deliver data in order, without gaps or duplicates. Flow control and congestion control adjust how much it sends. It carries web traffic over HTTP/1.1 and HTTP/2, email, SSH and more.
Japanese name: TCP
TCP (Transmission Control Protocol) appears in 17 practice questions across 2 topics, including Computer Networking Basics, Web Technology Basics.
Field: Computer Networking Basics
How TCP guarantees delivery
TCP gives every byte it sends a running number, the sequence number. The receiver returns an acknowledgment (ACK) that says, in effect, send me the data starting from this number next. If no ACK arrives within a set time, the sender sends the data again (retransmission timeout). If it receives three ACKs with the same number (duplicate ACKs), it retransmits without waiting for the timeout (fast retransmit). The receiver puts data that arrived out of order back in order, discards duplicates and uses a checksum to detect corrupted data. To the application, the data looks like a continuous stream of bytes with no message boundaries.
Header and connection management
A TCP header is 20 bytes without options. It holds the source and destination port numbers, the sequence number, the acknowledgment number, flags such as SYN, ACK, FIN and RST, the window size and a checksum. A connection is identified by four values: the source and destination IP addresses and port numbers. It opens with a three-way handshake and closes when each direction sends a FIN. If one segment is lost, later data cannot be passed to the application even if it has arrived (head-of-line blocking), which is one reason HTTP/3 uses QUIC over UDP instead.
FAQ
What is the difference between TCP and UDP?
TCP sets up a connection and delivers data reliably with acknowledgments, retransmission and ordering. UDP has no setup and no retransmission and simply sends datagrams, so its header is smaller and it adds less delay. TCP is used where completeness matters, such as the web and file transfer; UDP is used where low delay matters more than an occasional loss, such as voice calls, and for short exchanges such as DNS queries.
When does TCP retransmit?
There are two triggers: no ACK arriving before the retransmission timeout, which is calculated from measured RTTs, and three duplicate ACKs with the same acknowledgment number in a row, which triggers fast retransmit. If retransmissions keep failing, the timeout is doubled each time.
Why is TCP throughput lower than the link speed?
At most one window of data can be sent per round-trip time, so throughput falls as the distance to the other end grows or as the window shrinks. It also drops when packet loss makes congestion control cut the window, or when the receiving application reads data slowly.