TCP has a total of four main timers. As mentioned above, a timeout timer is the most complex one in TCP, and the other three are:
- Stick to Timer
- Active Timer
- 2msl Timer
The persistence timer is used to prevent the two sides from waiting for deadlocks after the announcement window is 0, while the persistence timer is used to process semi-open 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 ).
- 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 message segment (that is, the MSS to be received) or increase the buffer space of the receiver.
No matter the actual number.
- The sender can avoid confusion window syndrome by sending data only when one of the following conditions is met: (a) Yes
To send a full-length packet segment. (B) You can send a packet segment that is at least half the size of the receiver's announcement window. (c) You can
Send any data and do not want to receive ack (that is, we have no unconfirmed data) or the connection
You cannot use the Nagle algorithm.
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. Active 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.