Home  >  Article  >  Web Front-end  >  A brief analysis of the three-way handshake and four-wave strategy of TCP transmission

A brief analysis of the three-way handshake and four-wave strategy of TCP transmission

一个新手
一个新手Original
2017-10-14 09:22:391939browse

In order to accurately deliver data to the destination, the TCP protocol adopts a three-way handshake strategy. After the data packet is sent out using the TCP protocol, TCP will not ignore the situation after the transmission. It will definitely confirm to the other party whether it was successfully delivered. TCP flags are used during the handshake: SYN and ACK.
The sending end first sends a data packet with a SYN flag to the other party. After receiving it, the receiving end sends back a data packet with the SYN/ACK flag to convey confirmation information. Finally, the sending end sends back a data packet with an ACK flag, indicating the end of the "handshake". If the handshake is interrupted for no apparent reason at some stage, the TCP protocol will send the same data packets in the same order again.
Disconnecting a TCP connection requires "four waves":
The first wave: the active closing party sends a FIN to close the active party to the passive party The data transmission of the closing party, that is, the active closing party tells the passive closing party: I will no longer send you data (of course, if the data sent before the fin package does not receive the corresponding ack confirmation message, the active closing party will The closing party will still resend the data), but the actively 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 (the same as SYN, one FIN occupies one sequence number).
The third wave: the passive closing party sends a FIN to close the data transmission from the passive closing party to the active closing party, that is, to tell the active closing party that my data has been sent, no. I will send you the data again.
The fourth wave: After the active closing party receives the FIN, it sends an ACK to the passive closing party, and the confirmation sequence number is the received sequence number + 1. At this point, four waves are completed.

The above is the detailed content of A brief analysis of the three-way handshake and four-wave strategy of TCP transmission. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn