schweikert / fping

High performance ping tool
https://fping.org
Other
1.01k stars 250 forks source link

Time of execution when using retry -r increases in a nonlinear growth #304

Closed DimplyKhan13 closed 6 months ago

DimplyKhan13 commented 6 months ago

I've been installing fping for monitoring equipments in a network, and found a strange behavior that I don't understand and see it as a problem. When using -r, the execution time increases in a non-expected, not linear, way. Here is some data, using an IP address that doesn't exist in the network:

Without -r, it takes a second, as expected:

time fping 10.12.42.27 -b 32 -c 1 -t 1000 -i 50
10.12.42.27 : [0], timed out (NaN avg, 100% loss)

10.12.42.27 : xmt/rcv/%loss = 1/0/100%

real    0m1.004s
user    0m0.000s
sys     0m0.002s

With -r 1, a single retry, the time is as expected, (2*Timeout + 0.5s):

time fping 10.12.42.27 -b 32 -r 1 -t 1000 -i 50
10.12.42.27 is unreachable

real    0m2.505s
user    0m0.001s
sys     0m0.000s`

When doing 2 retries, the time grows outside what I expected:

time fping 10.12.42.27 -b 32 -r 2 -t 1000 -i 50
10.12.42.27 is unreachable

real    0m4.758s
user    0m0.001s
sys     0m0.000s

Here is a table of values following the same pattern:

-r 3        0m8.136s
-r 4        0m13.201s
-r 5        0m20.806s
-r 5        0m32.202s

Is there a reason for the increment after each try not be (Timeout + Time Between Tries)? Shouldn't it be a linear growth on time?

auerswal commented 6 months ago

fping increases the wait time for each reply by a factor that defaults to 1.5 (it can be controlled via -B). With a timeout T and a backoff factor B, the n-th wait between probes is T*B^(n-1). (The first wait is T, the second is T*B, the third is T*B*B, and so on.)

If you really want to, you can disable the effect using -B 1:

$ time fping -r3 -t1000 -B1 10.11.12.13
10.11.12.13 is unreachable

real    0m4,016s
user    0m0,000s
sys 0m0,001s
DimplyKhan13 commented 6 months ago

Thank you very much!