<?xml version="1.0" encoding="US-ASCII"?>
<!DOCTYPE rfc SYSTEM "rfc2629.dtd" [
<!ENTITY RFC2119 SYSTEM "https://xml2rfc.ietf.org/public/rfc/bibxml/reference.RFC.2119.xml">
<!ENTITY RFC5905 SYSTEM "https://xml2rfc.ietf.org/public/rfc/bibxml/reference.RFC.5905.xml">
<!ENTITY RFC7822 SYSTEM "https://xml2rfc.ietf.org/public/rfc/bibxml/reference.RFC.7822.xml">
<!ENTITY RFC8915 SYSTEM "https://xml2rfc.ietf.org/public/rfc/bibxml/reference.RFC.8915.xml">
<!ENTITY RFC9109 SYSTEM "https://xml2rfc.ietf.org/public/rfc/bibxml/reference.RFC.9109.xml">
]>
<?xml-stylesheet type='text/xsl' href='rfc2629.xslt' ?>
<?rfc strict="yes"?>
<?rfc toc="yes"?>
<?rfc tocdepth="3"?>
<?rfc symrefs="yes"?>
<?rfc sortrefs="yes"?>
<?rfc compact="yes"?>
<?rfc subcompact="no"?>

<rfc category="std" docName="draft-ietf-ntp-over-ptp-04" ipr="trust200902">
  <front>
    <title>NTP Over PTP</title>

    <author fullname="Miroslav Lichvar" initials="M." surname="Lichvar">
      <organization>Red Hat</organization>
      <address>
        <email>mlichvar@redhat.com</email>
      </address>
    </author>

    <date year="2025" month="Feb" day="19"/>

    <area>General</area>

    <workgroup>Internet Engineering Task Force</workgroup>

    <keyword>NTP</keyword>

    <abstract>
      <t>This document specifies a transport for the client-server and
        symmetric modes of the Network Time Protocol (NTP) which encapsulates
        NTP messages in messages of the Precision Time Protocol (PTP). This
        transport enables hardware timestamping in network interface
        controllers which can timestamp only PTP messages and enables delay
        corrections in PTP transparent clocks.</t>
    </abstract>
  </front>

  <middle>
    <section title="Introduction">
      <t>The <xref target="IEEE1588-2019">Precision Time Protocol (PTP)</xref>
        was designed for highly accurate synchronization of clocks in local
        networks. It relies on hardware timestamping supported in all network
        devices involved in the synchronization (e.g. network interface
        controllers, switches, and routers) to eliminate the impact of
        software, processing and queueing delays on accuracy of offset and
        delay measurements.</t>

      <t>PTP was originally designed for multicast communication. Later was
        added support for unicast messaging, which is useful in larger networks
        with partial on-path PTP support (e.g. telecom profiles G.8265.1 and
        G.8275.2).</t>

      <t>The <xref target="RFC5905">Network Time Protocol</xref> does not rely
        on hardware timestamping support, but implementations can use it if it
        is available to avoid the impact of software, processing and queueing
        delays, similarly to PTP. When comparing PTP with the timing modes of
        NTP, PTP is functionally closest to the NTP broadcast mode.</t>

      <t>An issue for NTP is hardware that can specifically timestamp only PTP
        packets. This limitation comes from a hardware design which can provide
        receive timestamps only at a limited rate instead of the maximum rate
        possible at the network link speed. To avoid missing receive timestamps
        when the interface is receiving other traffic at a high rate, a filter
        is implemented in the hardware to inspect each received packet and
        capture a timestamp only for packets that need it.</t>

      <t>The hardware filter can be usually configured for specific PTP
        transport (e.g. UDP over IPv4, UDP over IPv6, 802.3) and sometimes even
        the PTP message type (e.g. sync message or delay request) to further
        reduce the timestamping rate on the server or client side in the case
        of multicast messaging, but it typically cannot be configured to
        timestamp NTP messages sent to the UDP port 123.</t>

      <t>Another issue for NTP is missing hardware support in network switches
        and routers. With PTP the devices operate either as boundary clocks or
        transparent clocks. Boundary clocks are analogous to NTP clients that
        work also as servers for other clients. Transparent clocks are much
        simpler. They only measure the delay in forwarding of PTP packets
        and write this delay to the correction field of either the packet
        itself (one-step mode) or a later packet in the PTP exchange (two-step
        mode). Transparent clocks are specific to the PTP delay mechanism used
        in the network, either end-to-end (E2E) or peer-to-peer (P2P).</t>

      <t>This document specifies a new transport for NTP to enable hardware
        timestamping on NICs which can timestamp only PTP messages and also
        take advantage of one-step E2E PTP unicast transparent clocks. It adds
        a new type-length-value (TLV) for PTP to contain NTP messages and adds
        a new extension field for NTP to provide clients and peers with the
        correction of their NTP requests from transparent clocks. The NTP
        broadcast mode is not supported.</t>

      <t>The use of PTP messages requires that protocol rules of <xref
        target="IEEE1588-2019">IEEE1588</xref> are followed. NTP over PTP does
        not require other PTP clocks to be present in the network. It does not
        disrupt their operation if they are present. If the network uses
        one-step E2E transparent clocks, NTP clients and peers using PTP for
        transport can reach the same or better accuracy as PTP clocks using PTP
        for synchronization. Hosts in a network can use PTP for synchronization
        in one domain and transport of NTP messages in another domain at the
        same time.</t>

      <section title="Comparison with PTP">
        <t>The client-server mode of NTP, even with the PTP transport, has
          multiple advantages over PTP using multicast or unicast messaging:

          <list style="symbols">
            <t>NTP is more secure. Existing security mechanisms specified for
              NTP like <xref target="RFC8915">Network Time Security</xref> are
              not impacted by the PTP transport. It is more difficult to secure
              PTP against delay attacks due to the sync message not being an
              immediate response to a client request. The PTP unicast mode
              allows an almost-infinite traffic amplification, which can be
              exploited for denial-of-service attacks and can only be limited
              by security mechanisms requiring client authentication.</t>
            <t>NTP is more resilient to failures. Each client can use multiple
              servers and detect failed sources in its source selection. In PTP
              a single hardware or software failure can disrupt the whole PTP
              domain. Multiple independent domains have to be used to handle any
              failure.</t>
            <t>NTP is better suited for synchronization in networks which do not
              have full on-path PTP support, or where timestamping errors do
              not have a symmetric distribution (e.g. due to sensitivity to
              network load). NTP does not assume network delay is constant
              and the rate of measurements in opposite directions is symmetric.
              It can filter the measurements more effectively and is not
              sensitive to asymmetrically distributed network delays and
              timestamping errors. PTP has to measure the offset and delay
              separately to enable multicast messaging, which is needed to reduce
              the transmit timestamping rate.</t>
            <t>NTP needs fewer messages to get the same number of timestamps. It
              uses less network bandwidth than PTP using unicast messaging.</t>
            <t>NTP provides clients with an estimate of the maximum error of the
              clock (root distance).</t>
          </list>
        </t>

        <t>The disadvantage of NTP is transmit timestamping rate growing with
          the number of clients. A server which is limited by the hardware
          timestamping rate cannot provide a highly accurate time service to
          the same number of clients as with PTP using multicast messaging.</t>
      </section>

      <section title="Requirements Language">
        <t>The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT",
          "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this
          document are to be interpreted as described in <xref
            target="RFC2119">RFC 2119</xref>.</t>
      </section>
    </section>

    <section title="PTP transport for NTP">
      <t>A new TLV is defined for PTP to contain NTP messages in the client
        (3), server (4), and symmetric modes (1 and 2). Using other NTP modes in
        the TLV is not specified. Any transport specified for PTP that supports
        unicast messaging, and an IPv4 or IPv6 mapping, can be used for NTP
        over PTP.</t>

      <t>The NTP TLV is an organization-specific TLV having the following
        fields (with octets in network order):
        <list style="symbols">
          <t>type is 0x8000 (ORGANIZATION_EXTENSION_DO_NOT_PROPAGATE)</t>
          <t>lengthField is 8 + length of the NTP message</t>
          <t>organizationId is 00-00-5E (IANA OUI)</t>
          <t>organizationSubType is [[TBD]]</t>
          <t>dataField contains two zero octets for 32-bit alignment followed
            by the NTP message, which would normally be the UDP payload</t>
        </list>
      </t>

      <t>The NTP TLV MUST be included in a unicast PTP event message. An event
        message is required to enable the PTP-specific hardware timestamping
        and corrections of transparent clocks. The PTP message MUST conform to
        <xref target="IEEE1588-2008">PTP version 2</xref>, <xref
        target="IEEE1588-2019">PTP version 2.1</xref>, or any future version of
        the PTP specification.</t>

      <t>An NTP client or peer using the PTP transport sends NTP requests
        contained as the NTP TLV in PTP messages.</t>

      <t>An NTP server or peer responding to an NTP request received over the
        PTP transport MUST send its response as the NTP TLV using the same PTP
        transport. The PTP message containing the NTP response MUST NOT be
        longer than the PTP message containing the NTP request. If the NTP
        response is expected to be used for synchronization (e.g. it is not an
        error message), the PTP message SHOULD have the same length as the
        message containing the request, using the PAD TLV (type 0x8008) if
        needed, to avoid an asymmetric delay in networks without full on-path
        PTP support.</t>

      <t>The <xref target="IEEE1588-2019">PTP version 2.1</xref> specification
        states that "A domain shall define the scope of PTP message
        communication, state, operations, data sets, and timescale. Within a
        PTP Network, a domain is identified by two attributes: domainNumber and
        sdoId.". In the context of NTP over PTP version 2.1, this means that
        the NTP servers, clients, and peers MUST verify that received PTP
        messages use the domainNumber and sdoId configured for use by NTP over
        PTP. The domainNumber SHOULD be 123, and sdoId SHOULD be 0. This
        domainNumber 123 is not commonly used by PTP profiles, and so is less
        likely to interfere with any other PTP operation which might be running
        in the network.</t>

      <t>If the UDP transport is used for PTP, the UDP source and destination
        port numbers SHOULD be the PTP event port (319). If the client
        implemented <xref target="RFC9109">port randomization</xref>, requests
        and/or responses would not get a hardware receive timestamp due to the
        hardware filter matching only the PTP event port.</t>

      <t>Any authenticator fields included in the NTP messages MUST be
        calculated only over the NTP message following the header of the NTP
        TLV. Other data in the PTP message (outside of the NTP TLV) are not
        protected. With the exception of the PTP correction field requiring
        special handling as described in the following section, the other PTP
        fields are used only for the transport of the NTP message and have no
        impact on security of NTP, similarly to the IP and UDP headers.</t>

      <t>Receive and transmit timestamps contained in the NTP messages SHOULD
        NOT be adjusted for the beginning of the NTP data in the PTP message.
        To minimize the impact of different link speeds on accuracy in networks
        without full on-path PTP support, the transmit timestamp SHOULD
        correspond to the PTP message timestamp point (i.e. beginning of the
        first symbol after the Ethernet start of frame delimiter) and the
        receive timestamp SHOULD be transposed from the PTP message timestamp
        point to the ending of the reception (e.g. ending of the last symbol of
        the Ethernet frame check sequence).</t>
    </section>

    <section title="Network Correction Extension Field">
      <t>One-step E2E PTP transparent clocks modify the correction field in the
        header of the PTP event messages containing NTP messages. To be able to
        verify and apply the corrections to an NTP measurement, the client or
        peer needs to know the correction of both the request and response.
        The correction of the response is in the PTP header of the message
        itself. The correction of the request is provided by the server or
        other peer in a new NTP extension field included in the response.</t>

      <t>The format of the Network Correction Extension Field is shown in
        Figure <xref format="counter" target="net-correction-ext-field"/>.
      </t>

      <figure align="center" anchor="net-correction-ext-field"
          title="Format of Network Correction Extension Field">
        <artwork><![CDATA[
 0                   1                   2                   3
 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Type = [[TBD]]                |             Length            |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                                                               |
+                  Network Correction (64 bits)                 +
|                                                               |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
.                                                               .
.                            Padding                            .
.                                                               .
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
        ]]></artwork>
      </figure>

      <t>The length of the padding is the minimum required to make a valid
        extension field in the used version of NTP. In NTPv4 that is 16 octets
        to get a 28-octet extension field following <xref target="RFC7822">RFC
        7822</xref>.</t>

      <t>The Network Correction field in the extension field uses the 64-bit
        NTP timestamp format (resolution of about 1/4th of a nanosecond). The
        correction field in PTP header has a different format (64-bit
        nanoseconds + 16-bit fraction).</t>

      <t>The value of the NTP network correction is the sum of PTP
        corrections provided by transparent clocks and the time it takes to
        receive the packet (i.e. packet length including the frame check
        sequence divided by the link speed).</t>

      <t>The reason for not using the PTP correction alone is to avoid an
        asymmetric correction when the server and client, or peers, are
        connected to the network with different link speeds. The receive
        duration included in the NTP correction cancels out the transposition
        of PTP receive timestamp corresponding to the beginning of the
        reception to NTP receive timestamp corresponding to the end of the
        reception.</t>

      <t>The Figure <xref format="counter" target="ptp-vs-ntp-correction"/>
        shows the NTP timestamps, transmit/receive durations, and processing
        and queuing delays included in PTP corrections for an NTP exchange made
        over two PTP transparent clocks. The link speed is increasing on the
        network path from the client to the server. The propagation delays in
        cables are not shown.</t>

      <figure align="center" anchor="ptp-vs-ntp-correction"
          title="PTP vs NTP Correction">
        <artwork><![CDATA[
NTP server                          T2  T3
             --------------------|==|----|==|--------------------
PTP TC #2                      |~|          |~|
                          |====|              |====|
PTP TC #1               |~|                        |~|
             --|========|----------------------------|========|--
NTP client    T1                                              T4

PTP correction |========|~|====|~|       |==|~|====|~|
NTP correction |========|~|====|~|==|    |==|~|====|~|========|
        ]]></artwork>
      </figure>

      <t>When an NTP server which supports the PTP transport receives an NTP
        request containing the Network Correction Extension Field, it SHOULD
        respond with the extension field providing the network correction of
        the client's request. The server MUST ignore the value of the network
        correction in the request.</t>

      <t>An NTP client or peer which supports the PTP transport and is
        configured to use the network correction for the association SHOULD
        include the extension field in its NTP requests. In the case of a
        client, the correction value in the extension field SHOULD be always
        zero.</t>

      <t>When the client or peer has the network correction of both the request
        and response, it can correct the measured NTP peer delay and offset:

        <list style="symbols">
          <t>delta_c = delta - (nc_rs + nc_rq - dur_rs - dur_rq) * (1 - freq_tc)</t>
          <t>theta_c = theta + (nc_rs - nc_rq) / 2</t>
        </list>

        where

        <list style="symbols">
          <t>delta is the NTP peer delay from RFC 5905</t>
          <t>theta is the NTP offset from RFC 5905</t>
          <t>nc_rq is the network correction of the request</t>
          <t>nc_rs is the network correction of the response</t>
          <t>dur_rq is the transmit duration of the request</t>
          <t>dur_rs is the receive duration of the response</t>
          <t>freq_tc is the maximum assumed frequency error of transparent
            clocks</t>
        </list>
      </t>

      <t>The corrected delay (delta_c) and offset (theta_c) MUST NOT be
        accepted for synchronization if any of delta_c, nc_rs, and nc_rq is
        negative. This requirement limits the error caused by faulty
        transparent clocks and man-in-the-middle attacks.</t>

      <t>Root delay (DELTA) MUST NOT be corrected to not make the maximum
        assumed error (root distance) dependent on accurate network
        corrections.</t>

      <t>The scaling by the freq_tc constant (e.g. 100 ppm) is needed to
        make room for errors in corrections made by transparent clocks running
        faster than true time and avoid samples with larger corrections from
        getting a shorter delay than samples with smaller corrections, which
        would negatively impact their filtering and weighting.</t>

      <t>The dur_rq and dur_rs values make the corrected peer delay correspond
        to a direct connection to the server.  If they were not used, a
        perfectly corrected delay on a short network path would be too close to
        zero and frequently negative due to frequency offset between the client
        and server. Note that NTP peers and PTP clocks using the E2E delay
        mechanism are more sensitive to frequency offsets due to longer
        measurement intervals. If dur_rq is unknown, it MAY be assumed to be
        equal to dur_rs.</t>
    </section>

    <section anchor="Acknowledgements" title="Acknowledgements">
      <t>The author would like to thank Doug Arnold, Rodney Cummings, and
        Martin Langer for their comments and suggestions.</t>
    </section>

    <section anchor="IANA" title="IANA Considerations">
      <t>IANA is requested to allocate the following field in the <xref
        target="RFC5905">NTP Extension Field Types Registry</xref>:</t>

      <texttable>
        <ttcol>Field Type</ttcol>
        <ttcol>Meaning</ttcol>
        <ttcol>Reference</ttcol>

        <c>[[TBD]]</c>
        <c>Network correction</c>
        <c>[[this memo]]</c>
      </texttable>

      <t>IANA is requested to create a new registry "IANA PTP TLV Subtypes
        Registry" for entries having the following fields:

        <list>
          <t>Subtype (REQUIRED) - integer in the range 0-0xFFFFFF</t>
          <t>Description (REQUIRED)- short text description</t>
          <t>Reference (REQUIRED) - reference to the document describing the
            IANA PTP TLV</t>
        </list>
      </t>

      <t>Subtypes in the range 0x800000-0xFFFFFF are reserved for experimental
        and private use. They cannot be assigned by IANA.</t>

      <t>The initial content of the registry is the following entry:</t>

      <texttable>
        <ttcol>Subtype</ttcol>
        <ttcol>Description</ttcol>
        <ttcol>Reference</ttcol>

        <c>[[TBD]]</c>
        <c>Network Time Protocol Message</c>
        <c>[[this memo]]</c>
      </texttable>
    </section>

    <section title="Implementation Status - RFC EDITOR: REMOVE BEFORE PUBLICATION">
      <t>This section records the status of known implementations of the
        protocol defined by this specification at the time of posting of this
        Internet-Draft, and is based on a proposal described in RFC 7942. The
        description of implementations in this section is intended to assist
        the IETF in its decision processes in progressing drafts to RFCs.
        Please note that the listing of any individual implementation here does
        not imply endorsement by the IETF. Furthermore, no effort has been
        spent to verify the information presented here that was supplied by
        IETF contributors. This is not intended as, and must not be construed
        to be, a catalog of available implementations or their features.
        Readers are advised to note that other implementations may exist.</t>

      <t>According to RFC 7942, "this will allow reviewers and working groups
        to assign due consideration to documents that have the benefit of
        running code, which may serve as evidence of valuable experimentation
        and feedback that have made the implemented protocols more mature. It
        is up to the individual working groups to use this information as they
        see fit".</t>

      <section title="chrony">
        <t>chrony (https://chrony-project.org) added experimental support for
          NTP over PTP in version 4.2. As the type of the NTP TLV, it uses
          0x2023 from the experimental "do not propagate" range.</t>

        <t>It was tested on Linux with the following network controllers, which
          have hardware timestamping limited to PTP packets:

          <list>
            <t>Intel XL710 (i40e driver) - works</t>
            <t>Intel X540-AT2 (ixgbe driver) - works</t>
            <t>Intel 82576 (igb driver) - works</t>
            <t>Broadcom BCM5720 (tg3 driver) - works</t>
            <t>Broadcom BCM57810 (bnx2x driver) - does not timestamp unicast PTP
              packets</t>
            <t>Solarflare SFC9250 (sfc driver) - works</t>
          </list>
        </t>

        <t>The network correction was tested with the following switches which
          support operation as a one-step E2E PTP unicast transparent
          clock:

          <list>
            <t>FS.COM IES3110-8TF-R - works</t>
            <t>Juniper QFX5200-32C-32Q - works</t>
          </list>
        </t>
      </section>
    </section>

    <section anchor="Security" title="Security Considerations">
      <t>The PTP transport prevents NTP clients from randomizing their source
        port.</t>

      <t>The corrections provided by PTP transparent clocks cannot be
        authenticated. Man-in-the-middle attackers can modify the correction
        field, but only corrections smaller than the measured delay are
        accepted by clients. The impact is comparable to the impact of delaying
        unmodified NTP messages.</t>
    </section>
  </middle>

  <back>
    <references title="Normative References">
      &RFC2119;

      &RFC5905;

      &RFC7822;

      <reference anchor="IEEE1588-2019" target="https://www.ieee.org">
        <front>
          <title>
            IEEE std. 1588-2019, "IEEE Standard for a Precision Clock
            Synchronization Protocol for Networked Measurement and Control
            Systems."
          </title>
          <author>
            <organization>
              Institute of Electrical and Electronics Engineers
            </organization>
          </author>
          <date month="11" year="2019" />
        </front>
      </reference>
    </references>

    <references title="Informative References">
      &RFC8915;

      &RFC9109;
      <reference anchor="IEEE1588-2008" target="https://www.ieee.org">
        <front>
          <title>
            IEEE std. 1588-2008, "IEEE Standard for a Precision Clock
            Synchronization Protocol for Networked Measurement and Control
            Systems."
          </title>
          <author>
            <organization>
              Institute of Electrical and Electronics Engineers
            </organization>
          </author>
          <date month="7" year="2008"/>
        </front>
      </reference>
    </references>
  </back>
</rfc>
