• Terms of Service

Learn Internet Grow

Tech Skills

  • Learn
  • Books
  • Search
  • Create
  • Measure
  • Secure
  • Share
  • Terms of Service

The TCP Three-Way Handshake Does Not Solve the Two Generals Problem

Filed Under: Create

Look up the TCP three-way handshake and you will meet the same sentence everywhere: it solves the Two Generals Problem. It does not. Nothing does. The Two Generals Problem is a proof of impossibility — two parties cannot reach guaranteed common knowledge of an agreement over a channel that can lose messages, no matter how many messages they send.

The claim survives because it has the right texture: three messages, two parties, mutual agreement. But it inverts the problem, and buries the smaller, stranger, entirely real one the handshake was built for — stated plainly in the spec, and nothing to do with generals.

TCP three-way handshake — three signals crossing a dark gap, each one carrying back evidence that the last was received

A note on citations. RFC 793 (September 1981) designed this thing and is where the reasoning lives. It is also obsolete: the RFC Editor’s info page records it as obsoleted by RFC 9293, W. Eddy, Ed., August 2022, published as STD 7. Below, 793 is quoted for the 1981 argument and 9293 for what a conformant TCP must do today.

The Sentence Every Explanation Repeats

Two allied commanders must attack at the same time. Their only channel runs through hostile territory, so any message can be lost. A messenger arrives; the receiver now knows the plan, but the sender does not know the messenger arrived. Send a confirmation, and the confirmer does not know that arrived. No message count closes the gap, because whoever transmits last never learns whether their transmission landed. That is the entire result — a boundary, not a puzzle waiting for a better protocol.

So “three messages solve it” is not slightly imprecise, it is a category error. TCP stops at three not because three is enough for agreement, but because three is enough for something else.

Whoever sends the last message over a lossy channel never learns whether it arrived

One checkable fact ought to make anyone repeating the myth pause: the word “generals” appears in neither RFC 793 nor RFC 9293. Neither does “common knowledge.” Both are free plain text; the search takes ten seconds.

What RFC 793 Says the Handshake Is For

The real rationale is narrower and considerably more interesting. RFC 793, in its own words:

“A three way handshake is necessary because sequence numbers are not tied to a global clock in the network, and TCPs may have different mechanisms for picking the ISN’s. The receiver of the first SYN has no way of knowing whether the segment was an old delayed one or not, unless it remembers the last sequence number used on the connection (which is not always possible), and so it must ask the sender to verify this SYN.”

That is a statement about stale segments, not about mutual certainty. The spec then states the design principle outright:

“The principle reason for the three-way handshake is to prevent old duplicate connection initiations from causing confusion.”

RFC 9293 carries that sentence into 2022 with one edit — “principle” becomes “principal.” Forty-one years, one typo fixed, the reasoning untouched. It also names the mechanism without ceremony: “The ‘three-way handshake’ is the procedure used to establish a connection.” Not a coordination puzzle. A procedure for rejecting old messages.

The technique predates the RFC, and both documents credit the same paper: Dalal and Sunshine, “Connection Management in Transport Protocols,” Computer Networks, Vol. 2, No. 6, pp. 454–473, December 1978.

An old delayed SYN segment arriving at a listener that has no way to tell it is stale

The Stale SYN Is Not a Hypothetical

Why an old SYN is a hazard rather than a curiosity turns on one structural fact: a TCP connection has no name. Its identity is the 4-tuple of source address, source port, destination address, destination port — no connection ID, no session token, no generation counter. Reuse a socket pair, which a busy server’s ephemeral port range guarantees, and the new connection is indistinguishable on the wire from the old except by sequence number.

Now delay a SYN. A routing loop holds it; a queue drains late after a link flaps; a lower layer retransmits what it should have dropped. It arrives long after the moment it belonged to, at a listener with no shared clock and no memory of the last sequence number used on that socket pair.

RFC 793’s Figure 9 — renumbered Figure 8 in RFC 9293, same content — walks the recovery:

      TCP A                                                TCP B   1.  CLOSED                                               LISTEN   2.  SYN-SENT    --> <SEQ=100><CTL=SYN>               ...   3.  (duplicate) ... <SEQ=90><CTL=SYN>                --> SYN-RECEIVED   4.  SYN-SENT    <-- <SEQ=300><ACK=91><CTL=SYN,ACK>   <-- SYN-RECEIVED   5.  SYN-SENT    --> <SEQ=91><CTL=RST>                --> LISTEN   6.              ... <SEQ=100><CTL=SYN>               --> SYN-RECEIVED   7.  SYN-SENT    <-- <SEQ=400><ACK=101><CTL=SYN,ACK>  <-- SYN-RECEIVED   8.  ESTABLISHED --> <SEQ=101><ACK=401><CTL=ACK>      --> ESTABLISHED

(RFC 793, “Recovery from Old Duplicate SYN,” Figure 9.)

At line 3 the ancient duplicate arrives carrying sequence number 90. B cannot tell it is stale, so it does the only correct thing available: it answers and waits. At line 4 that answer reaches A, which is being asked to acknowledge a number it never sent. A resets, B returns to LISTEN having committed nothing, and the real SYN completes.

The third message is the initiator’s opportunity to say “that was not me.” Remove it and B never finds out — B is the party that committed, and A is the only one who can tell it is wrong.

Four Facts, Three Segments

The arithmetic gets easier once you stop counting messages and start counting facts. A TCP connection is two independent byte streams, and each direction numbers its bytes from its own Initial Sequence Number (ISN). RFC 9293: “For a connection to be established or initialized, the two TCP peers must synchronize on each other’s initial sequence numbers.” Each ISN must be announced and each announcement acknowledged — four events, of which the middle two ride in one segment, because a SYN carrying the ACK bit does both jobs at once.

SegmentWhat its sender assertsWhat its receiver can conclude
1. SYN (A → B)“My byte stream starts at X.”An ISN for the A→B direction — and no idea how old the claim is.
2. SYN + ACK (B → A)“I saw X. Mine starts at Y.”An ISN for the B→A direction, and evidence B received a SYN — not yet that it was A’s.
3. ACK (A → B)“I saw Y, and X really was mine.”That a live peer at this 4-tuple issued X. A stale duplicate produces a reset here instead.
Four pieces of information established by three TCP segments, with two folded into the single SYN-ACK

Read the third row carefully, because it is where the myth dies. The final ACK creates no shared belief: it gives B evidence A could not have manufactured from an old segment, since the ACK number depends on the Y that B chose after the SYN arrived. Freshness in one direction, not symmetric agreement.

Why Two Messages Cannot Do It, and Why Four Would Not Help

A two-message handshake is not a lazy version of a three-message one; it is structurally different. Every case in the figure above becomes an established connection to a peer that never asked for one, because after the SYN-ACK nothing can contradict it.

MessagesWhat the responder knows before committingFailure mode
Two (SYN, SYN-ACK)Only that some SYN arrived, of unknown age.An old duplicate opens a connection nobody asked for, and nothing says otherwise.
Three (SYN, SYN-ACK, ACK)That the initiator acknowledged a value chosen after the SYN arrived.The final ACK can be lost — but the responder retransmits, and a stale initiator resets.
Four (an ACK of the ACK)Nothing the third message did not establish.The last sender still never learns its segment arrived. The asymmetry moves, not closes.
A two-message handshake leaves the responder committed to a connection it can never learn was stale

That third row is the honest answer to “why not four?” Three is the point at which each side has acknowledged a value the other chose after the exchange began — exactly the freshness test the spec asks for. More messages buy no certainty, only latency. And RFC 9293 is unembarrassed about the residual risk: a receiver may buffer early data until ESTABLISHED “given that the three-way handshake reduces the possibility of false connections”.

Reduces. Not eliminates. The standard declines to make the claim a thousand tutorials make on its behalf.

The case that kills the client-and-server framing

TCP has no client and no server; the socket API does. RFC 9293 requires that “A TCP implementation MUST support simultaneous open attempts (MUST-10)” — both peers send a SYN, both receive one, and both reach ESTABLISHED without either having been in LISTEN. RFC 793 diagrams it as “Simultaneous Connection Synchronization.” If you picture a client knocking on a server’s door, that case will not fit.

The Initial Sequence Number Stopped Being an Engineering Convenience

Everything above turns on the ISN being unguessable in time, and in 1981 that was the only requirement anyone had. RFC 793 specifies the generator with disarming simplicity:

“The generator is bound to a (possibly fictitious) 32 bit clock whose low order bit is incremented roughly every 4 microseconds. Thus, the ISN cycles approximately every 4.55 hours.”

A clock. For the stale-duplicate job that is adequate: a value advancing monotonically and wrapping slowly separates one incarnation of a socket pair from the last.

It is nowhere near enough to separate a legitimate peer from an attacker, because a clock is predictable by construction. RFC 9293’s glossary quietly records the change — an ISN is now “Selected in a way that is unique within a given period of time and is unpredictable to attackers.” The normative recipe is a keyed function:

“ISN = M + F(localip, localport, remoteip, remoteport, secretkey)”

with an absolute constraint: “F() MUST NOT be computable from the outside (MUST-9), or an attacker could still guess at sequence numbers from the ISN used for some other connection.” Not “hard to guess” — the ISNs a host issues on connections you can see must reveal nothing about the one it will issue on a connection you cannot.

RFC 793 (September 1981)RFC 9293 (August 2022, STD 7)
Mechanism32-bit clock, low bit incremented every ~4 µsClock plus a pseudorandom function of the 4-tuple and a local secret
Property soughtUniqueness over timeUniqueness and unpredictability to an attacker
Normative forceA described generatorMUST NOT be computable from outside (MUST-9)
Initial sequence number selection moving from an exposed clock to a clock combined with a secret keyed function

How that choice became a security requirement — the spoofing attacks, and the standards (RFC 1948, then RFC 6528) that hardened against them — has its own article in this series. The point here: the freshness test and the security property now share one mechanism, and they arrived in that order, four decades apart.

The Round Trip You Are Paying For

Three segments cost a full round trip before a byte of application data moves, and on a long path that dominates a short request. This is a latency bill, not a bandwidth one — the gap between what a bandwidth measurement reports and what a page load feels like. Doubling the capacity of the link does nothing to a handshake; only shortening the path does.

The standards track has one narrow answer: TCP Fast Open (RFC 7413), which lets a client put data in the SYN if it presents a cookie the server issued on an earlier connection. Read against the above, the design is obvious — Fast Open does not remove the freshness test, it remembers a previous one, which is why it can only help the second and later connections to a host. The more radical answer, folding the transport and cryptographic handshakes together so a connection carries data in its first flight, is what the newer UDP-based transport covered elsewhere in this series was built to do.

❓ Frequently Asked Questions

Does the TCP three-way handshake solve the Two Generals Problem? No, and nothing can. Two Generals is an impossibility result about guaranteed common knowledge over a lossy channel. The handshake solves a narrower problem, stated in RFC 793: preventing “old duplicate connection initiations from causing confusion.” The word “generals” appears in neither RFC.

Why can’t a two-way handshake work? The responder would commit to a connection based on a SYN whose age it cannot determine, and nothing afterwards could correct it. The third message is the initiator’s chance to reject a connection it never requested — in RFC 793’s recovery figure, by resetting in reply to an acknowledgement of a number it never sent.

Why not four messages, then? A fourth adds no evidence. After three segments each side has acknowledged a value the other chose after the exchange began — the freshness property the spec asks for. A fourth only relocates the unacknowledged-final-message asymmetry, and that asymmetry is the Two Generals result, so no message count removes it.

Is RFC 793 still the right citation for TCP? Only for the 1981 design narrative. It is obsoleted by RFC 9293 (August 2022), STD 7, which is the citation for what a conformant implementation must do today. The two agree on the rationale almost word for word; the most visible change is the fix from “principle” to “principal.”

Why do initial sequence numbers have to be unpredictable? They did not, originally. RFC 793 used a plain 32-bit clock incremented every 4 microseconds or so, which satisfies the stale-duplicate requirement and nothing else. Predictable ISNs turned out to enable blind spoofing, so RFC 9293 requires an ISN derived from a keyed pseudorandom function whose output “MUST NOT be computable from the outside.”

Where This Sits

The handshake is a small, precisely reasoned answer to a problem that exists only because the layer beneath delivers datagrams with no ordering, no liveness, and no shared clock. It does not achieve certainty. It achieves freshness — weaker, sufficient, and unlike certainty actually available.

Asking for the achievable thing rather than the ideal one runs through this whole series on how TCP/IP came to carry the internet: the connection state that deliberately outlives a close, the voluntary restraint that stops senders swamping a network nobody polices, the lineage that turned a 1981 clock into a keyed function. The cornerstone on how TCP/IP won the protocol wars is where those threads meet — and if you would rather read primary sources than anyone’s summary, the resources below start with the free RFCs.


📚 Recommended Resources

Disclosure: some links below are Amazon affiliate links. If you buy through them, I earn a small commission — at no extra cost to you — which helps keep this site running.

Start with the free material, and mean it. This is one of the rare subjects where the primary sources genuinely beat the books: they are free, permanent, plain text, and short enough to read in an evening. Every quotation in this article was taken from the documents below rather than from a summary of them, and you can verify each one with a browser find-in-page. Read these first; buy a book for the operational context around them, which is where paper still earns its keep.

  • RFC 9293 — “Transmission Control Protocol (TCP)” (W. Eddy, Ed., MTI Systems, August 2022, STD 7) — the current standard, and the one to cite for anything about what a conformant TCP does today. Section 3.5, “Establishing a Connection,” is the whole of this article’s subject in about six pages, including the recovery-from-old-duplicate-SYN figure and the MUST-10 simultaneous-open requirement. Start here rather than with RFC 793 unless you specifically want the history.
  • RFC 793 — “Transmission Control Protocol” (September 1981) — obsolete as a specification, indispensable as an argument. It is where the reasoning for the three-way handshake is stated most directly, and it reads like a design document rather than a compliance checklist. The RFC Editor info page records the obsoletion chain, which is worth a glance in its own right: citing 793 as current is the commonest way to signal that a networking article was written from memory.
  • RFC 6528 — “Defending against Sequence Number Attacks” (F. Gont & S. Bellovin, February 2012) and its predecessor RFC 1948 (Bellovin, May 1996) — the two documents that turned initial-sequence-number selection from an implementation detail into a normative security requirement. RFC 1948 is the more interesting read of the pair: it opens by citing a numbered CERT advisory as evidence the attack was already happening, not merely conceivable.
  • RFC 7413 — “TCP Fast Open” (Cheng, Chu, Radhakrishnan, Jain, December 2014) — read it as a commentary on the handshake rather than as an optimisation. Its security-considerations section is unusually candid about which guarantees the cookie mechanism trades away in exchange for the round trip it saves.
  • RFC 1122 — “Requirements for Internet Hosts: Communication Layers” (R. Braden, Ed., October 1989) — what implementations were actually required to do in the years between the original spec and the modern one, and a useful corrective to the assumption that an RFC describes the software you are running.
  • The IETF Datatracker entry for RFC 9293 — free, and the fastest way to see a document’s status, its obsoletion relationships, and whether anything has updated it since. Worth bookmarking as a reflex: it answers “is this still current?” in one page load, which is the question this article’s citation note exists to raise.

TCP/IP Illustrated, Volume 1: The Protocols

Kevin R. Fall and W. Richard Stevens · 2nd edition, Addison-Wesley Professional, 2011 · Hardcover, 1,056 pp

The book to own if you want the handshake as observed traffic rather than as specification prose. Its method is why it has lasted: capture a real exchange, put the bytes on the page, and explain the state transitions against them — which is exactly the gap between reading RFC 9293’s Figure 6 and recognising the same three segments in a packet capture at three in the morning. It is also good on the cases this article only gestures at, including what a reset actually does and how half-open connections are resolved. Get the second edition; the 1994 first edition predates IPv6 and most of what you will actually capture today. Read it alongside the RFC rather than instead of it: the RFC tells you what must happen, and Stevens and Fall show you what did.


Computer Networks: A Systems Approach

Larry L. Peterson and Bruce S. Davie · 6th edition, Morgan Kaufmann, 2021 · Paperback, 848 pp

The textbook that treats connection establishment as a design problem with alternatives, which is exactly the frame this article argues for. It is genuinely good on why a two-message exchange fails, on what other transport protocols chose instead, and on the trade-offs a designer is actually making when they pick one — the comparative view that makes TCP’s choice look like a decision rather than an inevitability. That framing is what generalises: the same reasoning applies the next time you are asked to design a protocol handshake of any kind. Worth knowing before you buy that the authors maintain a freely licensed online edition of this text, so you can evaluate the writing properly first.


Unix Network Programming, Volume 1: The Sockets Networking API

W. Richard Stevens, Bill Fenner and Andrew M. Rudoff · 3rd edition, Addison-Wesley Professional, 2003 · Hardcover, 1,024 pp

The bridge between the protocol and the code you actually write, and the book that explains why listen(), accept() and connect() map onto the state machine as awkwardly as they do — including the point this article makes about client and server being socket-API roles rather than protocol ones. It is the right reference for what the backlog queue really holds, what SO_REUSEADDR does and does not change, and what your program observes when a handshake fails rather than completes. It is old, and its coverage of newer APIs shows that, but the socket semantics it documents have barely moved in twenty years — which is more than can be said for most programming books of its vintage.

Newsletter

Tags

Agentic AI Agentic Development AI AI Agents AI Coding Agents Blockchain Bounded Context Browser ChatGPT Plugins Claude Code CLPR Context Engineering Cryptocurrency DePin Developer Tools Distributed Systems DLT Domain-Driven Design Google Search HBAR Hedera Home Networking Internet Internet Performance LLM Machine Learning MCP Model Context Protocol Network Architecture Network Diagnostics Network Security News NLP Postgres PostgreSQL Productivity RAG Routers Saga Pattern SEO Software Architecture software engineering Troubleshooting Twitter Web3

Recent Articles

  • AI Agent Memory: Search and RAG Limits November 6, 2026
  • Plan Locally, Execute in the Cloud: Claude Code’s Own Recommended Workflow November 6, 2026
  • The AI Evaluation Scorer That Never Read a Transcript November 6, 2026
  • What Is a Browser Engine? Blink & V8 Explained November 5, 2026
  • Why Postgres Is Winning: The $1B Acquisition Wave November 5, 2026
  • RENDER Tokenomics Explained: Burn, Mint, Repeat November 5, 2026

Copyright © 2026 · News Pro Theme On Genesis Framework · WordPress · Log in

Content on this site is produced with the assistance of Large Language Models and edited by a human. It is intended for educational purposes — facts may occasionally be incorrect. If you spot an error, please email Larionovdmitri@learninternetgrow.com.

Affiliate Disclosure: This site contains affiliate links to Amazon and other partners. If you purchase through these links, LearnInternetGrow.com may earn a commission at no additional cost to you. We only recommend products we genuinely believe in.

Privacy Policy · Terms of Service