TCP Fast Open
TCP Fast Open
Thesis
TCP Fast Open (TFO) lets a client send data in the first SYN (with a cookie) so short RPCs avoid a full handshake RTT. Linux exposes it via net.ipv4.tcp_fastopen bits: client=1, server=2, both=3. This chapter reads the sysctl from procfs.
Mental model
first connection: SYN + cookie request
later: SYN + data + cookie
| Value | Meaning |
|---|---|
| 0 | off |
| 1 | client |
| 2 | server |
| 3 | client+server |
Worked examples
=== /proc/sys net.ipv4.tcp_fastopen ===
1
/proc/sys/net/ipv4/tcp_fastopen
/proc/sys/net/ipv4/tcp_fastopen_blackhole_timeout_sec
/proc/sys/net/ipv4/tcp_fastopen_key
/proc/sys/net/ipv4/tcp_fastopen=1
/proc/sys/net/ipv4/tcp_fastopen_blackhole_timeout_sec=0
/proc/sys/net/ipv4/tcp_fastopen_key=
=== ss ===
State Recv-Q Send-Q Local Address:Port Peer Address:Port
LISTEN 0 128 127.0.0.1:8791 0.0.0.0:*
LISTEN 0 100 0.0.0.0:6080 0.0.0.0:*
LISTEN 0 100 0.0.0.0:6081 0.0.0.0:*
LISTEN 0 32 127.0.0.1:5904 0.0.0.0:*
LISTEN 0 32 127.0.0.1:5900 0.0.0.0:*
LISTEN 0 32 127.0.0.1:5902 0.0.0.0:*
LISTEN 0 5 0.0.0.0:2375 0.0.0.0:*
6.12.94+
This guest has tcp_fastopen=1 (client enabled).
Trap
Enabling server TFO without measuring. Some middleboxes blackhole TFO (tcp_fastopen_blackhole_timeout_sec).
Boring rule
Keep client TFO on if the distro default says so. Turn on server TFO only behind metrics and with app support.
Try this
- Compare app docs for
TCP_FASTOPEN. - Watch TCPFastOpen counters under load.
- Read RFC 7413.
Sources
- RFC 7413
tcp(7)