Dave,
I think I have hunted down what is going on. It takes some serious
investigation. Turns out the modern adjtime(), at least in some systems,
is far from what I knew some years back. I have already described that
era from what I knew of SunOS, Ultrix, OSF/1 and Tru64, since I or my
graduate assistant implemented the precision time kernel used in those
production systems. Today, at least Solaris and Linux have put up stuff
that turns out to be absolute poison when attempting things like
measuring frequency.
The original model I started with was (a) messier the initial offset and
tell adjtime() to slew the kernel to that offset; (b) after five minutes
assume the kernel has largely completed the slew, measure the current
offset anc compute the frequency. This is a little tricky, since the
amount the kernel has slewed the time must be added before computing the
time difference.
Well, this didn't work, apparently because the kernel didn't do what it
was supposed to do. However, a hint is available in the form of the
second phase of the training interval where the residual offset is
amortized while holding the frequency constant. This involves
periodically measuring the offset and updating the adjtime() programmed
offset. This works, as evident my previous message. This could be due to
a nonlinearity in the adjtime() calculation of the slew rate, which is
apparently higher the larger the programmed offset. Apparently, the
repeated calls to adjtime() eventually lowers the offset and thus the
slew rate to something reasonable. Whatever the cause, the behavior when
the frequency file is present is within expectations.
So, I did the same thing during the frequency measurement phase, with
result the following loopstats from a Solaris system with initial offset
122 ms, no frequency file and the kernel enabled.
55506 78196.297 0.122624404 0.000 0.043354274 0.000000 4
55506 78200.301 0.108000004 0.000 0.040745455 0.000000 4
55506 78208.300 0.083775590 0.000 0.040190338 0.000000 4
55506 78226.299 0.047307323 0.000 0.045698174 0.000000 4
55506 78244.298 0.026714020 0.000 0.054270636 0.000000 4
55506 78262.298 0.015085167 0.000 0.063186252 0.000000 4
55506 78280.298 0.008518459 0.000 0.071337915 0.000000 4
55506 78298.298 0.004810297 0.000 0.078439342 0.000000 4
55506 78316.298 0.002716332 0.000 0.084507033 0.000000 4
55506 78334.297 0.001533888 0.000 0.089652370 0.000000 4
55506 78352.298 0.000866173 0.000 0.094006017 0.000000 4
55506 78370.298 0.000489120 0.000 0.097751274 0.000000 4
55506 78388.297 0.000276202 0.000 0.100850407 0.000000 4
55506 78406.297 0.000155969 0.000 0.103480985 0.000000 4
55506 78424.297 0.000088074 0.000 0.105713875 0.000000 4
55506 78442.297 0.000049735 0.000 0.107604976 0.000000 4
55506 78460.297 0.000028085 0.000 0.109209608 0.000000 4
55506 78478.298 0.000015859 0.000 0.110570569 0.000000 4
55506 78496.298 0.003133702 10.416 0.111724541 0.000000 4
55506 78512.297 0.001806182 10.416 0.104509792 0.000000 4
55506 78528.297 0.000873748 10.416 0.097760515 0.000000 4
55506 78544.297 0.000362151 10.416 0.091446767 0.000000 4
55506 78656.297 0.000353000 12.931 0.085540618 0.889337 4
55506 78688.298 0.000354000 13.104 0.080015921 0.834140 4
55506 78720.297 0.000226000 13.214 0.074848054 0.781241 4
55506 78736.297 -0.000163000 13.175 0.070014079 0.730920 4
55506 78864.299 -0.000234000 12.718 0.065492179 0.702547 4
55506 78912.299 -0.000289000 12.506 0.061262326 0.661420 4
55506 78944.298 -0.000286000 12.366 0.057305659 0.620669 4
55506 78992.297 -0.000286000 12.157 0.053604536 0.585287 5
55506 79008.297 -0.000233000 12.143 0.050142455 0.547509 5
55506 79269.297 -0.000469000 11.676 0.046904046 0.538099 5
55506 79430.297 -0.000319000 11.480 0.043874749 0.508089 5
55506 79495.297 -0.000265000 11.414 0.041041075 0.475841 5
55506 79755.304 -0.000206000 11.210 0.038390415 0.450932 5
55506 79852.297 -0.000257000 11.115 0.035910950 0.423146 5
55506 79949.297 -0.000249000 11.023 0.033591618 0.397155 6
It starts at second 78196 with offset 122 ms and frequency zero. At 300
s later, second 78496, the frequency is set at 10.496, which happens to
be within 1 PPM of the nominal value. At this point the residual offset
is about 3.1 ms. At second 78544 the residual offset drops below 0.5 ms
and the frequency clamp is removed. However, there is about a 0.3 ms
residual offset, which at this low poll interval of 16 s and low time
constant makes the frequency loop rather sensitive, so the frequency
jumps to 12.9 PPM. While this slowly subsides to the e nominal value,
note the residual offset stays below 0.35 ms. Victory is declared
I haven't tried this on other machines, but the sheer blunderbuss
approach here should tame even them. Your exploits to the contrary are
invited. The new code is in the backroom, but not yet a snapshot.
Dave
Dave Hart wrote:
On Sat, Nov 6, 2010 at 03:34 UTC, David L. Mills <mi...@udel.edu> wrote:
Now to the apparent initial frequency error. This is new, as tests in the
past have not confirmed that. I need to plant some debug code in
direct-freq().
I ran several more tests without a drift file on the same FreeBSD 6.4
machine, but now with the daemon loop. The kernel frequency was reset
with ntptime -f 0. This is using ntpd 4.2.7p78 with four LAN sources
each with less than 500ms delay on gigabit ethernet, maxpoll 6 and
iburst on each. The machine's drift when settled stays over 79 and
under 81 PPM.
55506 60099.298 0.112224703 0.000 0.039677424 0.000000 6
55506 60430.299 0.087985591 265.808 0.031875465 0.000000 6
55506 60497.299 0.082268047 265.808 0.029885212 0.000000 6
55506 60501.299 0.063703305 265.808 0.028715263 0.000000 6
55506 60566.299 0.044976216 265.808 0.027664662 0.000000 6
55506 60570.299 0.035161159 265.808 0.026109553 0.000000 6
55506 60632.299 0.016835865 265.808 0.025268008 0.000000 6
55506 60637.300 0.007505765 265.808 0.023865132 0.000000 6
55506 60699.299 -0.005871398 265.808 0.022819291 0.000000 6
55506 60703.299 -0.012182324 265.808 0.021461792 0.000000 6
Above I slowed the clock by 110ms before starting ntpd, and its
frequency estimate is 3x too big.
55506 61035.172 -0.109110664 0.000 0.038576445 0.000000 6
55506 61364.172 -0.039509331 -120.080 0.047442141 0.000000 6
55506 61432.172 -0.018407984 -120.080 0.045000783 0.000000 6
55506 61441.171 -0.000743150 -120.080 0.042555170 0.000000 6
55506 61570.172 -0.039411530 -120.383 0.042088955 0.107139 6
55506 61907.172 0.077963129 -118.817 0.057202679 0.562671 6
55506 62109.172 0.112914955 -117.457 0.054916590 0.712782 6
55506 62588.325 0.000000000 -117.457 0.000001907 0.666746 6
55506 62597.324 0.036879681 -117.437 0.013038936 0.623723 6
This time opposite offset and the drift ends up with the wrong sign.
55506 62673.088 0.046002361 0.000 0.016264291 0.000000 6
55506 63004.087 0.036022038 108.824 0.016594865 0.000000 6
55506 63072.088 0.024200794 108.824 0.016075870 0.000000 6
55506 63076.087 0.015639317 108.824 0.015339223 0.000000 6
55506 63139.087 0.007153841 108.824 0.014658809 0.000000 6
55506 63144.087 -0.001147804 108.824 0.014022670 0.000000 6
55506 63342.087 0.010581006 108.949 0.013756870 0.044150 6
55506 63546.087 -0.007289204 108.860 0.014335728 0.051841 6
55506 64089.087 -0.018442062 108.263 0.013977562 0.216530 6
55506 64156.087 -0.025361028 108.162 0.013301681 0.205686 6
55506 64224.087 -0.025423666 108.059 0.012442603 0.195821 6
46ms slow, frequency is ~28 PPM too large.
55506 64548.716 0.001700028 0.000 0.000601053 0.000000 6
55506 64879.717 0.023679569 71.539 0.010183162 0.000000 6
55506 64946.717 0.019872424 71.539 0.009620108 0.000000 6
55506 65013.717 0.002736900 71.539 0.010848108 0.000000 6
55506 65017.717 -0.008305963 71.539 0.010872643 0.000000 6
55506 65082.716 -0.004770959 71.539 0.010246931 0.000000 6
55506 65148.717 0.001608567 71.539 0.009846926 0.000000 6
55506 65219.717 0.012919477 71.594 0.010041603 0.019330 6
55506 65346.717 0.011396322 71.680 0.009408484 0.035457 6
55506 65486.716 0.003467074 71.709 0.009236544 0.034709 6
55506 65828.717 0.004913697 71.809 0.008655121 0.048044 6
55506 66236.717 0.006136544 71.959 0.008107660 0.069307 6
55506 66627.716 0.007779940 72.140 0.007606245 0.091173 6
55506 66776.716 0.009039619 72.220 0.007128916 0.089883 6
55506 67230.717 0.009392249 72.474 0.006669656 0.123060 6
55506 67373.716 0.009373844 72.554 0.006238895 0.118527 6
55506 67658.716 0.009579650 72.717 0.005836406 0.124912 6
55506 67908.717 0.009567647 72.860 0.005459459 0.127253 6
55506 67977.716 0.009286340 72.898 0.005107825 0.119797 6
55506 68513.717 0.009503342 73.201 0.004778549 0.155178 6
55506 68642.716 0.009570171 73.275 0.004469985 0.147469 6
55506 69168.716 0.009184942 73.563 0.004183506 0.171447 6
55506 69233.716 0.009189485 73.599 0.003913312 0.160868 6
55506 69365.716 0.009375908 73.672 0.003661161 0.152721 6
55506 69432.717 0.009193983 73.709 0.003425307 0.143446 6
55506 69959.717 0.008999743 73.992 0.003204817 0.167315 6
55506 70090.717 0.009024846 74.062 0.002997845 0.158480 6
55506 70155.716 0.008902531 74.097 0.002804561 0.148745 6
55506 70350.716 0.008570129 74.196 0.002626057 0.143526 6
55506 70672.716 0.008251968 74.355 0.002459026 0.145465 6
55506 71197.716 0.007350799 74.585 0.002322169 0.158521 6
55506 71456.716 0.007408970 74.699 0.002172288 0.153698 6
55506 71850.716 0.007506679 74.875 0.002032283 0.156700 6
55506 72376.716 0.007566595 75.113 0.001901145 0.168879 6
55506 72899.717 0.007325361 75.341 0.001780402 0.177408 6
55506 72965.716 0.007008212 75.368 0.001669184 0.166236 6
55506 73491.716 0.006596605 75.575 0.001568146 0.171833 6
55506 73689.716 0.006589897 75.653 0.001466868 0.163070 6
55506 74212.717 0.006427589 75.853 0.001373329 0.168186 6
55506 74407.717 0.006501221 75.929 0.001284895 0.159575 6
55506 74537.723 0.006513531 75.979 0.001201917 0.150332 6
55506 74672.717 0.006297412 76.030 0.001126884 0.141759 6
55506 74999.716 0.006044827 76.148 0.001057880 0.138992 6
55506 75524.716 0.005710565 76.327 0.000996588 0.144553 6
55506 75981.716 0.005532070 76.477 0.000934356 0.145334 6
55506 76313.716 0.005505819 76.586 0.000874059 0.141300 6
55506 76442.716 0.005524893 76.629 0.000817635 0.133025 6
55506 76768.716 0.005369956 76.733 0.000766787 0.129787 6
55506 77228.716 0.004834798 76.866 0.000741799 0.130137 6
55506 77685.716 0.004784225 76.996 0.000694120 0.130159 6
55506 78207.716 0.004621958 77.140 0.000651820 0.131942 6
55506 78273.716 0.004610433 77.158 0.000609735 0.123587 6
55506 78667.717 0.004535789 77.264 0.000570965 0.121585 6
55506 79191.716 0.004254460 77.397 0.000543272 0.123053 6
55506 79387.724 0.004210196 77.447 0.000508425 0.116412 6
55506 79451.716 0.004094866 77.462 0.000477333 0.109034 6
55506 79648.717 0.004053887 77.510 0.000446739 0.103371 6
55506 80173.716 0.003811266 77.629 0.000426599 0.105488 6
55506 80239.717 0.003807079 77.644 0.000399050 0.098817 6
55506 80761.716 0.003781913 77.762 0.000373383 0.101366 6
55506 80826.716 0.003742947 77.776 0.000349539 0.094957 6
55506 81286.717 0.003719909 77.878 0.000327066 0.095865 6
55506 81810.723 0.003575463 77.990 0.000310175 0.097981 6
55506 82008.717 0.003563863 78.032 0.000290171 0.092851 6
55506 82075.716 0.003460594 78.046 0.000273875 0.086991 6
55506 82139.716 0.003368641 78.059 0.000258241 0.081500 6
55506 82664.716 0.003331264 78.163 0.000241923 0.084677 6
55506 83058.716 0.003307356 78.240 0.000226456 0.083834 6
55506 83321.717 0.003079668 78.289 0.000226611 0.080255 6
55506 83452.716 0.002969860 78.312 0.000215501 0.075518 6
55506 83517.717 0.002958930 78.323 0.000201620 0.070757 6
55506 83646.716 0.002923137 78.346 0.000189022 0.066662 6
55506 84169.717 0.002828842 78.434 0.000179929 0.069717 6
55506 84233.716 0.002829801 78.445 0.000168310 0.065326 6
55506 84299.716 0.002810263 78.456 0.000157591 0.061232 6
55506 84823.716 0.002667552 78.539 0.000155809 0.064407 6
55506 85146.716 0.002627148 78.590 0.000146444 0.062845 6
55506 85601.716 0.002466953 78.657 0.000148233 0.063367 6
55506 86006.716 0.002419676 78.715 0.000139663 0.062769 6
55506 86122.717 0.002411172 78.732 0.000130677 0.059010 6
55506 86188.716 0.002383291 78.741 0.000122634 0.055298 6
Under 2ms initial offset, the frequency estimate is ~8 PPM too small.
Cheers,
Dave Hart
_______________________________________________
questions mailing list
questions@lists.ntp.org
http://lists.ntp.org/listinfo/questions