TCP protocol three-way handshake wave four times

As we all know, the TCP protocol is a connection-oriented, reliable, byte stream-based transport layer communication protocol. What is connection-oriented and reliability, I think this is mainly reflected in TCP's three-way handshake and four waved hands. Only after the three-way handshake is successful, a connection is established to transmit data; the connection is disconnected after four waves of hands.

Insert picture description here

The TCP header has 6 bit flags, respectively SYN (synchronous connection establishment) ACK (acknowledgement confirmation) PSH (push transmission) FIN (finish end) RST (reset reset) URG (urgent emergency)
seq: sequence number, ack: Confirmation Number

The first handshake: The client sends a packet to the server (or host 1 to host 2) to establish a connection with syn=1 seq=x.
The second handshake: the server receives the packet, and returns a syn=1 ack=1(x+1) seq=y confirmation with a sign of establishing a connection.
The third handshake: After the client receives the confirmation and online packet, it returns an acknowledgment packet with seq=1 ack=1(y+1) to the server.

When the three-way handshake is successful, the connection is established and data can be transmitted.

After the data is transmitted, the connection needs to be released, that is, the connection is disconnected.
Insert picture description here
After the client's data transmission is completed, the client sends the first end packet to the server ( the first breakup ); the server receives the packet to indicate that it knows, and returns a confirmation packet (the second breakup); then the server transmits the data After the end, send a closing package to the client (the third breakup); the client will receive a confirmation package (the fourth breakup ).

The package captured when requesting Baidu
Insert picture description here

The overall situation is: three handshake -> send get request -> Baidu send confirmation package -> Baidu send data packet -> receive data confirmation package -> 4 break up.

Guess you like

Origin blog.csdn.net/weixin_52379685/article/details/114234585