Sorry for any confusion. Yes, there is a reason to set net.ipv4.tcp_retries1 and net.ipv4.tcp_retries2 to different numbers, and there is different behavior associated with them:
net.ipv4.tcp_retries1 is the threshold for TCP to define a connection as problematic but potentially recoverable ("soft error"). Transient issues might cause packet loss, and the TCP stack will retransmit unacknowledged segments up to the tcp_retries1 limit before classifying the state of the connection as a soft error. During this phase, the connection is still considered active, and the retransmission intervals are managed through the Retransmission Timeout (RTO), which increases after each unsuccessful attempt.
net.ipv4.tcp_retries2 is the threshold for considering the connection as broken or lost ("hard error"). After the tcp_retries2 limit is reached without receiving any acknowledgments, TCP will give up and signal to the upper layers that the connection has failed. The RTO continues to increase between each attempt after tcp_retries1 has been reached, resulting in a longer interval between the last attempts as it approaches the tcp_retries2 limit.
The different behaviors attributed to these two thresholds are related to the handling of TCP sessions in the presence of network issues. The settings allow for a distinction between:
- Initial retransmissions, where it's more likely that lost packets are due to short-term issues like temporary network congestion. (
tcp_retries1 deals with this phase.)
- Continued retransmissions, which are indicative of more severe problems, such as a router crash or a remote machine going down, leading to an eventual timeout. (
tcp_retries2 deals with this phase.)
By setting tcp_retries1 and tcp_retries2 to different values, system administrators can balance between aggressively retransmitting and potentially flooding the network versus waiting too long to notify applications of a severed connection, which could be crucial for high availability systems that need to failover quickly.
Having a higher tcp_retries1 value means that TCP will hold off longer before considering the connection to be in a soft error state, which allows more time for transient issues to resolve without triggering higher-level timeouts. A lower value would lead to a faster soft error determination and potentially more aggressive retransmissions or faster failover behavior depending on the application.
Ultimately, the gap between tcp_retries1 and tcp_retries2 affects the TCP stack's tolerance for packet retransmissions before it signals a connection error to the application. Having a reasonable gap between the two allows TCP to attempt recovery in the face of transient issues, while still ensuring that truly dead connections are closed within a sensible timeframe to avoid unnecessary resource usage.