TCP 3-way handshake (SYN, SYN-ACK,ACK)

What is TCP Three-Way HandShake

TCP 3-way handshake is a process which is used in a TCP/IP network to make a connection between the client and server. It is a three-step process that requires both the client and server to exchange synchronization and acknowledgment packets before the real data communication process starts.

TCP message types

  • Syn - initiate and establish a connection. It helps synchronize sequence numbers between devices
  • ACK - help confirm to the other side that it has received the SYN
  • SYN-ACK - SYN message from local device and ACK of the earlier packet
  • FIN - terminate a connection

TCP 3-Way handshake process

TCP traffic begins with a 3-way handshake. In this handshake process, a client needs to initiate the conversation by requesting a communication session with the Server:

tcp-handshake

  1. Client establishes a connection with a server. It sends a segment with SYN and informs the server about the client should start communication, and with what should be its sequence number.
  2. Server responds to the client request with SYN-ACK signal set. ACK helps to signify the response of segment that is received and SYN signifies what sequence number it should able to start with the segments.
  3. Client acknowledges the response of the Server, and they both create a stable connection will begin the actual data transfer process.

Let’s delve into to see how it works:

tcp-handshake-1

  1. SYN - 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
  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
  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