Re: [Ntp] Antw: [EXT] Re: Timescales

Magnus Danielson <magnus@rubidium.se> Wed, 09 December 2020 22:40 UTC

Return-Path: <magnus@rubidium.se>
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 E97FB3A1785 for <ntp@ietfa.amsl.com>; Wed, 9 Dec 2020 14:40:42 -0800 (PST)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -2.1
X-Spam-Level:
X-Spam-Status: No, score=-2.1 tagged_above=-999 required=5 tests=[BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, NICE_REPLY_A=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-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=rubidium.se
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 OGyx5q7U3xwD for <ntp@ietfa.amsl.com>; Wed, 9 Dec 2020 14:40:40 -0800 (PST)
Received: from ste-pvt-msa2.bahnhof.se (ste-pvt-msa2.bahnhof.se [213.80.101.71]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by ietfa.amsl.com (Postfix) with ESMTPS id 6BEE73A17B8 for <ntp@ietf.org>; Wed, 9 Dec 2020 14:40:36 -0800 (PST)
Received: from localhost (localhost [127.0.0.1]) by ste-pvt-msa2.bahnhof.se (Postfix) with ESMTP id A4DF83FB14 for <ntp@ietf.org>; Wed, 9 Dec 2020 23:40:10 +0100 (CET)
Authentication-Results: ste-pvt-msa2.bahnhof.se; dkim=pass (2048-bit key; unprotected) header.d=rubidium.se header.i=@rubidium.se header.b=Wdb3JSnh; dkim-atps=neutral
X-Virus-Scanned: Debian amavisd-new at bahnhof.se
Authentication-Results: ste-ftg-msa2.bahnhof.se (amavisd-new); dkim=pass (2048-bit key) header.d=rubidium.se
Received: from ste-pvt-msa2.bahnhof.se ([127.0.0.1]) by localhost (ste-ftg-msa2.bahnhof.se [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id S7JOQDGja6oS for <ntp@ietf.org>; Wed, 9 Dec 2020 23:40:09 +0100 (CET)
Received: by ste-pvt-msa2.bahnhof.se (Postfix) with ESMTPA id 8877F3FB0E for <ntp@ietf.org>; Wed, 9 Dec 2020 23:40:08 +0100 (CET)
Received: from machine.local (unknown [192.168.0.15]) by magda-gw (Postfix) with ESMTPSA id 2A9FD9A02E5; Wed, 9 Dec 2020 23:40:33 +0100 (CET)
DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=rubidium.se; s=rubidium; t=1607553633; bh=cNppeSTdpnc/86LKwZI7BS6Zmsxidv3ABRmfM2jlN0A=; h=Cc:Subject:To:References:From:Date:In-Reply-To:From; b=Wdb3JSnh7uvR03Gj8R/cSNQTN4Es3za/Kmskd02ogugb5foql458i2UBLgxBy43eF JLRS/PNYwN7zsFTypo0/+AxEO8AC5Rzv5wv6g6gAZ7c9XVCM5tfiH7uAfhdleIvZOP WFPtKXAdmh4hq9jSg/XmR90e78wgxJ8AdVPAVbrexOr8QPTdpv81ENJ0icO4t8juDn 39UA71nd5pkXvcrGPffa9kfkHPprqivyIn9kCcC9VbAoLaXksoP27ulP1XLmEDBuDG c+bwAX1CY60rXV0NDyKOR0vRxRo1eNB/jvKRSUnkuCAtQ8nO1c8u3IVqcFaAxPUxD9 JdUpEkfELkpQw==
Cc: magnus@rubidium.se
To: ntp@ietf.org
References: <20201209190210.2408740605C@ip-64-139-1-69.sjc.megapath.net>
From: Magnus Danielson <magnus@rubidium.se>
Message-ID: <ae748c46-a180-1741-c082-4087d21f2995@rubidium.se>
Date: Wed, 09 Dec 2020 23:40:32 +0100
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.13; rv:78.0) Gecko/20100101 Thunderbird/78.5.1
MIME-Version: 1.0
In-Reply-To: <20201209190210.2408740605C@ip-64-139-1-69.sjc.megapath.net>
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 7bit
Content-Language: en-US
Archived-At: <https://mailarchive.ietf.org/arch/msg/ntp/5JiZvsA4OyYT4t9ZKaVrpeQSHzs>
Subject: Re: [Ntp] Antw: [EXT] Re: Timescales
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, 09 Dec 2020 22:40:43 -0000

Hal,

On 2020-12-09 20:02, Hal Murray wrote:
> mlichvar@redhat.com said:
>> Most computers work primarily in UTC.
> Most computers work on POSIX pseudo UTC time.
> (which is why we have this leap-second mess)

Most computers use one of two interpretations of POSIX Time.

One variant of UTC to POSIX time_t mapping was provided for a while, but
later removed from the POSIX documentation, mapping 23:59:60Z into
00:00:00, which is what you expect from (omitting date)

time_t = hours*3600 + min*60 + sec

and as this is re-interpreted as print-out time

sec = time_t % 60
min = (time_t / 60) % 60
hour = (time_t / 3600) % 24

reads out as 00:00:00, which next section also labelled 00:00:00. This
behavior is mimiced by the NTP time-scale for at NTPv3 and NTPv4 as I
recall it.

Then, for Linux the leap-second is not assigned the printed label
00:00:00 but the printed label 23:59:59, which keeps 00:00:00 unique to
the first second of the new UTC day. Thus, rather than double 00:00:00
read-outs you have double 23:59:59 read-outs. Thus, we cannot speak
about them both having UNIX or POSIX time as if it was the same, but
they are different and we need to treat them different. NTP
implementations needs to know how to handle it, and in practice it is
handled through the nanokernel interface [1]. The user applications
should use that interface too, to get the offset, but some operating
systems also support getting time in the TAI form, see CLOCK_TAI for
clock_gettime() [2].

While my manual references is to Linux, the BSD guys for sure can
illustrate the state there.

But, the lesson is that even within "UNIX type systems" you have a
diversity, but there may also be the common enough tool-set to help
applications to get time straight if we only enable the NTP process to
use the right interfaces and allow the protocol to transport all the
needed information.

I think some of the discussions of issues relates to older ways to get
time-stamps, which may no longer reflect the state of art available on a
wide selection of systems. The inclusion of these new interface is now
quite old, so it has rippled through the builds and support through
various libraries etc.

Cheers,
Magnus

[1] https://man7.org/linux/man-pages/man3/ntp_adjtime.3.html

[2] https://man7.org/linux/man-pages/man2/clock_gettime.2.html