[ntp:questions] What level of timesynch error is typical onWinXP?

Dave Hart davehart at gmail.com
Mon Nov 8 20:13:58 UTC 2010


On Mon, Nov 8, 2010 at 3:54 PM, Miroslav Lichvar <mlichvar at redhat.com> wrote:
> No, it really is about the 500ppm limit. In loopstats is only the
> measured clock frequency, it doesn't contain the phase
> adjustments which are included in the adjtime() argument.

Miroslav shared the following patch with me, which limits the startup
period adjtime() calls to 500 PPM:

diff -Nrpu a/ntpd/ntp_loopfilter.c b/ntpd/ntp_loopfilter.c
--- a/ntpd/ntp_loopfilter.c     2010-11-08 19:08:01 +00:00
+++ b/ntpd/ntp_loopfilter.c     2010-11-08 19:08:01 +00:00
@@ -729,6 +729,12 @@ adj_host_clock(
                adjustment = clock_offset / (CLOCK_PLL * ULOGTOD(1));
        else
                adjustment = clock_offset / (CLOCK_PLL * ULOGTOD(sys_poll));
+
+       if (adjustment + drift_comp > 500e-6)
+               adjustment = 500e-6 - drift_comp;
+       else if (adjustment + drift_comp < -500e-6)
+               adjustment = -500e-6 - drift_comp;
+
        clock_offset -= adjustment;
        adj_systime(adjustment + drift_comp);
 #endif /* LOCKCLOCK */

With that patch in place, the same tests I posted results from over
the last two days look much better.  Still FreeBSD 6.4, daemon loop.

55508 60640.805 -0.000112889 80.625 0.000079971 0.002516 6

That's the last line from before my tests, 80.6 PPM.

55508 62584.842 0.116936290 0.000 0.041343222 0.000000 6
55508 62588.843 0.114936290 0.000 0.038674235 0.000000 6
55508 62588.843 0.114936290 0.000 0.036178875 0.000000 6
55508 62644.843 0.086936290 0.000 0.034014104 0.000000 6
55508 62712.843 0.052936290 0.000 0.034018200 0.000000 6
55508 62778.842 0.019936290 0.000 0.038716101 0.000000 6
55508 62784.842 0.016936290 0.000 0.045273814 0.000000 6
55508 62850.842 0.002088993 0.000 0.053460467 0.000000 6
55508 62913.843 0.023326374 70.042 0.059967666 0.000000 6
55508 62982.842 0.019426182 70.042 0.056111561 0.000000 6
55508 62987.842 0.009569368 70.042 0.052603122 0.000000 6
55508 63049.843 0.002626795 70.042 0.049266899 0.000000 6
55508 63052.842 0.000356258 70.042 0.046091955 0.000000 6
55508 63389.842 0.000004426 70.042 0.043115255 0.000031 6
55508 63591.842 0.000969943 70.053 0.040332073 0.004129 6
55508 63795.842 0.003616808 70.097 0.037738804 0.016021 6
55508 63927.842 0.004220131 70.131 0.035302063 0.019037 6
55508 63998.842 0.006167700 70.157 0.033029235 0.020056 6
55508 64468.842 0.007198255 70.358 0.030898168 0.073722 6

With the clock initially behind reality by 117 msec, drift calc is
about 10 PPM low (12%).  Without the patch, the estimates were over
200 PPM.

55508 64810.505 -0.091600813 0.000 0.032385778 0.000000 6
55508 64814.505 -0.089600813 0.000 0.030294138 0.000000 6
55508 64870.505 -0.061600813 0.000 0.028640526 0.000000 6
55508 64871.505 -0.061100813 0.000 0.027978523 0.000000 6
55508 64872.505 -0.060600813 0.000 0.028659050 0.000000 6
55508 64937.505 -0.028100813 0.000 0.030823858 0.000000 6
55508 64938.505 -0.027600813 0.000 0.034372232 0.000000 6
55508 64940.505 -0.026600813 0.000 0.041171617 0.000000 6
55508 65009.505 -0.003508309 0.000 0.051052372 0.000000 6
55508 65076.505 -0.000418103 0.000 0.061308591 0.000000 6
55508 65139.506 0.022347887 68.099 0.070085224 0.000000 6
55508 65144.506 0.023377857 68.099 0.065559736 0.000000 6
55508 65205.506 0.018941878 68.099 0.061345569 0.000000 6
55508 65207.506 0.013694029 68.099 0.057413513 0.000000 6
55508 65210.506 0.008496926 68.099 0.053736847 0.000000 6
55508 65271.506 0.001262569 68.099 0.050331249 0.000000 6
55508 65275.506 -0.000857325 68.099 0.047086538 0.000000 6
55508 65476.506 0.000494344 68.105 0.044048016 0.002094 6
55508 65477.505 0.006590953 68.105 0.041259487 0.001964 6
55508 65880.505 0.000908097 68.127 0.038646979 0.007928 6
55508 66084.505 0.004146577 68.177 0.036169066 0.019307 6
55508 66558.506 0.007462619 68.388 0.033853370 0.076699 6
55508 66687.506 0.009303477 68.460 0.031673616 0.076073 6
55508 66753.505 0.010986167 68.503 0.029633927 0.072782 6
55508 66956.505 0.011209774 68.638 0.027720113 0.083274 6
55508 67364.505 0.012171310 68.934 0.025932020 0.130457 6

With the clock initially 92 msec ahead, the estimate is similar at 68
PPM, vs. negative estimates without the patch.

55508 67403.716 0.001215584 0.000 0.000429778 0.000000 6
55508 67407.716 0.001070611 0.000 0.000621438 0.000000 6
55508 67463.716 0.000180921 0.000 0.000586552 0.000000 6
55508 67465.716 0.000169790 0.000 0.000665156 0.000000 6
55508 67529.716 0.000022257 0.000 0.001611948 0.000000 6
55508 67531.716 0.000020887 0.000 0.002585427 0.000000 6
55508 67597.716 0.000002570 0.000 0.003733352 0.000000 6
55508 67603.716 0.000002124 0.000 0.005579274 0.000000 6
55508 67663.716 0.000000316 0.000 0.007104409 0.000000 6
55508 67730.716 0.020324351 62.154 0.009476638 0.000000 6
55508 67737.717 0.023031222 62.154 0.008916094 0.000000 6
55508 67799.717 0.017765292 62.154 0.008545519 0.000000 6
55508 67806.717 0.002502493 62.154 0.009644521 0.000000 6
55508 68135.716 0.005283004 62.257 0.009075026 0.036628 6
55508 68548.717 0.008549218 62.468 0.008567094 0.081916 6
55508 68587.233 0.001029933 0.000 0.000364141 0.000000 6
55508 68591.233 0.000907102 0.000 0.000342928 0.000000 6
55508 68649.234 0.000143858 0.000 0.000577777 0.000000 6
55508 68716.233 0.000017144 0.000 0.002067408 0.000000 6
55508 68785.233 0.000001917 0.000 0.004728534 0.000000 6
55508 68789.233 0.000001689 0.000 0.006535437 0.000000 6
55508 68856.233 0.000000201 0.000 0.009069983 0.000000 6
55508 68923.233 0.025418610 75.651 0.012096796 0.000000 6
55508 68985.234 0.019719836 75.651 0.011493494 0.000000 6
55508 68992.234 0.004535394 75.651 0.012017020 0.000000 6
55508 69058.233 -0.001300621 75.651 0.011428694 0.000000 6
55508 69319.233 0.004095189 75.714 0.010859444 0.022524 6
55508 69729.234 0.001282943 75.746 0.010206624 0.023807 6
55508 69795.234 0.001587684 75.752 0.009548030 0.022379 6
55508 69990.233 0.002580305 75.782 0.008938257 0.023466 6
55508 70400.233 0.003472318 75.867 0.008366919 0.037174 6
55508 70475.233 0.004057810 75.885 0.007829273 0.035359 6
55508 70740.233 0.004350221 75.954 0.007324344 0.041039 6
55508 71013.233 0.004560383 76.028 0.006851700 0.046497 6
55508 71556.234 0.004902133 76.186 0.006410317 0.070981 6
55508 72102.234 0.004911425 76.346 0.005996303 0.087190 6
55508 72568.234 0.005183287 76.490 0.005609852 0.096139 6
55508 72626.233 0.005289484 76.509 0.005247670 0.090162 6

Two runs with the clock initially 1ms off, estimates are 62 and 75
PPM.  So there's still a bit of noise here, but the great majority of
the error seems to have been eliminated by clamping adjtime() args to
500 PPM.  I bet similar results could be achieved without the clamp by
accounting for the leftover from adjtime(), which would allow willing
kernels to slew > 500 PPM.

Cheers,
Dave Hart



More information about the questions mailing list