4 way close

From Hackepedia
Revision as of 13:29, 24 March 2008 by Pbug (talk | contribs) (4 way close)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigationJump to search

To close a TCP session a four way closing handshake is performed.

Host A wants to close and sends FIN with seq 1000
Host B ACK's with ack set to 1001
Host B sends its own FIN with seq 500
Host A ACK's the last FIN with 501

The connection is then considered to be closed. The active part of closing (the initiator) keeps a state in TIME_WAIT state for 2MSL (MSL). Typically this can be observed in a server that has POP3 service. After the client sends the QUIT call the server replies with a +OK and immediately calls close() thus becoming the active closing end.

It's possible (often in windows) that once the FIN has been ACK'ed that the connection is torn down and the last ACK gets replied to with an RST.