The whole process of TCP three-way handshake and four-way wave

Three-way handshake:
the first handshake: the client sends the syn packet (seq=x) to the server, and enters the SYN_SENT state, waiting for the server to confirm;
the second handshake: the server receives the syn packet and must confirm the client's SYN (ack=x +1), at the same time, it also sends a SYN packet (seq=y), that is, a SYN+ACK packet. At this time, the server enters the SYN_RECV state;
the third handshake: the client receives the SYN+ACK packet from the server and sends an acknowledgement packet ACK to the server. (ack=y+1), after the packet is sent, the client and server enter the ESTABLISHED state and complete the three-way handshake.
The packet transmitted during the handshake process does not contain data. After the three-way handshake is completed, the client and the server officially begin to transmit data. Ideally, once a TCP connection is established, the TCP connection will be maintained until either party actively closes the connection.

 
Four-way wave:
Similar to the "three-way handshake" for establishing a connection, a "four-way handshake" is required to disconnect a TCP connection.
The first wave: the active closing party sends a FIN to close the data transmission from the active closing party to the passive closing party, that is, the active closing party tells the passive closing party: I will not send you any more data (of course, in the fin The data sent before the packet, if the corresponding ack confirmation message is not received, the active closing party will still resend the data), but the active closing party can still accept the data at this time.
The second wave: After the passive closing party receives the FIN packet, it sends an ACK to the other party, and the confirmation sequence number is the received sequence number + 1 (same as SYN, one FIN occupies one sequence number).
The third wave: The passive closing party sends a FIN to close the data transfer from the passive closing party to the active closing party, that is, to tell the active closing party that my data has been sent, and I will not send you any more data.
The fourth wave: After the active closing party receives the FIN, it sends an ACK to the passive closing party, and the confirmation serial number is the received serial number + 1. So far, four waveds have been completed.

Guess you like

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