Re: [Ntp] NTP over PTP

Miroslav Lichvar <mlichvar@redhat.com> Thu, 01 July 2021 10:25 UTC

Return-Path: <mlichvar@redhat.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 C3AE33A22CD for <ntp@ietfa.amsl.com>; Thu, 1 Jul 2021 03:25:05 -0700 (PDT)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: 2.005
X-Spam-Level: **
X-Spam-Status: No, score=2.005 tagged_above=-999 required=5 tests=[BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.198, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, GB_SUMOF=5, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001] autolearn=no autolearn_force=no
Authentication-Results: ietfa.amsl.com (amavisd-new); dkim=pass (1024-bit key) header.d=redhat.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 wAAHKfKKvbZw for <ntp@ietfa.amsl.com>; Thu, 1 Jul 2021 03:25:01 -0700 (PDT)
Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ietfa.amsl.com (Postfix) with ESMTPS id 6211A3A22CA for <ntp@ietf.org>; Thu, 1 Jul 2021 03:25:01 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1625135100; 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: in-reply-to:in-reply-to:references:references; bh=kz8NtdLpKyt3nnW9US4Itzg6BFQRIhr0/+JcLPnX4Kg=; b=id8XO9DhU5TYlzXvGLJT2JwS3oyHDUk6NZy3nKwYErkbAcbSWgm4iTCuKVbDaBA6xTKAWU /KNdQRucG5NRkvkiFFaTZAoG2UmQLrElPZnmC9EGxSaXxKXZvMQrcgIC1PFdWMOOKwh4pA IVvKTSwwoylBOk8SDSBRFpddctC0pDo=
Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-530-g67H7nGANN-fTo3tJZOhhA-1; Thu, 01 Jul 2021 06:24:57 -0400
X-MC-Unique: g67H7nGANN-fTo3tJZOhhA-1
Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 20BD78015D0; Thu, 1 Jul 2021 10:24:57 +0000 (UTC)
Received: from localhost (holly.tpb.lab.eng.brq.redhat.com [10.43.134.11]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 755A560854; Thu, 1 Jul 2021 10:24:55 +0000 (UTC)
Date: Thu, 1 Jul 2021 12:24:54 +0200
From: Miroslav Lichvar <mlichvar@redhat.com>
To: Heiko Gerstung <heiko.gerstung@meinberg.de>
Cc: "ntp@ietf.org" <ntp@ietf.org>
Message-ID: <YN2X9mwoEXkbbYK6@localhost>
References: <YNRtXhduDjU4/0T9@localhost> <36AAC858-BFED-40CE-A7F7-8C49C7E6782C@meinberg.de> <YNnSj8eXSyJ89Hwv@localhost> <D32FAF20-F529-496C-B673-354C0D60A5AF@meinberg.de> <YNrDGy2M2hpLz9zc@localhost> <C5D99A22-84B8-4D27-BE74-D8267FB1DCB0@meinberg.de> <YNrqWjHPtC7ToAL8@localhost> <125F908E-F80D-4873-A164-A460D96316E5@meinberg.de> <YNxCLd3vvm3yMTl7@localhost> <A64B90EF-00D0-4077-9771-9CB25C823FD6@meinberg.de>
MIME-Version: 1.0
In-Reply-To: <A64B90EF-00D0-4077-9771-9CB25C823FD6@meinberg.de>
X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13
Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mlichvar@redhat.com
X-Mimecast-Spam-Score: 0
X-Mimecast-Originator: redhat.com
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Archived-At: <https://mailarchive.ietf.org/arch/msg/ntp/WYRW42Y45n2HmoPf4qU638qErqM>
Subject: Re: [Ntp] NTP over PTP
X-BeenThere: ntp@ietf.org
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: Network Time Protocol <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: Thu, 01 Jul 2021 10:25:06 -0000

On Wed, Jun 30, 2021 at 03:42:53PM +0200, Heiko Gerstung wrote:
> > Well, yes, but the delay measurement is separate from the offset
> > measurement. If you can log and plot the offsets measured by PTP and
> > NTP in a network without PTP support, you will see how the
> > distribution is different due to the different calculation.
> 
> This depends, as pointed out earlier, on the network itself. If you have highly dynamic network paths where traffic patterns change quickly and therefore result in wildly changing queueing and forwarding delays, you will see slightly different delay distribution in NTP and PTP logs. In less dynamic environments, you will probably not notice something like that at all.

I'm referring to the distribution of the offset as measured by PTP
and NTP. Maybe this plot will make it more clear.

https://fedorapeople.org/~mlichvar/tmp/ntp-ptp-offset.png

It shows offset over time as calculated by NTP and PTP in identical
conditions. Hopefully you can see that the offset on the top has a
symmetric distribution and one on the bottom does not. With the PTP
offset calculation (same as in the NTP broadcast mode), the
distribution of the network delay in the server->client direction
transfers to the distribution of the offset. In the NTP client/server
mode the offset is calculated from the sum of delays in both
directions. It's not difficult to guess what is easier to work with
when controlling a clock.

> And in networks with partial or full on-path support, you will see that PTP is performing great with its inferior delay measurement approach. 

With full on-path support, yes, it performs great. That's what it was
designed for. Without full support on a mostly idle network or in a
network where PTP messages are prioritized, it can still work ok. But
as soon as PTP messages start waiting in longer queues, it falls apart
very quickly. NTP can generally perform well in worse conditions as it
measures the offset and delay at the same time, while PTP assumes the
delay didn't change when it measures the offset.

Of course, there are differences between implementations. A more
advanced PTP implementation can certainly perform better than a less
advanced NTP implementation. PTP implementations can also ignore the
PTP specification and use the NTP approach.

> >> Yes, there are implementations which take that into account by applying
> >> static correction values to compensate for link speed asymmetry. I believe this
> >> also affects NTP, but in most cases hundreds of nanoseconds are not a problem
> >> for applications relying on NTP synchronization.
> > 
> > NTP is much less impacted as it timestamps the end of the reception.
> > A software timestamp is captured after the packet is received.
> 
> That is a very confusing argument. 

I'm talking here specifically about the error that is caused by server
and client being on different link speeds, not other sources of error
due to processing delays, etc. NTP using trailing timestamps (which
requires transposition of hardware timestamps) is another reason why
NTP should be preferred over PTP in networks that don't have a full
on-path support.

> When we connect one of our grandmaster clocks (PTP server) to one of our PTP client devices over a direct crossover cable or fiber link, we can measure an offset of less than 20ns between the PPS generated by the GNSS synchronized master clock and the client. 

I see the same with NTP here.

> > Isn't that an issue for both NTP and PTP unicast using high rate sync
> > and delay requests?
> 
> Yes, but unicast PTP servers with hardware time stamping are typically commercial products with dedicated network hardware to support the large number of timestamps that have to be stored and processed.

Would this hardware not work with NTS-over-PTP, but work with
NTS4UPTP?

> The i210 has a time stamping queue length of 4, i.e. it stores a maximum of 4 timestamps in a ring buffer. A unicast PTP server with 10 clients running at 128 sync and delay pkt/s will generate 1,280 time stamps per second. Even on some serious hardware there will be a significant number of timestamps that are lost due to queue overruns.  

I think you are confusing the I210 with something else. It can
timestamp all received packets, at any rate.

Its performance in a server is limited by TX timestamping. It can
timestamp only one packet at a time. But the maximum rate is
definitely higher than 1280 per second. In my tests it's about 35000
TX timestamps per second. That's with the stock Linux driver which
seems to rely on an interrupt. I think it could be modified to poll
the timestamp register for a much higher rate of timestamps. In any
case, I'd say that is pretty good for a $50 NIC.

> > I think the best approach is for the hardware to timestamp all packets
> > as many NICs already do. The problem is with existing hardware that
> > cannot do that. I agree it doesn't look great when you have to run NTP
> > over PTP, but that seems to be the only way to get the timestamping
> > working on this hardware.
> 
> I believe there should be a standard that adds a hardware timestamp to the end of every Ethernet frame. It requires a NIC vendor to implement a hardware clock and a time stamping engine into their silicon. The bandwidth between the NIC and the OS layer (driver) has to accommodate the extra data (but you could reduce the MTU of course). 

That's how it works with the I210 and other NICs, except the timestamp
is before the frame, not after.

-- 
Miroslav Lichvar