Each connection. TCP manages four unused timers

  1. Retransmission timer, used when you want to receive an acknowledgement from the other end.
  2. Stick to the timer so that window size information keeps flowing even if the other end closes its receiving window
  3. A keepalive timer that detects when the other end of an idle connection crashes or restarts
  4. 2MSL timer, which measures how long a connection is in TIME_WAIT state

How to handle the loss of ACK of open window in TCP connection?

In the scenario of closing the window, the receiver notifies the sender that the window for receiving data is 0, and the sender does not send data anymore.

Damage of open window ACK loss: When the receiver announces an ACK with a non-zero window, this ACK is lost for some reason. At this time, the sender is waiting for the notification of open window forever, and the receiver is waiting for the arrival of new data forever. In this way, the connection may be closed due to waiting.

Solution: Use persistence timer, periodically query to the receiver, in order to find the change of the window

This periodic query of the segment of the message sent from the sender is called a probe window. The probe window contains one byte of data, but an ACK returning a window of zero does not acknowledge this byte

What is confused Window syndrome?

For the server, if the processing speed is too slow, it will set the value of the notification window smaller and smaller, or even smaller than the packet header. In this case, the communication efficiency is extremely low. This situation is called confused window syndrome.

How to avoid confused window syndrome?

  1. Receiver: The window size is advertised only when the window increases the MSS size by one or half of the cache size of the receiver can be increased
  2. Sender: Can send a full length message, can send a message that is at least half the size of the receiver’s notification window, or can send any data and does not want to receive an ACK (in which case the data has been confirmed)

In Nagle algorithm, when the packet is too small, it is not sent. The value here is small, indicating that the packet sent by the sender is smaller than the packet segment size

What is the use of the keepalive timer?

The server application is used to detect scenarios such as whether the client host crashes and starts, or crashes and shuts down. Specifically, the client host must be in one of the following 4 states:

  1. Normal operation. The TCP response is normal and the server knows that the client is working properly. The server resets the keepalive timer after two hours. If an application communicates with the server through the connection between the two hours, the keepalive timer resets in the next two hours after data exchange. The server application at this point does not need the aware keepalive timer
  2. The client host crashed and is shut down or restarting. The server sends a total of 10 probes, each 75 seconds apart. If there is no response, the client host is considered down and the connection is terminated.
  3. The client host crashed but has restarted. The server receives a probe response, but the response is a reset, causing the server to terminate the connection.
  4. The client host is normal, but the service is unreachable. Like 2, you get no probe response

The disadvantages are: 1. A brief error may cause a good connection to be released. 2 Saving wastes unnecessary bandwidth;

The appendix

Read the book (CHAPTER 22, Chapter 23)