Estimate Connection Timeout¶
Note
The values of TCP_KEEPIDLE and TCP_KEEPINTVL are in half seconds. For example, setting TCP_KEEPINTVL to 30 results in an interval of 15 seconds.
Considering the earlier example, you can estimate the failure detection time (D) window using this formula:
(INTVL) × (CNT + 1) < D < (IDLE) + (INTVL) × (CNT + 1)
Example:
(15) × (4+1) < D < (30) + (15) × (4+1)
75 seconds < D < 105 seconds
The detection time (D) is between 75 and 105 seconds, depending on when the failure occurs. In the worst case, the connection fails immediately after activity on the connection, forcing TCP to wait the full idle period first.
The sequence is:
-
Wait "TCP_KEEPIDLE" (30s), send a probe (the disconnection occurs somewhere in that period)
-
Wait "TCP_KEEPINTVL" (15s), send a probe
-
Repeat this last operation "TCP_KEEPCNT" times (15s x 4 = 60s)
-
Wait for an answer "TCP_KEEPINTVL" (15s) (This explains the (keepcnt+1) of the above formula)