II. tcp protocol
TCP is a connection-oriented, reliable, byte-stream-based transport layer communication protocol that belongs to the transport layer. To ensure that information arrives accurately, TCP uses the famous three or four handshakes and four hands-offs.
III. Three handshakes (ACK and ack are two different concepts)
1. The client sets the flag bit SYN to 1, generates a random seq=x, sends the packet to the server, and the client enters the SYN-SENT state, waiting for a response
2, the server receives the data bit packet by the flag bit SYN=1 to know that the client is requesting a connection, then SYN=1 and ACK=1, ack=x+1, and seq to generate a random number seq=y, then the packet is sent to the client to confirm the connection request, and the server enters the SYN-RCVD state
3, the client receives the confirmation, check whether the ack is x+1, ACK is 1, if correct, the flag bit ACK=1, seq=x+1, ack=y+1, the packet is sent to the server, the server confirms ack=y+1 and ACK+1, both the client and the server enter ESTAB-LISHED state to complete the three handshakes, and then the data transmission