TCP Fast Open

Also known as: TFO

On this page 7

TCP Fast Open (TFO) is an extension of TCP that allows a client to carry application data in the initial SYN segment and allows the server to deliver that data to the application before the three-way handshake completes. Among the transport protocols used in Networking, it is the standard way to remove one full round trip from repeated short connections, and it is specified as an experimental standard in RFC 7413.

The gain matters most when connections are short and latency is high: a web request over a path with a 100 ms round-trip time can start receiving a response about 100 ms sooner. TFO achieves this without weakening the basic protection against spoofed source addresses, because it relies on a cryptographic cookie that the server issued during an earlier, ordinary connection.

How TCP Fast Open removes a round trip

TCP Fast Open works by letting the server accept data on a SYN only when the client proves, with a previously issued cookie, that it really controls its claimed IP address. In a classic TCP handshake the client sends SYN, the server answers SYN-ACK, and only the final ACK may carry the first request, so the request reaches the server one round trip after the connection attempt starts.

TFO splits the process into two phases. In the cookie request phase, the client sends a SYN with an empty TFO option; the server computes a cookie, typically a MAC of the client IP address under a secret server key, and returns it in the SYN-ACK. The client caches this value per server. In the fast open phase, a later SYN carries both the cookie and the request payload, and the server, after validating the cookie, passes the data to the listening application immediately.

The following table compares the timing of a standard connection with a TFO connection for a simple request and response exchange.

Connection typeData in SYNRound trips until responseCondition
Standard TCPNo2 RTTAlways applicable
TFO first contactNo, cookie requested2 RTTNo cached cookie
TFO repeat contactYes, with cookie1 RTTValid cached cookie
TLS 1.3 over standard TCPNo3 RTT for HTTPS dataFull TLS handshake
TLS 1.3 early data over TFOYes1 RTT for HTTPS dataResumption and cookie
Round trips before the first response byte arrives

The cookie exists to prevent SYN data abuse by spoofed senders. Without it, an attacker could forge SYN segments with a victim address and make the server perform expensive work, or send large responses toward the victim, without ever completing a handshake. Because the cookie is bound to the client address, a sender that cannot receive packets at that address cannot obtain a valid one.

The cookie does not, however, make SYN data safe in every respect. A captured SYN with a valid cookie can be replayed or duplicated by the network, so the server application may receive the same request twice. RFC 7413 therefore states that TFO is suitable only for requests that are idempotent or tolerant of duplication, and it asks servers to limit the number of pending fast open connections.

The table below summarizes the main parameters that implementations expose and what each controls.

ParameterTypical valueWhat it controls
Cookie length4 to 16 bytes, often 8Resistance to guessing
Server key rotationHours to daysLifetime of issued cookies
Pending TFO queue limitSet by the listenerExposure to SYN data floods
Client cookie cachePer server addressWhich servers allow fast open
TCP option kind34 (experimental 254 earlier)How the option is encoded
Key TFO parameters and their effect

When the pending queue overflows or the cookie fails validation, the server simply falls back to a normal handshake: it acknowledges only the SYN, ignores the payload, and the client retransmits the data after the connection is established. This graceful degradation is a core design property, because it means TFO never makes a connection fail outright on the server side.

TCP Fast Open is one of several mechanisms that reduce connection setup latency, and it is often confused with the others. TFO operates purely at the transport layer and saves the TCP handshake round trip, whereas TLS session resumption and early data save round trips at the security layer. Protocols built on UDP, such as QUIC, integrate both layers into a single handshake.

TechniqueLayerRound trips savedMain limitation
TCP Fast OpenTransportOne on repeat connectionsMiddlebox interference
Persistent connectionsApplicationAll handshakes after the firstIdle connections hold resources
TLS 1.3 0-RTTSecurityOne on resumptionReplay risk for early data
QUIC 0-RTTTransport and securityUp to two on resumptionBlocked UDP in some networks
Multipath TCPTransportNone by itselfTargets resilience, not setup
How TFO differs from neighboring approaches

The approaches are complementary rather than exclusive. Connection reuse, often called keepalive at the HTTP level, avoids handshakes entirely while a connection stays open, and TFO helps precisely when a new connection is unavoidable, such as after an idle timeout or when a client reaches a server for the second time in a day.

Deploying TCP Fast Open in practice

Using TFO requires support on both ends and an explicit opt-in by the application. On Linux, the net.ipv4.tcp_fastopen sysctl is a bitmask: value 1 enables client support, 2 enables server support, and 3 enables both. A server sets the TCP_FASTOPEN socket option with a queue length, and a client sends data with sendto() and the MSG_FASTOPEN flag or uses the TCP_FASTOPEN_CONNECT option.

  • Enable TFO for short, repeated, idempotent requests, such as DNS over TCP, API queries or static content fetches.
  • Keep the first request small enough to fit in a single SYN segment, which is bounded by the MSS.
  • Rotate the server cookie key consistently across all servers behind one load balancer address.
  • Monitor fallback and failure counters to detect paths where middleboxes drop SYN data.

The decision table below shows when enabling TFO is worthwhile.

SituationRecommendationReason
High RTT, many short connectionsEnable on both endsLargest latency saving
Non-idempotent first requestDo not send SYN dataDuplicates may cause side effects
Long-lived bulk transfersOptionalSaving is negligible
Path through strict firewallsEnable with fallback monitoringSYN data may be dropped
When to enable TFO

Limitations and common misconceptions

The biggest practical obstacle is middlebox ossification. Firewalls, NAT devices and intrusion prevention systems sometimes drop SYN segments that carry data or unknown options, which causes connection timeouts instead of a clean fallback. For this reason, several client implementations disable TFO automatically after detecting failures, and some major browsers removed or never enabled TFO by default.

  • TFO is not a zero round-trip protocol: the response still needs one RTT, and the first contact gains nothing.
  • TFO does not replace TLS early data; a secure connection needs both to reach one round trip.
  • The cookie is not an authentication token: it proves address ownership, not client identity.
  • Cookies can act as a tracking identifier across connections, so privacy-sensitive clients may clear them.

A further constraint is NAT and address changes. Because the cookie is bound to the observed client address, a client behind a carrier-grade NAT with a changing public address presents an invalid cookie, and the server quietly reverts to a standard handshake.

In plain words

Normally, a computer and a server must exchange a quick greeting before any real request can be sent, and that greeting costs a trip across the network and back. TCP Fast Open lets a computer that has visited the server before skip the waiting and attach its question to the very first greeting.

It works like a regular customer with a membership card. The first visit takes the usual time, but the card lets the customer place an order while still walking in. The key idea is simple: repeat connections start faster, as long as nothing along the way blocks the shortcut.

A real-world example

A company runs a public DNS resolver that also answers queries over TCP and DNS over TLS. Its mobile clients often sit on networks with a round-trip time of 150 ms, and each query opens a short connection that closes after a few hundred bytes.

The operators enable TFO on the Linux servers with tcp_fastopen set to 3, a pending queue of 1,024 connections and a shared cookie key rotated daily across the whole anycast cluster. Since DNS lookups are idempotent, duplicated SYN data causes no harm.

After the change, repeat clients receive answers roughly one round trip sooner, cutting about 150 ms from each new connection. Monitoring shows that a small share of paths silently drop SYN data, so the client library keeps its automatic fallback to standard TCP, and those users see the same latency as before.