Re: [Ntp] Antwort: Re: The bump, or why NTP v5 must specify impulse response

Warner Losh <imp@bsdimp.com> Fri, 17 April 2020 15:35 UTC

Return-Path: <wlosh@bsdimp.com>
X-Original-To: ntp@ietfa.amsl.com
Delivered-To: ntp@ietfa.amsl.com
Received: from localhost (localhost [127.0.0.1]) by ietfa.amsl.com (Postfix) with ESMTP id 914133A0E59 for <ntp@ietfa.amsl.com>; Fri, 17 Apr 2020 08:35:33 -0700 (PDT)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -1.896
X-Spam-Level:
X-Spam-Status: No, score=-1.896 tagged_above=-999 required=5 tests=[BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, HTML_MESSAGE=0.001, SPF_HELO_NONE=0.001, SPF_NONE=0.001, URIBL_BLOCKED=0.001] autolearn=ham autolearn_force=no
Authentication-Results: ietfa.amsl.com (amavisd-new); dkim=pass (2048-bit key) header.d=bsdimp-com.20150623.gappssmtp.com
Received: from mail.ietf.org ([4.31.198.44]) by localhost (ietfa.amsl.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id mGc7DVQAHQen for <ntp@ietfa.amsl.com>; Fri, 17 Apr 2020 08:35:31 -0700 (PDT)
Received: from mail-qt1-x82c.google.com (mail-qt1-x82c.google.com [IPv6:2607:f8b0:4864:20::82c]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ietfa.amsl.com (Postfix) with ESMTPS id DD7E43A0A93 for <ntp@ietf.org>; Fri, 17 Apr 2020 08:35:30 -0700 (PDT)
Received: by mail-qt1-x82c.google.com with SMTP id o10so2256045qtr.6 for <ntp@ietf.org>; Fri, 17 Apr 2020 08:35:30 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bsdimp-com.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=mt+bcRZaaJ16GgNdFRhynDv4WO6fHfIrYM29kZ2CRwM=; b=MKEGfqF9bh/yKSbiGrtpDUInpS+EIeKB3g4ddKPg4UI1A1tdg4Nuz8qMqmsrj8ni6J r8Zl3600X1fG3zjE0g0LLbvlJKbkwtSx9dWiSy44Zo4WvQTu1A8ZBVkk0wcYbykj35PE GiNjwGbDRiDULNhRDEMLg4kq6rHBApjWkb9y9M98S8HMxG0Mg5E9cBkkGoy2mC6GjOAv RoiCrcf5/YrjdjHs6XFMENsy9+E1BpD6MAEF6N6WXrHBMLAO8jkmzpH4qKQG6imq4bHf WZMIhlMwaVR6bkg8iMfbjq8tnXTw31/PzASyEuqzQ6QsRX5NkgbnzGM3g144XwrAyiGi kaKA==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=mt+bcRZaaJ16GgNdFRhynDv4WO6fHfIrYM29kZ2CRwM=; b=qLjkTqcqfRnTF9ZxPPvXeVqzava9bcnKMgJQ1dIVTml6db0rnFiJoHqHVFuOwOJd0f P3VJhEVe9q/H+7u6+sFmiIx4AtgXz9x8r3d2CAlMF5bHHt1+a8ZzLCvjfTc5PSmISOoK TpKEBsmZheheEz9jsTU1rGuQ5bSY/1xCUQMBtErbjBj/GlcOooQBWVgwGWy7SCPdFLPQ VViFlTm7Fi1o/TDlXaZmb9H/JuW33ZidNLE0TRJTBTpyGR13j4gXJS3MIr3lH7mOB+f1 o5GM0Zsxc6r7Vzygs6kXb3KWFN849MNmBr5k5fq+uBu2KWmXVkLtoDTjffyEsWy6Smm6 P4rQ==
X-Gm-Message-State: AGi0PuZR1fBvbovJB4R7QJJvdMLlNSP4Zn6ewhBhjLAZ1wEEb+CALVlA jOjS7kMmAQuqINOqyeUcbMNAv7MwT5azXY4aRm+Brg==
X-Google-Smtp-Source: APiQypLiQqr15B9mXPfN25u+BZncdUo68C1PEm7IAKWsZ+0nDAVIw6CxdHPdsO1jSVKUJjWX81MqKThX0uqPJgpeSGY=
X-Received: by 2002:ac8:1206:: with SMTP id x6mr3514509qti.291.1587137729529; Fri, 17 Apr 2020 08:35:29 -0700 (PDT)
MIME-Version: 1.0
References: <CACsn0c=zzDKP6iBjPJWGF0rkqSaY3AY738ynGwDZO14sdBJ-Bg@mail.gmail.com> <CAJm83bB2A3VUxXX47Y0ubmS9Xne7PRSyV_xHY_D9YvHjqE-vFA@mail.gmail.com> <CACsn0cm3jpKZTUQ=novTgVaFhc1xCJgmUF3oOgdrzQa-HgOCUQ@mail.gmail.com> <CAJm83bAqbMMs2W3SyH+3c17wcC85paY4-_jk2SxczgsxBLyYyA@mail.gmail.com> <CAJm83bAQeR_6U3jgmbWzdus3pu+OO2_KP+M9RtbCFYOfDQy4dw@mail.gmail.com> <DB8PR02MB56111CCA23CDCF97A3C9F3E8CFDD0@DB8PR02MB5611.eurprd02.prod.outlook.com> <F7E5836A-4C7A-4A1A-B769-65EADE2C8F5C@gmail.com> <7d909ae3-a830-1270-6920-fa088a56525e@nwtime.org> <6C9832A9-E18B-4DE2-934F-9E471FC22F7B@akamai.com> <bc7920e2-dc81-ba7f-ec24-7926cda8589d@nwtime.org> <E591F38A-A303-4077-BC4C-A61AB7867F83@gmail.com> <OFF6FE7A91.279129DD-ONC125854D.00379455-C125854D.0038D979@ptb.de> <CAJm83bAUqCyy6iKVkGNyHN9hoaEbchuR4bx+kmc=Z-iOrZ3Bgg@mail.gmail.com>
In-Reply-To: <CAJm83bAUqCyy6iKVkGNyHN9hoaEbchuR4bx+kmc=Z-iOrZ3Bgg@mail.gmail.com>
From: Warner Losh <imp@bsdimp.com>
Date: Fri, 17 Apr 2020 09:35:17 -0600
Message-ID: <CANCZdfr1Ku6c-LMD5pTaY1yohEO229ppAqbwxQX2Qz3r+tG0bQ@mail.gmail.com>
To: Daniel Franke <dfoxfranke@gmail.com>
Cc: kristof.teichel@ptb.de, NTP WG <ntp@ietf.org>
Content-Type: multipart/alternative; boundary="000000000000941db405a37e4c84"
Archived-At: <https://mailarchive.ietf.org/arch/msg/ntp/0aOorBSEHt5lQdOeqL9LnnaKrnQ>
Subject: Re: [Ntp] Antwort: Re: The bump, or why NTP v5 must specify impulse response
X-BeenThere: ntp@ietf.org
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: <ntp.ietf.org>
List-Unsubscribe: <https://www.ietf.org/mailman/options/ntp>, <mailto:ntp-request@ietf.org?subject=unsubscribe>
List-Archive: <https://mailarchive.ietf.org/arch/browse/ntp/>
List-Post: <mailto:ntp@ietf.org>
List-Help: <mailto:ntp-request@ietf.org?subject=help>
List-Subscribe: <https://www.ietf.org/mailman/listinfo/ntp>, <mailto:ntp-request@ietf.org?subject=subscribe>
X-List-Received-Date: Fri, 17 Apr 2020 15:35:34 -0000

On Fri, Apr 17, 2020 at 8:53 AM Daniel Franke <dfoxfranke@gmail.com> wrote:

> On Fri, Apr 17, 2020 at 6:21 AM <kristof.teichel@ptb.de> wrote:
> >
> > Hey all,
> >
> > I wanted to offer my point of view on the question of modularity for
> NTPv5 as discussed here.
> > As many of you may know, the place that I'm coming from is not decades
> of practical experience in NTP implementation and/or maintenance, but
> instead years of close academic and theoretic scrutiny concerning
> guarantees for time synchronization methods.
> >
> > For me personally, the separation of NTP would ideally not only be made
> into protocol on the one hand and algorithmic and response behavior on the
> other hand, but go one step further.
> > I would prefer separation into three layers, specifically:
> >
> > 1) Network protocol (what kinds of messages can one send, and how does
> one have to respond to incoming messages); this should be specified on a
> per-association basis and security should be handled mostly here.
> > 2) Algorithmic offset calculations to the desired "true" time scale (how
> does one calculate time offset, frequency offset, perhaps offset of
> higher-order derivatives); this can involve multiple associations; security
> of the individual associations should be known so it can be taken into
> account if desired; this is the module that needs to be aware of the use of
> different time scales such as TAI vs. UTC, the handling of leap seconds
> etc.; this module should also be aware of how clock steering is handled
> (see below) and account for it.
> > 3) Clock steering (how is the participant's clock manipulated in order
> to accomodate the measured offset(s) and make the clock read something
> close to the "true" time, e.g. hard-setting the counter vs. manipulating
> the frequency via counter increment vs. manipulating the clock in other
> ways such as via the oscillator's voltage vs. handling all of that via
> virtual clocks); this can differ between machines, specifically between OS
> and hardware and should be treated appropriately.
> >
> > With this separation, we need well-defined interfaces between 1) and 2)
> and between 2) and 3).
> > Not dealing with 3) in a specification and leaving it to implementations
> should be seen as a real option, keeping in mind that knowledge of 3) can
> increase accuracy of 2).
> >
> > Regarding the nomenclature, I would strongly suggest getting consensus
> first on which of the many ways forward is going to be taken in order to
> arrive at something that can be called "NTPv5".
> > Specifically, it should be decided early which of 1), 2) and 3) that
> document should treat, the options as I see them being 1) only, or 1) and
> 2), or all three.
> >
> > What do you all think?
>
> My ontology is similar, but quite identical, to Kristof's:
>
> I. The syntax and semantics of the wire protocol
> IIa. The algorithm for estimating the offset between your clock and
> that of your peers
> IIb. The algorithm for combining estimates collected from multiple
> peers into one "consensus" estimate
> IIIa. How to use that estimate to steer the clock used for capturing
> the timestamps used in the wire protocol
> IIIb. How to use that estimate to steer the clock that other
> applications see when they ask for the system time
>
> The central question of this thread so far, up until Kristof entered,
> could be expressed as "How much is (IIIa), and by extension (IIa) and
> (IIb), really a part of (I)? When we say that the timestamps on the
> wire confer an estimate of the current time, how particular do we need
> to be about the properties of that estimate?".
>
> NTPv4 and prior don't distinguish at all between (IIIa) and (IIIb),
> but NTPv5 might have to. My sketch allows discontinuous adjustments to
> the `tai_loc_offset` field with each new data point obtained. But a
> lot of applications depend on having a single system clock that's all
> at once monotonic, reasonably accurate, and reasonably
> frequency-stable, which means there has to be some further smoothing
> step involved (perhaps a PLL, perhaps something else).
>
> In an ideal world, the contract between the OS and the NTP daemon
> would be the same on all platforms, and would be something like this:
> the OS provides the NTP daemon with a monotonic time counter driven by
> the hardware oscillator, and the NTP daemon provides the OS with a
> running estimate (maybe with error bars included) of the first few
> Taylor series coefficients of the function from that counter to TAI.
> What the OS does with this information and in particular how it
> communicates it to other applications on the system is none of the NTP
> daemon's concern.
>

Counters of sufficient resolution wrap. There's often a software counter
too. And getting either the raw software or raw hardware counters and/or
their notion of a relationship to the local system time can be tricky as
well. Some OSes allow access to the raw counters (since CPUs allow turning
that access on/off), and some even publish what's basically a 'phase at
count' testimate and a frequency estimate that the applications can then
use to compute time w/o a round trip into the kernel (this is often hidden
inside of libc's clock_gettime or similar).

Also, how does NTPd get access to this pure counter when it timestamps the
packets? It would need to know that in order to measure the evolution of
that counter over time to make estimates about it.

And I'd maintain that the NTP daemon needs to provide both the phase
estimate of the counter vs the TAI and a shorter-term frequency estimate
for the counter's evolution. Since the counter is likely to be lousy over
time and the frequency will wander all over the place (relative to a high
precision time keeping xtal or clock), the most useful information is that
counter X is TAI time Y and the short-term frequency is Z (maybe with a Z'
estimate as well). The OS will need to read the counter and produce a
TAI/UTC time quite often, and doing more than a simple computation will
show up in benchmarks. But that thinking may be a legacy of NTP steering
the OS's notion of time that it gets from a pure counter under the covers.
This is why we have ntp_adjtime providing a time delta and frequency error
and a bunch of other stuff that talk about ntpd's notion of how good those
are which are on a spectrum from generally useful, to totally NTPd
specific. I have a hard time seeing a way to not push the error in time /
frequency measurements down.

Second, the OS needs to keep a smooth time to its clients w/o time jumps
(but small changes in frequency are OK). So there will likely need to be
some coordination between the OS and the ntp daemon to communicate how much
of the 'steers' or 'tyler series' information it could ingest and what it's
notion of a future counter's time will be so NTP can help steer the OS's
use of the counter so it will be on time in the future and not overshoot as
the frequency wanders around.

Unfortunately, currently *no* OS provides us with anything this clean,
> and even if one did we'd still have to accommodate all the ones that
> don't if we want our spec to be platform-agnostic. Since we don't
> control the OS landscape and it changes on a different and faster
> schedule than NTP spec does, there's only so much we can do here. We
> can specify what we wish the interface would look like and maybe some
> kernel hackers will feel inspired by it, but for the foreseeable
> future NTP implementers are going to have to contend with
> less-than-ideal interfaces, and the most the IETF can do for them is
> give some abstract general guidance on that.
>

I think this sounds great from a theoretical view. I think it sounds lousy
from a practical view.

Generally, timekeeping is a critical part of the OS. This makes the above
ideal not implementable in many ways.

CPU Cost: If the OS is having to do something complicated to convert the
internal counters to a time as often as it needs time, the interface will
be a non-starter.

DoS issues: What does the OS do when ntpd information goes away? Because it
will. And then it will come back and the OS will have evolved its time
based on hardware counters whose frequency estimates will have been used as
best they can, but they will likely be wrong.

Convergence: How do we know NTPd's recommendations will converge with
whatever is going on inside the OS? Is there a stable form or do we get
oscillations. This is the same issue, btw, with algorithmic improvements
talked about elsewhere: you need to make sure that whatever is going on
with the steering of time doesn't cause oscillations as you resynchronize
with your upstreams. This will be especially an issue with pools of NTPd
servers that are steering using different algorithms. Steering to a steered
clock is tricky and well known problem in the high-precision time-keeping
biz. Often times I created a measurement of a free-running clock and
published my estimates of that clock so that people making measurements
could make adjustments after the fact since they needed a high precision
measurement of events, but didn't need it at the instant the measurement
was made. Had we steered the clock, there'd be lags to that accuracy. And
if they were steering their clocks, they'd get oscillations.

Warner