CSNetworkingDiagramBeginner
3-Way Handshake
KO: 3-Way 핸드셰이크·EN: 3-Way Handshake·JA: 3ウェイハンドシェイク
The three-step SYN, SYN-ACK, ACK exchange establishing a reliable TCP connection by synchronizing initial sequence numbers in both directions
Table of Contents
Structure Diagram
TCP 3-Way Handshake Connection Establishment (1 RTT)
Client State3 steps
Server State3 steps
STEP 11. Send SYN(25ms)
Quick Answer
What is 3-Way Handshake?
The three-step SYN, SYN-ACK, ACK exchange establishing a reliable TCP connection by synchronizing initial sequence numbers in both directions. It is a core concept in Networking within CS.
Core Principles
The TCP 3-Way Handshake verifies bidirectional reachability and synchronizes Initial Sequence Numbers (ISN) before payload transfer begins.
- SYN: Client sends random
seq = x(SYN_SENT). - SYN-ACK: Server replies with
ack = x + 1and its ownseq = y(SYN_RCVD). - ACK: Client acknowledges
y + 1, enteringESTABLISHED.
Three messages are required so both sides confirm the other can both send and receive.
Practical Takeaways
- Eliminate repeated 1-RTT overhead: Use HTTP Keep-Alive and DB connection pooling to amortize handshake latency over many requests.
- Defend against SYN Floods: Attackers exhaust the server's half-open
SYN backlogby withholding final ACKs; enable kernel SYN Cookies to stay stateless under attack. - Mind
TIME_WAITon teardown: Graceful closes use a 4-wayFIN/ACKhandshake leaving the active closer inTIME_WAITto drain delayed packets.
Notable Examples
- HTTP/1.1, HTTP/2, SSH, PostgreSQL: Every TCP session opens with a 3-way handshake.
- TCP Fast Open & QUIC: Modern optimizations eliminating separate handshake round trips.