Re: [ntpwg] [ntp:questions] Idea to improve ntpd accuracy

Tal Mizrahi <talmi@marvell.com> Fri, 26 February 2016 09:40 UTC

Return-Path: <ntpwg-bounces+ntp-archives-ahfae6za=lists.ietf.org@lists.ntp.org>
X-Original-To: ietfarch-ntp-archives-ahFae6za@ietfa.amsl.com
Delivered-To: ietfarch-ntp-archives-ahFae6za@ietfa.amsl.com
Received: from localhost (ietfa.amsl.com [127.0.0.1]) by ietfa.amsl.com (Postfix) with ESMTP id 080131A1A47 for <ietfarch-ntp-archives-ahFae6za@ietfa.amsl.com>; Fri, 26 Feb 2016 01:40:41 -0800 (PST)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -0.007
X-Spam-Level:
X-Spam-Status: No, score=-0.007 tagged_above=-999 required=5 tests=[BAYES_20=-0.001, RP_MATCHES_RCVD=-0.006] autolearn=ham
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 S9UcMal3OQSu for <ietfarch-ntp-archives-ahFae6za@ietfa.amsl.com>; Fri, 26 Feb 2016 01:40:38 -0800 (PST)
Received: from lists.ntp.org (lists.ntp.org [IPv6:2001:4f8:fff7:1::7]) by ietfa.amsl.com (Postfix) with ESMTP id D87FC1A1A45 for <ntp-archives-ahFae6za@lists.ietf.org>; Fri, 26 Feb 2016 01:40:38 -0800 (PST)
Received: from lists.ntp.org (lists.ntp.org [149.20.68.7]) by lists.ntp.org (Postfix) with ESMTP id B70A986DBAA for <ntp-archives-ahFae6za@lists.ietf.org>; Fri, 26 Feb 2016 09:40:37 +0000 (UTC)
X-Original-To: ntpwg@lists.ntp.org
Delivered-To: ntpwg@lists.ntp.org
Received: from mail1.ntp.org (mail1.ntp.org [IPv6:2001:4f8:fff7:1::5]) by lists.ntp.org (Postfix) with ESMTP id 70B6786DB06; Fri, 26 Feb 2016 09:22:49 +0000 (UTC)
Received: from mx0b-0016f401.pphosted.com ([67.231.156.173]) by mail1.ntp.org with esmtps (TLSv1:AES256-SHA:256) (Exim 4.77 (FreeBSD)) (envelope-from <talmi@marvell.com>) id 1aZEbg-0000va-MV; Fri, 26 Feb 2016 09:22:48 +0000
Received: from pps.filterd (m0045851.ppops.net [127.0.0.1]) by mx0b-0016f401.pphosted.com (8.15.0.59/8.15.0.59) with SMTP id u1Q9JxB1028059; Fri, 26 Feb 2016 01:22:39 -0800
Received: from il-exch02.marvell.com ([199.203.130.102]) by mx0b-0016f401.pphosted.com with ESMTP id 21akgq82g1-1 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Fri, 26 Feb 2016 01:22:39 -0800
Received: from IL-EXCH01.marvell.com (10.4.102.220) by IL-EXCH02.marvell.com (10.4.102.221) with Microsoft SMTP Server (TLS) id 15.0.1104.5; Fri, 26 Feb 2016 11:22:36 +0200
Received: from IL-EXCH01.marvell.com ([fe80::5d63:81cd:31e2:fc36]) by IL-EXCH01.marvell.com ([fe80::5d63:81cd:31e2:fc36%20]) with mapi id 15.00.1104.000; Fri, 26 Feb 2016 11:22:36 +0200
From: Tal Mizrahi <talmi@marvell.com>
To: "mayer@ntp.org" <mayer@ntp.org>, Weber <wsdl@osengr.org>
Thread-Topic: [ntp:questions] Idea to improve ntpd accuracy
Thread-Index: AQHRcEjbLblJjPibiES1H7fwz4AybZ8+CYpw
Date: Fri, 26 Feb 2016 09:22:36 +0000
Message-ID: <e8a82cbb01c94da7b43d60b18afa2b8a@IL-EXCH01.marvell.com>
References: <56CF7783.3010804@osengr.org> <56CFC1FF.2060408@ntp.org> <56CFC6A2.4010000@osengr.org> <56CFCB89.4010704@ntp.org>
In-Reply-To: <56CFCB89.4010704@ntp.org>
Accept-Language: en-US
Content-Language: en-US
X-MS-Has-Attach:
X-MS-TNEF-Correlator:
x-ms-exchange-transport-fromentityheader: Hosted
x-originating-ip: [10.94.250.30]
MIME-Version: 1.0
X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2016-02-26_07:, , signatures=0
X-Proofpoint-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=0 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1601100000 definitions=main-1602260179
X-SA-Exim-Connect-IP: 67.231.156.173
X-SA-Exim-Rcpt-To: mayer@ntp.org, ntpwg@lists.ntp.org, questions@lists.ntp.org
X-SA-Exim-Mail-From: talmi@marvell.com
X-SA-Exim-Version: 4.2
X-SA-Exim-Scanned: Yes (on mail1.ntp.org)
Subject: Re: [ntpwg] [ntp:questions] Idea to improve ntpd accuracy
X-BeenThere: ntpwg@lists.ntp.org
X-Mailman-Version: 2.1.20
Precedence: list
List-Id: IETF Working Group for Network Time Protocol <ntpwg.lists.ntp.org>
List-Unsubscribe: <http://lists.ntp.org/options/ntpwg>, <mailto:ntpwg-request@lists.ntp.org?subject=unsubscribe>
List-Archive: <http://lists.ntp.org/pipermail/ntpwg/>
List-Post: <mailto:ntpwg@lists.ntp.org>
List-Help: <mailto:ntpwg-request@lists.ntp.org?subject=help>
List-Subscribe: <http://lists.ntp.org/listinfo/ntpwg>, <mailto:ntpwg-request@lists.ntp.org?subject=subscribe>
Cc: "'ntpwg@lists.ntp.org'" <ntpwg@lists.ntp.org>, "questions@lists.ntp.org" <questions@lists.ntp.org>
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: 7bit
Errors-To: ntpwg-bounces+ntp-archives-ahfae6za=lists.ietf.org@lists.ntp.org
Sender: ntpwg <ntpwg-bounces+ntp-archives-ahfae6za=lists.ietf.org@lists.ntp.org>

Hi,

I believe NTP hardware timestamping is certainly a very interesting direction.
It is certainly worth taking a look at https://datatracker.ietf.org/doc/draft-ietf-ntp-checksum-trailer

I wonder what is the level of accuracy you are looking for.

The factor that affects the NTP client's accuracy more than anything else is the distance (latency) between the NTP server and the NTP client, which is roughly proportional to the delay variation.
If the NTP server and the NTP client are on the same LAN, I would estimate that you can achieve an accuracy on the order of tens of microseconds with software timestamping. In this case hardware timestamping may improve the accuracy.
If the latency between the NTP server and client is tens of *milliseconds*, then hardware timestamping will hardly affect the accuracy.

Please note that even if you have hardware-based timestamping, using a hardware clock in the NIC, you still need to synchronize the hardware clock with the system clock (for example, this can be done using phc2sys). This procedure will typically add some inaccuracy to the overall calculation...


>>>> What if the poll response packet contained a flag or indication of
>>>> some sort which means "this is an approximate transmit timestamp".
>>>> That packet would then be immediately followed by a second response
>>>> packet with a more accurate transmit time. The second packet could
>>>> be otherwise identical to the first, or it could be a new flavor of
>>>> packet that contained only the transmit time (that would save on network
>bandwidth).
>>>>

Sounds a bit like interleave mode, right (a bit similar to PTP two-step clocks)?

Regards,
Tal.

>-----Original Message-----
>From: Danny Mayer [mailto:mayer@ntp.org]
>Sent: Friday, February 26, 2016 5:51 AM
>To: Weber
>Cc: questions@lists.ntp.org; Tal Mizrahi
>Subject: Re: [ntp:questions] Idea to improve ntpd accuracy
>
>On 2/25/2016 10:29 PM, Weber wrote:
>> Thanks for the link. I'm not surprised that someone else already had
>> the idea. I was poking around and see that 1588 does something similar
>> with a "follow up" packet.
>>
>
>I should have mentioned that this checksum trailer extension field is needed to
>get the idea to work for NTP. Unfortunately you can't have security or a MAC
>to do this as it needs to make changes to the timestamps and then add the
>extension field to fix the UDP checksum. Tal can say more.
>
>Danny
>>
>> On 2/25/2016 7:09 PM, Danny Mayer wrote:
>>> Already thought of so it's a good idea! See
>>> https://datatracker.ietf.org/doc/draft-ietf-ntp-checksum-trailer/ for
>>> details.
>>>
>>> Danny
>>>
>>> On 2/25/2016 4:52 PM, Weber wrote:
>>>> This may or may not be worthwhile, but I thought I'd throw it out
>>>> there and see what happens:
>>>>
>>>> Recent work testing some microsecond-accurate NTP servers lead me to
>>>> an idea that could improve accuracy of measurements made by ntpd.
>>>> These NTP servers have hardware timestamps on receive but that's not
>>>> possible on transmit w/o a custom NIC. I've seen this issue discussed
>before.
>>>>
>>>> The next best thing is to generate the transmit timestamp based on a
>>>> guess as to how long it takes the NIC to get on the wire and send
>>>> the packet. That works pretty well as long as there's no other
>>>> network traffic. In this situation, it is possible to make use of
>>>> microsecond accuracy in an NTP server.
>>>>
>>>> Now, add some typical network traffic and the time it takes the NIC
>>>> to get on the wire becomes unpredictable to the tune of 200us or
>>>> more (for
>>>> 100 base-T Ethernet). The server's microsecond accuracy is largely
>>>> lost in the noise.
>>>>
>>>> The NIC generates an interrupt after the packet is sent which can
>>>> result in a fairly accurate trailing hardstamp. The problem is...the
>>>> packet is already gone and has the wrong transmit timestamp.
>>>>
>>>> Here's my idea:
>>>>
>>>> What if the poll response packet contained a flag or indication of
>>>> some sort which means "this is an approximate transmit timestamp".
>>>> That packet would then be immediately followed by a second response
>>>> packet with a more accurate transmit time. The second packet could
>>>> be otherwise identical to the first, or it could be a new flavor of
>>>> packet that contained only the transmit time (that would save on network
>bandwidth).
>>>>
>>>> The ntpd process would need to use the receive time of the first
>>>> packet (the one with an approximate tx timestamp) and merge in the
>>>> following accurate tx timestamp before performing the normal
>>>> processing associated with a poll response.
>>>>
>>>> Here are the pros and cons I can think of:
>>>>
>>>> Pros
>>>>
>>>> * Possible accuracy improvement of 1-2 orders of magnitude. I know
>>>> ntpd already does some work to try and filter out network delay
>>>> variation so the improvement might not be a full 2 orders of magnitude.
>>>> * Could potentially be made compatible backwards compatible with ntp
>>>> 3/4 protocols
>>>>
>>>> Cons
>>>>
>>>> * Increased network traffic
>>>> * Improvement to that level of accuracy might not be of interest to
>>>> anyone
>>>> * Could be a fair bit of work for at least a couple of folks
>>>> * I may have (or probably) missed some stuff regarding network
>>>> behavior that would reduce the level of improvement that could be
>realized.
>>>> * Perhaps this is less of an issue on G-bit Ethernet?
>>>>
>>>> Wondering if anyone thinks this idea is worth pursuing further...?
>>>
>>>
>> _______________________________________________
>> questions mailing list
>> questions@lists.ntp.org
>> http://lists.ntp.org/listinfo/questions
>>
>>

_______________________________________________
ntpwg mailing list
ntpwg@lists.ntp.org
http://lists.ntp.org/listinfo/ntpwg