[IT technology sharing] Cisco CCNA/CCNP/CCIE TCP three-way handshake and four-way handshake

TCP three-way handshake and four-way handshake

TCP three-way handshake

• In some cultures, two people often shake hands to greet each other when they meet. Both parties understood the act of shaking hands as a signal of friendly greetings. The connections in the network are similar. The first handshake requests synchronization. The second handshake confirms the initial synchronization request and synchronizes the connection parameters in the opposite direction. The third handshake network segment is a confirmation, used to notify the target that both ends agree to establish a connection.

• When two hosts communicate using TCP protocol, a connection will be established before data exchange. After the communication is complete, the session will be closed and the connection will be terminated. The connection and session mechanism guarantees the reliability of TCP. Please refer to the steps to establish and terminate the TCP connection in the right figure.

• The host tracks each data segment during the session and uses TCP header information to exchange information about the received data. TCP is a full-duplex protocol, and each connection represents two unidirectional communication data streams or sessions. To establish a connection, the host should perform a three-way handshake. The control bits in the TCP header indicate the progress and status of the connection. Three handshake:

1) Confirm that the destination device exists on the network;

2) Confirm that the destination device has active services and is accepting on the destination port number to be used by the source client

request;

3) Notify the destination device that the source client wants to establish a communication session on the port number.

• In a TCP connection, the host client establishes a connection with the server. The process of TCP connection creation is divided into three steps:

Step 1: The source client requests a client-server communication session with the server.

Step 2: The server confirms the client-server communication session and requests the server-client communication session.

Step 3: The source client confirms the server-client communication session.
[IT technology sharing] Cisco CCNA/CCNP/CCIE TCP three-way handshake and four-way handshake

Step 1: A sends a SYN request to B

Step 2: B sends ACK response and SYN request to A

Step 3: A sends an ACK response to B

• In order to understand the three-way handshake process, please check the different values ​​exchanged between the two hosts. In the TCP data segment header, there are six 1-bit fields containing control information, which are used to manage the TCP process. These fields are:

URG-Urgent pointer field (important) ACK-Acknowledgement field (important) PSH-Push function

RST-reset connection SYN-sync serial number

FIN-The sender has transmitted all data

• Both ACK and SYN fields are related to our three-way handshake analysis.

TCP waved four times

• To close the connection, the data segment header must set the complete (FIN) control flag. In order to terminate each one-way TCP session, a two-way handshake including FIN data segment and ACK data segment is required. Therefore, to terminate the entire session supported by TCP, four exchanges are required to terminate two bidirectional sessions, as shown in Figure 1.

• Note: In this section, for easier understanding, the terms client and server are used for description. In fact, the process of termination can be carried out between any two hosts with open sessions: Step 1: When there is no other data to be sent in the client’s data stream, it will send a FIN label

Data segment set by the log;

Step 2: The server sends an ACK message to confirm receipt of the request to terminate the session from the client

FIN information;

Step 3: The server sends FIN information to the client, terminating the session from the server to the client;

Step 4: The client sends an ACK response message to confirm receipt of the FIN message received from the server.

• When the client has no other data to transmit, it will set the FIN flag in the data segment header. Then, the server in the session sends the general data segment information including the ACK flag setting, and confirms that all data has been received through the confirmation number. When all data segments are confirmed, the session is closed.

• The session in the other direction is closed in the same way. The receiver sets the FIN flag in the header of the data segment, and then sends it to the receiver, indicating that there is no other data to be sent. The returned confirmation message confirms that all data has been received, and then the session in that direction is closed.

[IT technology sharing] Cisco CCNA/CCNP/CCIE TCP three-way handshake and four-way handshake

Step 1: A sends a FIN request to B

Step 2: B sends an ACK response to A

Step 3: B sends a FIN request to A

Step 4: A sends an ACK response to B

• You can also close the connection through a three-way handshake. When the client has no other data to be transmitted, it will send FIN information to the server. If the server has no other data to be transmitted, it will send a response message containing both the FIN and ACK flag settings, and will perform two steps and one step. Finally, the client returns an ACK message.

Guess you like

Origin blog.51cto.com/14966105/2546144