]> git.ipfire.org Git - thirdparty/ntp.git/commitdiff
Many files:
authorHarlan Stenn <stenn@ntp.org>
Mon, 4 Sep 2000 04:45:40 +0000 (04:45 -0000)
committerHarlan Stenn <stenn@ntp.org>
Mon, 4 Sep 2000 04:45:40 +0000 (04:45 -0000)
  * ntpq/ntpq.c: report offset as "offset", not "phase".  Lose
  compliance.
  * ntpd/refclock_local.c (local_poll): variance -> jitter
  * ntpd/refclock_chu.c (chu_major): Lose variance.
  * ntpd/ntp_util.c (hourly_stats): sys_error -> sys_jitter
  (record_loop_stats): ditto
  * ntpd/ntp_request.c (peer_info): variance -> jitter
  * ntpd/ntp_refclock.c (refclock_sample): variance -> jitter
  (refclock_receive): variance -> jitter
  * ntpd/ntp_proto.c (process_packet): variance -> jitter
  (clock_filter): variance -> jitter
  (clock_select): variance -> jitter
  (root_distance): variance -> jitter
  * ntpd/ntp_peer.c (newpeer): variance -> jitter
  * ntpd/ntp_loopfilter.c: Cleanup pll_nano selection bogon.
  Centralize the kernel API data.
  (local_clock): Lose sys_error.
  (loop_config): Code cleanup.
  * ntpd/ntp_control.c: Call offset "offset" and not "phase". Lose
  CS_COMPLIANCE.  Deal with variance/jitter rename.
  * include/ntp_refclock.h: Rename variance to jitter in struct
  refclockproc.
  * include/ntp_control.h (CS_COMPLIANCE): Lose it.
  * include/ntp.h: Rename variance to jitter in struct peer.
  From: Dave Mills

bk: 39b328f4dpXYZOswq_pUAwo-Ms_P-g

14 files changed:
ChangeLog
include/ntp.h
include/ntp_control.h
include/ntp_refclock.h
ntpd/ntp_control.c
ntpd/ntp_loopfilter.c
ntpd/ntp_peer.c
ntpd/ntp_proto.c
ntpd/ntp_refclock.c
ntpd/ntp_request.c
ntpd/ntp_util.c
ntpd/refclock_chu.c
ntpd/refclock_local.c
ntpq/ntpq.c

index 8acac3ac9b4176a0fef44d0ba378cf7f168dbd68..29a41084e007d81ec6509bc7223e4594b608c829 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,31 @@
+2000-09-04  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * ntpq/ntpq.c: report offset as "offset", not "phase".  Lose
+       compliance.
+       * ntpd/refclock_local.c (local_poll): variance -> jitter
+       * ntpd/refclock_chu.c (chu_major): Lose variance.
+       * ntpd/ntp_util.c (hourly_stats): sys_error -> sys_jitter
+       (record_loop_stats): ditto
+       * ntpd/ntp_request.c (peer_info): variance -> jitter
+       * ntpd/ntp_refclock.c (refclock_sample): variance -> jitter
+       (refclock_receive): variance -> jitter
+       * ntpd/ntp_proto.c (process_packet): variance -> jitter
+       (clock_filter): variance -> jitter
+       (clock_select): variance -> jitter
+       (root_distance): variance -> jitter
+       * ntpd/ntp_peer.c (newpeer): variance -> jitter
+       * ntpd/ntp_loopfilter.c: Cleanup pll_nano selection bogon.
+       Centralize the kernel API data.
+       (local_clock): Lose sys_error.
+       (loop_config): Code cleanup.
+       * ntpd/ntp_control.c: Call offset "offset" and not "phase". Lose
+       CS_COMPLIANCE.  Deal with variance/jitter rename.
+       * include/ntp_refclock.h: Rename variance to jitter in struct
+       refclockproc.
+       * include/ntp_control.h (CS_COMPLIANCE): Lose it.
+       * include/ntp.h: Rename variance to jitter in struct peer.
+       From: Dave Mills
+
 2000-09-01  Harlan Stenn  <stenn@whimsy.udel.edu>
 
        * ntpd/refclock_atom.c: Use the new ppsunit.  Cleanup and improve
index 8b36c73f35c3bdf7026218cd929e514298e042ee..b8231083be1b5e2dd64a163d153db9768a721d54 100644 (file)
@@ -117,7 +117,7 @@ typedef char s_char;
 #define BURST_INTERVAL2        1       /* succeeding interburst intervals (log2) */
 
 /*
- * Operations for jitter (variance) calculations (these use doubles).
+ * Operations for jitter calculations (these use doubles).
  *
  * Note that we carefully separate the jitter component from the
  * dispersion component (frequency error plus precision). The frequency
@@ -326,7 +326,7 @@ struct peer {
        l_fp    xmt;            /* transmit time stamp */
        double  offset;         /* peer clock offset */
        double  delay;          /* peer roundtrip delay */
-       double  variance;       /* peer variance (jitter) */
+       double  jitter;         /* peer jitter (squares) */
        double  disp;           /* peer dispersion */
        double  estbdelay;      /* clock offset to broadcast server */
 
index 0210bf716545454deb0d28832b200ca813f80bd0..c9ddece370b81f3072653a1b4bc411d44d21092a 100644 (file)
@@ -157,22 +157,21 @@ struct ntp_control {
 #define CS_STATE       10
 #define        CS_OFFSET       11
 #define        CS_DRIFT        12
-#define        CS_COMPLIANCE   13
-#define CS_JITTER      14
-#define        CS_CLOCK        15
-#define        CS_PROCESSOR    16
-#define        CS_SYSTEM       17
-#define CS_VERSION     18
-#define        CS_STABIL       19
-#define CS_VARLIST     20
+#define CS_JITTER      13
+#define        CS_CLOCK        14
+#define        CS_PROCESSOR    15
+#define        CS_SYSTEM       16
+#define CS_VERSION     17
+#define        CS_STABIL       18
+#define CS_VARLIST     19
 #ifdef PUBKEY
-#define CS_FLAGS       21
-#define CS_HOST                22
-#define CS_PUBLIC      23
-#define CS_DHPARAMS    24
-#define        CS_REVTIME      25
-#define CS_LEAPTAB     26
-#define CS_TAI         27
+#define CS_FLAGS       20
+#define CS_HOST                21
+#define CS_PUBLIC      22
+#define CS_DHPARAMS    23
+#define        CS_REVTIME      24
+#define CS_LEAPTAB     25
+#define CS_TAI         26
 #define        CS_MAXCODE      CS_TAI
 #else
 #define        CS_MAXCODE      CS_VARLIST
index fd1d0801d98e64381d6dfe8340b9bfe59bd4aa52..c66b617eaf36b1d6572a6f7def18aec06e8d35b0 100644 (file)
@@ -195,7 +195,7 @@ struct refclockproc {
        l_fp    lastrec;        /* local timestamp */
        double  offset;         /* mean offset */
        double  disp;           /* sample dispersion */
-       double  variance;       /* sample variance */
+       double  jitter;         /* jitter (mean squares) */
        double  filter[MAXSTAGE]; /* median filter */
 
        /*
index 527ac3012a5722e98250f66cc867e4f469c956e7..2afe9974560176b3e7b51ee755412baab98ca46c 100644 (file)
@@ -104,24 +104,23 @@ static struct ctl_var sys_var[] = {
        { CS_POLL,      RO, "poll" },           /* 8 */
        { CS_PEERID,    RO, "peer" },           /* 9 */
        { CS_STATE,     RO, "state" },          /* 10 */
-       { CS_OFFSET,    RO, "phase" },          /* 11 */
+       { CS_OFFSET,    RO, "offset" },         /* 11 */
        { CS_DRIFT,     RO, "frequency" },      /* 12 */
-       { CS_COMPLIANCE, RO, "error" },         /* 13 */
-       { CS_JITTER,    RO, "jitter" },         /* 14 */
-       { CS_CLOCK,     RO, "clock" },          /* 15 */
-       { CS_PROCESSOR, RO, "processor" },      /* 16 */
-       { CS_SYSTEM,    RO, "system" },         /* 17 */
-       { CS_VERSION,   RO, "version" },        /* 18 */
-       { CS_STABIL,    RO, "stability" },      /* 19 */
-       { CS_VARLIST,   RO, "sys_var_list" },   /* 20 */
+       { CS_JITTER,    RO, "jitter" },         /* 13 */
+       { CS_CLOCK,     RO, "clock" },          /* 14 */
+       { CS_PROCESSOR, RO, "processor" },      /* 15 */
+       { CS_SYSTEM,    RO, "system" },         /* 16 */
+       { CS_VERSION,   RO, "version" },        /* 17 */
+       { CS_STABIL,    RO, "stability" },      /* 18 */
+       { CS_VARLIST,   RO, "sys_var_list" },   /* 19 */
 #ifdef PUBKEY
-       { CS_FLAGS,     RO, "flags" },          /* 21 */
-       { CS_HOST,      RO, "hostname" },       /* 22 */
-       { CS_PUBLIC,    RO, "publickey" },      /* 23 */
-       { CS_DHPARAMS,  RO, "params" },         /* 24 */
-       { CS_REVTIME,   RO, "refresh"},         /* 25 */
-       { CS_LEAPTAB,   RO, "leaptable" },      /* 26 */
-       { CS_TAI,       RO, "tai"},             /* 27 */
+       { CS_FLAGS,     RO, "flags" },          /* 20 */
+       { CS_HOST,      RO, "hostname" },       /* 21 */
+       { CS_PUBLIC,    RO, "publickey" },      /* 22 */
+       { CS_DHPARAMS,  RO, "params" },         /* 23 */
+       { CS_REVTIME,   RO, "refresh"},         /* 24 */
+       { CS_LEAPTAB,   RO, "leaptable" },      /* 25 */
+       { CS_TAI,       RO, "tai"},             /* 26 */
 #endif /* PUBKEY */
        { 0,            EOV,    ""  }
 };
@@ -148,9 +147,8 @@ static      u_char def_sys_var[] = {
        CS_CLOCK,
        CS_STATE,
        CS_OFFSET,
-       CS_COMPLIANCE,
-       CS_JITTER,
        CS_DRIFT,
+       CS_JITTER,
        CS_STABIL,
 #ifdef PUBKEY
        CS_FLAGS,
@@ -234,10 +232,10 @@ static u_char def_peer_var[] = {
        CP_ROOTDISPERSION,
        CP_REFID,
        CP_REFTIME,
-       CP_DELAY,
        CP_OFFSET,
-       CP_JITTER,
+       CP_DELAY,
        CP_DISPERSION,
+       CP_JITTER,
        CP_REACH,
        CP_VALID,
        CP_HMODE,
@@ -1217,11 +1215,6 @@ ctl_putsys(
                ctl_putdbl(sys_var[CS_DRIFT].text, drift_comp * 1e6);
                break;
 
-       case CS_COMPLIANCE:
-               ctl_putdbl(sys_var[CS_COMPLIANCE].text, sys_error *
-                   1e3);
-               break;
-
        case CS_JITTER:
                ctl_putdbl(sys_var[CS_JITTER].text, sys_jitter * 1e3);
                break;
@@ -1508,7 +1501,7 @@ ctl_putpeer(
 
        case CP_JITTER:
                ctl_putdbl(peer_var[CP_JITTER].text,
-                   SQRT(peer->variance) * 1e3);
+                   SQRT(peer->jitter) * 1e3);
                break;
 
        case CP_DISPERSION:
index d50765980316d7fe421c74144612f0872cbded66..b107cf0e236b2172a7d1ba8a44e7b6ea48a1da53 100644 (file)
@@ -102,7 +102,9 @@ u_long      pps_control;            /* last pps sample time */
 static void rstclock P((int)); /* state transition function */
 
 #ifdef KERNEL_PLL
-int pll_status;                        /* status bits for kernel pll */
+struct timex ntv;              /* kernel API parameters */
+int    pll_status;             /* status bits for kernel pll */
+int    pll_nano;               /* nanosecond kernel switch */
 #endif /* KERNEL_PLL */
 
 /*
@@ -116,10 +118,6 @@ int        pps_update;             /* pps update valid */
 int    allow_set_backward = TRUE; /* step corrections allowed */
 int    correct_any = FALSE;    /* corrections > 1000 s allowed */
 
-#ifdef STA_NANO
-int    pll_nano;               /* nanosecond kernel switch */
-#endif /* STA_NANO */
-
 /*
  * Clock state machine variables
  */
@@ -129,7 +127,6 @@ int tc_counter;             /* poll-adjust counter */
 u_long last_time;              /* time of last clock update (s) */
 double last_offset;            /* last clock offset (s) */
 double allan_xpt;              /* Allan intercept (s) */
-double sys_error;              /* system RMS error (s) */
 double sys_jitter;             /* system RMS jitter (s) */
 
 #if defined(KERNEL_PLL)
@@ -176,10 +173,6 @@ local_clock(
        double dtemp, etemp;    /* double temps */
        int retval;             /* return value */
 
-#if defined(KERNEL_PLL)
-       struct timex ntv;       /* kernel interface structure */
-#endif /* KERNEL_PLL */
-
 #ifdef DEBUG
        if (debug)
                printf(
@@ -423,25 +416,21 @@ local_clock(
                                dtemp = -.5;
                        else
                                dtemp = .5;
-#ifdef STA_NANO
-                       if (pll_nano)
+                       if (pll_nano) {
                                ntv.offset = (int32)(clock_offset *
                                    1e9 + dtemp);
-                       else
-#endif /* STA_NANO */
+                               ntv.constant = sys_poll;
+                       } else {
                                ntv.offset = (int32)(clock_offset *
                                    1e6 + dtemp);
+                               ntv.constant = sys_poll - 4;
+                       }
                        if (clock_frequency != 0) {
                                ntv.modes |= MOD_FREQUENCY;
                                ntv.freq = (int32)((clock_frequency +
                                    drift_comp) * 65536e6);
                        }
-#ifdef STA_NANO
-                       ntv.constant = sys_poll;
-#else
-                       ntv.constant = sys_poll - 4;
-#endif /* STA_NANO */
-                       ntv.esterror = (u_int32)(sys_error * 1e6);
+                       ntv.esterror = (u_int32)(sys_jitter * 1e6);
                        ntv.maxerror = (u_int32)((sys_rootdelay / 2 +
                            sys_rootdispersion) * 1e6);
                        ntv.status = STA_PLL;
@@ -486,21 +475,17 @@ local_clock(
                if (ntp_adjtime(&ntv) == TIME_ERROR) {
                        if (ntv.status != pll_status)
                                msyslog(LOG_ERR,
-                                   "kernel pll status change %x",
+                                   "kernel time discipline status change %x",
                                    ntv.status);
                }
                pll_status = ntv.status;
-#ifdef STA_NANO
-               if (pll_nano)
+               if (pll_nano) {
                        clock_offset = ntv.offset / 1e9;
-               else
-#endif /* STA_NANO */
+                       sys_poll = ntv.constant;
+               } else {
                        clock_offset = ntv.offset / 1e6;
-#ifdef STA_NANO
-               sys_poll = ntv.constant;
-#else
-               sys_poll = ntv.constant + 4;
-#endif /* STA_NANO */
+                       sys_poll = ntv.constant + 4;
+               }
                clock_frequency = ntv.freq / 65536e6 - drift_comp;
                flladj = plladj = 0;
 
@@ -514,11 +499,9 @@ local_clock(
                                NLOG(NLOG_SYSEVENT)msyslog(LOG_INFO,
                                    "pps sync enabled");
                        pps_control = current_time;
-#ifdef STA_NANO
                        if (pll_nano)
                                sys_jitter = ntv.jitter / 1e9;
                        else
-#endif /* STA_NANO */
                                sys_jitter = ntv.jitter / 1e6;
                        sys_poll = ntv.shift;
                }
@@ -574,10 +557,7 @@ local_clock(
         */
        last_time = current_time;
        last_offset = clock_offset;
-       dtemp = SQUARE(sys_error);
-       sys_error = SQRT(dtemp + (SQUARE(last_offset) - dtemp) /
-           CLOCK_AVG);
-       dtemp = peer->disp + SQRT(peer->variance + SQUARE(sys_jitter));
+       dtemp = peer->disp + SQRT(peer->jitter + SQUARE(sys_jitter));
        if ((peer->flags & FLAG_REFCLOCK) == 0 && dtemp < MINDISPERSE)
                dtemp = MINDISPERSE;
        sys_rootdispersion = peer->rootdispersion + dtemp;
@@ -592,9 +572,9 @@ local_clock(
 #ifdef DEBUG
        if (debug > 1)
                printf(
-       "local_clock: err %.6f jit %.6f freq %.3f stab %.3f poll %d cnt %d\n",
-                   sys_error, sys_jitter, drift_comp * 1e6,
-                   clock_stability * 1e6, sys_poll, tc_counter);
+                   "local_clock: jit %.6f freq %.3f stab %.3f poll %d cnt %d\n",
+                   sys_jitter, drift_comp * 1e6, clock_stability * 1e6,
+                   sys_poll, tc_counter);
 #endif /* DEBUG */
        return (retval);
 }
@@ -723,58 +703,38 @@ loop_config(
        double freq
        )
 {
-#if defined(KERNEL_PLL)
-       struct timex ntv;
-#endif /* KERNEL_PLL */
 
-#ifdef DEBUG
-       if (debug)
-               printf("loop_config: state %d freq %.3f\n", item, freq *
-                   1e6);
-#endif
        switch (item) {
-
            case LOOP_DRIFTINIT:
-           case LOOP_DRIFTCOMP:
 
-               /*
-                * The drift file is present and the initial frequency
-                * is available, so set the state to S_FSET
-                */
-               rstclock(S_FSET);
-               drift_comp = freq;
-               if (drift_comp > NTP_MAXFREQ)
-                       drift_comp = NTP_MAXFREQ;
-               if (drift_comp < -NTP_MAXFREQ)
-                       drift_comp = -NTP_MAXFREQ;
 #ifdef KERNEL_PLL
                /*
-                * If the phase-lock code is implemented in the kernel,
-                * give the time_constant and saved frequency offset to
-                * the kernel. If not, no harm is done. Note the initial
-                * time constant is zero, but the first clock update
-                * will fix that.
+                * Assume the kernel supports the ntp_adjtime() syscall.
+                * If that syscall works, initialize the kernel
+                * variables. Otherwise, continue leaving no harm
+                * behind. While at it, ask to set nanosecond mode. If
+                * the kernel agrees, rejoice; othewise, it does only
+                * microseconds.
                 */
-               memset((char *)&ntv, 0, sizeof ntv);
                pll_control = 1;
-#ifdef MOD_NANO
+               memset((char *)&ntv, 0, sizeof ntv);
+#if NTP_API > 3 
                ntv.modes = MOD_NANO;
-#endif /* MOD_NANO */
+#endif /* NTP_API */
+
 #ifdef SIGSYS
+               /*
+                * Use sigsetjmp() to save state and then call
+                * ntp_adjtime(); if it fails, then siglongjmp() is used
+                * to return control
+                */
                newsigsys.sa_handler = pll_trap;
                newsigsys.sa_flags = 0;
                if (sigaction(SIGSYS, &newsigsys, &sigsys)) {
                        msyslog(LOG_ERR,
                            "sigaction() fails to save SIGSYS trap: %m");
                        pll_control = 0;
-                       return;
                }
-
-               /*
-                * Use sigsetjmp() to save state and then call
-                * ntp_adjtime(); if it fails, then siglongjmp() is used
-                * to return control
-                */
                if (sigsetjmp(env, 1) == 0)
                        (void)ntp_adjtime(&ntv);
                if ((sigaction(SIGSYS, &sigsys,
@@ -782,7 +742,6 @@ loop_config(
                        msyslog(LOG_ERR,
                            "sigaction() fails to restore SIGSYS trap: %m");
                        pll_control = 0;
-                       return;
                }
 #else /* SIGSYS */
                if (ntp_adjtime(&ntv) < 0) {
@@ -791,42 +750,68 @@ loop_config(
                        pll_control = 0;
                }
 #endif /* SIGSYS */
+#if NTP_API > 3
+               if (pll_control) {
+                       if (ntv.status & STA_NANO)
+                               pll_nano = 1;
+                       if (ntv.status & STA_CLK)
+                               ext_enable = 1;
+               }
+#endif /* NTP_API */
+#endif /* KERNEL_PLL */
+               break;
+
+           case LOOP_DRIFTCOMP:
 
                /*
-                * If the kernel support is available and enabled,
-                * initialize the parameters, but only if the external
-                * clock is not present.
+                * Initialize the kernel frequency and clamp to
+                * reasonable value. Also set the initial state to
+                * S_FSET to indicated the frequency has been
+                * initialized from the previously saved drift file.
                 */
-               if (pll_control && kern_enable) {
-                       msyslog(LOG_NOTICE,
-                           "using kernel phase-lock loop %04x",
-                           ntv.status);
-#ifdef STA_NANO
-                       if (ntv.status & STA_NANO)
-                               pll_nano = 1;
-#endif /* STA_NANO */
-#ifdef STA_CLK
+               rstclock(S_FSET);
+               drift_comp = freq;
+               if (drift_comp > NTP_MAXFREQ)
+                       drift_comp = NTP_MAXFREQ;
+               if (drift_comp < -NTP_MAXFREQ)
+                       drift_comp = -NTP_MAXFREQ;
 
-                       if (ntv.status & STA_CLK) {
-                               ext_enable = 1;
-                       } else {
-                               ntv.modes = MOD_BITS | MOD_FREQUENCY;
+#ifdef KERNEL_PLL
+               /*
+                * If the kernel support is available. initialize the
+                * parameters. If an external clock is present, it
+                * should be initialized and the STA_CLK bit set before
+                * NTP is started. If the kernel has been running for
+                * awhile and the offset and frequency previously set,
+                * but the kernel is explicitly disabled, scratch the
+                * previous offset and frequency values, but leave the
+                * time constant alone.
+                */
+               if (pll_control) {
+                       memset((char *)&ntv, 0, sizeof ntv);
+                       ntv.modes = MOD_BITS | MOD_FREQUENCY;
+                       if (kern_enable) {
+                               msyslog(LOG_NOTICE,
+                                  "using kernel time discipline %04x",
+                                   ntv.status);
                                ntv.freq = (int32)(drift_comp *
                                    65536e6);
-                               ntv.maxerror = MAXDISPERSE;
-                               ntv.esterror = MAXDISPERSE;
-                               ntv.status = STA_UNSYNC | STA_PLL;
-                               (void)ntp_adjtime(&ntv);
+                       } else {
+                               msyslog(LOG_NOTICE,
+                                  "kernel time discipline disabled %04x",
+                                   ntv.status);
+                               ntv.freq = 0;
                        }
-#else
-                       ntv.modes = MOD_BITS | MOD_FREQUENCY;
-                       ntv.freq = (int32)(drift_comp * 65536e6);
                        ntv.maxerror = MAXDISPERSE;
                        ntv.esterror = MAXDISPERSE;
                        ntv.status = STA_UNSYNC | STA_PLL;
                        (void)ntp_adjtime(&ntv);
-#endif /* STA_CLK */
+
+               } else {
+                       msyslog(LOG_NOTICE,
+                           "using NTP daemon time discipline");
                }
+               break;
 #endif /* KERNEL_PLL */
        }
 }
index 59e82f85f103d658b3bd1aab0de2c7da2b3b8aca..40c29febd8f03bdc0884b8826c1f6f8a3fa25143 100644 (file)
@@ -635,7 +635,7 @@ newpeer(
        peer->ttl = ttl;
        peer->leap = LEAP_NOTINSYNC;
        peer->precision = sys_precision;
-       peer->variance = MAXDISPERSE;
+       peer->jitter = MAXDISPERSE;
        peer->epoch = current_time;
        peer->stratum = STRATUM_UNSPEC;
        peer_clear(peer);
index d986a2e9140f3789cc78d0969411830a23606050..cf03b3a25fec1a37a23881e1ed2a7422cd77d224 100644 (file)
@@ -983,7 +983,7 @@ process_packet(
        clock_select();
        record_peer_stats(&peer->srcadr, ctlpeerstatus(peer),
            peer->offset, peer->delay, peer->disp,
-           SQRT(peer->variance));
+           SQRT(peer->jitter));
 }
 
 
@@ -1176,7 +1176,7 @@ peer_clear(
        peer->estbdelay = sys_bdelay;
        peer->hpoll = peer->minpoll;
        peer->pollsw = FALSE;
-       peer->variance = MAXDISPERSE;
+       peer->jitter = MAXDISPERSE;
        peer->epoch = current_time;
        for (i = 0; i < NTP_SHIFT; i++) {
                peer->filter_order[i] = i;
@@ -1202,7 +1202,7 @@ clock_filter(
        register int i, j, k, n;
        register u_char *ord;
        double distance[NTP_SHIFT];
-       double off, dly, var, dsp, dtemp, etemp;
+       double off, dly, dsp, jit, dtemp, etemp;
 
        /*
         * Update error bounds and calculate distances. The distance for
@@ -1266,13 +1266,13 @@ clock_filter(
        } 
        
        /*
-        * Compute the offset, delay, variance (squares) and error
-        * bound. The offset, delay and variance are weighted by the
+        * Compute the offset, delay, jitter (squares) and error
+        * bound. The offset, delay and jitter are weighted by the
         * reciprocal of distance and normalized. The error bound is
         * weighted exponentially. When no acceptable samples remain in
         * the shift register, quietly tiptoe home.
         */
-       off = dly = var = dsp = dtemp = 0;
+       off = dly = dsp = jit = dtemp = 0;
        for (i = NTP_SHIFT - 1; i >= 0; i--) {
                dsp = NTP_FWEIGHT * (dsp + peer->filter_disp[ord[i]]);
                if (i < n && distance[i] < MAXDISTANCE) {
@@ -1281,7 +1281,7 @@ clock_filter(
                            distance[i];
                        dly += peer->filter_delay[ord[i]] /
                            distance[i];
-                       var += DIFF(peer->filter_offset[ord[i]],
+                       jit += DIFF(peer->filter_offset[ord[i]],
                            peer->filter_offset[ord[0]]) /
                            SQUARE(distance[i]);
                }
@@ -1289,8 +1289,8 @@ clock_filter(
        if (dtemp == 0)
                return;
        peer->delay = dly / dtemp;
-       peer->variance = min(var / SQUARE(dtemp), MAXDISPERSE);
        peer->disp = min(dsp, MAXDISPERSE);
+       peer->jitter = min(jit / SQUARE(dtemp), MAXDISPERSE);
        peer->epoch = current_time;
        etemp = peer->offset;
        peer->offset = off / dtemp;
@@ -1334,9 +1334,9 @@ clock_filter(
 #ifdef DEBUG
        if (debug)
                printf(
-                   "clock_filter: offset %.6f delay %.6f disp %.6f std %.6f, age %lu\n",
+                   "clock_filter: offset %.6f delay %.6f disp %.6f jit %.6f, age %lu\n",
                    peer->offset, peer->delay, peer->disp,
-                   SQRT(peer->variance), current_time - peer->epoch);
+                   SQRT(peer->jitter), current_time - peer->epoch);
 #endif
 }
 
@@ -1621,7 +1621,7 @@ clock_select(void)
         */
        for (i = 0; i < nlist; i++) {
                peer = peer_list[i];
-               error[i] = peer->variance;
+               error[i] = peer->jitter;
                if (i < NTP_CANCLOCK)
                        peer->status = CTL_PST_SEL_SELCAND;
                else
@@ -1752,7 +1752,7 @@ clock_select(void)
                sys_peer = typeprefer;
                sys_peer->status = CTL_PST_SEL_SYSPEER;
                sys_offset = sys_peer->offset;
-               sys_epsil = sys_peer->variance;
+               sys_epsil = sys_peer->jitter;
 #ifdef DEBUG
                if (debug > 2)
                        printf("select: prefer offset %.6f\n",
@@ -1762,7 +1762,7 @@ clock_select(void)
                sys_peer = typepps;
                sys_peer->status = CTL_PST_SEL_PPS;
                sys_offset = sys_peer->offset;
-               sys_epsil = sys_peer->variance;
+               sys_epsil = sys_peer->jitter;
                if (!pps_control)
                        NLOG(NLOG_SYSEVENT) /* conditional syslog */
                                msyslog(LOG_INFO, "pps sync enabled");
@@ -1776,7 +1776,7 @@ clock_select(void)
                        sys_peer = peer_list[0];
                sys_peer->status = CTL_PST_SEL_SYSPEER;
                sys_offset = clock_combine(peer_list, nlist);
-               sys_epsil = sys_peer->variance + sys_maxd;
+               sys_epsil = sys_peer->jitter + sys_maxd;
 #ifdef DEBUG
                if (debug > 2)
                        printf("select: combine offset %.6f\n",
@@ -1818,7 +1818,7 @@ root_distance(
 {
        return ((fabs(peer->delay) + peer->rootdelay) / 2 +
                peer->rootdispersion + peer->disp +
-                   SQRT(peer->variance) + CLOCK_PHI * (current_time -
+                   SQRT(peer->jitter) + CLOCK_PHI * (current_time -
                    peer->update));
 }
 
index fde52f74607cab73a2f25a6d4893a05c058e9b15..65a4df01505acd4684346abed30caa3b77cef7b1 100644 (file)
@@ -491,18 +491,18 @@ refclock_process(
  *
  * This routine implements a recursive median filter to suppress spikes
  * in the data, as well as determine a performance statistic. It
- * calculates the mean offset and mean-square variance. A time
- * adjustment fudgetime1 can be added to the final offset to compensate
- * for various systematic errors. The routine returns the number of
- * samples processed, which could be 0.
+ * calculates the mean offset and jitter (squares). A time adjustment
+ * fudgetime1 can be added to the final offset to compensate for various
+ * systematic errors. The routine returns the number of samples
+ * processed, which could be zero.
  */
 static int
 refclock_sample(
        struct refclockproc *pp
        )
 {
-       int i, j, k, n;
-       double offset, disp;
+       int i, j, k, m, n;
+       double offset, jitter;
        double off[MAXSTAGE];
 
        /*
@@ -522,8 +522,8 @@ refclock_sample(
         * approximately 60 percent of the samples remain.
         */
        i = 0; j = n;
-       k = n - (n * 2) / NSTAGE;
-       while ((j - i) > k) {
+       m = n - (n * 2) / NSTAGE;
+       while ((j - i) > m) {
                offset = off[(j + i) / 2];
                if (off[j - 1] - offset < offset - off[i])
                        i++;    /* reject low end */
@@ -532,21 +532,21 @@ refclock_sample(
        }
 
        /*
-        * Determine the offset and variance.
+        * Determine the offset and jitter.
         */
-       offset = disp = 0;
-       for (; i < j; i++) {
-               offset += off[i];
-               disp += SQUARE(off[i]);
+       offset = jitter = 0;
+       for (k = i; k < j; k++) {
+               offset += off[k];
+               if (k > i)
+                       jitter += SQUARE(off[k] - off[k - 1]);
        }
-       offset /= k;
-       pp->offset = offset;
-       pp->variance = disp / k - SQUARE(offset);
+       pp->offset = offset / m;
+       pp->jitter = jitter / m;
 #ifdef DEBUG
        if (debug)
                printf(
-                   "refclock_sample: n %d offset %.6f disp %.6f std %.6f\n",
-                   n, pp->offset, pp->disp, SQRT(pp->variance));
+                   "refclock_sample: n %d offset %.6f disp %.6f jitter %.6f\n",
+                   n, pp->offset, pp->disp, SQRT(pp->jitter));
 #endif
        return (n);
 }
@@ -592,7 +592,7 @@ refclock_receive(
                report_event(EVNT_REACH, peer);
        peer->reach |= 1;
        peer->reftime = peer->org = pp->lastrec;
-       peer->rootdispersion = pp->disp + SQRT(pp->variance);
+       peer->rootdispersion = pp->disp + SQRT(pp->jitter);
        get_systime(&peer->rec);
        if (!refclock_sample(pp))
                return;
@@ -600,7 +600,7 @@ refclock_receive(
        clock_select();
        record_peer_stats(&peer->srcadr, ctlpeerstatus(peer),
            peer->offset, peer->delay, CLOCK_PHI * (current_time -
-           peer->epoch), SQRT(peer->variance));
+           peer->epoch), SQRT(peer->jitter));
        if (pps_control && pp->sloppyclockflag & CLK_FLAG1)
                pp->fudgetime1 -= pp->offset * FUDGEFAC;
 }
index bc9133d36ccabbf5a2d3c00c5811bbc6daf3d62d..6ca1440fd515d23e136166aaefc46a7be6d0ee6f 100644 (file)
@@ -770,7 +770,7 @@ peer_info (
                HTONL_FP(&ltmp, &ip->offset);
                ip->delay = HTONS_FP(DTOFP(pp->delay));
                ip->dispersion = HTONS_FP(DTOUFP(SQRT(pp->disp)));
-               ip->selectdisp = HTONS_FP(DTOUFP(SQRT(pp->variance)));
+               ip->selectdisp = HTONS_FP(DTOUFP(SQRT(pp->jitter)));
                ip = (struct info_peer *)more_pkt();
        }
        flush_pkt();
@@ -880,7 +880,7 @@ sys_info(
        extern double sys_bdelay;
        extern l_fp sys_authdelay;
        extern double clock_stability;
-       extern double sys_error;
+       extern double sys_jitter;
 
        is = (struct info_sys *)prepare_pkt(srcadr, inter, inpkt,
            sizeof(struct info_sys));
@@ -897,7 +897,7 @@ sys_info(
        is->precision = sys_precision;
        is->rootdelay = htonl(DTOFP(sys_rootdelay));
        is->rootdispersion = htonl(DTOUFP(sys_rootdispersion));
-       is->frequency = htonl(DTOFP(sys_error));
+       is->frequency = htonl(DTOFP(sys_jitter));
        is->stability = htonl(DTOUFP(clock_stability * 1e6));
        is->refid = sys_refid;
        HTONL_FP(&sys_reftime, &is->reftime);
index beaf202e56607f948d827146a4fb803e837c69c5..d9c7527d961cdc86ca8c7e6dfdadc965a4e70a76 100644 (file)
@@ -225,7 +225,8 @@ hourly_stats(void)
        NLOG(NLOG_SYSSTATIST)
                msyslog(LOG_INFO,
                    "offset %.6f sec freq %.3f ppm error %.6f poll %d",
-                   last_offset, drift_comp * 1e6, sys_error, sys_poll);
+                   last_offset, drift_comp * 1e6, sys_jitter, sys_poll);
+
        
        if (stats_drift_file != 0) {
                if ((fp = fopen(stats_temp_file, "w")) == NULL) {
@@ -513,7 +514,7 @@ record_loop_stats(void)
        if (loopstats.fp != NULL) {
                fprintf(loopstats.fp, "%lu %lu.%03lu %.9f %.6f %.9f %.6f %d\n",
                    day, sec, msec, last_offset, drift_comp * 1e6,
-                   sys_error, clock_stability * 1e6, sys_poll);
+                   sys_jitter, clock_stability * 1e6, sys_poll);
                fflush(loopstats.fp);
        }
 }
index 2ede24292d197f2912c995c31ff9bb221c33f524..293c2281c783266106cc65702446c9f8aff62935 100644 (file)
@@ -1390,7 +1390,6 @@ chu_major(
                return (0);
        }
        pp->lastref = offset;
-       pp->variance = 0;
        for (i = 0; i < up->ntstamp; i++) {
                toffset = offset;
                L_SUB(&toffset, &up->tstamp[i]);
index 12184dbc97cdd96e02330ae4dc5d7ee99d7474c8..6d2a5329518023fd52cf265aa126241d13034f81 100644 (file)
@@ -213,7 +213,7 @@ local_poll(
        refclock_process_offset(pp, pp->lastrec, pp->lastrec, pp->fudgetime1);
        pp->leap = LEAP_NOWARNING;
        pp->disp = DISPERSION;
-       pp->variance = 0;
+       pp->jitter = 0;
 #if defined(KERNEL_PLL) && defined(STA_CLK)
 
        /*
@@ -246,7 +246,7 @@ local_poll(
                                pp->leap = LEAP_NOTINSYNC;
                        }
                        pp->disp = ntv.maxerror / 1e6;
-                       pp->variance = SQUARE(ntv.esterror / 1e6);
+                       pp->jitter = SQUARE(ntv.esterror / 1e6);
                }
        } else {
                ext_enable = 0;
index 4367b7593a6ae8a2cc9ffe502c65bc3c936e1bd7..24a852f304d756fc51420ab156f0d87667d46c36 100644 (file)
@@ -107,16 +107,15 @@ struct ctl_var sys_var[] = {
        { CS_POLL,      UI,     "poll" },       /* 8 */
        { CS_PEERID,    UI,     "peer" },       /* 9 */
        { CS_STATE,     UI,     "state" },      /* 10 */
-       { CS_OFFSET,    FL,     "phase" },      /* 11 */
+       { CS_OFFSET,    FL,     "offset" },     /* 11 */
        { CS_DRIFT,     FS,     "frequency" },  /* 12 */
-       { CS_COMPLIANCE, FU,    "error" },      /* 13 */
-       { CS_JITTER,    FU,     "jitter" },     /* 14 */
-       { CS_CLOCK,     TS,     "clock" },      /* 15 */
-       { CS_PROCESSOR, ST,     "processor" },  /* 16 */
-       { CS_SYSTEM,    ST,     "system" },     /* 17 */
-       { CS_VERSION,   ST,     "version" },    /* 18 */
-       { CS_STABIL,    FS,     "stability" },  /* 19 */
-       { CS_VARLIST,   ST,     "sys_var_list" }, /* 20 */
+       { CS_JITTER,    FU,     "jitter" },     /* 13 */
+       { CS_CLOCK,     TS,     "clock" },      /* 14 */
+       { CS_PROCESSOR, ST,     "processor" },  /* 15 */
+       { CS_SYSTEM,    ST,     "system" },     /* 16 */
+       { CS_VERSION,   ST,     "version" },    /* 17 */
+       { CS_STABIL,    FS,     "stability" },  /* 18 */
+       { CS_VARLIST,   ST,     "sys_var_list" }, /* 19 */
        { 0,            EOV,    ""      }
 };