TCP Handshake - Difference between FIN and RST flag

3mp3r0r
2 min readSep 22, 2020

--

While sending some information between two points in a connection-oriented network, some set of rules or protocols are followed.

Two such protocols are TCP and UDP used for sending bits of data — known as packets — over the Internet. Both protocols build on top of the IP protocol. In other words, whether you’re sending a packet via TCP or UDP, that packet is sent to an IP address.

TCP and UDP aren’t the only protocols that work on top of IP. However, they are the most widely used.

TCP is preferred over any other protocol in a connection-oriented network. You may have heard this as TCP provides a secure and reliable connection link between two devices. But this is possible due to the 3-way handshake process as shown in the diagram. The SYN or synchronization flag can be described as a request for establishing a secure connection.

Client-server TCP handshake diagram

The 3 way handshake starts with a SYN flag always but can be terminated in more than one way.
The way to understand this is that there are 2 ways to close TCP connection:

  • Send FIN flag
  • Send RST flag

Major Difference

Major difference:
RST causes immediate/abrupt connection termination.
In FIN you get a confirmation.

Explaining with an example:

  • FIN says: “I finished talking to you, but I’ll still listen to everything you have to say until you say that you’re done.
  • RST says: “There is no conversation. I won’t say anything and I won’t listen to anything you say.

RST is useful if you have long lasting TCP connection with little traffic. If one of the computers is restarted, it forgets about the connection, and the other computer gets RST, as soon as it sends another packet. An RST packet is sent either in the middle of the 3-way handshake when the server rejects the connection or is unavailable OR in the middle of data transfer.

Visit my website: http://harjasnagi.ml

--

--