#define CLOCK_PANIC 1000. /* default panic threshold (s) */
#define CLOCK_PHI 15e-6 /* max frequency error (s/s) */
#define CLOCK_PLL 16. /* PLL loop gain (log2) */
-#define CLOCK_FLL (NTP_MAXPOLL + 1.) /* FLL loop gain */
-#define CLOCK_AVG 4. /* parameter averaging constant */
+#define CLOCK_AVG 8. /* parameter averaging constant */
+#define CLOCK_FLL (NTP_MAXPOLL + CLOCK_AVG) /* FLL loop gain */
#define CLOCK_ALLAN 1500. /* compromise Allan intercept (s) */
#define CLOCK_DAY 86400. /* one day in seconds (s) */
#define CLOCK_LIMIT 30 /* poll-adjust threshold */
/*
* The FLL and PLL frequency gain constants
* depend on the poll interval and Allan
+ * intercept. The PLL is always used, but
+ * becomes ineffective above the Allan
* intercept. The FLL is not used below one-half
* the Allan intercept. Above that the loop gain
* increases in steps to 1 / CLOCK_AVG.
*/
if (ULOGTOD(sys_poll) > allan_xpt / 2) {
dtemp = CLOCK_FLL - sys_poll;
- if (dtemp < CLOCK_AVG)
- dtemp = CLOCK_AVG;
flladj = (fp_offset - last_base -
clock_offset) /
(max(mu, allan_xpt) * dtemp);
register struct pkt *pkt; /* receive packet pointer */
int hisversion; /* packet version */
int hismode; /* packet mode */
+ int hisstratum; /* packet stratum */
int restrict_mask; /* restrict bits */
int has_mac; /* length of MAC field */
int authlen; /* offset of MAC field */
pkt = &rbufp->recv_pkt;
hisversion = PKT_VERSION(pkt->li_vn_mode);
hismode = (int)PKT_MODE(pkt->li_vn_mode);
+ hisstratum = PKT_TO_STRATUM(pkt->stratum);
if (hismode == MODE_PRIVATE) {
if (restrict_mask & RES_NOQUERY) {
sys_restricted++;
return; /* not enabled */
}
+ /*
+ * Do not respond if the stratum is below the floor or
+ * at or above the ceiling.
+ */
+ if (hisstratum < sys_floor || hisstratum >= sys_ceiling)
+ return;
+
/*
* Do not respond if our time is worse than the
* manycaster or it has already synchronized to us.
*/
- if (sys_peer == NULL || PKT_TO_STRATUM(pkt->stratum) <
- sys_stratum || (sys_cohort &&
- PKT_TO_STRATUM(pkt->stratum) == sys_stratum) ||
+ if (sys_peer == NULL || hisstratum < sys_stratum ||
+ (sys_cohort && hisstratum) == sys_stratum ||
rbufp->dstadr->addr_refid == pkt->refid)
return; /* no help */
(RES_NOPEER | RES_DONTTRUST)), is_authentic))
return; /* bad auth */
+ /*
+ * Do not respond if the stratum is below the floor or
+ * at or above the ceiling.
+ */
+ if (hisstratum < sys_floor || hisstratum >= sys_ceiling)
+ return;
+
switch (sys_bclient) {
/*
restrict_mask);
return; /* hooray */
}
+
+ /*
+ * Do not respond if the stratum is below the floor or
+ * at or above the ceiling.
+ */
+ if (hisstratum < sys_floor || hisstratum >= sys_ceiling)
+ return;
+
if ((peer = newpeer(&rbufp->recv_srcadr,
rbufp->dstadr, MODE_PASSIVE, hisversion,
NTP_MINDPOLL, NTP_MAXDPOLL, 0, MDF_UCAST, 0,
} else if (!strncmp(tbuf, "SR", 2)) {
strcpy(up->status, tbuf + 2);
- if (pp->sloppyclockflag & CLK_FLAG4) {
+ if (pp->sloppyclockflag & CLK_FLAG4)
write(pp->io.fd, "LA", 2);
- return;
- } else {
+ else
write(pp->io.fd, "B5", 2);
- }
+ return;
+
} else if (!strncmp(tbuf, "LA", 2)) {
strcpy(up->latlon, tbuf + 2);
write(pp->io.fd, "LO", 2);
*/
if (!refclock_process(pp))
refclock_report(peer, CEVNT_BADTIME);
+ else if (peer->disp > MAXDISTANCE)
+ refclock_receive(peer);
if (up->tcswitch >= ARBSTAGE) {
write(pp->io.fd, "B0", 2);
}
struct timespec timeout, ts;
long sec, nsec;
double dtemp;
+ char tbuf[80]; /* monitor buffer */
/*
* Convert the timespec nanoseconds field to signed double and
* PPS clock advanced three or more times, either the signal has
* failed for a number of seconds or we have runts, in which
* case just ignore them.
+ *
+ * If flag4 is lit, record each second offset to clockstats.
+ * That's so we can make awesome Allan deviation plots.
*/
sec = ts.tv_sec - up->ts.tv_sec;
nsec = ts.tv_nsec - up->ts.tv_nsec;
ts.tv_nsec -= NANOSECOND;
dtemp = -(double)ts.tv_nsec / NANOSECOND;
SAMPLE(dtemp + pp->fudgetime1);
+ if (pp->sloppyclockflag & CLK_FLAG4){
+ sprintf(tbuf, "%.9f", dtemp);
+ record_clock_stats(&peer->srcadr, tbuf);
+ }
#ifdef DEBUG
if (debug > 1)
printf("atom_timer: %lu %f %f\n", current_time,
*/
if (!refclock_process(pp))
refclock_report(peer, CEVNT_BADTIME);
-
+ else if (peer->disp > MAXDISTANCE)
+ refclock_receive(peer);
}
*/
if (!refclock_process(pp))
refclock_report(peer, CEVNT_BADTIME);
+ if (peer->disp > MAXDISTANCE)
+ refclock_receive(peer);
}