NETWORKING / A CONCEPT NOTE
TCP Handshake
how two machines agree to talk
Overview · mechanism
pitfall · examples
01 / THE SHORT VERSION
The idea in a few sentences.
Before sending any data, the client and server exchange three packets (SYN, SYN-ACK, ACK) to synchronize sequence numbers and establish a reliable session.
02 / FOLLOW THE MECHANISM
How a handshake flows
Client
sends a SYN packet with a random sequence number to initiate connection.
Server
responds with SYN-ACK, acknowledging the client's SYN and sending its own sequence number.
Client
sends an ACK packet back. The connection is now established.
04 / COMMAND NOTES
Read the command, then the result.
Inspect the flags and arguments before trying an example. Snippets can need local setup, replacement values, or resources in your own environment.
check for half-open connections (potential SYN flood)
netstat -anp | grep SYN_RECVcapture raw SYN packets on the wire
tcpdump -i any tcp[tcpflags] & tcp-syn != 005 / CHECK YOURSELF
Could you explain TCP Handshake to a teammate?
Try it out loud in two sentences: what it is, and the one detail that changes the picture. If you stall, the gap is the part to reread.
Up next in NetworkingHTTP Request Lifecyclewhat happens when you hit Enter