Transport, chapter 21 of 36
TCP: The Connection
No byte of the page can move until the server answers and the laptop confirms.
The browser knows that www.example.net is 192.0.2.80, and it asks the laptop's kernel for a connection to port 443. The kernel answers with 74 bytes: a 32-bit starting number, a receive window of 64,240 octets, and four options, three of them offers that the server may accept or ignore.
- 0x8a3f6c21
- the laptop's initial sequence number, a keyed hash plus a clock
- 60 s
- TIME-WAIT in Linux, where the standard asks for four minutes
Three segments before the first byte
The handshake of our connection with the sequence numbers from the book's dumps. Step through it and watch which number each side learns.
Why did it take 41 years to replace RFC 793?
RFC 793 appeared in September 1981 with Jon Postel as editor. Then came four decades of patches: RFC 1122 corrected it, RFC 1323, RFC 2018, and RFC 3168 added options and flags, and RFC 5961, RFC 6528, and RFC 6093 changed resets, initial sequence numbers, and the urgent pointer.
RFC 9293 (August 2022) gathers the normative content into one Internet Standard, STD 7, and gives every requirement keyword a label, MUST-1 to MUST-69 among them (RFC 9293, Section 2.1). It left the rationale behind, so the design voice of 1981 lives on in the old text.
Why does opening a connection take three segments?
Two addresses and two ports name a connection, and the same four values get used again, so a delayed segment from an earlier incarnation can be taken for new data. Each incarnation therefore starts at a sequence number that old segments cannot match, and each side confirms the other's starting point before anything is delivered.
The reason was written down in 1974 in RFC 675, Section 4.3.1, and RFC 9293, Section 3.4.1 keeps it almost word for word: sequence numbers are not tied to a global clock in the network.
How does the laptop choose 0x8a3f6c21?
RFC 793 tied the number to a clock whose low bit ticks roughly every 4 microseconds. A clock is predictable: in 1985 R. T. Morris described how to guess the next number and complete a handshake from a forged address (RFC 6528, Appendix A).
The fix adds a keyed pseudorandom function of the addresses and ports to the clock. A purely random number would also stop the attack, but it would break the BSD heuristic that accepts a new SYN for a connection still in TIME-WAIT when its number lies above the old incarnation's sequence numbers (RFC 6528, Section 2). Linux computes the function with SipHash [Linux2026].
What makes a reset believable?
Under RFC 793, any RST inside the receive window was valid. In 2004 Watson showed what that gives an attacker who knows the four values that name the connection: 65,536 tries on average for a 32,768-byte window (RFC 5961, Section 1.3).
RFC 5961 says a TCP should accept a RST only if its sequence number is exactly RCV.NXT (RFC 5961, Section 3.2). A RST elsewhere in the window draws a challenge ACK, which a genuine peer that lost its state answers with an exact RST and a blind attacker never sees.
Why does a 16-bit window need a scale factor?
Sixteen bits stop at 64 KiB. On our path, with a round trip of about 12 ms, one 65535-octet window per round trip caps a connection at about 43.7 Mbit/s. The window scale option carries a shift count and takes effect only if both SYNs carry it (RFC 7323, Section 2.2). Both sides announced 7, so each can express windows up to 8,388,480 octets.
What happens when a million SYNs arrive?
Each SYN to a listening port creates state, and a SYN from a forged address never completes. Dan Bernstein's SYN cookies keep no state at all: the server encodes it into its own initial sequence number and recovers it from the acknowledgment number of the third segment (RFC 4987, Section 3.6).
In the scheme of RFC 4987, Appendix A, options that need state are lost, window scaling among them. Linux recovers some: if the SYN carried timestamps, the window scale, SACK, and ECN flags ride in the low 6 bits of the SYN-ACK's TSval, which the client echoes back [Linux2026].
Why did TCP Fast Open stall?
A SYN may carry data, but the receiver must hold it until the handshake completes (RFC 9293, Section 3.5). Skipping that wait would save a round trip, 12 ms on our path. RFC 7413 adds a server cookie that the client obtains on a first connection and presents with data in later SYNs.
Studies cited in RFC 7413, Section 7.1 found that 6 percent of probed paths drop SYNs that carry data or unknown options, and the client then pays a timeout for the round trip it tried to save. The effort moved up the stack, into TLS 1.3 and QUIC.
The book keeps asking
This chapter has 5,857 words and 16 questions. These 9 are answered only in the book and the audiobook.
- What exactly did the laptop send?
- What states can a connection be in?
- What does it mean to close a connection that talks both ways?
- Why does TIME-WAIT last four minutes, and why does it not?
- What do timestamps and SACK add?
- How does a receiver say "stop"?
- Why does a small write sometimes wait for an acknowledgment?
- How does an idle connection find out that the peer is gone?
- Is the urgent pointer good for anything?
Open the sources
- RFC 9293 Transmission Control Protocol (TCP)
- RFC 793 Transmission Control Protocol
- RFC 7323 TCP Extensions for High Performance
- RFC 2018 TCP Selective Acknowledgment Options
- RFC 5961 Improving TCP's Robustness to Blind In-Window Attacks
- RFC 4987 TCP SYN Flooding Attacks and Common Mitigations
- RFC 7413 TCP Fast Open
- [Linux2026] Linux kernel source tree, v7.4-rc1 (commit 6628e7d4c6b2, 1 November 2026)
All 42 documents this chapter cites, each with a link to its publisher and a copy kept here.
