Week 8 · Lesson 4

TCP Connection Establishment (3-Way Handshake)

TCP opens every connection with a three-message ritual: SYN, SYN+ACK, ACK. This lesson fixes the canonical flags, the exact sequence and acknowledgment arithmetic, why three steps (and not two), and attacks that abuse the ritual on web servers.

CCNA 200-301 Domain 1.0 Network Fundamentals Verified 2026-10-11
Part 1

The control bits that matter

The TCP header’s flag byte holds six control bits. For connection management you need four of them now (the other two — PSH for push and URG for urgent — are data-related and rarely tested for establishment):

FlagFull nameMeaning
SYNSynchronise“Here is my initial sequence number; synchronise with me.” Starts a connection.
ACKAcknowledge“The acknowledgement field is valid.” Confirms receipt.
FINFinish“No more data from my side.” Starts a graceful close (Lesson 5).
RSTResetAbort the connection immediately; also a “no such connection” reply.
Note TCP flags are independent bits and combine freely. “SYN+ACK” is one segment with both bits set — it synchronises the server’s side and acknowledges the client’s SYN at the same time. “FIN+ACK” works the same way during the close.
Flag byte · click the bits to set them
Byte 13 — the control bits (order from left)

SYN

Part 2

The three-way handshake, precisely

Before any application data flows, the client and server exchange exactly three segments. Learn the canonical version (RFC 793) with symbols:

Step 1   Client  -->  Server     SYN
                              Flags:  SYN = 1, ACK = 0     (no ACK yet)
                              SEQ = X   (X = client's ISN, the byte number the
                                         client's first data byte will carry)
                              ACK field: not meaningful

Step 2   Server  -->  Client     SYN + ACK
                              Flags:  SYN = 1, ACK = 1
                              SEQ = Y   (Y = server's OWN ISN)
                              ACK = X + 1   (acknowledges step 1; confirms the
                                             client's SYN occupies one SYN byte)

Step 3   Client  -->  Server     ACK
                              Flags:  SYN = 0, ACK = 1
                              SEQ = X + 1   (client's next byte)
                              ACK = Y + 1   (acknowledges step 2; confirms the
                                             server's SYN byte)

The arithmetic is the whole exam point, so do it slowly with real numbers. Let X = 2000 (client’s ISN) and Y = 7121 (server’s ISN):

Check the two rules you already learned in Lesson 3: (a) each SYN consumes one byte of sequence space, so the ACK that answers a SYN is always ISN + 1; (b) an ACK number names the next expected byte. The client’s first real data byte is 2001, hence step 3’s SEQ is 2001; the server’s first real data byte is 7122, hence step 3’s ACK is 7122. If asked “after the handshake, what is the client’s next sequence number?” the answer is X+1 — the SYN byte was already numbered X but carries no application data.

Exam tip — the only arithmetic the exam uses SYN → ACK ISN+1. SYN+ACK → ACK ISN+1. The two ACK values are X+1 and Y+1; never subtract. A common trap is writing the client’s final SEQ as X+1 but the server’s ACK for it as X+1 too — check which stack you are in: the client’s SEQ mirrors X+1; the server’s ACK field is X+1.
Handshake calculator · type your ISNs

      

Part 3

Why three steps and not two

A classic exam question: why can’t the client-to-server reachability be proved in two messages? Think about what each party knows after each step:

Why three Three messages are the minimum for both endpoints to confirm bidirectional reachability, synchronised sequence numbers, and agreed parameters. Two messages could only ever let one side be sure.
What does each side know? · step through

Part 4

ISN randomisation and parameter exchange

The ISN is not zero and not predictable. A fixed, guessable starting sequence would let an attacker hijack a connection by injecting segments whose sequence numbers it can predict (the old sequence-number-guessing attack). Modern stacks pick an initial sequence number that is hard to predict (RFC 6528 / RFC 1948: derived from a hash of the connection and a secret key). The ISN still counts bytes like any other sequence number — randomisation only changes where counting starts, never how it works. (UDP has no sequence numbers at all, which is one reason it is not connection-oriented.)

SYNs also carry the options both sides must agree on before data flows:

Because both SYNs carry options, steps 2 and 3 do double duty: they synchronise numbers and settle the connection’s parameters before a single data byte moves.

Part 5

The timing diagram

  CLIENT                                    SERVER
    |                                          |
    |  1. SYN                     SYN=1,ACK=0  |
    |----> SEQ=2000  ------------------------->|        client ISN X  = 2000
    |                                          | server transitions:
    |                                          |   LISTEN --> SYN-RECEIVED
    |  2. SYN+ACK                 SYN=1,ACK=1  |
    |<--- SEQ=7121, ACK=2001  -----------------|        server ISN Y = 7121
    |                                          |
    |  3. ACK                      SYN=0,ACK=1 |
    |----> SEQ=2001, ACK=7122  -------------->|        client is now ESTABLISHED
    |                                          | server: SYN-RECEIVED --> ESTABLISHED
    |=====================================================================>
    |            Both directions verified;        |
    |            data may now flow (full duplex)  |
Exam tip — matching the diagram Read a handshake capture like a script. The middle segment is the only one with both SYN and ACK set. The first and last segments share seq=X…X+1 and ack=…Y+1 on the server’s side — if a filter question shows you these two values, you should name the phase instantly.
Part 6

The SYN flood attack on web servers

Here is the security tie-in (a future week deepens it): the handshake is expensive for the server. An attacker sends thousands of step-1 SYNs using spoofed source IP addresses that will never reply. The server dutifully answers each with SYN+ACK and allocates a half-open connection (the SYN-RECEIVED state) in its connection backlog, then waits for the ACK that never comes, holding the entry until a timeout cleans it up.

Exam link A web server receiving a torrent of SYNs from random source addresses and then failing to serve legitimate clients is a SYN flood. You will revisit it in the network-security part of the course (Denial of Service and network protection), where SYN cookies and ingress filtering re-appear as the countermeasures.
SYN flood simulator · how many spoofed SYNs?
Mitigations in place · click to toggle

Part 7 · Your turn

Review

Check what you have learned with these review questions.

Review · 6 questions

Sources

Sources & references

  1. Postel, J. RFC 793: Transmission Control Protocol (1981), Section 3.4 (establishing a connection), the state diagram (LISTEN, SYN-RECEIVED, ESTABLISHED). rfc-editor.org/rfc/rfc793.
  2. Bellovin, S. RFC 1948: Defending Against Sequence Number Attacks (1996); RFC 6528 updates the ISN generation guidance. rfc-editor.org/rfc/rfc1948.
  3. Bernstein, D. J. SYN cookies (technical note on the defence). cr.yp.to/syncookies.html.
  4. IANA. Service Name and Transport Protocol Port Number Registry (the ports the web server listens on). iana.org.
  5. Cisco. CCNA (200-301) Exam Topics, Network Fundamentals. cisco.com.

Target exams: CCNA 200-301 v1.1 · CyberOps Associate 200-201. Last content verification: 2026-10-11.