Monday, August 8, 2016

Normal TCP termination sequence

We have two peers: A and B

    A calls close()
        A sends FIN to B
        A goes into FIN_WAIT_1 state
    B receives FIN
        B sends ACK to A
        B goes into CLOSE_WAIT state
    A receives ACK
        A goes into FIN_WAIT_2 state
    B calls close()
        B sends FIN to A
        B goes into LAST_ACK state
    A receives FIN
        A sends ACK to B
        A goes into TIME_WAIT state
    B receives ACK
        B goes to CLOSED state – i.e. is removed from the socket tables