]> git.ipfire.org Git - thirdparty/ntp.git/commitdiff
Clockhop and documentation fixes from Dave Mills
authorHarlan Stenn <stenn@ntp.org>
Tue, 29 Sep 2009 02:36:59 +0000 (22:36 -0400)
committerHarlan Stenn <stenn@ntp.org>
Tue, 29 Sep 2009 02:36:59 +0000 (22:36 -0400)
bk: 4ac172cbIdfmhqwM70mmsljCqSLLyg

ChangeLog
html/confopt.html
html/copyright.html
html/decode.html
html/miscopt.html
include/ntp.h
libntp/statestr.c
ntpd/ntp_config.c
ntpd/ntp_proto.c

index ab10375f4038be6e2a51aee03c084c6054331f74..34f51daa33919bdf3394bb390e3cb434bf4b5453 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,4 @@
+* Clockhop and documentation fixes from Dave Mills.
 (4.2.5p223) 2009/09/28 Released by Harlan Stenn <stenn@ntp.org>
 * [Bug 1321] build doesn't work if . isn't on $PATH.
 * [Bug 1323] Implement "revoke #" to match documentation, deprecate
index 769d06f52aede958f7f4e1059885f545ec2a5f84..6051ced85a0e09d57e0a7a85df9f818f0b9f12d8 100644 (file)
@@ -12,9 +12,7 @@
 Walt Kelly</a>
 <p>The chicken is getting configuration advice.</p>
 <p>Last update:
-       <csobj format="ShortTime" h="25" locale="00000409" region="0" t="DateTime" w="61"></csobj>
-       <csobj format="LongDate" h="25" locale="00000409" region="0" t="DateTime" w="250"> July
-               5, 2008</csobj>
+       <!-- #BeginDate format:En2m -->24-Sep-2009  16:12<!-- #EndDate -->
 </p>
 <br clear="left">
 <h4>Related Links</h4>
index 6043a4746b4084839375470b0f6ba65ba4a1dead..a49e5d18652089fb93c145ae14945a6e97633045 100644 (file)
 
        <body>
                <h3>Copyright Notice</h3>
-               <img src="pic/sheepb.jpg" alt="jpg" align="left"> &quot;Clone me,&quot; says Dolly sheepishly.<p>Last update: <csobj format="ShortTime" h="25" locale="00000409" region="0" t="DateTime" w="61">15:19</csobj> UTC <csobj format="LongDate" h="25" locale="00000409" region="0" t="DateTime" w="250">Sunday, March 02, 2008</csobj></p>
-               <br clear="left">
+               <img src="pic/sheepb.jpg" alt="jpg" align="left"> &quot;Clone me,&quot; says Dolly sheepishly.
+               <p>Last update:
+                       <!-- #BeginDate format:En2m -->24-Sep-2009  16:04<!-- #EndDate --> 
+               UTC</csobj></p>
+<br clear="left">
                <hr>
                <p>The following copyright notice applies to all files collectively called the Network Time Protocol Version 4 Distribution. Unless specifically declared otherwise in an individual file, this notice applies as if the text was explicitly included in the file.</p>
                <pre>
@@ -73,6 +76,7 @@
                        <li class="inline"><a href="mailto:%20tmoore@fievel.daytonoh.ncr.com">Tom Moore &lt;tmoore@fievel.daytonoh.ncr.com&gt;</a> i386 svr4 port
                        <li class="inline"><a href="mailto:%20kamal@whence.com">Kamal A Mostafa &lt;kamal@whence.com&gt;</a> SCO OpenServer port
                        <li class="inline"><a href="mailto:%20derek@toybox.demon.co.uk">Derek Mulcahy &lt;derek@toybox.demon.co.uk&gt;</a> and <a href="mailto:%20d@hd.org">Damon Hart-Davis &lt;d@hd.org&gt;</a> ARCRON MSF clock driver
+                       <li class="inline"><a href="mailto:%20neal@ntp.org">Rob Neal &lt;neal@ntp.org&gt;</a> Bancomm refclock and config/parse code maintenance
                        <li class="inline"><a href="mailto:%20Rainer.Pruy@informatik.uni-erlangen.de">Rainer Pruy &lt;Rainer.Pruy@informatik.uni-erlangen.de&gt;</a> monitoring/trap scripts, statistics file handling
                        <li class="inline"><a href="mailto:%20dirce@zk3.dec.com">Dirce Richards &lt;dirce@zk3.dec.com&gt;</a> Digital UNIX V4.0 port
                        <li class="inline"><a href="mailto:%20wsanchez@apple.com">Wilfredo S&aacute;nchez &lt;wsanchez@apple.com&gt;</a> added support for NetInfo
@@ -87,8 +91,7 @@
                        <li class="inline"><a href="mailto:%20tsuruoka@nc.fukuoka-u.ac.jp">Tomoaki TSURUOKA &lt;tsuruoka@nc.fukuoka-u.ac.jp&gt;</a>TRAK clock driver
                        <li class="inline"><a href="mailto:%20vixie@vix.com">Paul A Vixie &lt;vixie@vix.com&gt;</a> TrueTime GPS driver, generic TrueTime clock driver
                        <li class="inline"><a href="mailto:%20Ulrich.Windl@rz.uni-regensburg.de">Ulrich Windl &lt;Ulrich.Windl@rz.uni-regensburg.de&gt;</a> corrected and validated HTML documents according to the HTML DTD
-                       <li class="inline"><a href="mailto:%20neal@ntp.org">Rob Neal &lt;neal@ntp.org&gt;</a> Bancomm refclock and config/parse code maintenance
-               </ol>
+       </ol>
                <hr>
                <script type="text/javascript" language="javascript" src="scripts/footer.txt"></script>
        </body>
index c3b5d3f1416b7364b94e2e1a1d0c6568d06ff6fe..3cf1952f5f50e0e5ee1b9bb6b2201125d9ca9bc5 100644 (file)
@@ -13,7 +13,7 @@
 <p>Caterpillar knows all the error codes, which is more than most of us do.</p>
 
 <p>Last update:
-<!-- #BeginDate format:En2m -->11-Jul-2009  20:34<!-- #EndDate -->
+<!-- #BeginDate format:En2m -->24-Sep-2009  1:31<!-- #EndDate -->
 UTC</p>
 <br clear="left">
 
@@ -278,6 +278,11 @@ UTC</p>
 <td><tt>stale leapsecond values</tt></td>
 <td>new NIST leapseconds file needed</td>
 </tr>
+<tr>
+<td><tt>10</tt></td>
+<td><tt>clockhop</tt></td>
+<td>spurious clock hop suppressed</td>
+</tr>
 
 </table>
 
index 83afe6c33febaf9dc9eebc9caf747a8016e50188..2ff8e77e9d061fdb51003bdf99fe7bf27b321d34 100644 (file)
@@ -13,7 +13,7 @@
                <img src="pic/boom3.gif" alt="gif" align="left"><a href="http://www.eecis.udel.edu/~mills/pictures.html">from <i>Pogo</i>, Walt Kelly</a>
                <p>We have three, now looking for more.</p>
                <p>Last update:
-                       <!-- #BeginDate format:En2m -->10-Sep-2009  20:11<!-- #EndDate --> 
+                       <!-- #BeginDate format:En2m -->25-Sep-2009  20:39<!-- #EndDate --> 
                        UTC</p>
                <br clear="left">
        <h4>Related Links</h4>
                                        <dt><tt>minclock <i>minclock</i></tt></dt>
                                        <dd>Specify the number of servers used by the clustering algorithm as the minimum to include on the candidate list. The default is 3. This is also the number of servers to be averaged by the combining algorithm.</dd>
                                        <dt><tt>mindist <i>mindistance</i></tt></dt>
-                                       <dd>Specify the increment used by the selection algorithm to augment the correctness interval. The default is .005 s. In some cases, such as reference clocks with high jitter and a PPS signal, it is useful to increase the increment to insure the intersection interval is always nonempty.</dd>
+                                       <dd>Specify the minimum distance used by the selection and anticlockhop
+                                               algorithm. Larger values increase the tolerance for outliers;
+                                               smaller values increase the selectivity. The default is .001 s. In some
+                                               cases, such as reference clocks with high jitter and a PPS signal, it is
+                                               useful to increase the value to insure the intersection interval is
+                                               always nonempty.</dd>
                                        <dt><tt>minsane <i>minsane</i></tt></dt>
                                        <dd>Specify the number of servers used by the selection algorithm as the minimum to set the system clock. The default is 1 for legacy purposes; however, for critical applications the value should be somewhat higher but less than <tt>minclock</tt>.</dd>
                                        <dt><tt>orphan <i>stratum</i></tt></dt>
index f3e06078a5188c401020af0c36190cd66b1c3774..97c03ccb3ae895aaca1196d4037e9be6c2b84263 100644 (file)
@@ -612,6 +612,7 @@ struct pkt {
 #define        EVNT_KERN       13      /* kernel event */
 #define        EVNT_TAI        14      /* TAI */
 #define        EVNT_LEAPVAL    15      /* stale leapsecond values */
+#define        EVNT_CLKHOP     16      /* clockhop */
 
 /*
  * Peer event codes
index fcb2c121e8c93371b2d059f321b71889ebde8e4d..cc6d23c77d7e9d3d0e65f86b760d6d56d5c409fd 100644 (file)
@@ -128,6 +128,7 @@ struct codestring sys_codes[] = {
        { EVNT_KERN,            "kern" },
        { EVNT_TAI,             "TAI" },
        { EVNT_LEAPVAL,         "stale_leapsecond_values" },
+       { EVNT_CLKHOP,          "clockhop" },
        { -1,                   "" }
 };
 
index 2d353874de3de2ddf7be62b64109791f6019ecbf..0a2e58c3f0215dda8682ae83865fb674479cdfe4 100644 (file)
@@ -744,7 +744,6 @@ dump_config_tree(
                case T_Maxclock:
                case T_Minsane:
                case T_Beacon:
-               case T_Maxhop:
                        fprintf(df, " %s %d", keyword(atrv->attr),
                                (int)atrv->value.d);
                        break;
@@ -1907,10 +1906,6 @@ config_tos(
                case T_Beacon:
                        item = PROTO_BEACON;
                        break;
-
-               case T_Maxhop:
-                       item = PROTO_MAXHOP;
-                       break;
                }
                proto_config(item, 0, tos->value.d, NULL);
                tos = next_node(tos);
index ce72706741c94edb0b4b4b421b05a53adc628aaf..fbdb61becf41697a5a1f29e62c1f7b518889da9f 100644 (file)
@@ -78,7 +78,7 @@ double        sys_mindisp = MINDISPERSE; /* minimum distance (s) */
 double sys_maxdist = MAXDISTANCE; /* selection threshold */
 double sys_jitter;             /* system jitter */
 u_long         sys_epoch;              /* last clock update time */
-static int sys_maxhop = MAXHOP; /* anticlockhop threshol */
+static double sys_clockhop;    /* clockhop threshold */
 int    leap_tai;               /* TAI at next next leap */
 u_long leap_sec;               /* next scheduled leap from file */
 u_long leap_peers;             /* next scheduled leap from peers */
@@ -2149,8 +2149,15 @@ clock_filter(
         * the maximum interval between minimum samples is eight
         * packets.
         */
-       if (peer->filter_epoch[k] > peer->epoch)
-               peer->epoch = peer->filter_epoch[k];
+       if (peer->filter_epoch[k] <= peer->epoch) {
+#if DEBUG
+       if (debug)
+               printf("clock_filter: old sample %lu\n", current_time -
+                   peer->filter_epoch[k]);
+#endif
+               return;
+       }
+       peer->epoch = peer->filter_epoch[k];
 
        /*
         * The mitigated sample statistics are saved for later
@@ -2162,9 +2169,9 @@ clock_filter(
 #ifdef DEBUG
        if (debug)
                printf(
-                   "clock_filter: n %d off %.6f del %.6f dsp %.6f jit %.6f, age %lu\n",
+                   "clock_filter: n %d off %.6f del %.6f dsp %.6f jit %.6f\n",
                    m, peer->offset, peer->delay, peer->disp,
-                   peer->jitter, current_time - peer->filter_epoch[k]);
+                   peer->jitter);
 #endif
        if (peer->burst == 0 || sys_leap == LEAP_NOTINSYNC)
                clock_select();
@@ -2176,7 +2183,7 @@ clock_filter(
  *
  * LOCKCLOCK: (1) If the local clock is the prefer peer, it will always
  * be enabled, even if declared falseticker, (2) only the prefer peer
- * can be selected as the system peer, (3) if the external source is
+ * caN Be selected as the system peer, (3) if the external source is
  * down, the system leap bits are set to 11 and the stratum set to
  * infinity.
  */
@@ -2455,12 +2462,11 @@ clock_select(void)
 #endif /* REFCLOCK */
 
                /*
-                * The metric is the scaled root distance plus the peer
-                * stratum. For compliance with the specification, both
-                * values are multiplied by the select threshold.
+                * The metric is the scaled root distance at the next
+                * poll interval plus the peer stratum.
                 */
-               d = (root_distance(peer) / sys_maxdist +
-                    peer->stratum) * sys_maxdist;
+               d = (root_distance(peer) + clock_phi * (peer->nextdate -
+                   current_time)) / sys_maxdist + peer->stratum;
                if (j >= NTP_MAXASSOC) {
                        if (d >= synch[j - 1])
                                continue;
@@ -2585,7 +2591,6 @@ clock_select(void)
         * is always won.
         */
        leap_vote = 0;
-       j = 0;
        for (i = 0; i < nlist; i++) {
                peer = peer_list[i];
                peer->unreach = 0;
@@ -2597,28 +2602,45 @@ clock_select(void)
                        else 
                                leap_vote++;
                }
-               if (peer == osys_peer)
-                       j = i;
                if (peer->flags & FLAG_PREFER)
                        sys_prefer = peer;
        }
 
        /*
-        * Anticlockhop provisions. Ordinarily, use the first survivor
-        * on the survivor list, if there is one, and if there are
-        * least sys_minsane survivors. Othersie, there are no
-        * survivors. However, if the previous system peer is on the
-        * list but not first, use it if the synchronization distance
-        * is not greater than the accumulation over the last
-        * sys_maxhop * poll intervals. Do this only if there are at
-        * least one kitten in the litter.
+        * Unless there are at least sys_misane survivors, leave the
+        * building dark. Otherwise, do a clockhop dance. Ordinarily,
+        * use the first survivor on the survivor list. However, if the
+        * last selection is not first on the list, use it as long as
+        * it doesn't get too old or too ugly.
         */
        if (nlist > 0 && nlist >= sys_minsane) {
-               if (synch[j] < synch[0] + ULOGTOD(sys_poll) *
-                   sys_maxhop * clock_phi)
-                       typesystem = peer_list[j];
-               else
-                       typesystem = peer_list[0];
+               double  x;
+               char    tbuf[80];
+
+               typesystem = peer_list[0];
+               if (osys_peer == NULL || osys_peer == typesystem) {
+                       sys_clockhop = 0; 
+               } else if ((x = fabs(typesystem->offset -
+                   osys_peer->offset)) < sys_mindisp) {
+                       if (sys_clockhop == 0)
+                               sys_clockhop = sys_mindisp;
+                       else
+                               sys_clockhop *= .5;
+#ifdef DEBUG
+                       if (debug)
+                               printf("select: clockhop %d %.6f %.6f\n",
+                                   j, x, sys_clockhop);
+#endif
+                       if (fabs(x) < sys_clockhop) {
+                               typesystem = osys_peer;
+                       } else {
+                               sprintf(tbuf, "%.6f", x);
+                               report_event(EVNT_CLKHOP, NULL, tbuf);
+                               sys_clockhop = 0;
+                       }
+               } else {
+                       sys_clockhop = 0;
+               }
        }
 
        /*
@@ -3592,10 +3614,6 @@ proto_config(
                sys_ceiling = (int)dvalue;
                break;
 
-       case PROTO_MAXHOP:      /* clockhop threshold (clockhop) */
-               sys_maxhop = (int)dvalue;
-               break;
-
        case PROTO_COHORT:      /* cohort switch (cohort) */
                sys_cohort = (int)dvalue;
                break;