]> git.ipfire.org Git - thirdparty/ntp.git/commitdiff
ChangeLog, ntp_syscall.h, ntp_loopfilter.c, ntp_proto.c:
authorHarlan Stenn <stenn@ntp.org>
Mon, 21 May 2001 18:48:45 +0000 (18:48 -0000)
committerHarlan Stenn <stenn@ntp.org>
Mon, 21 May 2001 18:48:45 +0000 (18:48 -0000)
  * ntpd/ntp_proto.c (clock_filter): Huff-n-Puff and Popcorn
  improvements.
  * ntpd/ntp_loopfilter.c (local_clock): Debug cleanup
  From: Dave Mills.
  * include/ntp_syscall.h (ntp_gettime): Updated patch from Ulrich.
  My original attempt was not backwards compatible.

bk: 3b09630dBFACJpvBNsJVZnAsn77IIg

ChangeLog
include/ntp_syscall.h
ntpd/ntp_loopfilter.c
ntpd/ntp_proto.c

index 8a71dc6f643ec2c7a2f7c9f823f2ad524d07a692..50f5e5addd7878f6d7701f7b86db56bed9ee1e65 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2001-05-21  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * ntpd/ntp_proto.c (clock_filter): Huff-n-Puff and Popcorn
+       improvements.
+       * ntpd/ntp_loopfilter.c (local_clock): Debug cleanup
+       From: Dave Mills.
+
+       * include/ntp_syscall.h (ntp_gettime): Updated patch from Ulrich.
+       My original attempt was not backwards compatible.
+
 2001-05-17  Harlan Stenn  <stenn@whimsy.udel.edu>
 
        * include/ntp_syscall.h (ntp_gettime): Fill in the tai member.
index d5e4ce9e2392d12e9baa55e84a3d17bf3da4057b..29dff91190da8257cc40d37c009ae8098a38cfe2 100644 (file)
@@ -33,10 +33,14 @@ ntp_gettime(
 
        tntx.modes = 0;
        result = __adjtimex (&tntx);
-       ntv->tai = tntx.tai;
        ntv->time = tntx.time;
        ntv->maxerror = tntx.maxerror;
        ntv->esterror = tntx.esterror;
+#ifdef NTP_API
+# if NTP_API > 3
+       ntv->tai = tntx.tai;
+# endif
+#endif
        return(result);
 }
 # else /* !HAVE__ADJTIMEX */
index 681438bf36600b38c9e71a05fcf0ce33a984fd61..9616bb97b1bc2e9de32627abd623c2eade9c61ad 100644 (file)
@@ -215,7 +215,7 @@ local_clock(
 #ifdef DEBUG
        if (debug)
                printf(
-                   "local_clock: assocID %d offset %.6f jitter %.6f state %d\n",
+                   "local_clock: assocID %d off %.6f jit %.6f sta %d\n",
                    peer->associd, fp_offset, SQRT(epsil), state);
 #endif
        if (!ntp_enable) {
@@ -676,16 +676,10 @@ local_clock(
        sys_rootdispersion = peer->rootdispersion + dtemp;
        record_loop_stats(last_offset, drift_comp, sys_jitter,
            clock_stability, sys_poll);
-#ifdef DEBUG
-       if (debug > 1)
-               printf(
-                   "local_clock: fadj %.3f fll %.3f pll %.3f\n",
-                   clock_frequency * 1e6, flladj * 1e6, plladj * 1e6);
-#endif /* DEBUG */
 #ifdef DEBUG
        if (debug)
                printf(
-                   "local_clock: mu %.0f noise %.3f stabil %.3f poll %d count %d\n",
+                   "local_clock: mu %.0f noi %.3f stb %.3f pol %d cnt %d\n",
                    mu, sys_jitter * 1e6 / mu, clock_stability * 1e6,
                    sys_poll, tc_counter);
 #endif /* DEBUG */
index ef73bbbc220fe9fd530a8d7e1b84e977f2f3f8ff..49620572155ec7c8a945a94c683504df2f671705 100644 (file)
@@ -1307,7 +1307,7 @@ clock_filter(
        double dst[NTP_SHIFT];          /* distance vector */
        int ord[NTP_SHIFT];             /* index vector */
        register int i, j, k, m;
-       double dsp, jit, dtemp, etemp, ftemp;
+       double dsp, jit, dtemp, etemp;
 
        /*
         * Shift the new sample into the register and discard the oldest
@@ -1330,10 +1330,10 @@ clock_filter(
 
        /*
         * Update dispersions since the last update and at the same
-        * time initialize the distance and index vectors. The distance
-        * is a compound metric: If the sample dispersion is less than
-        * MAXDISTANCE and younger than the minimum Allan intercept, use
-        * delay. Otherwise, use MAXDISTANCE plus conventional distance.
+        * time initialize the distance and index lists. The distance
+        * list uses a compound metric. If the sample is valid and
+        * younger than the minimum Allan intercept, use delay;
+        * otherwise, use biased dispersion.
         */
        dtemp = clock_phi * (current_time - peer->update);
        peer->update = current_time;
@@ -1343,19 +1343,19 @@ clock_filter(
                        if (peer->filter_disp[j] > MAXDISPERSE)
                                peer->filter_disp[j] = MAXDISPERSE;
                }
-               ftemp = peer->filter_delay[j] / 2. +
-                   peer->filter_disp[j];
-               if (ftemp < MAXDISTANCE && current_time -
-                   peer->filter_epoch[j] < allan_xpt)
-                       dst[i] = peer->filter_delay[j];
+               if (peer->filter_disp[j] >= MAXDISPERSE)
+                       dst[i] = MAXDISPERSE;
+               else if (peer->update - peer->filter_epoch[j] >
+                   allan_xpt)
+                       dst[i] = MAXDISTANCE + peer->filter_disp[j];
                else
-                       dst[i] = MAXDISTANCE + ftemp;
+                       dst[i] = peer->filter_delay[j];
                ord[i] = j;
                j++; j %= NTP_SHIFT;
        }
 
         /*
-        * Sort the samples in the register by the compound metric.
+        * Sort the samples in both lists by distance.
         */
        for (i = 1; i < NTP_SHIFT; i++) {
                for (j = 0; j < i; j++) {
@@ -1371,53 +1371,47 @@ clock_filter(
        }
 
        /*
-        * Copy the ord[] array to the association structure so ntpq
-        * can see it later.
+        * 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
+        * jitter calculation.
         */
+       m = 0;
        for (i = 0; i < NTP_SHIFT; i++) {
                peer->filter_order[i] = ord[i];
-#if DEBUG
-               if (debug > 1) {
-                       j = ord[i];
-                       printf("cfilter: %d %d %f %f %f %f\n", i,
-                           j, dst[i], peer->filter_offset[j],
-                           peer->filter_delay[j],
-                           peer->filter_disp[j]);
-               }
-#endif
+               if (dst[i] >= MAXDISPERSE || (m >= 2 && dst[i] >=
+                   MAXDISTANCE))
+                       continue;
+               m++;
        }
        
        /*
-        * Compute the offset, delay, dispersion and jitter squares
-        * weighted by the sample metric and normalized. The sample
-        * metric is the distance from the limb line with slope 0.5
-        * centered on the minimum delay sample offset. The dispersion
-        * is weighted exponentially by NTP_FWEIGHT (0.5) so to
-        * normalize close to 1.0. If no acceptable samples remain in
-        * the shift register, quietly tiptoe home leaving only the
+        * Compute the dispersion and jitter squares. The dispersion
+        * is weighted exponentially by NTP_FWEIGHT (0.5) so it is
+        * normalized close to 1.0. The jitter is the mean of the square
+        * differences relative to the lowest delay sample. If no
+        * acceptable samples remain in the shift register, quietly
+        * tiptoe home leaving only the
         * dispersion.
         */
        jit = 0;
        peer->disp = 0;
        k = ord[0];
-       m = 0;
        for (i = NTP_SHIFT - 1; i >= 0; i--) {
 
                j = ord[i];
                peer->disp = NTP_FWEIGHT * (peer->disp +
                    peer->filter_disp[j]);
-               if (dst[i] >= MAXDISTANCE)
-                       continue;
-               m++;
-               jit += DIFF(peer->filter_offset[j],
-                   peer->filter_offset[k]);
+               if (i < m)
+                       jit += DIFF(peer->filter_offset[j],
+                           peer->filter_offset[k]);
        }
 
        /*
         * If no acceptable samples remain in the shift register,
-        * quietly tiptoe home leaving only the dispersion. Otherwise
-        * normalize the offset, delay and jitter averages. Note the
-        * jitter must not be less than the system precision.
+        * quietly tiptoe home leaving only the dispersion. Otherwise,
+        * save the offset, delay and jitter average. Note the jitter
+        * must not be less than the system precision.
         */
        if (m == 0)
                return;
@@ -1436,7 +1430,7 @@ clock_filter(
 #ifdef DEBUG
                if (debug)
                        printf("clock_filter: discard %lu\n",
-                           peer->filter_epoch[k] - peer->epoch);
+                           peer->epoch - peer->filter_epoch[k]);
 #endif
                return;
        }
@@ -1452,7 +1446,7 @@ clock_filter(
            (1 << (sys_poll + 1))) {
 #ifdef DEBUG
                if (debug)
-                       printf("clock_filter: samples %d popcorn spike %.6f jitter %.6f\n",
+                       printf("clock_filter: n %d popcorn spike %.6f jitter %.6f\n",
                            m, peer->offset, SQRT(peer->jitter));
 #endif
                return;
@@ -1467,9 +1461,9 @@ clock_filter(
 #ifdef DEBUG
        if (debug)
                printf(
-                   "clock_filter: offset %.6f delay %.6f disp %.6f jit %.6f, age %lu\n",
-                   peer->offset, peer->delay, peer->disp,
-                   SQRT(peer->jitter), current_time - peer->epoch);
+                   "clock_filter: n %d off %.6f del %.6f dsp %.6f jit %.6f, age %lu\n",
+                   m, peer->offset, peer->delay, peer->disp,
+                   SQRT(peer->jitter), peer->update - peer->epoch);
 #endif
 }