TCP 3-way handshake

farook fazni
3 min readJul 3, 2022

TCP/IP did you heard this term before. Yes you may heard of this in here,

TCP/IP stands for Transmission Control Protocol/ Internet Protocol. And it’s a suite of communication protocols used to interconnect network devices on the internet.

TCP Header Format

As you can see in the above image TCP Header has some Flags and they are,

URG (urgent) : Data which should be consider as a priority over other data when this flag was set.

ACK : This Flag used for Acknowledgement.

PSH (push) : when this flag is set the data should be transferred immediately and won’t wait until the entire TCP segment filled.

RST (Reset) : This flag resets the connection. when we receive this we have to terminate the connection. it’s only used if there are unrecoverable errors.

SYN: This is used to set the initial sequence number.

FIN (finish) : It’s used to end the TCP connection.

(Why we use TCP….)TCP is widely used because it’s a secure and reliable connection between client and user.

Let’s get an clear overview of establishing the connection,

www.netoworkustad.com

As the above image the First Step(Step-1) is connecting client with server, when client sends the message to server, it sets SYN (as 1)Flag as SET and sends a Sequence Number.

This sequence number is used only once in one connection. For another transmission, it uses another random sequence number.

In Second Step(Step-2) Server respond to the message which it received with an Acknowledgement Number. And it makes ACK (as 1) Flag as SET.

Generally Acknowledged number is greater than the sequence number.

In Last Step(Step-3) client receives the servers message and client sets ACK (as 1) Flag and respond. In this place the connection was established.

Let’s get an clear overview of Terminating connection,

To terminate the connection Server sends the message to the client as (Hey I am going to terminate the connection…….) FIN (as 1) Flag SET with a Sequence Number.

And then client sends message to Server(I don’t mind……) with ACK Flag. And client sends (I don’t care I am also closing the connection…..) FIN Flag to Server.

When Server receives FIN from client it sends back (OK…) ACK Flag. And we are done connection Terminated. I hope you all understood and let’s meet in another article.(Bye Bye….)

--

--

farook fazni

I am an undergraduate of computer science and technology in Uva Wellassa university of Sri Lanka