Abstract: In the case of two handshakes, the “passive initiator” has no intermediate state for the “active initiator” to block the historical connection, so the “passive initiator” may establish a historical connection, resulting in a waste of resources.

This article is shared in the huawei cloud community “Why does TCP Two Handshakes Fail to Block Historical Connections?” , author: Kobayashi Coding.

In the two-handshake scenario, the passive initiator enters ESTABLISHED after receiving the SYN packet, meaning that it can send data to the peer. However, the active initiator does not enter ESTABLISHED yet. Assume that the connection is historical. The active initiator determines that the connection is historical and sends an RST message to disconnect the connection. The passive initiator enters the ESTABLISHED state when shaking hands for the first time, so it can send data. However, it does not know that the connection is historical and disconnects the connection only after receiving the RST message.

In the preceding scenario, the passive initiator does not block the historical connection before sending data to the Active Initiator. As a result, the passive initiator establishes a historical connection and sends data for nothing, wasting the resources of the passive initiator.

Therefore, the best way to solve this problem is to block the historical connection before the “passive initiator” sends the data, that is, before establishing the connection, so as not to waste resources, and to achieve this function, three handshakes are required.

In the following figure, the sequence numbers of the two connections are different. Therefore, the old and new SYN packets are not retransmitted timeout. The two connections are independent.

The client sends multiple SYN packets to establish connections. In the case of network congestion:

  • An old SYN packet arrived at the server earlier than the latest SYN packet.

  • In this case, the server sends a SYN + ACK packet to the client.

  • After receiving the packet, the client can determine that it is a historical connection (serial number expired) based on its own context. Then, the client sends an RST packet to the server to terminate the connection.

As you can see, in the three-way handshake, you can prevent the historical connection from being established before the server can establish the connection, thus ensuring that the established connection is not historical.

Click to follow, the first time to learn about Huawei cloud fresh technology ~