TCP 3-way Handshake -SYN, SYN-ACK, ACK

The TCP 3-way handshake also is known as TCP-handshake. It contains three message handshake or SYN, SYN-ACK, ACK. It is the method for TCP/IP connection over an IP-based network. TCP’s 3-way handshaking is often called SYN, SYN-ACK, ACK technique because there are three messages transmitted by TCP to negotiate and start a TCP session between two hosts.

Hosts on the network read all data segments within a session and exchange information about what data is received using the information in the TCP header. TCP is a full-duplex protocol, where each logical connection represents two one-way communication streams or sessions. To set up the connection, the hosts do a TCP 3-way handshake. Control bits in the TCP header show the progress and status of the connection.

The TCP handshake method is designed for hosts attempting to communicate and can negotiate the limits of the TCP socket connection before transmitting data. This is the 3-way handshake process also designed for both ends can start and negotiate separate TCP socket connections at the same time.

It is being able to negotiate multiple TCP socket connections in both directions at the same time allows a single physical network interface, such as Ethernet, to be multiplexed to transfer multiple streams of TCP data simultaneously. The figure below illustrates the TCP 3-way handshake.

The steps of the TCP 3-way handshake is following:-

  1. The host sends a TCP SYNchronize packet to the server
  2. The server receives Host’s SYN
  3. The server sends a SYNchronize-ACKnowledgement to host
  4. The host receives the server’s SYN-ACK
  5. The host sends ACKnowledge to Severs
  6. The server receives ACK.
  7. Both sending data.

When data sending is complete then the sessions are going to close because of finishing sending data. The connection and session mechanisms also enable TCP’s reliability. For termination of the connection, another 3-way communication is going to perform and tear down the TCP socket.

This setup and teardown of a TCP socket connection is part of what qualifies TCP as a reliable protocol. TCP also acknowledges successful data receiving and guarantees the data is reassembling in the correct order.