Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Datetime with -Q behaves strangely #203

Closed
kaspergrubbe opened this issue Sep 14, 2020 · 7 comments
Closed

Datetime with -Q behaves strangely #203

kaspergrubbe opened this issue Sep 14, 2020 · 7 comments
Labels

Comments

@kaspergrubbe
Copy link

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
@gsnw
Copy link
Contributor

gsnw commented Dec 20, 2020

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)

@gsnw
Copy link
Contributor

gsnw commented Dec 21, 2020

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 ***/
 

@gsnw
Copy link
Contributor

gsnw commented Dec 27, 2020

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

@gsnw
Copy link
Contributor

gsnw commented May 27, 2021

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

@jeffsf
Copy link

jeffsf commented Jan 5, 2022

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.

@schweikert
Copy link
Owner

this should be fixed in fping 5.1

@kaspergrubbe
Copy link
Author

Thank you! 👍

cagney added a commit to cagney/fping that referenced this issue Dec 19, 2023
Change update_current_time() so that current_time is set
from CLOCK_REALTIME and current_time_ms is set from
CLOCK_MONOTONIC.  This way log messages display wall clock
time while any timing calculations use monotonic time.

See schweikert#203

In seqmap_add(), before checking to see if .time_ts wrapped,
check that .time_ts was set.

See schweikert#288
gsnw pushed a commit to gsnw/fping that referenced this issue Dec 20, 2023
Change update_current_time() so that current_time is set
from CLOCK_REALTIME and current_time_ms is set from
CLOCK_MONOTONIC.  This way log messages display wall clock
time while any timing calculations use monotonic time.

See schweikert#203

In seqmap_add(), before checking to see if .time_ts wrapped,
check that .time_ts was set.

See schweikert#288
gsnw pushed a commit to gsnw/fping that referenced this issue Dec 21, 2023
Change update_current_time() so that current_time is set
from CLOCK_REALTIME and current_time_ms is set from
CLOCK_MONOTONIC.  This way log messages display wall clock
time while any timing calculations use monotonic time.

See schweikert#203

In seqmap_add(), before checking to see if .time_ts wrapped,
check that .time_ts was set.

See schweikert#288
auerswal added a commit to auerswal/fping that referenced this issue Jun 23, 2024
Some changes of fping resulted in some systems reporting
implausible timestamps, see, e.g., GH issue schweikert#203.  This
commit adds a simplistic plausability check for timestamps
in Unix time format: they need to be greater or equal to
1000000000 (2001-09-09 03:46:40+02:00).
auerswal added a commit to auerswal/fping that referenced this issue Jun 23, 2024
Some changes of fping resulted in some systems reporting
implausible timestamps, see, e.g., GH issue schweikert#203.  This
commit adds a simplistic plausability check for timestamps
in Unix time format: they need to be greater or equal to
1000000000 (2001-09-09 03:46:40+02:00).
auerswal added a commit to auerswal/fping that referenced this issue Jun 23, 2024
Some changes of fping resulted in some systems reporting
implausible timestamps, see, e.g., GH issue schweikert#203.  This
commit adds a simplistic plausability check for timestamps
in Unix time format: they need to be greater or equal to
1000000000 (2001-09-09 03:46:40+02:00).
auerswal added a commit that referenced this issue Jun 28, 2024
Some changes of fping resulted in some systems reporting
implausible timestamps, see, e.g., GH issue #203.  This
commit adds a simplistic plausability check for timestamps
in Unix time format: they need to be greater or equal to
1000000000 (2001-09-09 03:46:40+02:00).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
3 participants