[ntp:questions] enable calibrate?
davehart at gmail.com
Wed Nov 16 00:27:47 UTC 2011
[yikes. I replied with the below message to Doug 3 hours after his
OP, forgetting to reply all. I wonder how many other times I've done
that and not noticed? I only noticed this time because I wanted to
reply to my own post with more info.]
On Sun, Nov 13, 2011 at 05:59, Doug Calvert
<dfc-list at douglasfcalvert.net> wrote:
> I just ran across the "enable calibrate" feature in the documentation.
> Unfortunately there is little information on how it works, how to use
> it. What do I do after I enable calibrate?
The paragraph before the list of drivers sheds a bit more light.
Those are the only two references I find describing the feature. One
point that's missing is where to find the result after things have
refclock_receive() has this code:
if (cal_enable && fabs(last_offset) < sys_mindisp && sys_peer !=
if (sys_peer->refclktype == REFCLK_ATOM_PPS &&
peer->refclktype != REFCLK_ATOM_PPS)
pp->fudgetime1 -= pp->offset * FUDGEFAC;
FUDGEFAC is 0.1. The code does not match the docs, which say all
refclocks are calibrated to match the source marked prefer. What
actually is done is: only if the sys_peer is the ATOM driver (22),
nudge every other non-ATOM refclock's fudge time1 by -10% of its
current offset from the system clock. Over time it will settle down
with the needed fudge time1 value in effect for each non-ATOM refclock
to agree with the ATOM driver.
To use it with the current implementation, you must have a PPS source
and you must configure the ATOM driver for that PPS source (as opposed
to using, for example NMEA's PPS support), then ntpd will
automatically determine the fudge time1 value for the remaining
refclock(s). You can ensure the clock(s) you want to calibrate aren't
used by adding noselect to their server lines. You can montior fudge
time1 using ntpq's cv ASSOCID/cv &X (X is 1-based index of refclock in
billboard/as output, ASSOCID would be from ntpq -c as). Once it's
settled configure the fudge time1 for each in ntp.conf, remove the
"enable calibrate" and any "noselect"s added for calibration, and if
needed revert to your original PPS configuration. Upon restart, all
the refclocks should now agree with the PPS.
Note you can calibrate by hand by marking a refclock noselect,
ensuring its fudge time1 is 0, enabling peerstats or clockstats, then
start ntpd and let it run long enough to settle down. Grab the peer
offset for the clock from peerstats/clockstats (possibly averaging
over a number of samples after the system had settled), then configure
fudge time1 to the negation of the offset (or offset average).
I think it would make sense to change the code so "enable calibrate"
can calibrate any refclock that is not controlling the host clock, and
can calibrate to whichever source (including network) the system is
using. It may also make sense to calibrate only those refclocks
marked noselect. I'd love to hear what Dr. Mills thinks of this
Doug, I invite you to file a bug report on the doc/code mismatch,
since you raised the issue. Hopefully if you don't I will, but I will
be involved anyway and always appreciate extra eyes on an issue.
More information about the questions