You are here: Foswiki>Cosmo Web>RadioT4>RadioT4TimingTenMs (revision 6)EditAttach
<< WebHome


Can ntp be used to keep time accurate to within 10ms ?

Initial analysis

  • It seems that a default debian/etch install: aptitude install ntp ntpdate gives a good default configuration that indirectly contacts a large pool of "stratum 1" ntp servers, e.g. icm.edu.pl which seems to have an atomic clock, and that the precision should be sufficient
    • ignore ntp-server, ntp-simple
    • optionally install ntp-doc
  • By installing ntp, the daemon ntpd will automatically be started. Do not try to run ntpdate by hand or with cron, since it should be disabled anyway, since the daemon is running.
    • There is a daily cron job installed with the daemon package (ntp), but all it does is rotate the log files (instead of logrotate :P). You can edit /etc/cron.daily/ntp in order to keep a much longer backlog of logs - the default is just the last 7 days.
  • The typical polling interval of remote ntp servers appears to be about 15-20 minutes on 3 different machines.
  • The absolute offsets were a little less than 10ms for the last 7 days on all 3 machines.
  • The ntp algorithm in general seems to be quite intelligent, using heuristic models to overcome various real-time problems such as occasional network congestion, individual server failure, and the hardware characteristics of localhost.
  • 2008.10.20 to 2008.10.28 on simulation machine: ntp_offset_20081020_20081028_bell.png: ntp_offset_20081020_20081028_bell.png

algorithm

From ntpd/ntp_loopfilter.c (ntp-4.2.2.p4+dfsg):
 * This is an implementation of the clock discipline algorithm described
 * in UDel TR 97-4-3, as amended. It operates as an adaptive parameter,
 * hybrid phase/frequency-lock loop. A number of sanity checks are
 * included to protect against timewarps, timespikes and general mayhem.
 * All units are in s and s/s, unless noted otherwise.

What offsets plotted above and below? What info is listed in peerstats ?

Unless otherwise noted here, these are column 5 of /etc/log/ntpstats/peerstats* in lines which have the status code 9614.

  • slightly old description from SUN: http://www.sun.com/blueprints/0901/NTPpt3.pdf
    • page 15 states "The fifth field in the peerstat output shows estimated offset to that particular host (in seconds), which represents how far the client's clock appears to be off that of the listed server."
    • From ntpd/ntp_util.c it looks like the eighth field (not mentioned in NTPpt3.pdf) is the skew.

source ntp-4.2.2.p4+dfsg

  • ntpd/ntp_util.c
     
            record_loop_stats(
            double  offset,
            double  freq,
            double  jitter,
            double  stability,
            int spoll
            )
    {
      ...
             if (peerstats.fp != NULL) {
                    fprintf(peerstats.fp,
                        "%lu %s %s %x %.9f %.9f %.9f %.9f\n",
                        day, ulfptoa(&now, 3), stoa(addr), status, offset,
                        delay, dispersion, skew);
                    fflush(peerstats.fp);
            }
          
  • ntpd/ntp_loopfilter.c
grep -n record_loop ntpd/ntp_loopfilter.c
245:            record_loop_stats(fp_offset, drift_comp, clock_jitter,
291:            record_loop_stats(fp_offset, drift_comp, clock_jitter,
755:    record_loop_stats(clock_offset, drift_comp, clock_jitter,

possible parameters to play with

config files

  • /etc/defaults/ntp
    • Maybe add -N To the extent permitted by the operating system, run the ntpd at the highest priority. ?
  • /etc/ntp.conf
    • minpoll, maxpoll - increase frequency of "polling" servers?
      • replace server [0123].debian.pool.ntp.org iburst by server [0123].debian.pool.ntp.org iburst minpoll 6 maxpoll 8 = 1 to 4 minutes instead of the default 1 to 17 minutes ?
        • this seems to be effective - see below

source files - recompile

  • include/ntp.h
    • Clock filter algorithm tuning parameters ?
    • Selection algorithm tuning parameters ?
      • decrease: #define MINDISPERSE .005 /* min dispersion increment */ ?

maxpoll 8 in ntp.conf

statistics on simulation machine: 8 days with maxpoll 10 and 2 days with maxpoll 8

The setting maxpoll 8 means max polling interval is 2^8 \mbox{s} = 256 \mbox{s} \approx 4 \mbox{minutes}, maxpoll 10 (debian/etch default) means about 16 minutes max polling interval. Two plots of the same data - offsets from the server which at that moment is chosen as the synchronisation server - with different vertical scales:

ntp_offset_20081020_20081102.png ntp_offset_20081020_20081102_2ms.png

At each polling interval, several servers are contacted. A complex algorithm is used to choose among these and decide which server is most reliable/precise. In practice, the chosen server can remain stable for many hours or days.

Statistics of these offsets in units of 300 km (a.k.a. 1 ms):

maxpoll approx. test duration (d) min max mean s.d. rms
10 8 -4.51 7.76 -0.42 1.55 1.61
8 4 -21.48 7.59 -0.54 2.24 2.31
8 exclude 2.4h spike 3.9 -3.48 1.93 -0.28 0.59 0.65

The third line excludes the 2.4 hour spike from 10.32 days to 10.42 days. The largest offset during the 2.4h spike was -21.5 ms.

In the interval 8.5 to 9.4 days, some experimentation was going on, so this period should be ignored.

TODO

Does this 10ms limit remain valid during intense simulated telescope usage?

  • Monitor this!

Check that all is OK after aptitude update/upgrade

  • Seems fine after upgrade.

-- BoudRoukema - 28 Oct 2008
Topic attachments
I Attachment Action Size Date Who Comment
a499c61355ac1135bbeb89a118b4985a.pngpng a499c61355ac1135bbeb89a118b4985a.png manage 0.7 K 31 Oct 2008 - 13:49 UnknownUser  
ntp_offset_20081020_20081028_bell.pngpng ntp_offset_20081020_20081028_bell.png manage 2.0 K 28 Oct 2008 - 22:56 BoudRoukema  
ntp_offset_20081020_20081031.pngpng ntp_offset_20081020_20081031.png manage 2.2 K 31 Oct 2008 - 13:45 BoudRoukema  
ntp_offset_20081020_20081031_2ms.pngpng ntp_offset_20081020_20081031_2ms.png manage 2.5 K 31 Oct 2008 - 13:45 BoudRoukema  
ntp_offset_20081020_20081102.pngpng ntp_offset_20081020_20081102.png manage 2.2 K 02 Nov 2008 - 22:06 BoudRoukema  
ntp_offset_20081020_20081102_2ms.pngpng ntp_offset_20081020_20081102_2ms.png manage 2.6 K 02 Nov 2008 - 22:07 BoudRoukema  
ntp_peerstats_offset_20081029_5h_maxpoll8.pngpng ntp_peerstats_offset_20081029_5h_maxpoll8.png manage 1.0 K 29 Oct 2008 - 15:51 BoudRoukema this is just a very short sample, it should be replaced later on
Edit | Attach | Print version | History: r15 | r7 < r6 < r5 < r4 | Backlinks | View wiki text | Edit WikiText | More topic actions...
Topic revision: r6 - 02 Nov 2008, BoudRoukema
 
This site is powered by FoswikiCopyright © CC-BY-SA by the contributing authors. All material on this collaboration platform is copyrighted under CC-BY-SA by the contributing authors unless otherwise noted.
Ideas, requests, problems regarding Foswiki? Send feedback