NETWORKING / A CONCEPT NOTE

TCP Handshake

how two machines agree to talk

~60 sec read

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

  1. Client

    sends a SYN packet with a random sequence number to initiate connection.

  2. Server

    responds with SYN-ACK, acknowledging the client's SYN and sending its own sequence number.

  3. 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.

EXAMPLE 01 · REFERENCE

check for half-open connections (potential SYN flood)

netstat -anp | grep SYN_RECV

EXAMPLE 02 · REFERENCE

capture raw SYN packets on the wire

tcpdump -i any tcp[tcpflags] & tcp-syn != 0

Explore command anatomy in the CLI lab