TCP/IP 3-WAY Handshake

When we meet someone the first thing we do is a Handshake to connect with the person (which also tells how strong the bond is or if the person interested in talking). In the same way, the client and the server also need to establish a connection between them before sending/receiving data. Thus a handshake takes place called TCP/IP 3-WAY Handshake.

TCP/IP handshake is designed in such a way that it helps both the client and the server to initiate, negotiate, and confirms the transmission of packets.

It is also referred to as SYN, SYN-ACK, and ACK. As the above picture states, The client first SYNchronizes its sequence number with the server. The server then ACKnowledges the client's sequence number and SYNchronizes with its sequence number. The client then ACKnowledges the server's sequence number. Three message takes place to complete a handshake using TCP/IP protocol. Thus, TCP/IP Three-way Handshake. (After everything is done there is a FIN message to terminate the connection)

TCP Three-way Handshake Process

Step 1: The client establishes a connection with the server by sending a segment number with SYN and informs the server. Basically, the client says, "Hi, let's connect. I will number my messages starting from 420."

Step 2: The server responds to the client's request with an SYN-ACK packet. Well, it should be ACK-SYN as server ACKnowledges the number, and then SYNchronizes its number with the client. Basically, the server replies, "All right, I am ready for message 421 and I will number my messages starting from 786."

Step 3: The client ACKnowledges the response and establishes a stable connection. Basically, the client replies, "Noted, I am ready for message 787."

Why is this sequence number important?

If a message did not receive by the other end because of network traffic the packet got dropped or one message was sent multiple times this would help to rectify this mistake.
  • Detects when messages are duplicated. (Hey, I got multiple copies of message 787. Well I will ignore the others since I already have one.)
  • Detects if the packets are missing. (Hey, I got 787, 788, 790. I did not receive 789.)


Type of Message Description
SYN Used to initiate, establish the connection, and synchronize the number. 
SYN-ACK SYN message is from the local device and ACK is replying to the previous message.
ACK Confirms to the sending entity that it has received SYN.
FIN Use to terminate the message.

We hope this helps. If any suggestions or doubts you can add a comment and we will reply as soon as possible.

No comments:

Post a Comment