How the Internet works

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.

41 years
between RFC 793 and RFC 9293, the text that replaced it in 2022
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.

A (closes first)B (closes second) FIN (A: FIN-WAIT-1, B: CLOSE-WAIT)ACK (A: FIN-WAIT-2)FIN (B: LAST-ACK, A: TIME-WAIT)ACK (B: CLOSED, A: CLOSED after 2 MSL)
From the book: A normal close and the states on each side, after RFC 9293, Figure 12

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) 2022, Internet Standard, STD 7
  • RFC 793 Transmission Control Protocol 1981, Internet Standard; obsoleted by RFC 9293
  • RFC 7323 TCP Extensions for High Performance 2014, Proposed Standard
  • RFC 2018 TCP Selective Acknowledgment Options 1996, Proposed Standard
  • RFC 5961 Improving TCP's Robustness to Blind In-Window Attacks 2010, Proposed Standard
  • RFC 4987 TCP SYN Flooding Attacks and Common Mitigations 2007, Informational
  • RFC 7413 TCP Fast Open 2014, Experimental
  • [Linux2026] Linux kernel source tree, v7.4-rc1 (commit 6628e7d4c6b2, 1 November 2026) 2026, free

All 42 documents this chapter cites, each with a link to its publisher and a copy kept here.

Transport, chapter 22 of 36

Congestion Control: From Collapse to BBR

Transport, chapter 23 of 36

Beyond TCP: SCTP, DCCP, and Multipath

Names and Trust, chapter 24 of 36

DNS: The Namespace and the Wire Format

Names and Trust, chapter 25 of 36

Resolvers, DNSSEC, and Encrypted DNS

Names and Trust, chapter 26 of 36

TLS 1.3: The Handshake

Names and Trust, chapter 27 of 36

Certificates and the Web PKI

Applications, chapter 28 of 36

HTTP: Semantics and HTTP/1.1

Applications, chapter 29 of 36

HTTP/2: Multiplexing over One Connection

Applications, chapter 30 of 36

QUIC: A Transport in Userspace

Applications, chapter 31 of 36

HTTP/3: The Web on QUIC

Applications, chapter 32 of 36

Mail: SMTP and Forty Years of Patches

Applications, chapter 33 of 36

Time, Shells, and Files: NTP, SSH, Telnet, and FTP

The Whole Path, chapter 34 of 36

Measuring and Debugging the Path

The Whole Path, chapter 35 of 36

The Whole Journey, Byte by Byte

The Whole Path, chapter 36 of 36

Ossification and What Comes Next

You have reached the server. The book goes further.

Everything on this site is a short version. Follow the Packet is the long one: 36 chapters and about 280,000 words, with every protocol fact traced to the section of the standard that defines it, every byte dump built by a script you can run, and a directory of more than a thousand cited documents. It comes as a printable book and as an audiobook.

Hear how chapter 1 opens. 70 seconds, narrated by a synthetic voice.

Get the book or the audiobook Read the start of chapter 1 Browse every source

Cover of Follow the Packet: How the Internet Works, Layer by Layer, from ARPANET to QUIC, by Wolfgang Kerschbaumer

The signup uses double opt-in. Every message includes an unsubscribe link.

Published by Sysinit Press. The public addresses, AS numbers and names of the scenario come from ranges reserved for documentation, and the home network uses private addresses, so the site describes no real network. RFC texts are copied unchanged from the RFC Editor.