Three-way handshake and four-way wave in TCP protocol

The three-way handshake and four-way wave three-way handshake in the TCP protocol


(connection establishment)
1. The client sends a connection request message
2. After the server segment accepts the connection, it replies with an ACK message and allocates resources for this connection.
3. After receiving the ACK message, the client also sends an ACK message to the Server segment and allocates resources, so that the TCP connection is established.



Wave four times (disconnection)
1. The disconnection end can be the client end or the server end.

The client initiates a disconnection
1. Sends a FIN message.
2. After the server receives the FIN message, it means "my client has no data to send to you", but if you still have data that has not been sent, you don't have to rush to close the Socket, you can continue to send data. So you send ACK first, "tell the client that I have received your request, but I am not ready, please continue to wait for my message".
3. At this time, the client side enters the FIN_WAIT state and continues to wait for the FIN message from the server side.
4. When the server side determines that the data has been sent, it sends a FIN message to the client side, "tell the client side, OK, I have finished sending the data here, and I'm ready to close the connection".
5. After the client receives the FIN message, "it knows that the connection can be closed, but he still does not believe in the network, afraid that the server does not know to close, so it enters the TIME_WAIT state after sending ACK, if the server does not receive ACK, then It can be retransmitted.
6. After the server receives the ACK, it "knows that the connection can be disconnected".
7.
8. The TCP connection is closed like this.



Refer to original text: http://blog.csdn.net/whuslei/article/details/6667471

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=327010771&siteId=291194637