Three-way handshake, waving four times!

The first handshake: connection is established, the client sends syn packets (syn = J) to the server, and enters the SYN_SENT state, waiting for the server to confirm; the SYN: synchronization sequence number (Synchronize Sequence Numbers). 

Second handshake: server receives syn packets, must confirm the customer's SYN (ACK = + J . 1 ), while themselves sends a SYN packet (syn = k), i.e., + SYN the ACK packet, then the server enters a state SYN_RECV; 

Third handshake: a client server receives the SYN + the ACK packet, the server sends an acknowledgment packet to the ACK (ACK = K + . 1 ), this packet is sent, the client and server into the ESTABLISHED (TCP connection succeeds) state, to complete the three-way handshake. 
---------------- 
Disclaimer: This article is the original article CSDN bloggers "green grapefruit _", and follow CC 4.0 BY- SA copyright agreement, reproduced, please attach the original source and link this statement. 
Original link: HTTPS: // blog.csdn.net/qq_38950316/article/details/81087809

 

1 ) The client process issues a connection release message and stops sending data. Releasing the data packet header, the FIN = 1 , the sequence number seq = u (equal to the previously transmitted data over the last byte sequence number plus 1), 
In this case, the client-WAIT-enter the FIN 1 (termination waiting 1) state. TCP provisions, FIN segment, if not carrying data, but also consume a serial number. 2 ) the server receives a connection release message, a confirmation message, the ACK = . 1 , ACK = U + . 1 , and bring its own sequence number seq = v, case, the server proceeds to the CLOSE-WAIT (wait off) status.
TCP server to inform high-level application process, the client to the server on the release direction, this time in a semi-closed state, that is, the client has no data to send, but if the server sending data, the client still has to be accepted.
This state will continue for some time, that is, the entire CLOSE- WAIT state duration. 3 ) Client receives acknowledgment requests the server side, in which case, the client-WAIT-enters the FIN 2 (2 termination waiting) state, waiting for the server to send a connection release message
last (this also need to agree before the server sends data).
4 ) After the server transmits the final data is completed, the client sends a connection release message, the FIN = . 1 , = U + ACK . 1 , since the half-closed state, and the server is likely to transmit some data
, Assumed in this case sequence number seq = w, at this time, the server into the LAST- the ACK (acknowledgment last) state, waiting for an acknowledgment of the client. 5 ) The client receives a connection release message of the server, a confirmation, the ACK = . 1 , ACK = + W . 1 , and its own serial number is = U + SEQ . 1 , at this time, the client enters the TIME - the WAIT ( time waiting) state.
Note that the TCP connection has not been released at this time, the must be 2 ** MSL (maximum segment lifetime) time, when the client undo the TCB corresponding, before entering the CLOSED state.
6 ) As long as the server has received confirmation sent by the client, immediately enter CLOSED state. Similarly, after the revocation of TCB, it is over the TCP connection. You can see, the end of time than client server TCP connection ends earlier.

 

Guess you like

Origin www.cnblogs.com/cxm123123form/p/11442243.html