The TCP 3-Way Handshake is the process used by the Transmission Control Protocol (TCP) to establish a reliable connection between a client and a server before data transmission begins. It synchronises sequence numbers and ensures that both the client and server are ready to exchange data reliably.

TCP Flags Used in Handshake
| Flag | Purpose |
|---|---|
| SYN (Synchronize) | Initiates a TCP connection by sending the client's Initial Sequence Number (ISN). |
| ACK (Acknowledgment) | Acknowledges the received sequence number and confirms successful receipt of the segment. |
| SYN + ACK (Combination of SYN and ACK Flags) | Acknowledges the client's ISN while sending the server's own Initial Sequence Number (ISN). |
TCP 3-way Handshake Process
- Step 1 (SYN): In the first step, the client wants to establish a connection with a server, so it sends a segment with SYN(Synchronize Sequence Number) which informs the server that the client is likely to start communication and with what sequence number it starts segments with
- Step 2 (SYN + ACK): Server responds to the client request with SYN-ACK signal bits set. Acknowledgement(ACK) signifies the response of the segment it received and SYN signifies with what sequence number it is likely to start the segments with
- Step 3 (ACK): In the final part client acknowledges the response of the server and they both establish a reliable connection with which they will start the actual data transfer.
Numerical Example of Sequence and Acknowledgment Numbers

Assume:
- Client Initial Sequence Number (ISN) = 1000
- Server Initial Sequence Number (ISN) = 5000
Step 1: Client -> Server (SYN)
- Sequence Number = 1000
- SYN flag = 1
- No acknowledgment number (since this is the first segment)
The client proposes its starting sequence value.
Step 2: Server -> Client (SYN-ACK)
- Sequence Number = 5000
- Acknowledgment Number = 1001
- (1000 + 1)
The server acknowledges the client’s SYN by adding 1 to the client’s sequence number.
The value increases by 1 because the SYN consumes one sequence number.
Step 3: Client -> Server (ACK)
- Sequence Number = 1001
- Acknowledgment Number = 5001
- (5000 + 1)
The client acknowledges the server’s SYN by adding 1 to the server’s sequence number.
How Synchronization Happens
- Each side shares its Initial Sequence Number.
- Each side confirms the other’s sequence number using acknowledgment.
- After both acknowledgments are verified, the connection enters the ESTABLISHED state.
This ensures both endpoints agree on starting sequence values before actual data transmission begins.