TCP Three Way Handshake

The TCP Three Way Handshake, also known as the TCP 3 way handshake, is a fundamental process in TCP/IP networks used to establish a connection between a server and a client. It consists of three essential steps that involve the exchange of synchronization and acknowledgment packets before actual data transmission can occur.


This handshake process is meticulously designed to allow both ends to initialize, negotiate, and establish TCP socket connections simultaneously, facilitating bidirectional data transfer.


TCP Message Types:


→ SYN: This message initiates and establishes a connection. It also synchronizes sequence numbers between devices.


→ ACK: Used to confirm receipt of the SYN message to the other side.


→ SYN ACK: Represents the SYN message from the local device and acknowledges the earlier packet.


→ FIN: Indicates the intent to terminate a connection.


TCP Three Way Handshake Process:


The TCP communication begins with a three→way handshake, initiated by the client's request to establish a communication session with the server:


Step 1: The client commences the process by sending a segment with the SYN flag set, informing the server that it wishes to initiate communication and specifying its sequence number.


Step 2: The server responds by sending a SYN ACK signal. This signifies both acknowledgment of the received segment and the sequence number from which it will begin sending data.


Step 3: In the final step, the client acknowledges the server's response. At this point, a stable connection is established, and the actual data transfer commences.

Real World Example:

Consider a simplified real world scenario:


1. Host X initiates the connection by sending a TCP SYN packet to its destination host. This packet includes a random sequence number, such as 6594, indicating the starting point for data transmission.


2. The server receives the packet and responds with its sequence number. The response includes an acknowledgment number, which is Host X's sequence number incremented by 1 (e.g., 6595).


3. Host X acknowledges the server's response by sending the acknowledgment number, typically the server's sequence number incremented by 1.


After the data transmission is complete, TCP automatically terminates the connection between the two endpoints.


In Summary:


The TCP Three Way Handshake is a crucial process in TCP/IP Networks for establishing connections between servers and clients.


→ SYN is used to initiate and establish connections.

→ ACK confirms the receipt of SYN.

→ SYN ACK comprises a SYN message from the local device and an acknowledgment of the earlier packet.

→ FIN indicates the intent to terminate a connection (Finish) .


The handshake process begins with the client requesting a communication session with the server, leading to a stable connection and subsequent data transfer. Eventually, TCP autonomously terminates the connection between the endpoints.