]> git.ipfire.org Git - thirdparty/ntp.git/commitdiff
Cleanup and improvements from Dave Mills.
authorHarlan Stenn <stenn@ntp.org>
Thu, 9 Jan 2003 01:38:12 +0000 (20:38 -0500)
committerHarlan Stenn <stenn@ntp.org>
Thu, 9 Jan 2003 01:38:12 +0000 (20:38 -0500)
bk: 3e1cd2846HlLwpCE7ROEz92VWx1zMg

include/ntp.h
ntpd/ntp_loopfilter.c
ntpd/ntp_proto.c

index e8be8036f8cefa544b2544ea66f8dfe84822af7e..ae648d2705a9eaf2b6e76388f50a7919e36933a2 100644 (file)
@@ -122,7 +122,7 @@ typedef char s_char;
 #define        NTP_MINCLOCK    3       /* minimum survivors */
 #define        NTP_MAXCLOCK    10      /* maximum candidates */
 #define MAXDISTANCE    1.      /* max root distance */
-#define CLOCK_SGATE    4.      /* popcorn spike gate */
+#define CLOCK_SGATE    3.      /* popcorn spike gate */
 #define HUFFPUFF       900     /* huff-n'-puff sample interval (s) */
 #define HYST           .5      /* anti-clockhop hysteresis */
 #define HYST_TC                .875    /* anti-clockhop hysteresis decay */
index 0e4f03eae24c4fd067ff04181b672496c4ffa99d..bb2d07c745bcc7038c8afb3c9dfc61ade6e68c24 100644 (file)
@@ -40,7 +40,7 @@
 #define CLOCK_AVG      4.      /* parameter averaging constant */
 #define CLOCK_MINSEC   256.    /* min FLL update interval (s) */
 #define CLOCK_MINSTEP  900.    /* step-change timeout (s) */
-#define        CLOCK_ALLAN     3000.   /* compromise Allan intercept (s) */
+#define        CLOCK_ALLAN     1500.   /* compromise Allan intercept (s) */
 #define CLOCK_DAY      86400.  /* one day in seconds (s) */
 #define CLOCK_LIMIT    30      /* poll-adjust threshold */
 #define CLOCK_PGATE    4.      /* poll-adjust gate */
@@ -429,24 +429,22 @@ local_clock(
 
                /*
                 * We come here in the normal case for linear phase and
-                * frequency adjustments. If the offset exceeds the
-                * previous time error estimate by CLOCK_SGATE and the
-                * interval since the last update is less than twice the
-                * poll interval, consider the update a popcorn spike
-                * and ignore it.
+                * frequency adjustments. If the difference between the
+                * last offset and the current one exceeds the jitter by
+                * CLOCK_SGATE (4) and the interval since the last
+                * update is less than twice the system poll interval,
+                * consider the update a popcorn spike and ignore it..
                 */
                default:
                        allow_panic = FALSE;
-                       if (fabs(fp_offset - last_offset) >
-                           CLOCK_SGATE * oerror && mu <
+                       dtemp = fabs(fp_offset - last_offset);
+                       if (dtemp > CLOCK_SGATE * oerror && mu <
                            ULOGTOD(sys_poll + 1)) {
 #ifdef DEBUG
                                if (debug)
                                        printf(
                                    "local_clock: popcorn %.6f %.6f\n",
-                                           fabs(fp_offset -
-                                           last_offset), CLOCK_SGATE *
-                                           oerror);
+                                           dtemp, oerror);
 #endif
                                last_offset = fp_offset;
                                return (0);
@@ -457,22 +455,21 @@ local_clock(
                         * which depend on the poll interval, update
                         * interval and Allan intercept. For the FLL,
                         * the averaging interval is clamped not less
-                        * than the Allan intercept. For the PLL, the
-                        * averaging interval is clamped not greater
+                        * than the Allan intercept and the weight
+                        * proportional to the poll interval from zero
+                        * to unity at the Allan intercept. For the PLL,
+                        * the averaging interval is clamped not greater
                         * than the poll interval. Particularly for the
                         * PLL, these measures allow oversampling, but
                         * not undersampling and insure stability even
                         * when the rules of fair engagement are broken.
                         */
+                       etemp = min(1, sqrt(mu) / allan_xpt);
                        dtemp = max(mu, allan_xpt);
-                       flladj = (fp_offset - clock_offset) /
+                       flladj = (fp_offset - clock_offset) * etemp /
                            (CLOCK_FLL * dtemp);
-
-printf("xxx diff %f d %f\n", (fp_offset - clock_offset) * 1e6,
-    CLOCK_FLL * dtemp);
-                       dtemp = 4 * CLOCK_PLL * ULOGTOD(sys_poll);
                        etemp = min(mu, ULOGTOD(sys_poll));
+                       dtemp = 4 * CLOCK_PLL * ULOGTOD(sys_poll);
                        plladj = fp_offset * etemp / (dtemp * dtemp);
                        last_time = peer->epoch;
                        last_offset = clock_offset = fp_offset;
@@ -614,10 +611,6 @@ printf("xxx diff %f d %f\n", (fp_offset - clock_offset) * 1e6,
         */
        etemp = clock_frequency + flladj + plladj;
        drift_comp += etemp;
-
-printf("ofs %f freq %f cf %f pll %f fll %f\n", fp_offset, drift_comp *
-    1e6, clock_frequency * 1e6, plladj * 1e6, flladj * 1e6);
-
        if (drift_comp > NTP_MAXFREQ)
                drift_comp = NTP_MAXFREQ;
        else if (drift_comp <= -NTP_MAXFREQ)
index 848c29d4068990bfd56f9b8077096a23319bffc4..fa2cea6a358296dac389782b67c327547290ed33 100644 (file)
@@ -1650,7 +1650,8 @@ clock_filter(
         */
        if (m == 0)
                return;
-       etemp = peer->offset;
+       etemp = fabs(peer->offset - peer->filter_offset[k]);
+       dtemp = sqrt(peer->jitter);
        peer->offset = peer->filter_offset[k];
        peer->delay = peer->filter_delay[k];
        if (m > 1)
@@ -1677,13 +1678,13 @@ clock_filter(
         * the last update is less than twice the system poll interval,
         * consider the update a popcorn spike and ignore it.
         */
-       if (m > 1 && fabs(peer->offset - etemp) > SQRT(peer->jitter) *
-           CLOCK_SGATE && peer->filter_epoch[k] - peer->epoch <
-           (1 << (sys_poll + 1))) {
+       if (m > 1 && etemp > CLOCK_SGATE * dtemp &&
+           peer->filter_epoch[k] - peer->epoch < (1 << (sys_poll +
+           1))) {
 #ifdef DEBUG
                if (debug)
-                       printf("clock_filter: n %d popcorn spike %.6f jitter %.6f\n",
-                           m, peer->offset, SQRT(peer->jitter));
+                       printf("clock_filter: popcorn %.6f %.6f\n",
+                           etemp, dtemp);
 #endif
                return;
        }