From: Harlan Stenn
Date: Tue, 29 Sep 2009 02:36:59 +0000 (-0400)
Subject: Clockhop and documentation fixes from Dave Mills
X-Git-Tag: NTP_4_2_5P224~2
X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=fe2155917428d40cb53d99adb88adf2a8643da13;p=thirdparty%2Fntp.git
Clockhop and documentation fixes from Dave Mills
bk: 4ac172cbIdfmhqwM70mmsljCqSLLyg
---
diff --git a/ChangeLog b/ChangeLog
index ab10375f4..34f51daa3 100644
--- 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
* [Bug 1321] build doesn't work if . isn't on $PATH.
* [Bug 1323] Implement "revoke #" to match documentation, deprecate
diff --git a/html/confopt.html b/html/confopt.html
index 769d06f52..6051ced85 100644
--- a/html/confopt.html
+++ b/html/confopt.html
@@ -12,9 +12,7 @@
Walt Kelly
The chicken is getting configuration advice.
Last update:
-
- July
- 5, 2008
+ 24-Sep-2009 16:12
Related Links
diff --git a/html/copyright.html b/html/copyright.html
index 6043a4746..a49e5d186 100644
--- a/html/copyright.html
+++ b/html/copyright.html
@@ -10,8 +10,11 @@
Copyright Notice
-
"Clone me," says Dolly sheepishly.Last update: 15:19 UTC Sunday, March 02, 2008
-
+
"Clone me," says Dolly sheepishly.
+ Last update:
+ 24-Sep-2009 16:04
+ UTC
+
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.
@@ -73,6 +76,7 @@
Tom Moore <tmoore@fievel.daytonoh.ncr.com> i386 svr4 port
Kamal A Mostafa <kamal@whence.com> SCO OpenServer port
Derek Mulcahy <derek@toybox.demon.co.uk> and Damon Hart-Davis <d@hd.org> ARCRON MSF clock driver
+ Rob Neal <neal@ntp.org> Bancomm refclock and config/parse code maintenance
Rainer Pruy <Rainer.Pruy@informatik.uni-erlangen.de> monitoring/trap scripts, statistics file handling
Dirce Richards <dirce@zk3.dec.com> Digital UNIX V4.0 port
Wilfredo Sánchez <wsanchez@apple.com> added support for NetInfo
@@ -87,8 +91,7 @@
Tomoaki TSURUOKA <tsuruoka@nc.fukuoka-u.ac.jp>TRAK clock driver
Paul A Vixie <vixie@vix.com> TrueTime GPS driver, generic TrueTime clock driver
Ulrich Windl <Ulrich.Windl@rz.uni-regensburg.de> corrected and validated HTML documents according to the HTML DTD
- Rob Neal <neal@ntp.org> Bancomm refclock and config/parse code maintenance
-
+
diff --git a/html/decode.html b/html/decode.html
index c3b5d3f14..3cf1952f5 100644
--- a/html/decode.html
+++ b/html/decode.html
@@ -13,7 +13,7 @@
Caterpillar knows all the error codes, which is more than most of us do.
Last update:
-11-Jul-2009 20:34
+24-Sep-2009 1:31
UTC
@@ -278,6 +278,11 @@ UTC
stale leapsecond values |
new NIST leapseconds file needed |
+
+| 10 |
+clockhop |
+spurious clock hop suppressed |
+
diff --git a/html/miscopt.html b/html/miscopt.html
index 83afe6c33..2ff8e77e9 100644
--- a/html/miscopt.html
+++ b/html/miscopt.html
@@ -13,7 +13,7 @@
from Pogo, Walt Kelly
We have three, now looking for more.
Last update:
- 10-Sep-2009 20:11
+ 25-Sep-2009 20:39
UTC
Related Links
@@ -107,7 +107,12 @@
minclock minclock
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.
mindist mindistance
- 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.
+ 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.
minsane minsane
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 minclock.
orphan stratum
diff --git a/include/ntp.h b/include/ntp.h
index f3e06078a..97c03ccb3 100644
--- a/include/ntp.h
+++ b/include/ntp.h
@@ -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
diff --git a/libntp/statestr.c b/libntp/statestr.c
index fcb2c121e..cc6d23c77 100644
--- a/libntp/statestr.c
+++ b/libntp/statestr.c
@@ -128,6 +128,7 @@ struct codestring sys_codes[] = {
{ EVNT_KERN, "kern" },
{ EVNT_TAI, "TAI" },
{ EVNT_LEAPVAL, "stale_leapsecond_values" },
+ { EVNT_CLKHOP, "clockhop" },
{ -1, "" }
};
diff --git a/ntpd/ntp_config.c b/ntpd/ntp_config.c
index 2d353874d..0a2e58c3f 100644
--- a/ntpd/ntp_config.c
+++ b/ntpd/ntp_config.c
@@ -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);
diff --git a/ntpd/ntp_proto.c b/ntpd/ntp_proto.c
index ce7270674..fbdb61bec 100644
--- a/ntpd/ntp_proto.c
+++ b/ntpd/ntp_proto.c
@@ -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;