[ntp:questions] Loop Frequency and Offset

Miguel Gonçalves mail at miguelgoncalves.com
Mon Sep 26 13:29:42 UTC 2011


[Sorry for such a long message]

Hi David!

On 25 September 2011 20:55, David Woolley <david at ex.djwhome.demon.invalid>wrote:

> Miguel Gonçalves wrote:
>
>>
>> I have a machine running FreeBSD 7.4 and it seems that the CPU clock runs
>> too fast or slow (positive offset in loopstats is fast or slow?).
>>
>
> Neither.  A constant sign on an offset is an indication that something is
> broken, either the algorithm, or the static frquency error exceeds 500ppm.
>  Offsets should be normally distributed around 0.  Well, maybe not a normal
> distribution, but certainly they should be both sides of zero.


OK. Understood. I fiddled with the machdep.tsc_freq sysctl variable it it
seems to work the other way around. I am a bit confused. Please see
bellow...


>  The frequency is too high it seems. Since this is a software clock can
>> this
>> be changed to get a lower frequency and thus a smaller offset?
>>
>
> tickadj can be used to make 100ppm steps, but if the clock is out by more
> then 500ppm, something is broken, and it would be better to fix it.
>

On FreeBSD I followed the recommendation in
http://www.ntp.org/ntpfaq/NTP-s-trbl-general.htm#Q-CORRECT-TICK and changed
the machdep.tsc_freq sysctl variable like this (I am documenting it here for
the future reference of others who might have this problem).

So... I was getting around 180 ppm frequency offset in /etc/ntp.drift and
this value also appeared in loopstats file.

I checked the machdep.tsc_freq value (this is estimated at boot but can be
changed after the boot completes):

tick# sysctl machdep.tsc_freq
machdep.tsc_freq: 498053689

Now... if the clock is running 180 ppm fast (I assumed slower and the result
was the opposite i.e. it ran even faster) I have to decrease the frequency
by 180 ppm:

498053689 - (498053689 * 180/1000000) = 497964040

After removing ntp.drift file and restarting NTP loopstats was still showing
0.800 ppm so I repeated the above and now I am getting this:

tick# tail -20 /var/log/ntp/loopstats ; ntpq -p; ntptime
55830 48124.307 -0.000000867 0.029 0.000002503 0.001010 10
55830 48141.308 -0.000001511 0.029 0.000000601 0.000945 10
55830 48157.308 -0.000001360 0.029 0.000000484 0.000884 10
55830 48175.324 -0.000002170 0.029 0.000000774 0.000827 10
55830 48192.309 -0.000001375 0.029 0.000000879 0.000774 10
55830 48209.315 -0.000001562 0.029 0.000001097 0.000724 10
55830 48224.315 -0.000001839 0.019 0.000000600 0.003492 10
55830 48241.315 -0.000002042 0.019 0.000000817 0.003266 10
55830 48258.316 -0.000001567 0.019 0.000000626 0.003055 10
55830 48276.311 -0.000001146 0.019 0.000002616 0.002858 10
55830 48292.307 -0.000001464 0.019 0.000000878 0.002674 10
55830 48308.312 -0.000001022 0.019 0.000000612 0.002501 10
55830 48323.313 -0.000001218 0.019 0.000000489 0.002339 10
55830 48341.309 -0.000000421 0.019 0.000001017 0.002188 10
55830 48358.313 -0.000000492 0.019 0.000000612 0.002047 10
55830 48375.309 -0.000000457 0.019 0.000000274 0.001915 10
55830 48390.309 -0.000001434 0.019 0.000000865 0.001791 10
55830 48408.311 0.000000191 0.019 0.000000716 0.001675 10
55830 48424.310 -0.000000543 0.019 0.000001052 0.001567 10
55830 48441.311 0.000000400 0.019 0.000001109 0.001466 10
     remote           refid      st t when poll reach   delay   offset
jitter
==============================================================================
*GPS_NMEA(0)     .GPS.            0 l   14   16  377    0.000    0.000
0.004
-ntp-p1.obspm.fr .TS-3.           1 u  857 1024  377   54.376    2.222
0.454
-ptbtime1.ptb.de .PTB.            1 u  500 1024  377   74.464    0.559
0.360
+ntp.inrim.it    .CTD.            1 u  839 1024  367   68.039    0.313
0.428
-ntp1.oma.be     .PPS.            1 u  860 1024  377   60.420    4.012
1.877
-canon.inria.fr  .GPSi.           1 u  872 1024  377   53.507    1.039
2.830
+time.fu-berlin. .PPS.            1 u  875 1024  373   73.133   -0.095
1.109
-chronos.csr.net .GPS.            1 u  507 1024  377   87.641   -3.010
0.317
-ntp1.nl.uu.net  .PPS.            1 u  835 1024  377   67.485    0.926
1.646
ntp_gettime() returns code 0 (OK)
  time d22afc47.a990c06c  Mon, Sep 26 2011 13:27:35.662, (.662365031),
  maximum error 7501 us, estimated error 1 us, TAI offset 0
ntp_adjtime() returns code 0 (OK)
  modes 0x0 (),
  offset -0.502 us, frequency 0.019 ppm, interval 256 s,
  maximum error 7501 us, estimated error 1 us,
  status 0x2107 (PLL,PPSFREQ,PPSTIME,PPSSIGNAL,NANO),
  time constant 10, precision 0.001 us, tolerance 496 ppm,
  pps frequency 0.019 ppm, stability 0.008 ppm, jitter 1.124 us,
  intervals 249, jitter exceeded 282, stability exceeded 1, errors 4.

In the other machine (tock) I did the same and I getting now this:

tock# tail -20 /var/log/ntp/loopstats ; ntpq -p; ntptime
55830 48250.451 -0.000001296 -0.094 0.000000888 0.002944 4
55830 48266.451 -0.000000905 -0.094 0.000000182 0.002754 4
55830 48282.451 -0.000000794 -0.094 0.000000212 0.002576 4
55830 48298.452 -0.000000449 -0.094 0.000000207 0.002410 4
55830 48314.451 0.000000281 -0.094 0.000000215 0.002254 4
55830 48330.451 0.000000608 -0.094 0.000000214 0.002109 4
55830 48346.451 0.000001087 -0.094 0.000000251 0.001972 4
55830 48362.451 0.000001379 -0.094 0.000000253 0.001845 4
55830 48378.451 0.000002010 -0.094 0.000000211 0.001726 4
55830 48394.451 0.000002238 -0.094 0.000000305 0.001614 4
55830 48410.451 0.000002088 -0.094 0.000000247 0.001510 4
55830 48426.451 0.000002797 -0.094 0.000000186 0.001413 4
55830 48442.451 0.000003081 -0.094 0.000000276 0.001321 4
55830 48458.451 0.000003151 -0.094 0.000000228 0.001236 4
55830 48474.451 0.000003002 -0.071 0.000000270 0.008500 4
55830 48490.451 0.000002718 -0.071 0.000000165 0.007951 4
55830 48506.451 0.000002455 -0.071 0.000000198 0.007438 4
55830 48522.451 0.000002080 -0.071 0.000000310 0.006957 4
55830 48538.451 0.000001546 -0.071 0.000000172 0.006508 4
55830 48554.451 0.000000867 -0.071 0.000000301 0.006088 4
     remote           refid      st t when poll reach   delay   offset
jitter
==============================================================================
oGPS_NMEA(0)     .GPS.            0 l    2   16  377    0.000    0.001
0.001
-ntp-p1.obspm.fr .TS-3.           1 u    5   64  377   53.036    1.939
0.820
+ptbtime1.ptb.de .PTB.            1 u   24   64  377   70.020   -1.242
3.459
+ntp.ien.it      .CTD.            1 u   19   64  377   66.933   -0.371
1.501
-ntp1.oma.be     .PPS.            1 u   34   64  377   59.156    3.263
1.199
-canon.inria.fr  .GPSi.           1 u    -   64  377   52.875    1.355
2.025
+time.fu-berlin. .PPS.            1 u   20   64  377   71.802   -0.643
0.554
-chronos.csr.net .GPS.            1 u   12   64  377   85.025   -4.509
1.436
-ntp1.nl.uu.net  .PPS.            1 u   20   64  377   64.314    2.501
2.028
ntp_gettime() returns code 0 (OK)
  time d22afcac.fd4088fc  Mon, Sep 26 2011 13:29:16.989, (.989266399),
  maximum error 1235 us, estimated error 0 us, TAI offset 0
ntp_adjtime() returns code 0 (OK)
  modes 0x0 (),
  offset 0.900 us, frequency -0.071 ppm, interval 256 s,
  maximum error 1235 us, estimated error 0 us,
  status 0x2107 (PLL,PPSFREQ,PPSTIME,PPSSIGNAL,NANO),
  time constant 4, precision 0.001 us, tolerance 496 ppm,
  pps frequency -0.071 ppm, stability 0.015 ppm, jitter 0.245 us,
  intervals 91, jitter exceeded 106, stability exceeded 0, errors 3.

It seems much better. I am happy! ;-)

Thanks for all your help!



More information about the questions mailing list