Subject: [ntpwg] RFC 5905, page 21, "Precision"

From: "Ulrich Windl" <[email-masked]>
Date: Thu, 05 Nov 2015 14:18:13 +0100

Hi!

I think I found a bug in RFC 5905 on page 21:

"Precision: 8-bit signed integer representing the precision of the
system clock, in log2 seconds.  For instance, a value of -18
corresponds to a precision of about one microsecond."

2^-21
.0000004768
2^-20
.0000009536
2^-19
.0000019073
2^-18
.0000038146

So I guess it's 2^-20 that is closest to 1 microsecond resolution, unless the specification is wrong.
Maybe the specification should include the term "less or equal to 2^-precision".

In the reference implementation the code can be found in ntpd/ntp_proto.c (set_sys_tick_precision).
        /*
         * Find the nearest power of two.
         */
        for (i = 0; tick <= 1; i--)
                tick *= 2;
        if (tick - 1 > 1 - tick / 2)
                i++;

In the OLD xntp (xntpd/npt_proto(default_get_precision)) there is this code:
        val = MAXSTEP;
[...]
        if (usec >= HUSECS)
                val = MINSTEP;  /* val <= MINSTEP; fast machine */
        diff = HUSECS;
        for (i = 0; diff > val; i--)
                diff >>= 1;
        return (i);

Regards,
Ulrich Windl

_______________________________________________
ntpwg mailing list
[email-masked]
http://lists.ntp.org/listinfo/ntpwg

---

From: Miroslav Lichvar <[email-masked]>
Date: Thu, 5 Nov 2015 16:04:18 +0100

> So I guess it's 2^-20 that is closest to 1 microsecond resolution, unless the specification is wrong.

Yes, it seems precision of 1 microsecond should be encoded as -20, so
-18 in the example in the RFC should be -20. I think I actually
noticed that some time ago, but forgot about it.

-- 
Miroslav Lichvar

---

From: Brian Haberman <[email-masked]>
Date: Thu, 5 Nov 2015 19:28:22 -0500

https://www.rfc-editor.org/errata_search.php?eid=2476

---

From: "Ulrich Windl" <[email-masked]>
Date: Fri, 06 Nov 2015 08:23:22 +0100

>>> Brian Haberman <[email-masked]> schrieb am 06.11.2015 um 01:28 in
> https://www.rfc-editor.org/errata_search.php?eid=2476 

Thanks!

After sending, I faintly remembered that I heard about that before.
The problem with all these erratas is  that they aren't integrated to the document, so you still get the original document with all the errors. Maybe it would be nice to have RFCxxx-FIXy that has the errata applied. An alternative would be complete "replacement pages", possibly "extra long" as a change in page break should be avoided.

And for the records: It seems RFC 1305 is more precise about the definition:
"Precision (sys.precision, peer.precision, pkt.precision): This is a signed integer indicating the
precision of the various clocks, in seconds to the nearest power of two. The value must be
rounded to the next larger power of two; for instance, a 50-Hz (20 ms) or 60-Hz (16.67 ms)
power-frequency clock would be assigned the value -5 (31.25 ms), while a 1000-Hz (1 ms)
crystal-controlled clock would be assigned the value -9 (1.95 ms)."

So with that definition, the value in RFC 5905 should actually be -19.

Regards,
Ulrich