TCP建立和釋放

握手

TCP連接狀態

三次握手

在這裏插入圖片描述
下面是狀態的解釋:

State Description
LISTEN The socket is listening for incoming connections. Such sockets are not included in the output unless you specify the --listening (-l) or --all (-a) option.
SYN_SENT The socket is actively attempting to establish a connection.
SYN_RECV A connection request has been received from the network.
ESTABLISHED The socket has an established connection.

四次釋放

在這裏插入圖片描述
上面的網圖看着還是挺清晰的,但是有個小瑕疵,就是不應該是客戶端對服務端,而是主動關閉端對應被動關閉端。主動關閉端要求進入TIME_WAIT 狀態。

下面是各種狀態的解釋:

State Description
ESTABLISHED The socket has an established connection.
FIN_WAIT1 The socket is closed, and the connection is shutting down.
FIN_WAIT2 Connection is closed, and the socket is waiting for a shutdown from the remote end.
TIME_WAIT The socket is waiting after close to handle packets still in the network.
CLOSE The socket is not being used.
CLOSE_WAIT The remote end has shut down, waiting for the socket to close.
LAST_ACK The remote end has shut down, and the socket is closed. Waiting for acknowledgement.
CLOSING Both sockets are shut down but we still don’t have all our data sent.
TIME_WAIT重置場景

主動端關閉連接之後,被動端發送了FIN報文代表被動端也想要關閉連接。此時,主動端發送的確認報文失效。

被動端沒有收到FIN的確認報文,因此重發FIN報文,主動端收到會重置時鐘,發送ACK確認報文。
在這裏插入圖片描述

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章