TCP's Three Way Handshake

TCP's Three Way Handshake

·

2 min read

In the Transmission Control Protocol, a three way handshake is used to build a strong , reliable
connection between two devices out of which one is the server and the other one is the client.
It is used to ensure that the both devices, server and client, are open to sending and receiving
data, respectively.

This process occurs in three steps-
1. SYN(Synchronize) -
The client sends a TCP segment* with the SYN flag* to start the connecting process.
Let’s say, this packet contains an initial sequence number (x).
*Segment is basically a unit of data used at the Transport Layer of the TCP/IP model.
*Flags are part of the header in network packets. There is a header and data/payload in
a network packet.

2. SYN-ACK(Synchronize-Acknowledge) -
The server responds to the client with SYN-ACK flag set which ensures that the SYN
flag is ready to establish a connection by server while the ACK flag acknowledges the
client’s SYN request by increasing the client’s ISN* by 1.
It contains its own sequence number (y) and it acknowledges the client's sequence
number (x+1)
*ISN is the first sequence number sent by a device (client or server) when initiating a
TCP connection. It ensures that reliable data is transferred by keeping track of the order
of data and detecting any lost or duplicated packets.

3. ACK(Acknowledge) -
The client finally sends an ACK packet, acknowledging the server's SYN which helps
ensure that connection has been built and now the data can be transferred.
It acknowledges the server's sequence number (y+1)
Why is a three way handshake required?
It generally helps in sending reliable and synchronized data, while making sure that both the
client and server are ready for connection and no data is sent prematurely.
Also, without it TCP won’t be of much use because primarily we use TCP for reliability and
without a three way handshake, we can not guarantee a synchronized and reliable TCP
connection.