I'm going to copy an answer from a certain website and write an article about it. TCP four times wave Under normal circumstances, as long as the data transmission is completed, both the client and the server can actively initiate four waves to release the connection. Just like the picture above, assuming that the four waves are initiated by the client, it is the active party. The server passively receives the client's wave request and is called the passive party. Both the client and the server are initially in the ESTABLISHED state.
The above mentioned is that the active party no longer sends data. But if the passive party still has data to send at this time, then continue to send it. Note that although the passive party can send data to the active party between the second and third wave, it is not certain whether the active party can receive it normally. This will be discussed later.
The first and third waves are actively triggered by us in the application (such as calling the close() method), which is what we need to pay attention to when writing code. The second and fourth waves are automatically completed by the kernel protocol stack. We don't touch this part when writing code, so we don't need to worry too much. In addition, whether active or passive, each party sends a FIN and an ACK. It also receives a FIN and an ACK. Back to the main question. If the server does not receive the fourth wave request during the four TCP wave requests, will the server keep waiting?The fourth wave is triggered by the third wave. If the server does not receive the fourth wave, it will think that its third wave is lost, so the server keeps retrying to send the third wave (FIN). The number of retries is controlled by the system's tcp_orphan_retries parameter. If the server fails to retry many times, it will directly disconnect the connection. So the conclusion is that the server will not keep waiting for the fourth wave. TCP fourth wave lost # cat / proc / sys / net / ipv4 / tcp_orphan_retries In addition, you will find that the tcp_orphan_retries parameter is 0, but it does not mean no retries. When it is 0, the default value is 8, which means 8 retries. /* Calculate maximal number or retries on an orphaned socket. */ Of course, if the server retries to send the FIN for the third time, using the same port and IP, and a new client is started, the client will regard the retried FIN as an abnormal data packet after it is received, and will directly send a RST to the server, and the connection between the two ends will be disconnected. |
<<: One of the biggest features of 5G is the security minefield
>>: Why do base stations need to go to the sky?
RAKsmart has launched a promotional event for the...
Following the integration of 5G base stations wit...
The arrival of the New Year is always exciting, e...
On March 23, the Chinese national football team w...
[[375985]] [51CTO.com original article] "If ...
According to a new research report from IoT analy...
My girlfriend gets off work at 7 o'clock ever...
A few days ago, we shared information about spins...
With the eager anticipation of the whole nation, ...
[[387217]] In the modern society where technology...
The COVID-19 outbreak that has ravaged the world ...
80VPS is a long-established Chinese hosting compa...
A new report from MarketsandMarkets predicts that...
The 5G era is coming, and applications based on m...
At present, the digital economy has become the to...