<html lang='en'>
<head>
<meta content='text/html; charset=utf-8' http-equiv='Content-Type'>
<title>
GitLab
</title>
</meta>
</head>
<style>
img {
max-width: 100%;
height: auto;
}
p.details {
font-style:italic;
color:#777
}
.footer p {
font-size:small;
color:#777
}
pre.commit-message {
white-space: pre-wrap;
}
.file-stats a {
text-decoration: none;
}
.file-stats .new-file {
color: #090;
}
.file-stats .deleted-file {
color: #B00;
}
</style>
<body>
<div class='content'>
<h3>
Hal Murray pushed to branch master
at <a href="https://gitlab.com/NTPsec/ntpsec">NTPsec / ntpsec</a>
</h3>
<h4>
Commits:
</h4>
<ul>
<li>
<strong><a href="https://gitlab.com/NTPsec/ntpsec/commit/2807ed51ec562bed4bee2034b9d12143cb251914">2807ed51</a></strong>
<div>
<span>by Hal Murray</span>
<i>at 2015-12-21T18:31:18Z</i>
</div>
<pre class='commit-message'>Add clockstats line to ATOM/PPS driver</pre>
</li>
</ul>
<h4>4 changed files:</h4>
<ul>
<li class='file-stats'>
<a href='#diff-0'>
docs/driver22.txt
</a>
</li>
<li class='file-stats'>
<a href='#diff-1'>
include/refclock_atom.h
</a>
</li>
<li class='file-stats'>
<a href='#diff-2'>
ntpd/ntp_refclock.c
</a>
</li>
<li class='file-stats'>
<a href='#diff-3'>
ntpd/refclock_atom.c
</a>
</li>
</ul>
<h4>Changes:</h4>
<li id='diff-0'>
<a href='https://gitlab.com/NTPsec/ntpsec/commit/2807ed51ec562bed4bee2034b9d12143cb251914#diff-0'>
<strong>
docs/driver22.txt
</strong>
</a>
<hr>
<pre class="highlight"><code><span style="color: #000000;background-color: #ffdddd">--- a/docs/driver22.txt
</span><span style="color: #000000;background-color: #ddffdd">+++ b/docs/driver22.txt
</span><span style="color: #aaaaaa">@@ -123,6 +123,35 @@ synchronization without needing the Internet at all.
</span> Record a timestamp once for each second if 1. Useful for constructing
Allan deviation plots.
<span style="color: #000000;background-color: #ddffdd">+== Clockstats ==
+
+If clockstats is enabled, the driver will log a few counters. Examples:
+
+----------------------------------------------------------------------------
+57378 3313.351 127.127.22.0 423681 64 0 0 0
+57378 3377.352 127.127.22.0 423745 64 0 0 0
+57378 3441.352 127.127.22.0 423809 64 0 0 0
+57378 3505.351 127.127.22.0 423873 64 0 0 0
+----------------------------------------------------------------------------
+
+.Clockstats
+[cols="10%,20%,70%",options="header"]
+|=============================================================================
+|Column|Sample |Meaning
+|1 |57378 |MJD
+|2 |3505.351 |Time of day in seconds
+|3 |127.127.22.0 |IP Address from server config line
+|4 |423873 |Total number of PPS pulses the kernel has seen
+|5 |64 |Number of PPS pulses the driver processed
+ This should be the difference between col 4 and
+ col 4 from the previous line
+|6 |0 |ntpd doesn't know the time yet
+|7 |0 |Error from Kernel
+|8 |0 |Number of times there was no pulse ready
+|=============================================================================
+
+
+
</span> == Additional Information ==
link:refclock.html[Reference Clock Drivers]
<span style="color: #aaaaaa">@@ -142,3 +171,4 @@ David L. Mills <mills@udel.edu>
</span> '''''
include::includes/footer.txt[]
<span style="color: #000000;background-color: #ddffdd">+
</span></code></pre>
<br>
</li>
<li id='diff-1'>
<a href='https://gitlab.com/NTPsec/ntpsec/commit/2807ed51ec562bed4bee2034b9d12143cb251914#diff-1'>
<strong>
include/refclock_atom.h
</strong>
</a>
<hr>
<pre class="highlight"><code><span style="color: #000000;background-color: #ffdddd">--- a/include/refclock_atom.h
</span><span style="color: #000000;background-color: #ddffdd">+++ b/include/refclock_atom.h
</span><span style="color: #aaaaaa">@@ -1,15 +1,22 @@
</span> /*
* Definitions for the atom driver and its friends
*/
<span style="color: #000000;background-color: #ffdddd">-#undef NANOSECOND /* some systems define it differently */
-#define NANOSECOND 1000000000 /* one second (ns) */
</span>
struct refclock_atom {
pps_handle_t handle;
pps_params_t pps_params;
struct timespec ts;
<span style="color: #000000;background-color: #ddffdd">+ unsigned long sequence;
</span> };
<span style="color: #000000;background-color: #ddffdd">+typedef enum {
+ PPS_OK,
+ PPS_SETUP, /* PPS not setup */
+ PPS_KERNEL, /* PPS error from kernel */
+ PPS_NREADY /* PPS not ready */
+} pps_status;
+
</span> extern bool refclock_ppsapi(int, struct refclock_atom *);
extern bool refclock_params(int, struct refclock_atom *);
<span style="color: #000000;background-color: #ffdddd">-extern bool refclock_pps(struct peer *, struct refclock_atom *, int);
</span><span style="color: #000000;background-color: #ddffdd">+extern pps_status refclock_pps(struct peer *, struct refclock_atom *, int);
+
</span></code></pre>
<br>
</li>
<li id='diff-2'>
<a href='https://gitlab.com/NTPsec/ntpsec/commit/2807ed51ec562bed4bee2034b9d12143cb251914#diff-2'>
<strong>
ntpd/ntp_refclock.c
</strong>
</a>
<hr>
<pre class="highlight"><code><span style="color: #000000;background-color: #ffdddd">--- a/ntpd/ntp_refclock.c
</span><span style="color: #000000;background-color: #ddffdd">+++ b/ntpd/ntp_refclock.c
</span><span style="color: #aaaaaa">@@ -65,7 +65,7 @@ bool cal_enable; /* enable refclock calibrate */
</span> * Forward declarations
*/
static int refclock_cmpl_fp (const void *, const void *);
<span style="color: #000000;background-color: #ffdddd">-static int refclock_sample (struct refclockproc *);
</span><span style="color: #000000;background-color: #ddffdd">+static int refclock_sample (struct peer *);
</span> static bool refclock_ioctl(int, u_int);
<span style="color: #aaaaaa">@@ -443,12 +443,14 @@ refclock_process(
</span> */
static int
refclock_sample(
<span style="color: #000000;background-color: #ffdddd">- struct refclockproc *pp /* refclock structure pointer */
</span><span style="color: #000000;background-color: #ddffdd">+ struct peer *peer /* peer structure pointer */
</span> )
{
<span style="color: #000000;background-color: #ddffdd">+ struct refclockproc *pp = peer->procptr;
</span> size_t i, j, k, m, n;
double off[MAXSTAGE];
<span style="color: #000000;background-color: #ffdddd">- double offset;
</span><span style="color: #000000;background-color: #ddffdd">+ double offset, std_dev;
+ double mean_all, std_dev_all;
</span>
/*
* Copy the raw offsets and sort into ascending order. Don't do
<span style="color: #aaaaaa">@@ -492,6 +494,26 @@ refclock_sample(
</span> }
pp->offset /= m;
pp->jitter = max(SQRT(pp->jitter / m), LOGTOD(sys_precision));
<span style="color: #000000;background-color: #ddffdd">+
+ std_dev = 0;
+ for (k = i; k < j; k++)
+ std_dev += SQUARE(off[k] - pp->offset);
+ std_dev = SQRT(std_dev / m);
+
+ mean_all = 0;
+ for (k = 0; k < n; k++)
+ mean_all += off[k];
+ mean_all /= n;
+ std_dev_all = 0;
+ for (k = 0; k < n; k++)
+ std_dev_all += SQUARE(off[k] - mean_all);
+ std_dev_all = SQRT(std_dev_all / n);
+
+ record_ref_stats(&peer->srcadr, n, i, j-1,
+ off[0], off[i], pp->offset, off[j-1], off[n-1],
+ pp->jitter, std_dev, std_dev_all);
+
+
</span> #ifdef DEBUG
if (debug)
printf(
<span style="color: #aaaaaa">@@ -545,7 +567,7 @@ refclock_receive(
</span> peer->aorg = pp->lastrec;
peer->rootdisp = pp->disp;
get_systime(&peer->dst);
<span style="color: #000000;background-color: #ffdddd">- if (!refclock_sample(pp))
</span><span style="color: #000000;background-color: #ddffdd">+ if (!refclock_sample(peer))
</span> return;
clock_filter(peer, pp->offset, 0., pp->jitter);
<span style="color: #aaaaaa">@@ -1169,7 +1191,7 @@ refclock_params(
</span> * timestamp from the kernel and saves the sign-extended fraction in
* a circular buffer for processing at the next poll event.
*/
<span style="color: #000000;background-color: #ffdddd">-bool
</span><span style="color: #000000;background-color: #ddffdd">+pps_status
</span> refclock_pps(
struct peer *peer, /* peer structure pointer */
struct refclock_atom *ap, /* atom structure pointer */
<span style="color: #aaaaaa">@@ -1190,11 +1212,11 @@ refclock_pps(
</span> */
pp = peer->procptr;
if (ap->handle == 0)
<span style="color: #000000;background-color: #ffdddd">- return false;
</span><span style="color: #000000;background-color: #ddffdd">+ return PPS_SETUP;
</span>
if (ap->pps_params.mode == 0 && sys_leap != LEAP_NOTINSYNC) {
if (refclock_params(pp->sloppyclockflag, ap) < 1)
<span style="color: #000000;background-color: #ffdddd">- return false;
</span><span style="color: #000000;background-color: #ddffdd">+ return PPS_SETUP;
</span> }
timeout.tv_sec = 0;
timeout.tv_nsec = 0;
<span style="color: #aaaaaa">@@ -1202,18 +1224,26 @@ refclock_pps(
</span> if (time_pps_fetch(ap->handle, PPS_TSFMT_TSPEC, &pps_info,
&timeout) < 0) {
refclock_report(peer, CEVNT_FAULT);
<span style="color: #000000;background-color: #ffdddd">- return false;
</span><span style="color: #000000;background-color: #ddffdd">+ return PPS_KERNEL;
</span> }
timeout = ap->ts;
<span style="color: #000000;background-color: #ffdddd">- if (ap->pps_params.mode & PPS_CAPTUREASSERT)
</span><span style="color: #000000;background-color: #ddffdd">+ if (ap->pps_params.mode & PPS_CAPTUREASSERT) {
</span> ap->ts = pps_info.assert_timestamp;
<span style="color: #000000;background-color: #ffdddd">- else if (ap->pps_params.mode & PPS_CAPTURECLEAR)
</span><span style="color: #000000;background-color: #ddffdd">+ ap->sequence = pps_info.assert_sequence;
+ }
+ else if (ap->pps_params.mode & PPS_CAPTURECLEAR) {
</span> ap->ts = pps_info.clear_timestamp;
<span style="color: #000000;background-color: #ddffdd">+ ap->sequence = pps_info.clear_sequence;
+ }
</span> else
<span style="color: #000000;background-color: #ffdddd">- return false;
</span><span style="color: #000000;background-color: #ddffdd">+ return PPS_NREADY;
</span>
<span style="color: #000000;background-color: #ddffdd">+ /* Check for duplicates.
+ * Sequence number might not be implemented.
+ * saved (above) for debugging.
+ */
</span> if (0 == memcmp(&timeout, &ap->ts, sizeof(timeout)))
<span style="color: #000000;background-color: #ffdddd">- return false;
</span><span style="color: #000000;background-color: #ddffdd">+ return PPS_NREADY;
</span>
/*
* Convert to signed fraction offset and stuff in median filter.
<span style="color: #aaaaaa">@@ -1229,7 +1259,7 @@ refclock_pps(
</span> printf("refclock_pps: %lu %f %f\n", current_time,
dtemp, pp->fudgetime1);
#endif
<span style="color: #000000;background-color: #ffdddd">- return true;
</span><span style="color: #000000;background-color: #ddffdd">+ return PPS_OK;
</span> }
#endif /* HAVE_PPSAPI */
#endif /* REFCLOCK */
</code></pre>
<br>
</li>
<li id='diff-3'>
<a href='https://gitlab.com/NTPsec/ntpsec/commit/2807ed51ec562bed4bee2034b9d12143cb251914#diff-3'>
<strong>
ntpd/refclock_atom.c
</strong>
</a>
<hr>
<pre class="highlight"><code><span style="color: #000000;background-color: #ffdddd">--- a/ntpd/refclock_atom.c
</span><span style="color: #000000;background-color: #ddffdd">+++ b/ntpd/refclock_atom.c
</span><span style="color: #aaaaaa">@@ -84,6 +84,10 @@
</span> struct ppsunit {
struct refclock_atom atom; /* atom structure pointer */
int fddev; /* file descriptor */
<span style="color: #000000;background-color: #ddffdd">+ int pcount; /* PPS samples added to FIFO */
+ int scount; /* PPS not setup */
+ int kcount; /* PPS error from kernel */
+ int rcount; /* PPS not ready */
</span> };
/*
<span style="color: #aaaaaa">@@ -183,16 +187,31 @@ atom_timer(
</span> struct peer *peer /* peer structure pointer */
)
{
<span style="color: #000000;background-color: #ffdddd">- struct ppsunit *up;
- struct refclockproc *pp;
- char tbuf[80];
</span><span style="color: #000000;background-color: #ddffdd">+ struct ppsunit *up;
+ struct refclockproc *pp;
+ pps_status rc;
</span>
UNUSED_ARG(unit);
pp = peer->procptr;
up = pp->unitptr;
<span style="color: #000000;background-color: #ffdddd">- if (refclock_pps(peer, &up->atom, pp->sloppyclockflag) <= 0)
- return;
</span><span style="color: #000000;background-color: #ddffdd">+ rc = refclock_pps(peer, &up->atom, pp->sloppyclockflag);
+ switch (rc) {
+ case PPS_OK:
+ up->pcount++;
+ break;
+ default:
+ case PPS_SETUP:
+ up->scount++;
+ break;
+ case PPS_KERNEL:
+ up->kcount++;
+ break;
+ case PPS_NREADY:
+ up->rcount++;
+ break;
+ }
+ if (rc != PPS_OK) return;
</span>
peer->flags |= FLAG_PPS;
<span style="color: #aaaaaa">@@ -201,9 +220,8 @@ atom_timer(
</span> * That's so we can make awesome Allan deviation plots.
*/
if (pp->sloppyclockflag & CLK_FLAG4) {
<span style="color: #000000;background-color: #ffdddd">- snprintf(tbuf, sizeof(tbuf), "%.9f",
- pp->filter[pp->coderecv]);
- record_clock_stats(&peer->srcadr, tbuf);
</span><span style="color: #000000;background-color: #ddffdd">+ mprintf_clock_stats(&peer->srcadr, "%.9f",
+ pp->filter[pp->coderecv]);
</span> }
}
<span style="color: #aaaaaa">@@ -217,19 +235,32 @@ atom_poll(
</span> struct peer *peer /* peer structure pointer */
)
{
<span style="color: #000000;background-color: #ddffdd">+ struct ppsunit *up;
</span> struct refclockproc *pp;
UNUSED_ARG(unit);
<span style="color: #000000;background-color: #ddffdd">+ pp = peer->procptr;
+ up = (struct ppsunit *)pp->unitptr;
+
</span> /*
* Don't wiggle the clock until some other driver has numbered
* the seconds.
*/
<span style="color: #000000;background-color: #ffdddd">- if (sys_leap == LEAP_NOTINSYNC)
</span><span style="color: #000000;background-color: #ddffdd">+ if (sys_leap == LEAP_NOTINSYNC) {
+ pp->codeproc = pp->coderecv; // xxx ??
+ up->pcount = up->scount = up->kcount = up->rcount = 0;
</span> return;
<span style="color: #000000;background-color: #ddffdd">+ }
</span>
<span style="color: #000000;background-color: #ffdddd">- pp = peer->procptr;
</span> pp->polls++;
<span style="color: #000000;background-color: #ddffdd">+
+ mprintf_clock_stats(&peer->srcadr,
+ "%ld %d %d %d %d",
+ up->atom.sequence,
+ up->pcount, up->scount, up->kcount, up->rcount);
+ up->pcount = up->scount = up->kcount = up->rcount = 0;
+
</span> if (pp->codeproc == pp->coderecv) {
peer->flags &= ~FLAG_PPS;
refclock_report(peer, CEVNT_TIMEOUT);
</code></pre>
<br>
</li>
</div>
<div class='footer' style='margin-top: 10px;'>
<p>
—
<br>
<a href="https://gitlab.com/NTPsec/ntpsec/commit/2807ed51ec562bed4bee2034b9d12143cb251914">View it on GitLab</a>.
<br>
You're receiving this email because of your account on gitlab.com.
If you'd like to receive fewer emails, you can adjust your notification settings.
<script type="application/ld+json">{"@context":"http://schema.org","@type":"EmailMessage","action":{"@type":"ViewAction","name":"View Commit","url":"https://gitlab.com/NTPsec/ntpsec/commit/2807ed51ec562bed4bee2034b9d12143cb251914"}}</script>
</p>
</div>
</body>
</html>