Handshaking is used to establish the connection before transmission of data.
TCP make use of 3-way handshaking,
Why to use it?
Handshaking is used to establish connection between CLIENT and SERVER.
Suppose an example where user wants to access some website, here client is user and website is
server,
Here TCP will make use of 3way Handshaking where user will initiate by sending connection
request, and then if server wants to accept that connection, it will reply to connection request by
accepting that connection and will reply to that connection request by sending an
acknowledgement and user on receiving acknowledgement reply with another acknowledgement
and connection will be established between client and server.
This is how connection is establish between client and server and because 3 times request is send
between client and server therefore it is known as 3 way handshaking.
Let’s understand it in detail:
Connection establishment is done by Client Machine and therefore it is known as Active Open
Application.
And Server Application is known as Passive Open Application.
To establish/break connection, TCP makes use of 3 bits:
SYN: Synchronize (Used to establish connection)
FYN: Finish (Used to break connection)
RST: Reset (Used to Reset connection)
Thus to establish connection, client will send a packet to server with SYN bit = 1, representing
Client wants to establish connection.
The first segment will have SYNCHRONOZE Bit( SYN = 1) and because it has no
Acknowledgment therefore ACK Bit =0
Client
Server
Active Open
Passive Open
Sequence
No: x
SYN=1, AC
K=0
: x+1
N o: y, Ack
nce
Seque , ACK=
1
SYN=1
Sequence
No: x, Ack
SYN=0, AC : y+1
K=1
Since server is accepting connection request, therefore it will reply to this request by sending a
segment.
Because Server is accepting connection request therefore its segment will have
SYNCHRONOZE Bit (SYN = 1) and because it is replying to previous segment therefore it will
have ACKNOWLEDGEMENT Bit (ACK = 1).
On receiving acknowledgment from Server, Client will reply with a segment that it has received
the segment rom server,
As third stage is not connection establishment therefore its SYN will be 0, and because it is
replying to previous segment therefore it will have ACKNOWLEDGEMENT Bit (ACK = 1).
This is how connection is establish between Client and Server using 3-Way handshaking.