Re: [Ntp] Leap second draft

Martin Burnicki <martin.burnicki@meinberg.de> Wed, 03 April 2019 08:41 UTC

Return-Path: <martin.burnicki@meinberg.de>
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 3BC9C12000E for <ntp@ietfa.amsl.com>; Wed, 3 Apr 2019 01:41:58 -0700 (PDT)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -4.3
X-Spam-Level:
X-Spam-Status: No, score=-4.3 tagged_above=-999 required=5 tests=[BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, RCVD_IN_DNSWL_MED=-2.3, SPF_PASS=-0.001, URIBL_BLOCKED=0.001] autolearn=ham autolearn_force=no
Authentication-Results: ietfa.amsl.com (amavisd-new); dkim=pass (1024-bit key) header.d=meinberg.de
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 54e9ynqdDxVz for <ntp@ietfa.amsl.com>; Wed, 3 Apr 2019 01:41:54 -0700 (PDT)
Received: from server1a.meinberg.de (server1a.meinberg.de [176.9.44.212]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by ietfa.amsl.com (Postfix) with ESMTPS id E9EDD120013 for <ntp@ietf.org>; Wed, 3 Apr 2019 01:41:53 -0700 (PDT)
Received: from srv-kerioconnect.py.meinberg.de (unknown [193.158.22.2]) (using TLSv1.1 with cipher ECDHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by server1a.meinberg.de (Postfix) with ESMTPSA id 43F9771C0BE7; Wed, 3 Apr 2019 10:41:37 +0200 (CEST)
X-DKIM: Sendmail DKIM Filter v2.8.2 server1a.meinberg.de 43F9771C0BE7
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=meinberg.de; s=mail201101; t=1554280911; bh=m+p1LDaYAW6hN8o/WIHArAv+m31L0w9uc/lsdrMaKP0=; h=Subject:To:Cc:References:From:Message-ID:Date:MIME-Version: In-Reply-To:Content-Type:Content-Transfer-Encoding; b=AtlXm892QNB3AO3AHZ3uT+dUgy6akch2Dy8OcnXz9LGipQLAbJZY3VfOjdT+ap3cf 0eaU9cpQXKmHO2BqrZnlijbUeY5plj0IRs1A19Brr1AUY4aZgpa6aglFFJAJ4Mop6b o8zpHuAYz4EePqAtA8pclX/NbWvvf2IAxKXKWm20=
X-Kerio-Anti-Spam: Build: [Engines: 2.15.9.1226, Stamp: 3], Multi: [Enabled, t: (0.000005,0.009208)], BW: [Enabled, t: (0.000006)], RTDA: [Enabled, t: (0.036618), Hit: No, Details: v2.7.31; Id: 15.1i6u2ph.1d7h5om09.1rtmv], total: 0(700)
X-Footer: bWVpbmJlcmcuZGU=
Received: from localhost ([127.0.0.1]) by srv-kerioconnect.py.meinberg.de with ESMTPSA (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256 bits)); Wed, 3 Apr 2019 10:41:35 +0200
To: Kurt Roeckx <kurt@roeckx.be>
Cc: ntp@ietf.org, Daniel Franke <dfoxfranke@gmail.com>
References: <CAJm83bD5Ozkpg5TpkogOW6xeeNQL3ZziLO9URM7haqN8Wrp=Wg@mail.gmail.com> <CAJm83bCbVzO3NNCbjTy+O_16T7DBeA7O6018WWGu_-GyuN-8UA@mail.gmail.com> <20190401161816.GN7706@roeckx.be> <5590de79-de9e-a576-eee8-10a7df6d0ffb@meinberg.de> <20190402170411.GQ7706@roeckx.be>
From: Martin Burnicki <martin.burnicki@meinberg.de>
Openpgp: preference=signencrypt
Autocrypt: addr=martin.burnicki@meinberg.de; prefer-encrypt=mutual; keydata= xsFNBFUJbhwBEADpbjlFJrR+RWZSc5WFFmRVQUFQ+XwgRBrAtTkJyu+xhu6DvD6zq2IgnXQ3 W8pz/MoMMfKWaNOJ1qCxMfd8XrCR1Wa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94rF/hOFHuR4GQWeFR xBSWd41qArjdABIxhZrnMICSW3fMyo9yfiQ6tXoyD1cHD/i2WmOnqCKEOtFScVeQJZJhqQb5 4NBx+viRax9d+X066AKYiBspm7kYwBVzNsng3uHOfyQXnVmcCEawxWIPyCtxSoV6fCKYdAfJ CQeElBXE89inkdGmdb0KLmYkHDoV4L1deAsPUI/t6qZjwqF3pKcr8kdGExqHwvytL8n1KGbY PyJ6Fn1z/idOOiTYgN+Q7FWRRX0QplyVpSBU4OnD0Gd3KkP+a0+kErokA1Lk3/YCE45VT8J8 8f4YGbRsIkf0xW+Ei0fk3fl9VPOrbTD+gFv+AzbT+Gp1+kElwVKj0VzXy0OC6UIQJ3J1on0l ArkcfPTIMcWxGmfGPw==
Organization: Meinberg Funkuhren, Bad Pyrmont, Germany
Message-ID: <03d4b30d-556c-c585-84dc-a73df953f38e@meinberg.de>
Date: Wed, 03 Apr 2019 10:41:34 +0200
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.5.0
MIME-Version: 1.0
In-Reply-To: <20190402170411.GQ7706@roeckx.be>
Content-Type: text/plain; charset="utf-8"
Content-Language: en-US
Content-Transfer-Encoding: 8bit
X-Virus-Scanned: clamav-milter 0.100.2 at server1a
X-Virus-Status: Clean
Archived-At: <https://mailarchive.ietf.org/arch/msg/ntp/0imZ-akCp13NH6evdICqA0V4hDE>
Subject: Re: [Ntp] Leap second draft
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: Wed, 03 Apr 2019 08:41:58 -0000

Kurt Roeckx wrote:
> On Tue, Apr 02, 2019 at 09:40:58AM +0200, Martin Burnicki wrote:
>> Kurt Roeckx wrote:
>>> One question I have that I can't seem to find the answer for is
>>> which second do you announce during the leap second in NTP.
>>>
>>> There was a leap second at 3692217600. Do you send:
>>> 3692217599
>>> 3692217599 (leap second)
>>> 3692217600
>>>
>>> Or:
>>>
>>> 3692217599
>>> 3692217600 (leap second)
>>> 3692217600
>>>
>>> I can see arguments for both ways, and if it's not specified
>>> somewhere yet, I think we need to specify it.
>>
>> NTP implementations I've seen just pick up the current system time, so
>> which timestamps are returned during a leap second depends on the way
>> the particular operating system handles the leap second, and e.g. ntpd
>> running on one type of operating system can behave differently than ntpd
>> running on a different type of operating system.
>>
>> So the discussion which way is the "better" one had to be done with the
>> maintainers of the OS kernel clock implementation. ;-)
>>
>> Letting an NTP daemon decide what kind of timestamp to return would
>> require that it
>>
>> 1.) uses the adjtimex()/ntp_adjtime() API calls to retrieve a timestamp
>> including some status information, and then modifies the time stamp in a
>> preferred way
>>
>> 2.) maintains its own clock beside the system clock so it could handle
>> the leap second in a different way than the kernel clock
>>
>> Solution 1.) is normally not used because adjtimex()/ntp_adjtime() take
>> longer to execute than a simple clock_gettime()
>>
>> Solution 2.) can cause additional problems if the daemon's internal leap
>> second handling differs from the leap second handling observed by
>> applications running on the particular system.
> 
> One option would be the allow both the cases, but I still think
> that should get documented.
> 
> But to be compliant with the current draft, you would need to know
> that a timestamp is within the leap second.
> 
> It can be that with the current kernel APIs, this is very hard to
> properly do, but I don't see that as a problem of the draft.

I agree, but on the other hand, what's the advantage of a draft if it is
not implemented, e.g. because the performance is degraded?

Many years ago Dave Mills suggested to implement kernel clocks in a way
that the system time doesn't have to be stepped back to insert a leap
second. Instead, it should basically be stopped during that second, but
this would result in always the same time stamp during the leap second,
so the final proposal was to increment the least significant bit of the
time stamp e.g. 1 microsecond or nanosecond whenever any application
retrieves a time stamp. This approach makes sure the system time is
always strictly monotonically increasing.

Thus, an approach like this at the kernel level would avoid many
problems with user space applications across a leap second, and some
time ago I've discussed this with one of the Linux kernel developers.

He told me it's simply too expensive (in terms of execution time) to let
the kernel check whether its time is inside a leap second, or not,
whenever any applications asks for the system time, just because this
may happen during a single second in a couple of years.

So the kernel in fact simply steps the time back at the beginning or end
of a leap second, which often causes problems with applications that
don't expect such step, but anyway it's less expensive for the kernel.

Basically the same problem arises if you call adjtimex()/ntp_adjtime()
whenever you want to get a current system timestamp. If a program like
ntpd did it the number of client requests it can handle per second would
probably be decrease, and on the other hand this wouldn't even improve
the situation of applications running on a client.

In my opinion the current mechanisms provided by the protocol to
announce and handle a leap second are sufficient, even across several
stratum levels.

What was generally missing (unless you used autokey) was a way to
propagate the current TAI/UTC offset over the network, so it's good to
have a replacement which can be used to do this in the absence of
autokey, if required, e.g. using an extension field.

A bigger problem than the protocol itself is to have a way to inject
information on an upcoming leap seconds, TAI offset, etc. reliably at
the top of the timing chain.

With reliably I mean that this must not only work as long as the OS
maintainers provide software update packages that contain a tzdata/leap
second file, but independently from firmware updates. We have discussed
this a couple of days ago.

> Assuming it's not possible to properly implement the bits
> indicating that a timestamp is within the leap second, maybe the
> draft should mention that in that case you should either not reply
> around the leap second or return that you're not synchronized.

Yes, the current behavior of ntpd to claim to be *not* synchronized for
a short interval across a leap second (as has been suggested by
Miroslav) doesn't hurt, but reduces potential problems especially with
simple clients, and I agree that *this* behavior should be documented.


Martin
-- 
Martin Burnicki

Senior Software Engineer

MEINBERG Funkuhren GmbH & Co. KG
Email: martin.burnicki@meinberg.de
Phone: +49 5281 9309-414
Linkedin: https://www.linkedin.com/in/martinburnicki/

Lange Wand 9, 31812 Bad Pyrmont, Germany
Amtsgericht Hannover 17HRA 100322
Geschäftsführer/Managing Directors: Günter Meinberg, Werner Meinberg,
Andre Hartmann, Heiko Gerstung
Websites: https://www.meinberg.de  https://www.meinbergglobal.com
Training: https://www.meinberg.academy