The TCP Three-Way Handshake: How the SYN, SYN-ACK, and ACK Sequence Establishes Reliable Network Connections
Before any data is transferred across the internet, devices exchange three synchronized messages to establish a reliable connection. This foundational mechanism, defined by the IETF, ensures packet order and prevents data loss.
By Hui Lin
- Network Operations
- Focuses on the handshake as a mechanism for reliability and diagnostic troubleshooting.
- Cybersecurity
- Views the handshake's stateful nature as a structural vulnerability that requires active mitigation.
- Standards Engineering
- Prioritizes strict adherence to the protocol state machine to ensure global interoperability.
Perspectives this story doesn't cover
- Application Developers
- End Users
Key terms
- TCP (Transmission Control Protocol)
- A foundational internet protocol that ensures data is delivered reliably, accurately, and in the correct order between devices.
- SYN (Synchronize)
- A control flag in a TCP packet used to initiate a connection and establish the starting sequence number for data transfer.
- ACK (Acknowledgment)
- A control flag used to confirm that a specific packet or sequence of data has been successfully received.
- Sequence Number
- A randomly generated 32-bit number used by TCP to track the order of packets and reassemble them correctly at their destination.
- FIN (Finish)
- A control flag used to gracefully terminate a TCP connection when neither side has any more data to transmit.
Key points
- The TCP three-way handshake establishes a reliable connection before any application data is transferred.
- The sequence consists of a SYN packet from the client, a SYN-ACK from the server, and a final ACK from the client.
- Both devices exchange randomly generated 32-bit sequence numbers to track data order and prevent packet confusion.
- The handshake process is strictly defined by the Internet Engineering Task Force in RFC 9293.
- Malicious actors exploit the handshake mechanism to launch SYN flood denial-of-service attacks by leaving connections incomplete.
Every time a web browser loads a single webpage, the underlying computers exchange exactly three invisible messages—a sequence of just a few dozen bytes—before a single pixel of content is ever sent. This mechanism, known as the TCP three-way handshake, is the foundational agreement that makes the modern internet reliable.[4]
For network engineers and system administrators, mastering this sequence is the first step in diagnosing network failures. When a server goes offline or a firewall blocks traffic, packet capture tools will show exactly where the handshake failed. If the three steps do not complete, no data transfer can occur.[2][3]
The process begins when a client device attempts to communicate with a server. The client sends a single packet with the Synchronize (SYN) control flag set to 1. This initial message acts as a formal request, informing the server that the client wishes to open a communication channel.[2][4]
Crucially, this SYN packet contains a randomly generated 32-bit sequence number. Because a 32-bit field can hold over 4.2 billion unique values, starting with a random number prevents older, delayed packets from previous network sessions from being mistakenly accepted as current data.[1]
Upon receiving the SYN packet, the server must acknowledge the request. It replies with a packet that has two flags set: SYN and ACK (Acknowledgment). This SYN-ACK packet serves a dual purpose: it confirms receipt of the client's sequence number and provides the server's own randomly generated sequence number.[2][4]
The acknowledgment number sent by the server is not arbitrary. It is exactly the client's initial sequence number plus 1. This mathematical increment is how the Transmission Control Protocol (TCP) tracks data and guarantees that no packets are lost in transit.[2]
The acknowledgment number sent by the server is not arbitrary.
Finally, the client receives the SYN-ACK packet and must confirm it. The client sends a third packet back to the server, this time with only the ACK flag set to 1. The acknowledgment number in this final packet is the server's sequence number plus 1.[2][4]
Once the client sends that final ACK, the connection is fully established. The operating systems on both ends transition the socket state to an established mode, and bidirectional data transfer can begin immediately. The entire exchange typically takes just a few milliseconds, depending on the physical distance between the client and the server.[1]
The rules governing this exchange are strictly defined by the Internet Engineering Task Force (IETF). While the original specification was published in 1981 as RFC 793, the standard was comprehensively updated in 2022 with the publication of RFC 9293, which consolidated decades of errata and improvements into a single document.[1]
Because the handshake requires the server to allocate memory for the pending connection after sending the SYN-ACK, it introduces a structural vulnerability. "SYN flood attacks work by exploiting the handshake process of a TCP connection," explains Cloudflare's technical documentation on denial-of-service vulnerabilities. "Under normal conditions, TCP connection exhibits three distinct processes in order to make a connection." Malicious actors send thousands of SYN packets per second from spoofed IP addresses, deliberately ignoring the server's replies.[3][5]
The server leaves the ports open, waiting for the final ACK packets that never arrive. Eventually, the server's backlog fills up, and it drops legitimate traffic. Modern mitigation strategies involve handling the handshake in a distributed cloud network, absorbing the resource cost of bogus SYN packets before they reach the targeted origin server.[5]
Just as a connection requires three steps to open, it requires a formal process to close. The standard graceful termination uses a four-step exchange involving the FIN (Finish) flag. The client sends a FIN, the server sends an ACK, the server sends its own FIN, and the client sends a final ACK.[1]
Network monitoring tools routinely track these handshake metrics to identify malicious behavior. For example, connections that terminate within the first 10 ingress packets are often classified as anomalous, using incomplete handshakes to detect port scanning or connection tampering.[3]
The three-way handshake remains the invisible scaffolding of digital communication. Whether streaming a 4K video or sending a plain text email, the reliability of the exchange depends entirely on those first three synchronized messages successfully crossing the network.[6]
Frequently asked
What happens if the final ACK packet is lost?
If the server does not receive the final ACK packet, it assumes its SYN-ACK packet was lost in transit. The server will retransmit the SYN-ACK packet after a predetermined timeout period until it receives the acknowledgment or hits a retry limit.
Why does TCP use a three-way handshake instead of two?
A two-way handshake would only allow one side to acknowledge the other's initial sequence number. Because TCP is a bidirectional protocol, both the client and the server must synchronize and acknowledge each other's sequence numbers, which requires three distinct messages.
How much data is sent during the handshake?
No application data is sent during the standard three-way handshake. The exchange consists entirely of TCP headers, which are typically 20 to 60 bytes per packet, meaning the entire handshake uses less than 200 bytes of bandwidth.
What is a SYN flood attack?
A SYN flood is a denial-of-service attack where an attacker sends thousands of SYN requests to a server but intentionally fails to send the final ACK. This forces the server to keep connections open, eventually exhausting its memory and blocking legitimate traffic.
Sources
[1]IETF DatatrackerStandards EngineeringRFC 9293 - Transmission Control Protocol (TCP)
Read on IETF Datatracker →
[2]Microsoft LearnNetwork OperationsThree-way handshake via TCP/IP
Read on Microsoft Learn →
[3]Akamai BlogCybersecurityTCP Three-Way Handshake
Read on Akamai Blog →
[4]CourseraNetwork OperationsWhat Is a Three-Way Handshake?
Read on Coursera →
[5]CloudflareCybersecurityWhat is a SYN flood attack?
Read on Cloudflare →
[6]Factlen Editorial TeamStandards EngineeringSynthesis by Factlen editorial team
Read on Factlen Editorial Team →
Comments
More in Guides
See all →Building Science
The R=1/U Formula: How Thermal Resistance and Transmittance Dictate Building Envelope Energy Loss
7 sources
Cryptography
The Two Primes and the Totient Function: How RSA Encryption Generates Public and Private Keys
5 sources
Thermodynamics
The Eutectic Point and the Phase Diagram: How a Mixture's Melting Point Can Be Lower Than Its Components
5 sources
Cybersecurity Frameworks
NIST CSF 2.0 vs. EU DORA and NIS2: A Guide to the Global Divide Between Voluntary Frameworks and Mandatory Directives
4 sources
Every angle. Every day.
Get Guides stories with full source coverage and perspective breakdowns delivered to your inbox.




