{ CP_FILTERROR, RO, "filtdisp=" }, /* 34 */
{ CP_FLASH, RO, "flash" }, /* 35 */
{ CP_TTL, RO, "ttl" }, /* 36 */
- { CP_RANK, RO, "rank" }, /* 37 */
- { CP_VARLIST, RO, "peer_var_list" }, /* 38 */
+ { CP_VARLIST, RO, "peer_var_list" }, /* 37 */
#ifdef OPENSSL
- { CP_FLAGS, RO, "flags" }, /* 39 */
- { CP_HOST, RO, "hostname" }, /* 40 */
- { CP_VALID, RO, "valid" }, /* 41 */
- { CP_INITSEQ, RO, "initsequence" }, /* 42 */
- { CP_INITKEY, RO, "initkey" }, /* 43 */
- { CP_INITTSP, RO, "timestamp" }, /* 44 */
- { CP_DIGEST, RO, "signature" }, /* 45 */
- { CP_IDENT, RO, "identity" }, /* 46 */
+ { CP_FLAGS, RO, "flags" }, /* 38 */
+ { CP_HOST, RO, "hostname" }, /* 39 */
+ { CP_VALID, RO, "valid" }, /* 40 */
+ { CP_INITSEQ, RO, "initsequence" }, /* 41 */
+ { CP_INITKEY, RO, "initkey" }, /* 42 */
+ { CP_INITTSP, RO, "timestamp" }, /* 43 */
+ { CP_DIGEST, RO, "signature" }, /* 44 */
+ { CP_IDENT, RO, "identity" }, /* 45 */
#endif /* OPENSSL */
- { 0, EOV, "" } /* 39/47 */
+ { 0, EOV, "" } /* 38/46 */
};
ctl_putuint(peer_var[CP_UNREACH].text, peer->unreach);
break;
- case CP_RANK:
- ctl_putuint(peer_var[CP_RANK].text, peer->rank);
- break;
-
case CP_TIMER:
ctl_putuint(peer_var[CP_TIMER].text,
peer->nextdate - current_time);
l_fp sys_authdelay; /* authentication delay */
static u_long sys_authdly[2]; /* authentication delay shift reg */
static u_char leap_consensus; /* consensus of survivor leap bits */
-static double sys_mindist = MINDISTANCE; /* selection floor (s) */
+static double sys_mindist = MINDISTANCE; /* selection threshold (s) */
static double sys_maxdist = MAXDISTANCE; /* selection ceiling (s) */
double sys_jitter; /* system jitter (s) */
keyid_t sys_private; /* private value for session seed */
/*
* TOS and multicast mapping stuff
*/
-int sys_floor = 1; /* cluster stratum floor */
-int sys_ceiling = STRATUM_UNSPEC; /* cluster stratum ceiling*/
+int sys_floor = 0; /* cluster stratum floor */
+int sys_ceiling = STRATUM_UNSPEC; /* cluster stratum ceiling */
int sys_minsane = 1; /* minimum candidates */
int sys_minclock = NTP_MINCLOCK; /* minimum survivors */
int sys_cohort = 0; /* cohort switch */
dst[i] = MAXDISPERSE;
else if (peer->update - peer->filter_epoch[j] >
allan_xpt)
- dst[i] = MAXDISTANCE + peer->filter_disp[j];
+ dst[i] = sys_maxdist + peer->filter_disp[j];
else
dst[i] = peer->filter_delay[j];
ord[i] = j;
/*
* Copy the index list to the association structure so ntpq
* can see it later. Prune the distance list to samples less
- * than MAXDISTANCE, but keep at least two valid samples for
+ * than max distance, but keep at least two valid samples for
* jitter calculation.
*/
m = 0;
for (i = 0; i < NTP_SHIFT; i++) {
peer->filter_order[i] = (u_char) ord[i];
if (dst[i] >= MAXDISPERSE || (m >= 2 && dst[i] >=
- MAXDISTANCE))
+ sys_maxdist))
continue;
m++;
}
/*
* The order metric is formed from the stratum times
- * MAXDISTANCE (1.) plus the root distance. It strongly
+ * max distance (1.) plus the root distance. It strongly
* favors the lowest stratum, but a higher stratum peer
* can capture the clock if the low stratum dominant
* hasn't been heard for awhile.
*/
- d = peer->stratum;
- if (d < sys_floor)
- d += sys_floor;
- if (d > sys_ceiling)
- d = STRATUM_UNSPEC;
- d = root_distance(peer) + d * MAXDISTANCE;
+ d = root_distance(peer) + peer->stratum * sys_maxdist;
d *= 1. - peer->hyst;
if (j >= NTP_MAXCLOCK) {
if (d >= synch[j - 1])
for (k = j; k > 0; k--) {
if (d >= synch[k - 1])
break;
+
peer_list[k] = peer_list[k - 1];
error[k] = error[k - 1];
synch[k] = synch[k - 1];
* Manycast is sooo complicated.
*/
leap_consensus = 0;
+ typesystem = peer_list[0];
for (i = nlist - 1; i >= 0; i--) {
peer = peer_list[i];
leap_consensus |= peer->leap;
peer->status = CTL_PST_SEL_SYNCCAND;
- peer->rank++;
- peer->flags |= FLAG_SYSPEER;
- if (peer->stratum >= sys_floor && osurv >= sys_minclock)
- peer->hyst = HYST;
- else
- peer->hyst = 0;
- if (peer->stratum <= sys_ceiling)
- sys_survivors++;
+ sys_survivors++;
if (peer->flags & FLAG_PREFER)
sys_prefer = peer;
#ifdef REFCLOCK
if (peer->refclktype == REFCLK_ATOM_PPS)
sys_pps = peer;
#endif /* REFCLOCK */
-
- /*
- * If this is the old system peer and it's stratum is
- * the same as the head of the list, don't hop the
- * clock.
- */
- if (peer == osys_peer && peer->stratum ==
- peer_list[0]->stratum)
- typesystem = peer;
+#if DEBUG
+ if (debug > 1)
+ printf("cluster: survivor %s metric %.6f hyst %.6f\n",
+ ntoa(&peer_list[i]->srcadr), synch[i],
+ peer_list[i]->hyst);
+#endif
}
/*
* Mitigation rules of the game. There are several types of
* peers that can be selected here: (1) prefer peer (flag
* FLAG_PREFER) (2) pps peers (type REFCLK_ATOM_PPS), (3) the
- * existing system peer, if any, and (4) the head of the
- * survivor list. Note that only one peer can be declared
- * prefer. Note that all of these must be at the lowest stratum,
- * i.e., the stratum of the head of the survivor list.
+ * existing system peer, if any, and (3) the head of the
+ * survivor list.
*/
if (sys_prefer) {
} else {
/*
- * If a system peer has been identified, choose it;
- * otherwise choose the head of the survivor list.
+ * Otherwise, choose the head of the survivor list.
*/
- if (typesystem)
- sys_peer = typesystem;
- else
- sys_peer = peer_list[0];
+ sys_peer = peer_list[0];
sys_peer->status = CTL_PST_SEL_SYSPEER;
- sys_peer->rank++;
clock_combine(peer_list, nlist);
sys_jitter = SQRT(SQUARE(sys_peer->jitter) +
SQUARE(sys_jitter));
sys_offset);
#endif
}
+
+ /*
+ * We have found the alpha male. Mark its scent and ding the
+ * anticlockhop hysteresis.
+ */
+ sys_peer->flags |= FLAG_SYSPEER;
+ if (osurv >= sys_minclock)
+ sys_peer->hyst = HYST;
+ else
+ sys_peer->hyst = 0;
if (osys_peer != sys_peer) {
char *src;
* Determine if the peer is unfit for synchronization
*
* A peer is unfit for synchronization if
- * > unreachable or bad leap or bad stratum or noselect
+ * > unreachable or bad leap ornoselect
+ * > stratum below the floor or at or above the ceiling
* > root distance exceeded
* > a synchronization loop would form
*/
{
int rval = 0;
- peer->flash &= ~(TEST11 | TEST12 | TEST13);
+ peer->flash &= ~(TEST11 | TEST12 | TEST13 | TEST14);
if (!peer->reach || peer->leap == LEAP_NOTINSYNC ||
peer->stratum >= STRATUM_UNSPEC || peer->flags &
FLAG_NOSELECT)
rval |= TEST13; /* unfit */
+ if (peer->stratum < sys_floor || peer->stratum >= sys_ceiling)
+ rval |= TEST14; /* stratum out of bounds */
+
if (root_distance(peer) >= sys_maxdist + clock_phi *
ULOGTOD(sys_poll))
rval |= TEST11; /* distance exceeded */