Re: [Ntp] Antw: [EXT] Timescales, leapseconds and smearing

Martin Burnicki <martin.burnicki@meinberg.de> Tue, 08 December 2020 18:31 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 877AD3A1015 for <ntp@ietfa.amsl.com>; Tue, 8 Dec 2020 10:31:24 -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=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 AYzA6nYFjMcZ for <ntp@ietfa.amsl.com>; Tue, 8 Dec 2020 10:31:22 -0800 (PST)
Received: from server1a.meinberg.de (server1a.meinberg.de [176.9.44.212]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ietfa.amsl.com (Postfix) with ESMTPS id 1D51A3A0045 for <ntp@ietf.org>; Tue, 8 Dec 2020 10:31:22 -0800 (PST)
Received: from srv-kerioconnect.py.meinberg.de (unknown [193.158.22.2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by server1a.meinberg.de (Postfix) with ESMTPSA id 4683471C04A8; Tue, 8 Dec 2020 19:31:19 +0100 (CET)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=meinberg.de; s=dkim; t=1607452279; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Od9uvP/dfs0EACOdVFRANWOZfJoSMAIX6wYZbgY/8Ec=; b=heBvYvbmlpYV3qxRiLdG3HQwf4yNfjZBXXuz1ru6RFpoB7S86bCAVVplohNsz9YHJzUgnk KXKI6Bw1Pv/5GweAgpny0fUhvkG3lZ1+dLFArB+Z2vIJBmSRP+4C3fPMkU+7bkRcxVWwz0 1Cv1BhBPW/G0E9mGGpDOZm1CRtTJiyDkGth2qLPAfCZR2WnbiV9A1GVkh097hL53I58TNz gPux8Mu8lfKCwkKuv4w3fli12Q3RF/TZuPAy6C75gUCJzgT87Wt2UdXpX8I9mT8UVZ0edu HBCOcUOR4FMKoJbZE88BUl0FAHR/wjwjkBRhmbqRF/N7NI5CJtKceYHp1N4oFw==
X-Footer: bWVpbmJlcmcuZGU=
Received: from localhost ([127.0.0.1]) by srv-kerioconnect.py.meinberg.de with ESMTPSA (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256 bits)); Tue, 8 Dec 2020 19:31:16 +0100
To: Kurt Roeckx <kurt@roeckx.be>, Ulrich Windl <Ulrich.Windl@rz.uni-regensburg.de>
Cc: "ntp@ietf.org" <ntp@ietf.org>
References: <X86sVykHUqlkXP96@roeckx.be> <5FCF4DC8020000A10003D5FB@gwsmtp.uni-regensburg.de> <X89eBhhdUDijLVpL@roeckx.be>
From: Martin Burnicki <martin.burnicki@meinberg.de>
Organization: Meinberg Funkuhren GmbH & Co. KG, Bad Pyrmont, Germany
Message-ID: <c73d4c57-5cb8-4e5e-e786-391c50b8d368@meinberg.de>
Date: Tue, 08 Dec 2020 19:31:16 +0100
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.5.0
MIME-Version: 1.0
In-Reply-To: <X89eBhhdUDijLVpL@roeckx.be>
Content-Type: text/plain; charset="utf-8"
Content-Language: en-US
Content-Transfer-Encoding: 8bit
Archived-At: <https://mailarchive.ietf.org/arch/msg/ntp/4SmK1OhtJNmnkREqKnZ2-iZQoDE>
Subject: Re: [Ntp] Antw: [EXT] Timescales, leapseconds and smearing
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: Tue, 08 Dec 2020 18:31:25 -0000

Kurt Roeckx wrote:
> On Tue, Dec 08, 2020 at 10:56:24AM +0100, Ulrich Windl wrote:
>> Hi!
>>
>> I think if we agree to use anything other than UTC in NTPv5, we absolutely
>> need to specify some use-level API how to get the current time:
>> time()
>> gettimeofday()
>> clock_gettime()
>> localtime()
>> strftime()
>>
>> They all assume UTC... It's rather useless if NTP has the exact time, but no
>> ("standard") program can use it.
> 
> They don't use UTC, they use POSIX/UNIX time. POSIX time, just like
> NTP, ignores the leap seconds. POSIX actually says that the length
> of a second is not specified, an implementation can then say it's
> SI seconds. POSIX has support for a leap second in struct tm, so as
> long as you don't convert it to a time_t you can work in UTC.
> strftime() works with a struct tm, so can work in UTC.

Right, and the problem is that protocols like NTP or PTP (and their
implementations) have to cope with the limitations of those specs.

I don't believe that this can be handled at the time synchronization
protocol level. That only shifts the reason of the problems to some
slightly different location.

> The linux kernel has support for TAI. You can set a TAI offset, so
> that applications making use of the POSIX API still get the POSIX
> time. The clock_gettime() function you mentioned has TAI support.
> The information to convert from TAI to UTC is available, so it's
> possible to work in TAI or UTC on Linux, it's just that most
> applications don't.

But in any case you first need to have a trusted source for the TAI
offset, so some program can send it down to the kernel.

By the way, if you start a Linux kernel and the TAI offset has not been
set by some program, the kernel reports TAI offset 0.

However, when the kernel receives a leap second warning from an NTP or
PTP daemon, and it inserts a leap second, the kernel increments its TAI
offset when the leap second is inserted.

To the kernel reports TAI offset 1 after it has observed a leap second,
which is obviously wrong, but it shows that you can't simply check if
the TAI offset is 0 if you need to know if the kernel knows the real TAI
offset.

Tricky, all this stuff.


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