[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[gpsd-dev] [PATCH 3/3] Print offset in ntpshmmon instead of reference ti
From: |
Miroslav Lichvar |
Subject: |
[gpsd-dev] [PATCH 3/3] Print offset in ntpshmmon instead of reference time |
Date: |
Thu, 7 May 2015 12:34:34 +0200 |
---
contrib/ntpshmviz | 4 ++--
ntpshmmon.c | 11 +++++++----
ntpshmmon.xml | 28 +++++++++++++---------------
3 files changed, 22 insertions(+), 21 deletions(-)
diff --git a/contrib/ntpshmviz b/contrib/ntpshmviz
index 17c754d..9152819 100755
--- a/contrib/ntpshmviz
+++ b/contrib/ntpshmviz
@@ -110,7 +110,7 @@ class ntpOffset:
# - The NTP unit from which it was collected.
# - Collection time of day, expressed in seconds
# - Receiver time of day, expressed in seconds
- # - Clock time of day, expressed in seconds
+ # - Offset, expressed in seconds
# - Leep-second notification status
# - Source precision (log(2) of source jitter)
@@ -128,7 +128,7 @@ class ntpOffset:
if line[:1] != '#':
line = line.lstrip()
record = line.split(' ')
- offset = (float(record[3]) - float(record[4]))
+ offset = float(record[4])
# If the NTP unit is in the dictionary
# append the offset to the list
diff --git a/ntpshmmon.c b/ntpshmmon.c
index c2a621c..07d3c32 100644
--- a/ntpshmmon.c
+++ b/ntpshmmon.c
@@ -21,6 +21,9 @@
/* WARNING! this will overflow if x and y differ by more than a few seconds */
#define timespec_diff_ns(x, y)
(long)(((x).tv_sec-(y).tv_sec)*1000000000+(x).tv_nsec-(y).tv_nsec)
+/* difference between timestamps as a double */
+#define timespec_diff_dbl(x, y)
(((x).tv_sec-(y).tv_sec)+1e-9*((x).tv_nsec-(y).tv_nsec))
+
static struct shmTime *segments[NTPSEGMENTS + 1];
static struct timespec tick[NTPSEGMENTS + 1];
@@ -79,8 +82,8 @@ int main(int argc, char **argv)
exit(EXIT_SUCCESS);
}
- (void)printf("ntpshmmon version 1\n");
- (void)printf("# Name Seen@ Clock Real
L Prec\n");
+ (void)printf("ntpshmmon version 2\n");
+ (void)printf("# Name Seen@ Received@
Offset L Prec\n");
do {
struct shm_stat_t shm_stat;
@@ -93,11 +96,11 @@ int main(int argc, char **argv)
{
case OK:
if (timespec_diff_ns(shm_stat.tvc, tick[i]) >= cycle *
1000000000) {
- printf("sample %s %ld.%09ld %ld.%09ld %ld.%09ld %d %3d\n",
+ printf("sample %s %ld.%09ld %ld.%09ld %+020.9f %d %3d\n",
ntp_name(i),
(long)shm_stat.tvc.tv_sec, shm_stat.tvc.tv_nsec,
(long)shm_stat.tvr.tv_sec, shm_stat.tvr.tv_nsec,
- (long)shm_stat.tvt.tv_sec, shm_stat.tvt.tv_nsec,
+ timespec_diff_dbl(shm_stat.tvt, shm_stat.tvr),
shm_stat.leap, shm_stat.precision);
tick[i] = shm_stat.tvc;
--nsamples;
diff --git a/ntpshmmon.xml b/ntpshmmon.xml
index 82e1bd0..498d70d 100644
--- a/ntpshmmon.xml
+++ b/ntpshmmon.xml
@@ -49,15 +49,14 @@ fields.</para>
<para>Here is an example of the beginning of a report file:
<literallayout>
-ntpshmmon version 1
-# Name Seen@ Clock Real L
Prec
-sample NTP2 1424926256.443030206 1424926256.115869233 1424926256.000000000 0
-1
-sample NTP3 1424926256.443060517 1424926255.995430821 1424926256.000000000 0
-20
-sample NTP3 1424926256.995747347 1424926256.995422728 1424926257.000000000 0
-20
-sample NTP2 1424926257.112433572 1424926257.111936726 1424926257.000000000 0
-1
-sample NTP3 1424926257.996221153 1424926257.995410232 1424926258.000000000 0
-20
-sample NTP2 1424926258.107769409 1424926258.107451006 1424926258.000000000 0
-1
-sample NTP3 1424926258.995647636 1424926258.995406476 1424926259.000000000 0
-20
+ntpshmmon version 2
+# Name Seen@ Received@ Offset L
Prec
+sample NTP1 1430993523.879335377 1430993522.999999050 +000000000.000000950 0
-20
+sample NTP0 1430993524.435727285 1430993524.434913144 -000000000.434913144 0
-1
+sample NTP1 1430993524.880300614 1430993524.000001746 -000000000.000001746 0
-20
+sample NTP0 1430993525.437669569 1430993525.437044263 -000000000.437044263 0
-1
+sample NTP1 1430993525.881070289 1430993525.000000172 -000000000.000000172 0
-20
+sample NTP0 1430993526.438515249 1430993526.430013058 -000000000.430013058 0
-1
</literallayout></para>
<para>The output always begins with a header line expressing the
@@ -80,7 +79,7 @@ itself.</para>
<listitem><para>Receiver time of day, seconds.</para></listitem>
-<listitem><para>Clock time of day, seconds.</para></listitem>
+<listitem><para>Offset betweeen reference time and receiver time,
seconds.</para></listitem>
<listitem><para>Leap-second notification status.</para></listitem>
@@ -88,11 +87,10 @@ itself.</para>
</orderedlist>
</para>
-<para>In these fields, "clock time" is the high-precision time
-measured by the source and "receiver time" is Unix UTC time at the
-receiver. It is normal for the seconds part of receiver time to
-coincide with the seconds part of collection time and for the
-nanoseconds part of receiver time to be zero.</para>
+<para>In these fields, "receiver time" is Unix UTC time when was the reference
+time received. It is normal for the seconds part of receiver time to
+coincide with the seconds part of collection time. The offset should be close
+to zero when the clock is synchronized.</para>
<variablelist>
<varlistentry>
--
2.1.0
- [gpsd-dev] [PATCH 0/3] ntpshm stuff, Miroslav Lichvar, 2015/05/07
- [gpsd-dev] [PATCH 2/3] Fix typo in ntpshm.h, Miroslav Lichvar, 2015/05/07
- [gpsd-dev] [PATCH 3/3] Print offset in ntpshmmon instead of reference time,
Miroslav Lichvar <=
- Re: [gpsd-dev] [PATCH 3/3] Print offset in ntpshmmon instead of reference time, Gary E. Miller, 2015/05/07
- Re: [gpsd-dev] [PATCH 3/3] Print offset in ntpshmmon instead of reference time, Gary E. Miller, 2015/05/07
- Re: [gpsd-dev] [PATCH 3/3] Print offset in ntpshmmon instead of reference time, Miroslav Lichvar, 2015/05/13
- Re: [gpsd-dev] [PATCH 3/3] Print offset in ntpshmmon instead of reference time, Gary E. Miller, 2015/05/13
- Re: [gpsd-dev] [PATCH 3/3] Print offset in ntpshmmon instead of reference time, Miroslav Lichvar, 2015/05/14
- Re: [gpsd-dev] [PATCH 3/3] Print offset in ntpshmmon instead of reference time, Gary E. Miller, 2015/05/14
[gpsd-dev] [PATCH 1/3] Print ntpshmmon banner as comment to follow spec, Miroslav Lichvar, 2015/05/07