A TCP stack is the piece of software that implements the Transmission Control Protocol on a device. It usually lives inside the operating system kernel, below applications and above the IP layer, and it is what actually performs the handshake, tracks every open connection, splits application data into segments, numbers and acknowledges them, retransmits what is lost and decides how fast to send. Applications commonly access it through sockets, writing and reading bytes without managing individual TCP segments. Specialised software can instead supply a user-space stack. The protocol is defined by the IETF, currently in RFC 9293, which replaced the 1981 specification. The stack is one vendor's realisation of that document, so Linux, Windows, the BSDs, Apple's systems and embedded network libraries each have their own TCP implementation, interoperable with one another yet distinguishable in detail.
Connection State and Segment Processing
Every TCP connection has a lifecycle, and the stack records where each connection stands in a per-connection data structure that RFC 9293 calls the transmission control block. The specification defines the states a connection passes through, from LISTEN and SYN-SENT through ESTABLISHED to the closing states such as FIN-WAIT, CLOSE-WAIT and TIME-WAIT. A connection begins with the TCP handshake: the client sends a segment with the SYN flag and an initial sequence number, the server answers with SYN and ACK, and the client completes the exchange with an ACK. After this three-way handshake both ends know each other's starting sequence numbers and the options exchanged, such as advertised maximum segment sizes and negotiated window scaling.
Once established, the stack processes incoming segments against the state it holds. Every byte sent over a connection has a sequence number, and acknowledgements are cumulative, confirming everything before the acknowledged position. The stack checks whether a segment falls inside the window it is willing to accept, buffers data that arrives out of order until the gap is filled, discards duplicates that arrive because of retransmission, and delivers an in-order byte stream to the application. Teardown is also stateful: each side signals that it has finished sending, and the active closer normally enters TIME-WAIT so that delayed segments from the old connection cannot be confused with a new one using the same addresses and ports.
Flow Control, Congestion and Retransmission
Two mechanisms limit how much data a stack may have in flight. Flow control protects the receiver: each acknowledgement advertises a receive window, the amount of additional data the receiver can buffer, and the sender must not exceed it. Congestion control protects the network: the sender maintains a congestion window whose size responds to acknowledgements and signals such as loss, measured delivery rate or explicit congestion notification, depending on the algorithm. The sender may transmit no more than the smaller of the two windows. RFC 9293 makes congestion control a requirement for TCP implementations and points to RFC 5681, which defines the four intertwined algorithms of slow start, congestion avoidance, fast retransmit and fast recovery. Many stacks implement newer algorithms with different growth and reduction rules, which is one reason throughput over the same path can differ between operating systems.
Retransmission is how TCP delivers reliability over an unreliable network. The stack starts a timer for unacknowledged data and resends when the timer expires; the specification requires the retransmission timeout to be computed according to RFC 6298, which smooths measured round-trip times and backs the timeout off exponentially after repeated failures. In the classic fast-retransmit algorithm, three duplicate acknowledgements can signal a loss before the timer expires. Newer recovery algorithms use additional evidence. The stack also handles selective acknowledgements, where supported, so that a single lost segment does not force resending everything after it.
TCP Implementation vs the TCP/IP Model
The phrase TCP/IP describes a layered model and a protocol family: link, internet, transport and application layers, with IP routing packets between hosts and TCP or UDP carrying data between processes. A TCP stack is narrower. It is the code for one transport protocol within one operating system, and it works with the IP layer beneath it and an application interface, usually sockets, above it. Discussions of the model concern how responsibilities are divided; discussions of a stack concern how one vendor made specific choices inside the transport layer.
| Aspect | TCP/IP model | TCP stack |
|---|---|---|
| What it is | Layered architecture and protocol family | Software implementing TCP on one system |
| Defined by | IETF standards for each protocol | An operating system or library vendor |
| Varies between systems | No, the model is shared | Yes, in defaults, options and algorithms |
| Where it runs | Conceptual | Kernel, or user space for specialised stacks |
Standards leave room for choice. They mandate behaviour that affects interoperability but leave defaults such as the initial window size, the order in which options appear in the SYN, and the choice among suitable congestion algorithms. The surrounding IP implementation also selects defaults such as a packet's initial time-to-live. Two stacks can both conform fully and still produce visibly different packets.
Observing an Implementation: TCP Stack Fingerprint
Those differences make a TCP stack fingerprint possible. By examining TCP fields together with surrounding IP headers, an observer can often infer which operating system family produced them. Nmap's documentation describes the signals its OS detection uses: the TCP options present and their order, since the standard does not require any particular ordering and implementations settle on their own; the initial window size; the initial time-to-live, commonly one of a handful of values; whether the don't-fragment bit is set; and patterns in how initial sequence numbers and IP identification fields are generated. Passive tools apply similar logic to traffic they merely observe rather than probe.
This is an observation of the implementation, not a definition of it, and it has limits. Firewalls that drop probes or normalise packets, network address translation and middleboxes that rewrite options can produce misleading results, and some systems use enough window values that a single sample is ambiguous. The practical consequence for anyone comparing signals is that the TCP fingerprint describes the machine whose stack sent the packets. A proxy that terminates one TCP connection and opens another exposes its outgoing stack on the final hop, while headers inside the HTTP request may claim a different operating system. A mismatch may simply reflect that architecture; it is not evidence of a particular user or malicious intent.
What the Stack Does Not Guarantee
TCP provides an ordered byte stream with retransmission and duplicate handling, but a successful write to a local socket does not prove delivery. An acknowledgement concerns receipt by the peer's TCP implementation, not durable storage or successful business processing. A crash can still leave the sender unsure whether an operation completed. Applications need their own responses, timeouts and, where appropriate, duplicate-operation safeguards. TCP itself also supplies neither encryption nor proof of a user's identity. Its implementation can reveal details about a network endpoint, while saying little about the person behind it.