schweikert/fping

Datetime with -Q behaves strangely

Closed this issue ยท 7 comments

Hi,

I am running this program at 02:27 (at night/early morning) however the output from fping believes it is 14:42, first I thought it interpreted 02: as 14:, but the minutes are also off by 15 minutes compared to the system clock:

$ echo $(date) && fping -B 1 -D -r0 -O 0 -p 1000 -Q 10 -l billetto.dk
Mon Sep 14 02:27:57 BST 2020
[14:42:09]
billetto.dk : xmt/rcv/%loss = 10/10/0%, min/avg/max = 22.6/24.8/33.1
[14:42:19]
billetto.dk : xmt/rcv/%loss = 10/10/0%, min/avg/max = 22.3/26.3/46.0
[14:42:29]
billetto.dk : xmt/rcv/%loss = 10/9/10%, min/avg/max = 22.2/24.5/31.6

Version

Installed through Homebrew on OSX Catalina.

$ fping -v
fping: Version 5.0

It is reproducible on FreeBSD 12.2-RELEASE-p2, too but not on Debian 10.7

FreeBSD

date +%s
1608499884

fping -D -l google.com
[877269.67467] google.com : [0], 64 bytes, 12.6 ms (12.6 avg, 0% loss)
[877270.70469] google.com : [1], 64 bytes, 12.4 ms (12.5 avg, 0% loss)

Debian

date +%s
1608500159

fping -D -l google.com
[1608500168.76708] google.com : [0], 64 bytes, 10.2 ms (10.2 avg, 0% loss)
[1608500169.75319] google.com : [1], 64 bytes, 9.92 ms (10.1 avg, 0% loss)
[1608500170.75338] google.com : [2], 64 bytes, 10.1 ms (10.1 avg, 0% loss)

At the build process the compiler don't set the macro #define CLOCKID CLOCK_REALTIME
The following hot workaround fix temporary this issue on FreeBSD

diff --git a/src/fping.c b/src/fping.c
index c392fae..fb12eec 100644
--- a/src/fping.c
+++ b/src/fping.c
@@ -118,10 +118,11 @@ extern int h_errno;
 
 /*** Constants ***/
 
-#if HAVE_SO_TIMESTAMPNS
+//#if HAVE_SO_TIMESTAMPNS
 #define CLOCKID CLOCK_REALTIME
-#endif
+//#endif
 
+/*
 #if !defined(CLOCKID)
 #if defined(CLOCK_MONOTONIC)
 #define CLOCKID CLOCK_MONOTONIC
@@ -129,6 +130,7 @@ extern int h_errno;
 #define CLOCKID CLOCK_REALTIME
 #endif
 #endif
+*/
 
 /*** Ping packet defines ***/
 

I'm not realy happy with this solution.
You can considered as fast workaround because openbsd or other unix systems still has the problem.

But I have two other conception.

  1. Extending configure.ac at line 39 and checking SO_TIMESTAMP, too
  2. Spliting the time function in human-readable and timediff between events.
    This means checking the supported kernel clock at runtime

I have create a new version that fix the issue over configure.ac
If this is the better solution in the project than to make the OS distinction in the code

gsnw@2d8d292

Definitely would appreciate this making it upstream as macOS and FreeBSD are my primary OSes.

Edit: It looks like 04af04c resolve may have resolved this.

this should be fixed in fping 5.1

Thank you! ๐Ÿ‘