]> git.ipfire.org Git - thirdparty/ntp.git/commitdiff
Stuff from Dave Mills
authorHarlan Stenn <stenn@ntp.org>
Tue, 17 May 2005 05:17:18 +0000 (01:17 -0400)
committerHarlan Stenn <stenn@ntp.org>
Tue, 17 May 2005 05:17:18 +0000 (01:17 -0400)
bk: 42897e5eaD0aed-NFMLgy3jnq0L8IQ

ntpd/ntp_loopfilter.c
ntpd/ntp_proto.c
ntpd/refclock_arbiter.c
ntpd/refclock_atom.c
ntpd/refclock_pst.c
ntpd/refclock_wwvb.c

index d7508c9799158c29baea4d4f3980d5d892ff018e..222679f619ba0acbd5078b7cf97e3b30387f7ed6 100644 (file)
@@ -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);
index 7a4f34c4726a8826381adf10d82332347d04eca2..7e7e3476cef515a7e8a8d916f3ef8b5337910d9d 100644 (file)
@@ -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,
index 6162bc43455cf661f426d73bd2e51acae5d29938..334ee10549879c5fc263466cd0f741f793dca65f 100644 (file)
@@ -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);
        }
index 3070d3d618c7eb93a6e5a7aeb500b96e105eb60e..e5663aca5389f98d8d2b541d89163a85029772bd 100644 (file)
@@ -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,
index 2443b2ca9c8ac61e16467a45499ddb785d4abfd3..776e28eaf43d0df806c04542f626efb9839076fc 100644 (file)
@@ -269,7 +269,8 @@ pst_receive(
         */
        if (!refclock_process(pp))
                refclock_report(peer, CEVNT_BADTIME);
-
+       else if (peer->disp > MAXDISTANCE)
+               refclock_receive(peer);
 }
 
 
index e0d2903bc1c85e089bd78778025ef25d191d26df..c2452c92daa6efad2514a3ca3c2782b9d50ef07b 100644 (file)
@@ -372,6 +372,8 @@ wwvb_receive(
         */
        if (!refclock_process(pp))
                refclock_report(peer, CEVNT_BADTIME);
+       if (peer->disp > MAXDISTANCE)
+               refclock_receive(peer);
 }