]> git.ipfire.org Git - thirdparty/ntp.git/commitdiff
Many files:
authorHarlan Stenn <stenn@ntp.org>
Sun, 20 Aug 2000 20:08:26 +0000 (20:08 -0000)
committerHarlan Stenn <stenn@ntp.org>
Sun, 20 Aug 2000 20:08:26 +0000 (20:08 -0000)
  * util/ntptime.c (main): Report TAI stuff
  * ntpq/ntpq.c: CS_COMPLIANCE/CS_JITTER cleanup
  * ntpd/ntp_loopfilter.c (local_clock): sys_error/sys_jitter cleanup.
  kernel PPL cleanup.
  * ntpd/ntp_crypto.c: Check NTP_API if we're doing KERNEL_PLL so we
  can get the TAI stuff.
  * ntpd/ntp_control.c: CS_COMPLIANCE now reports "error" instead of
  "jitter".  CS_JITTER now reports jitter.
  * include/ntpd.h: Added sys_jitter
  * include/ntp_control.h (CS_JITTER): Added
  From: Dave Mills

bk: 39a03abaoCpAzZJSx21aNTeAEAwG2Q

ChangeLog
include/ntp_control.h
include/ntpd.h
ntpd/ntp_control.c
ntpd/ntp_crypto.c
ntpd/ntp_loopfilter.c
ntpq/ntpq.c
util/ntptime.c

index 543d80307b08872238ef2d456b61594c58c70056..7a6517a8ab4c6d7ae9b2a1e5b7e30bdbf65e7e0f 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,17 @@
 2000-08-20  Harlan Stenn  <stenn@whimsy.udel.edu>
 
+       * util/ntptime.c (main): Report TAI stuff
+       * ntpq/ntpq.c: CS_COMPLIANCE/CS_JITTER cleanup
+       * ntpd/ntp_loopfilter.c (local_clock): sys_error/sys_jitter cleanup.
+       kernel PPL cleanup.
+       * ntpd/ntp_crypto.c: Check NTP_API if we're doing KERNEL_PLL so we
+       can get the TAI stuff.
+       * ntpd/ntp_control.c: CS_COMPLIANCE now reports "error" instead of
+       "jitter".  CS_JITTER now reports jitter.
+       * include/ntpd.h: Added sys_jitter
+       * include/ntp_control.h (CS_JITTER): Added
+       From: Dave Mills
+
        * ntpd/cmd_args.c (getCmdOpts): Crack -N at pre-scan, as we do the
        priority wiggle before the final scan.
        From: Tom Smith <smith@cag.lkg.dec.com>
index 624925b3ecd26cb3930a780553cfdb71dfbb30a3..0210bf716545454deb0d28832b200ca813f80bd0 100644 (file)
@@ -158,20 +158,21 @@ struct ntp_control {
 #define        CS_OFFSET       11
 #define        CS_DRIFT        12
 #define        CS_COMPLIANCE   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
+#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
 #ifdef PUBKEY
-#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_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_MAXCODE      CS_TAI
 #else
 #define        CS_MAXCODE      CS_VARLIST
index 653a77c390f28baa4175407759e3abed5ebc2f56..fa9ed48996a8e916772e633bf314d598ef8f45fc 100644 (file)
@@ -286,7 +286,8 @@ extern int  tc_counter;             /* poll-adjust counter */
 extern u_long  last_time;              /* time of last clock update (s) */
 extern double  last_offset;            /* last clock offset (s) */
 extern double  allan_xpt;              /* Allan intercept (s) */
-extern double  sys_error;              /* system standard error (s) */
+extern double  sys_error;              /* system RMS error (s) */
+extern double  sys_jitter;             /* system RMS jitter (s) */
 
 /* ntp_monitor.c */
 extern struct mon_data mon_mru_list;
index 4c40fd74f85ac0a3fa53d375aaf63148a4cf3a27..527ac3012a5722e98250f66cc867e4f469c956e7 100644 (file)
@@ -106,21 +106,22 @@ static struct ctl_var sys_var[] = {
        { CS_STATE,     RO, "state" },          /* 10 */
        { CS_OFFSET,    RO, "phase" },          /* 11 */
        { CS_DRIFT,     RO, "frequency" },      /* 12 */
-       { CS_COMPLIANCE, 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 */
+       { 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 */
 #ifdef PUBKEY
-       { 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 */
+       { 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 */
 #endif /* PUBKEY */
        { 0,            EOV,    ""  }
 };
@@ -147,8 +148,9 @@ static      u_char def_sys_var[] = {
        CS_CLOCK,
        CS_STATE,
        CS_OFFSET,
-       CS_DRIFT,
        CS_COMPLIANCE,
+       CS_JITTER,
+       CS_DRIFT,
        CS_STABIL,
 #ifdef PUBKEY
        CS_FLAGS,
@@ -1220,6 +1222,10 @@ ctl_putsys(
                    1e3);
                break;
 
+       case CS_JITTER:
+               ctl_putdbl(sys_var[CS_JITTER].text, sys_jitter * 1e3);
+               break;
+
        case CS_CLOCK:
                get_systime(&tmp);
                ctl_putts(sys_var[CS_CLOCK].text, &tmp);
index b98e8b087f134c2188990d7e92ba07ade3411924..431499cf29549526db89012706f9c3fc48c715f7 100644 (file)
 #include "ntp_string.h"
 #include "ntp_crypto.h"
 
+#ifdef KERNEL_PLL
+#include "ntp_syscall.h"
+#endif /* KERNEL_PLL */
+
 /*
  * Extension field message formats
  *
@@ -312,6 +316,11 @@ crypto_recv(
        u_int rsalen = sizeof(R_RSA_PUBLIC_KEY) - sizeof(u_int) + 4;
        u_int bits;
        int j;
+#ifdef KERNEL_PLL
+#if NTP_API > 3
+       struct timex ntv;       /* kernel interface structure */
+#endif /* NTP_API */
+#endif /* KERNEL_PLL */
 #endif /* PUBKEY */
 
        /*
@@ -788,6 +797,15 @@ crypto_recv(
                        peer->flash &= ~TEST10;
                        crypto_flags |= CRYPTO_FLAG_TAI;
                        sys_tai = temp / 4 + TAI_1972 - 1;
+#ifdef KERNEL_PLL
+#if NTP_API > 3
+                       ntv.modes = MOD_TAI;
+                       ntv.constant = sys_tai;
+                       if (ntp_adjtime(&ntv) == TIME_ERROR)
+                               msyslog(LOG_ERR,
+                                   "kernel TAI update failed");
+#endif /* NTP_API */
+#endif /* KERNEL_PLL */
 
                        /*
                         * Initialize leapseconds table and extension
@@ -1553,6 +1571,11 @@ crypto_tai(
        u_int len;
        char *rptr;
        int rval, i;
+#ifdef KERNEL_PLL
+#if NTP_API > 3
+       struct timex ntv;       /* kernel interface structure */
+#endif /* NTP_API */
+#endif /* KERNEL_PLL */
 
        /*
         * Open the key file and discard comment lines. If the first
@@ -1624,6 +1647,14 @@ crypto_tai(
        tai_leap.sig = emalloc(private_key.bits / 8);
        crypto_flags |= CRYPTO_FLAG_TAI;
        sys_tai = len / 4 + TAI_1972 - 1;
+#ifdef KERNEL_PLL
+#if NTP_API > 3
+       ntv.modes = MOD_TAI;
+       ntv.constant = sys_tai;
+       if (ntp_adjtime(&ntv) == TIME_ERROR)
+               msyslog(LOG_ERR, "kernel TAI update failed");
+#endif /* NTP_API */
+#endif /* KERNEL_PLL */
 
 
        /*
index 5b62c1e81a1e3923d10513e510edb7bb1d88d31b..d50765980316d7fe421c74144612f0872cbded66 100644 (file)
@@ -97,7 +97,7 @@ static double clock_offset;   /* clock offset adjustment (s) */
 double drift_comp;             /* clock frequency (ppm) */
 double clock_stability;        /* clock stability (ppm) */
 double clock_max = CLOCK_MAX;  /* max offset allowed before step (s) */
-static double clock_panic = CLOCK_PANIC; /* max offset allowed before panic */
+static double clock_panic = CLOCK_PANIC; /* max offset before panic */
 u_long pps_control;            /* last pps sample time */
 static void rstclock P((int)); /* state transition function */
 
@@ -129,7 +129,8 @@ 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 standard error (s) */
+double sys_error;              /* system RMS error (s) */
+double sys_jitter;             /* system RMS jitter (s) */
 
 #if defined(KERNEL_PLL)
 /* Emacs cc-mode goes nuts if we split the next line... */
@@ -218,9 +219,9 @@ local_clock(
        /*
         * Update the jitter estimate.
         */
-       oerror = sys_error;
-       dtemp = SQUARE(sys_error);
-       sys_error = SQRT(dtemp + (epsil - dtemp) / CLOCK_AVG);
+       oerror = sys_jitter;
+       dtemp = SQUARE(sys_jitter);
+       sys_jitter = SQRT(dtemp + (epsil - dtemp) / CLOCK_AVG);
 
        /*
         * Clock state machine transition function. This is where the
@@ -507,23 +508,19 @@ local_clock(
                 * If the kernel pps discipline is working, monitor its
                 * performance.
                 */
-               if (ntv.status & STA_PPSTIME) {
+               if (ntv.status & STA_PPSTIME && ntv.status &
+                   STA_PPSSIGNAL) {
                        if (!pps_control)
                                NLOG(NLOG_SYSEVENT)msyslog(LOG_INFO,
                                    "pps sync enabled");
                        pps_control = current_time;
 #ifdef STA_NANO
                        if (pll_nano)
-                               record_peer_stats(
-                                   &loopback_interface->sin,
-                                   ctlsysstatus(), ntv.offset / 1e9,
-                                   0, ntv.jitter / 1e9, 0);
+                               sys_jitter = ntv.jitter / 1e9;
                        else
 #endif /* STA_NANO */
-                               record_peer_stats(
-                                   &loopback_interface->sin,
-                                   ctlsysstatus(), ntv.offset / 1e6,
-                                   0, ntv.jitter / 1e6, 0);
+                               sys_jitter = ntv.jitter / 1e6;
+                       sys_poll = ntv.shift;
                }
        }
 #endif /* KERNEL_PLL */
@@ -551,7 +548,7 @@ local_clock(
         */
        if (state == S_SYNC) {
                if (clock_stability < CLOCK_MAXSTAB &&
-                   fabs(clock_offset) < CLOCK_PGATE * sys_error) {
+                   fabs(clock_offset) < CLOCK_PGATE * sys_jitter) {
                        tc_counter += sys_poll;
                        if (tc_counter > CLOCK_LIMIT) {
                                tc_counter = CLOCK_LIMIT;
@@ -577,11 +574,14 @@ local_clock(
         */
        last_time = current_time;
        last_offset = clock_offset;
-       dtemp = peer->disp + SQRT(peer->variance + SQUARE(sys_error));
+       dtemp = SQUARE(sys_error);
+       sys_error = SQRT(dtemp + (SQUARE(last_offset) - dtemp) /
+           CLOCK_AVG);
+       dtemp = peer->disp + SQRT(peer->variance + SQUARE(sys_jitter));
        if ((peer->flags & FLAG_REFCLOCK) == 0 && dtemp < MINDISPERSE)
                dtemp = MINDISPERSE;
        sys_rootdispersion = peer->rootdispersion + dtemp;
-       (void)record_loop_stats();
+       record_loop_stats();
 #ifdef DEBUG
        if (debug > 1)
                printf(
@@ -592,9 +592,9 @@ local_clock(
 #ifdef DEBUG
        if (debug > 1)
                printf(
-       "local_clock: jitter %.6f freq %.3f stab %.3f poll %d count %d\n",
-                   sys_error, drift_comp * 1e6, clock_stability * 1e6,
-                   sys_poll, tc_counter);
+       "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);
 #endif /* DEBUG */
        return (retval);
 }
index 912dc85063d2015687b18f22f0d6fdecfd67e1f9..4367b7593a6ae8a2cc9ffe502c65bc3c936e1bd7 100644 (file)
@@ -109,12 +109,14 @@ struct ctl_var sys_var[] = {
        { CS_STATE,     UI,     "state" },      /* 10 */
        { CS_OFFSET,    FL,     "phase" },      /* 11 */
        { CS_DRIFT,     FS,     "frequency" },  /* 12 */
-       { CS_COMPLIANCE, FU,    "jitter" },     /* 13 */
-       { CS_CLOCK,     TS,     "clock" },      /* 14 */
-       { CS_PROCESSOR, ST,     "processor" },  /* 15 */
-       { CS_SYSTEM,    ST,     "system" },     /* 16 */
-       { CS_STABIL,    FS,     "stability" },  /* 17 */
-       { CS_VARLIST,   ST,     "sys_var_list" }, /* 18 */
+       { 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 */
        { 0,            EOV,    ""      }
 };
 
index 4aaa53f00a90b424aea04bfa6d0e7d317b7fecf1..effa1d60b4ee58420a2f6e1895f95ac406d0cde1 100644 (file)
@@ -258,12 +258,18 @@ main(
                ts.l_uf &= ts_mask;
                printf("  time %s, (.%0*d),\n",
                       prettydate(&ts), fdigits, (int) time_frac);
-               printf("  maximum error %lu us, estimated error %lu us.\n",
+               printf("  maximum error %lu us, estimated error %lu us",
                       (u_long)ntv.maxerror, (u_long)ntv.esterror);
-               if (rawtime) printf("  ntptime=%x.%x unixtime=%x.%0*d %s",
+               if (rawtime)
+                   printf("  ntptime=%x.%x unixtime=%x.%0*d %s",
                    (unsigned int) ts.l_ui, (unsigned int) ts.l_uf,
                    (int) ntv.time.tv_sec, fdigits, (int) time_frac,
                    ctime((const time_t *) &ntv.time.tv_sec));
+#if NTP_API > 3
+               printf(", TAI offset %d\n", ntv.tai);
+#else
+               printf("\n");
+#endif /* NTP_API */
        }
        status = ntp_adjtime(&ntx);
        if (status < 0)