What is TCP? A Comprehensive Learning Section on the Transmission Control Protocol
The Transmission Control Protocol (TCP) is a core Internet transport protocol that runs above IP and provides a reliable, ordered byte-stream service between two endpoints. TCP was originally specified in RFC 793, which describes TCP as a connection-oriented, end-to-end reliable protocol intended to work over an unreliable datagram service from lower layers. In practice, TCP underpins many application protocols because it delivers data “as a stream” with reliability mechanisms such as acknowledgments and retransmissions.
At a high level, TCP offers:
- Ordered delivery of a byte stream.
- Reliability over a best-effort IP network.
- Flow control to avoid overwhelming the receiver.
- Congestion control to avoid overloading the network.
Mermaid overview of how TCP fits into the protocol stack:
Footnotes
-
RFC 793 Transmission Control Protocol - Original TCP specification; connection-oriented, end-to-end reliable host-to-host protocol. ↩ ↩2 ↩3
-
The Transmission Control Protocol — Computer Networking: Principles, Protocols and Practice - Explains sequence numbers, acknowledgments, and the window-based reliable transfer mechanism in TCP. ↩
-
RFC 5681 TCP Congestion Control - Standard defining TCP congestion control mechanisms including slow start and related algorithms. ↩
TCP connection setup (handshake) and termination walkthrough
TCP in the protocol stack and what “byte-stream” means
TCP provides a reliable byte-stream service rather than message-based delivery. This means the receiver’s TCP reassembles the same sequence of bytes that the sender wrote, without gaps, duplication, or reordering (as a stream view). TCP also uses a sequence-numbered mechanism where each byte consumes sequence number space, enabling acknowledgments and ordered reconstruction.
TCP is connection-oriented: endpoints establish state before sending application data, then close the connection later using an orderly teardown procedure defined in the TCP specification.2
Key terms to keep straight:
- Connection-oriented
- Byte stream
- Sequence number
- Acknowledgment (ACK)
Footnotes
-
The Transmission Control Protocol — Computer Networking: Principles, Protocols and Practice - Explains sequence numbers, acknowledgments, and the window-based reliable transfer mechanism in TCP. ↩
-
RFC 793 Transmission Control Protocol - Original TCP specification; connection-oriented, end-to-end reliable host-to-host protocol. ↩
-
RFC 9293 - Transmission Control Protocol (TCP) - Current TCP specification including connection teardown states and behavior. ↩
How TCP delivers reliable, ordered data (conceptual sliding-window flow)
- 1Step 1
TCP performs a connection setup so both sides agree on initial sequence numbers and options; the connection then enters the data transfer phase.
Footnotes
-
RFC 793 Transmission Control Protocol - Original TCP specification; connection-oriented, end-to-end reliable host-to-host protocol. ↩
-
- 2Step 2
The sender divides the stream into TCP segments, tagging each segment with sequence numbers so the receiver can place bytes in order.
Footnotes
-
The Transmission Control Protocol — Computer Networking: Principles, Protocols and Practice - Explains sequence numbers, acknowledgments, and the window-based reliable transfer mechanism in TCP. ↩
-
- 3Step 3
For sent data, the receiver returns ACKs indicating the next byte it expects, allowing the sender to know what has been delivered successfully.
Footnotes
-
The Transmission Control Protocol — Computer Networking: Principles, Protocols and Practice - Explains sequence numbers, acknowledgments, and the window-based reliable transfer mechanism in TCP. ↩
-
- 4Step 4
TCP uses a window-based mechanism to control how much unacknowledged data can be in flight, enabling efficient reliable transfer without waiting for every segment individually.
Footnotes
-
The Transmission Control Protocol — Computer Networking: Principles, Protocols and Practice - Explains sequence numbers, acknowledgments, and the window-based reliable transfer mechanism in TCP. ↩
-
- 5Step 5
When acknowledgments do not advance as expected, TCP retransmits missing data to restore reliable in-order delivery (loss recovery is part of TCP’s reliability design).
Footnotes
-
RFC 793 Transmission Control Protocol - Original TCP specification; connection-oriented, end-to-end reliable host-to-host protocol. ↩
-
- 6Step 6
The sender’s usable sending rate is constrained by both the receiver’s advertised receive window (flow control) and the sender’s congestion window (congestion control).
The TCP header’s roles (what TCP needs to do reliability + ordering)
TCP relies on several header fields and mechanisms to provide its services. A key source description of the original design explains that TCP’s sequence number and acknowledgment number fields, together with a window-based mechanism, are used to provide reliable, window-controlled transfer. The advertised window is critical: it tells the sender how much buffer capacity the receiver still has.
A simplified mapping of goals → header mechanisms:
- Sequence numbers → ordering & loss recovery
- ACK numbers → reliability progress
- Window → prevent receiver overload
For performance over high-bandwidth-delay products, TCP can also use extensions such as window scaling (defined by RFC 7323) to overcome the 16-bit window field limitation.
Footnotes
-
The Transmission Control Protocol — Computer Networking: Principles, Protocols and Practice - Explains sequence numbers, acknowledgments, and the window-based reliable transfer mechanism in TCP. ↩ ↩2
-
RFC 7323 TCP Extensions for High Performance - Defines window scaling to allow TCP windows larger than the 16-bit field limit. ↩
Connection setup and teardown: why TCP has states
Because TCP is connection-oriented, it uses an explicit setup phase and maintains a connection state machine. RFC 793 describes TCP as a highly reliable host-to-host protocol with orderly communication between processes, operating above IP’s unreliable datagram service.
Handshake purpose (setup)
The connection setup phase synchronizes sequence number state and ensures both endpoints are ready to send/receive, which is essential before either side starts streaming application data.
Teardown (close) purpose
To close, TCP performs an orderly exchange using FIN/ACK semantics defined by TCP’s connection teardown behavior. RFC 9293 (the current TCP specification) describes multiple teardown states (e.g., FIN-WAIT-1, FIN-WAIT-2, TIME-WAIT, LAST-ACK), showing that closure is managed to handle possible delayed or duplicate packets safely. TIME-WAIT is especially important because it holds state long enough to deal with retransmissions of the peer’s FIN and to avoid confusing a new connection with stray packets from the previous one.
Footnotes
-
RFC 793 Transmission Control Protocol - Original TCP specification; connection-oriented, end-to-end reliable host-to-host protocol. ↩ ↩2
-
RFC 9293 - Transmission Control Protocol (TCP) - Current TCP specification including connection teardown states and behavior. ↩
-
TCP Connection States Explained - Explains TCP teardown states and the purpose of TIME_WAIT in practical terms. ↩
Pro Tip: Separate reliability from congestion
If your TCP connection is slow, it may be limited by congestion control (network capacity) or flow control (receiver buffer). TCP’s sending rate is bounded by both: the congestion window and the receive window.
Warning: TIME_WAIT can look like a problem (but often isn’t)
High counts of TIME_WAIT are common on many servers with many short-lived connections. TIME_WAIT exists for correctness (handling retransmissions and delayed segments) per TCP’s design and state-machine rules.2
Footnotes
-
RFC 9293 - Transmission Control Protocol (TCP) - Current TCP specification including connection teardown states and behavior. ↩
-
TCP Connection States Explained - Explains TCP teardown states and the purpose of TIME_WAIT in practical terms. ↩
Congestion control and slow start (core TCP performance behavior)
TCP congestion control is standardized and described in detail in RFC 5681. It explains that TCP uses an approach based on several algorithms—such as slow start and congestion avoidance—to avoid sending more data than the network can handle. RFC 5681 also states that slow start begins with a congestion window and increases cwnd as acknowledgments arrive (effectively probing available capacity).
Wikipedia provides an additional accessible explanation that slow start increases the congestion window from an initial value and can grow roughly exponentially per RTT by increasing by 1 MSS each ACK, though the precise growth depends on implementation and RFC parameters.
Key term set:
- cwnd (congestion window)
- ssthresh
- duplicate ACK
- fast retransmit
Footnotes
-
RFC 5681 TCP Congestion Control - Standard defining TCP congestion control mechanisms including slow start and related algorithms. ↩
-
TCP congestion control - Wikipedia - Accessible explanation of slow start behavior (cwnd growth per ACK/RTT) and its role in congestion control. ↩
Conceptual constraints on TCP sending rate
TCP can only send data up to what both flow control and congestion control allow.
TCP tracks bytes using sequence numbers and uses cumulative ACKs to confirm what was received; missing data triggers retransmission to restore in-order delivery.2
Footnotes
-
RFC 793 Transmission Control Protocol - Original TCP specification; connection-oriented, end-to-end reliable host-to-host protocol. ↩
-
The Transmission Control Protocol — Computer Networking: Principles, Protocols and Practice - Explains sequence numbers, acknowledgments, and the window-based reliable transfer mechanism in TCP. ↩
TCP lifecycle (at a glance)
Handshake / initial state
Connection setupSynchronizes initial sequence numbers and negotiates options; TCP becomes established for data transfer."
Footnotes
-
RFC 793 Transmission Control Protocol - Original TCP specification; connection-oriented, end-to-end reliable host-to-host protocol. ↩
Reliable, ordered byte streaming
Data transferSegments are sequence-numbered; ACKs advance progress; sliding window enables efficient retransmission and flow regulation."
Footnotes
-
The Transmission Control Protocol — Computer Networking: Principles, Protocols and Practice - Explains sequence numbers, acknowledgments, and the window-based reliable transfer mechanism in TCP. ↩
Congestion control in action
Rate adaptationSlow start and related algorithms adapt cwnd to available network capacity."
Footnotes
-
RFC 5681 TCP Congestion Control - Standard defining TCP congestion control mechanisms including slow start and related algorithms. ↩
FIN/ACK close and TIME_WAIT
Connection teardownTCP transitions through teardown states and uses TIME-WAIT to handle delayed/duplicate segments correctly.2"
Footnotes
-
RFC 9293 - Transmission Control Protocol (TCP) - Current TCP specification including connection teardown states and behavior. ↩
-
TCP Connection States Explained - Explains TCP teardown states and the purpose of TIME_WAIT in practical terms. ↩
Common misconceptions (and precise clarifications)
TCP Quick Knowledge Check
Knowledge Check
Which statement best describes TCP?