TCP three-way handshake and four waving related

Original link: http://www.cnblogs.com/camouflage/p/11098861.html

A client server B
the SYN (1 bit identifier to establish a connection to establish a connection) the ACK (acknowledge bit identifier 1 is confirmed) SEQ (a random code sequence) ACK (a confirmation number, usually seq + 1)

Three-way handshake:
1.A initiate a request to establish a connection. Transmitting data containing SYN = 1, and seq = 123456 packets to B, B by the SYN = 1 A that a connection is required. A case ## enters a state SYN_SEND.
A 2.B after receipt of the request, the need to find A confirmation. It transmits a SYN = 1, ACK = 1, ack = 123456 + 1, the data packet to seq = 234567 A. At this time, a ## SYN_RECV B enters state.
3.A After receiving the request, check (2.ack == 1.seq + 1) && (2.ACK == 1)) , if correct, then a transmission comprising ack = 2.seq + 1 and ACK = packet. 1 of B, and check the ack B receives the ACK again, if correct, then the connection is established. ## A and B into the ESTABLISHED state

 

Four waving reasons:
1.A send a FIN packet that would like to close the connection.
2.B after receiving a FIN ACK is sent back to the A-acknowledged receipt of the request to shut down, but I can not confirm that no data is sent to you, so you need to wait.
After confirmed that no data is sent 3.B A, sends a FIN to A.
4.A sends an ACK to B, B is disconnected. A after waiting a period of time will automatically disconnect.


# And shaking hands three times the difference is not as connected as to establish a connection to shut down immediately after the shutdown request, I need to wait for confirmation after the data is sent over here, it will start to close.

Reproduced in: https: //www.cnblogs.com/camouflage/p/11098861.html

Guess you like

Origin blog.csdn.net/weixin_30193897/article/details/95257684