Home> Common Problem> body text

What do you mean by holding your fingers in three messages?

藏色散人
Release: 2020-06-29 09:22:13
Original
5629 people have browsed it

Three-message handshake refers to tracking and negotiating the amount of data sent each time, ensuring the synchronization of sending and receiving data segments, and confirming data transmission and reception based on the amount of data received. The contact is withdrawn and a virtual connection is established.

What do you mean by holding your fingers in three messages?

The so-called "three-way handshake": In order to track and negotiate the amount of data sent each time and ensure that the sending and receiving of data segments are synchronized, according to the received When the data is sent and received, the contact is canceled and a virtual connection is established.

In order to provide reliable delivery, TCP sequence numbers the data packets in a specific order before sending new data, and requires confirmation messages after these packets are delivered to the target machine. TCP is always used to send large amounts of data. TCP is also used when an application needs to confirm after receiving data.

In order to establish a TCP connection, both communicating parties must know the following information from the other party:

Three-way handshake

1. The starting sequence number of the other party's message sending .

2. The buffer size of the data sent by the other party.

3. The maximum message segment length that can be received, MSS.

4. Supported TCP options.

In the TCP protocol, the communicating parties will understand the above information through three TCP message segments, and establish a TCP connection on this basis. The exchange process of the three TCP message segments between the communicating parties, This is what is commonly known as the Three-Way Handshake process of establishing a TCP connection.

When the connection is established, then:

1. Both communicating parties of the TCP connection can know the sequence number of the first byte that will be sent by the other party on the connection (sent to the other party) Confirmation number, the confirmation number sent by A to B is the sequence number that B will send, and the same is true for B);

2. Both parties can know the MSS that can be sent on the connection, so they can choose to exchange it during the handshake phase. The smaller value of the MSS option in the SYN message and SYN ACK message is used as the actual value;

3. Both parties can know the other party’s receive buffer size;

4. Both parties can You can know whether the other party can use SACK, window scaling and other options.

Based on this information, both parties can establish a TCP connection (x, y) and start the transmission of message segments based on this connection.

The three-way handshake method is used to establish a TCP connection. If two hosts attempt to establish a connection between the same sockets at the same time, only one connection will be established (these two connections are regarded as identical, that is, the same connection), because all connections are identified by their endpoints. If the first request results in the establishment of a connection identified by (x, y), and the second request also establishes a connection identified by (X, y), then there will only be one TCP connection table inside the TCP entity. term(x,y).

Process

First time

First handshake: When establishing a connection, the client sends a syn packet (seq=j) to the server, And enter the SYN_SENT state, waiting for server confirmation; SYN: Synchronize Sequence Numbers.

Second handshake: The server receives the syn packet, must confirm the client's SYN (ack=j 1), and also sends a SYN packet (seq=k) , that is, SYN ACK packet, at this time the server enters the SYN_RECV state.

The third time

The third handshake: The client receives the SYN ACK packet from the server and sends a confirmation packet ACK (ack=k 1) to the server. After the packet is sent, the client Enter the ESTABLISHED (TCP connection successful) state with the server and complete the three-way handshake.

Complete the three-way handshake, the client and the server begin to transmit data. In the above process, there are some important concepts:

(1) Unconnected queue

After three times In the handshake protocol, the server maintains an unconnected queue, which opens an entry for each client's SYN packet (seq=j). This entry indicates that the server has received the SYN packet and sent a confirmation to the client, and is waiting for the client's confirmation. Bag. The connection identified by these entries is in the Syn_RECV state on the server. When the server receives the client's confirmation packet, the entry is deleted and the server enters the ESTABLISHED state.

(2) Backlog parameter

indicates the maximum number of connections queued by the kernel for the corresponding socket. The number of SYN-ACK retransmissions. After the server has sent the SYN-ACK packet, if it does not receive the client confirmation packet, the server will perform the first retransmission. After waiting for a period of time and still not receiving the client confirmation packet, it will perform the second retransmission. If the number of retransmissions If the maximum number of retransmissions specified by the system is exceeded, the system will delete the connection information from the semi-connection queue. Note that the waiting time for each retransmission is not necessarily the same.

(3) Semi-connection survival time

refers to the longest time for the entry of the semi-connection queue to survive, that is, the longest time from the server receiving the SYN packet to confirming that the message is invalid. , this time value is the sum of the longest waiting times of all retransmission request packets. Sometimes we also call the semi-connection survival time as Timeout time and SYN_RECV survival time.

The above is the detailed content of What do you mean by holding your fingers in three messages?. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!