what is the difference between FIN and RST
FIN :
A FIN is used to gracefully shutdown a TCP session.
A FIN packet is usually sent from server or client to terminate a connection, after establishment of TCP 3-way handshake and successful transfer of data.
A FIN is intended to terminate an established connection.
FIN says, "I finished talking to you, but I'll still listen to everything you have to say until you're done" (Wait for an ACK)
RST:
RST can be used to shutdown a session at any time.
A 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 when either the server or client becomes unavailble or rejects further communication without the formal 4-way TCP connection termination process.
A RST can be used that way as well, but can also be used to abort a connection that is only partially formed or is being rejected.
RST says, "There is no conversation. I am resetting the connection!"