From: Harlan Stenn Date: Tue, 17 May 2005 05:17:18 +0000 (-0400) Subject: Stuff from Dave Mills X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d91d11e27f1bee81e9cabe47fefa30a064205463;p=thirdparty%2Fntp.git Stuff from Dave Mills bk: 42897e5eaD0aed-NFMLgy3jnq0L8IQ --- diff --git a/ntpd/ntp_loopfilter.c b/ntpd/ntp_loopfilter.c index d7508c9799..222679f619 100644 --- a/ntpd/ntp_loopfilter.c +++ b/ntpd/ntp_loopfilter.c @@ -39,8 +39,8 @@ #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 */ @@ -446,14 +446,14 @@ local_clock( /* * 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); diff --git a/ntpd/ntp_proto.c b/ntpd/ntp_proto.c index 7a4f34c472..7e7e3476ce 100644 --- a/ntpd/ntp_proto.c +++ b/ntpd/ntp_proto.c @@ -279,6 +279,7 @@ receive( 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 */ @@ -332,6 +333,7 @@ receive( 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++; @@ -656,13 +658,19 @@ receive( 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 */ @@ -725,6 +733,13 @@ receive( (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) { /* @@ -808,6 +823,14 @@ receive( 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, diff --git a/ntpd/refclock_arbiter.c b/ntpd/refclock_arbiter.c index 6162bc4345..334ee10549 100644 --- a/ntpd/refclock_arbiter.c +++ b/ntpd/refclock_arbiter.c @@ -267,12 +267,12 @@ arb_receive( } 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); @@ -397,6 +397,8 @@ arb_receive( */ 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); } diff --git a/ntpd/refclock_atom.c b/ntpd/refclock_atom.c index 3070d3d618..e5663aca53 100644 --- a/ntpd/refclock_atom.c +++ b/ntpd/refclock_atom.c @@ -334,6 +334,7 @@ atom_timer( struct timespec timeout, ts; long sec, nsec; double dtemp; + char tbuf[80]; /* monitor buffer */ /* * Convert the timespec nanoseconds field to signed double and @@ -377,6 +378,9 @@ atom_timer( * 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; @@ -403,6 +407,10 @@ atom_timer( 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, diff --git a/ntpd/refclock_pst.c b/ntpd/refclock_pst.c index 2443b2ca9c..776e28eaf4 100644 --- a/ntpd/refclock_pst.c +++ b/ntpd/refclock_pst.c @@ -269,7 +269,8 @@ pst_receive( */ if (!refclock_process(pp)) refclock_report(peer, CEVNT_BADTIME); - + else if (peer->disp > MAXDISTANCE) + refclock_receive(peer); } diff --git a/ntpd/refclock_wwvb.c b/ntpd/refclock_wwvb.c index e0d2903bc1..c2452c92da 100644 --- a/ntpd/refclock_wwvb.c +++ b/ntpd/refclock_wwvb.c @@ -372,6 +372,8 @@ wwvb_receive( */ if (!refclock_process(pp)) refclock_report(peer, CEVNT_BADTIME); + if (peer->disp > MAXDISTANCE) + refclock_receive(peer); }