3-way handshaking

A three-way handshake is a 3 step process that TCP/IP networks use to establish a secure and reliable connection between sender(client) and receiver(server).

A three-way handshake includes the following steps:

  1. Step 1(SYN):
  •   To establish a connection, the client sends an SYN (Synchronize Sequence Number) request to the server.
  •  The request message contains information like the initial sequence number, maximum segment size,  window size, SYN bit set to 1, and ACK bit set to 0. 
  • The client then awaits a response from the server.
  1. Step 2(SYN+ACK):
  •   The server answers with an SYN-ACK message after receiving the client’s request.
  • In the response, both ACK and SYN  bits are set to 1 indicating the server has acknowledged the request and wishes to establish a connection with the client.
  • The server also sends a random sequence number, window size, maximum segment size, and ACK’s acknowledgment number(which is the client’s received sequence number+1).
  1. Step 3(ACK):  
  • The client sends an acknowledgment(ACK) to the server after receiving SYN-ACK from the server.
  •  The client sets the ACK bit to 1 and sends it to the server along with an acknowledgment number (which is the server’s SYN sequence number +1) and also sets the SYN bit to 0.
  • After this procedure is completed, the client and server establish a connection through which they will begin the data transfer.