Four timers in TCP:
1. Time-out timer (the most complex one) 2. Persistence timer 3. Retention timer 4. 2msl Timer
The persistence timer is used to prevent the C/S sides from waiting for deadlocks after the announcement window is 0, while the persistence timer is used to process semi-development connections;
1. Stick to the timer
It is simple to stick to the timer principle. When the TCP server receives the client's 0 sliding window message, it starts a timer to time the message, when the timer overflows, check whether the window has increased to the client. If a non-zero window is obtained, send data again, if the window is 0, a new timer is created to prepare for the next query. We can see through observation that the TCP persistence timer uses 1, 2, 4, 8, 16 ...... The ordinary Exponential Backoff sequence such as 64 seconds serves as the overflow time for each time.
Confused window syndrome
The TCP Window Protocol causes a problem that is usually called confused window syndrome. The specific manifestation is that when the client advertises a small non-zero window, the server immediately sends small data to the client and is filled with its buffer. Once used, the network will be filled with small TCP datagram, thus affecting network utilization. This obfuscation of the sender and acceptor. TCP provides some suggestions (or rules ).
1. The recipient does not notice a small window. The common algorithm is that the receiver does not advertise a window larger than the current window (which can be 0), unless the window can increase the size of a packet segment (that is, the MSS to be received) alternatively, you can increase the cache space of the recipient by half, regardless of the actual amount. The sender can avoid confusion window syndrome by sending data only when one of the following conditions is met:
(A) A full-length packet segment can be sent;
(B) A packet segment that is at least half the size of the receiver's announcement window can be sent;
(C) You can send any data and do not want to receive ack (that is, we do not have unconfirmed data) or the Nagle algorithm cannot be used on the connection.
Okay. Now let's recall that many TCP regulations are designed to send as much data as possible during a single transmission, such as the routing rule with Ack data packets and the Nagle algorithm, the policy for sending original data packets during re-transmission, and so on.
2. Life-saving timer
It is easier to keep the timer. Do you still remember that FTP or HTTP servers have the sesstion time mechanism? Because TCP is connection-oriented, there will be a "semi-open connection" that only connects and does not transmit data. The server must detect this connection and release this connection in some cases, this is the role of the active timer. The time limit varies with the server implementation. In addition, if one end crashes and restarts, if it receives the "active" detection from this end, send an rst data packet to help the other end the connection.