Linux协议栈之TCP传输协议(二)

TCP发起连接的过程:

客户端                                                                                    服务器端 

(State:closed)                                                                       (State:listen)

---------------->(SYN连接请求)

                      (State:SYN_SENT)                                           

                                                                                              ACK <-------------

                                                                                              (State:SYN_RECV)

----------------->ACK

                      (State:ESTABLISHED)                                     

                                                                                              (State:ESTABLISHED)   

 

TCP关闭连接的过程:

客户端                                                                                    服务器端 

(State:connected)                                                                 (State:connected))

---------------->(FIN关闭请求)

                      (State:FIN_WAIT_1)                                        

                                                                                              ACK <-------------

                                                                                              (State:CLOSE_WAIT)

                      (State:FIN_WAIT_2)                                     

                                                                                              FIN关闭请求<--------

                                                                                              (State:LAST_ACK)

                      (State:TIME_WAIT) ---------->ACK                    (State:CLOSED)

                      2MS定时器

                      (State:CLOSED) 

如果通信双方同时发送FIN关闭请求,则双方状态置为CLOSING,等到对方应答后状态转为CLOSE_WAIT。

你可能感兴趣的:(linux)