# [ntp:questions] Re: Reading time offset from ntp variables using ntpq

Daniel Kabs daniel.kabs at gmx.de
Thu Feb 16 09:25:43 UTC 2006

```Hello Professor Mills!

> The peer offset is recorded for each client/server exchange. Let it run
> for a few hours and record the time of day and the offsets at the
> beginning and end. Subtract and divide by the interval. It's really not
> complicated.

The calculation is not complicated, that's correct. Getting the precise
time is. Please see the example as follows.

According to "Plan B", NTP is configured with "disable ntp". I ran a
cron job to query the peer clock variables using ntpq -c 'rv
<assoc_id_of_peer>' at 9:00 and 10:00. The billboards are attached below
as reference.

During the two "measurements", the offset (peer.offset) increased by
975.174 ms.

Given the cron jobs where started on time (which I doubt :-), the
"measurement" interval was 3600 s, thus the daily time offset of my
system clock will be:

975.174 / 3600 * 86400 / 1000 s     = 23.40 s

However, the difference in peer.reftime (8:58:38.253 to 9:58:47.253)
gives an interval of 3609 s, thus the extrapolation yields:

975.174 / 3609 * 86400 / 1000 s     = 23.35 s

The difference in peer.org is 3615.973 s, so the rule of proportions gives:

975.174 / 3615.973 * 86400 / 1000 s = 23.30 s

And finally peer.rec gives a time difference of 3616.977 s, making a
daily time offset of

975.174 / 3616.977 * 86400 / 1000 s = 23.29 s

I'd like to know, which calculation is most accurate. What is the
timestamp to record when reading the offset?

Cheers
Daniel Kabs

PS: The billboards look like this
assID=32468 status=9614 reach, conf, sel_sys.peer, 1 event, event_reach,
stratum=1, precision=-18, rootdelay=0.000, rootdispersion=6.516,
refid=DCFa, reach=377, unreach=0, hmode=3, pmode=4, hpoll=6, ppoll=6,
flash=00 ok, keyid=0, ttl=0, offset=-19583.268, delay=0.718,
dispersion=3.282, jitter=49.301,
reftime=c79eaf2e.40eef1ba  Thu, Feb 16 2006  8:58:38.253,
org=c79eaf2e.c3a5c1c6  Thu, Feb 16 2006  8:58:38.764,
rec=c79eaf42.628d5410  Thu, Feb 16 2006  8:58:58.384,
xmt=c79eaf42.5a03d577  Thu, Feb 16 2006  8:58:58.351,
filtdelay= 33.29    2.73    0.72    2.75    2.80    2.54    5.90    2.70,
filtoffset= -19604. -19601. -19583. -19565. -19547. -19531. -19516. -19497.,
filtdisp=   0.03    1.01    1.95    2.90    3.86    4.80    5.79    6.75

assID=32468 status=9614 reach, conf, sel_sys.peer, 1 event, event_reach,
stratum=1, precision=-18, rootdelay=0.000, rootdispersion=6.714,
refid=DCFa, reach=377, unreach=0, hmode=3, pmode=4, hpoll=6, ppoll=6,
flash=00 ok, keyid=0, ttl=0, offset=-20558.442, delay=0.679,
dispersion=3.734, jitter=45.116,
reftime=c79ebd47.40cf6be3  Thu, Feb 16 2006  9:58:47.253,
org=c79ebd4e.bcd4562e  Thu, Feb 16 2006  9:58:54.737,
rec=c79ebd63.5c88509b  Thu, Feb 16 2006  9:59:15.361,
xmt=c79ebd63.5a01abd1  Thu, Feb 16 2006  9:59:15.351,
filtdelay=     9.81    0.70    9.66    0.68    9.13    2.84    0.69    1.74,
filtoffset= -20618. -20595. -20581. -20558. -20538. -20524. -20508. -20490.,
filtdisp=      0.03    1.02    2.01    2.99    3.93    4.88    5.82    6.80

```