<?xml version="1.0" encoding="UTF-8"?>

<!-- [CS] updated by Chris 12/23/21 -->

<!DOCTYPE rfc [
  <!ENTITY nbsp    "&#160;">
  <!ENTITY zwsp   "&#8203;">
  <!ENTITY nbhy   "&#8209;">
  <!ENTITY wj     "&#8288;">
]>

<rfc xmlns:xi="http://www.w3.org/2001/XInclude" docName="draft-mymb-sfc-nsh-allocation-timestamp-12" number="0000" ipr="trust200902" obsoletes="" updates="" submissionType="independent" category="info" xml:lang="en" tocInclude="true" tocDepth="4" symRefs="true" sortRefs="true" version="3">

  <!-- xml2rfc v2v3 conversion 3.12.0 -->
  <front>
    <title abbrev="NSH Timestamp">Network Service Header (NSH) Fixed-Length
    Context Header Allocation: Timestamp</title>
    <seriesInfo name="RFC" value="0000"/>
    <author fullname="Tal Mizrahi" initials="T." surname="Mizrahi">
      <organization abbrev="">Huawei</organization>
      <address>
        <postal>
          <street/>
          <city/>
          <code/>
          <country>Israel</country>
        </postal>
        <email>tal.mizrahi.phd@gmail.com</email>
      </address>
    </author>
    <author fullname="Ilan Yerushalmi" initials="I.Y." surname="Yerushalmi">
      <organization>Marvell</organization>
      <address>
        <postal>
          <street>6 Hamada</street>
          <!-- Reorder these if your country does things differently -->

          <city>Yokneam</city>
          <code>2066721</code>
          <country>Israel</country>
        </postal>
        <email>yilan@marvell.com</email>
      </address>
    </author>
    <author fullname="David Melman" initials="D.M." surname="Melman">
      <organization>Marvell</organization>
      <address>
        <postal>
          <street>6 Hamada</street>
          <!-- Reorder these if your country does things differently -->

          <city>Yokneam</city>
          <code>2066721</code>
          <country>Israel</country>
        </postal>
        <email>davidme@marvell.com</email>
      </address>
    </author>
    <author fullname="Rory Browne" initials="R.B." surname="Browne">
      <organization>Intel</organization>
      <address>
        <postal>
          <street>Dromore House</street>
          <!-- Reorder these if your country does things differently -->

          <city>Shannon</city>
          <region>Co.Clare</region>
          <country>Ireland</country>
        </postal>
        <email>rory.browne@intel.com</email>
      </address>
    </author>
    <date year="2022" month="January" />
    <area>General</area>
    <workgroup>Network Working Group</workgroup>
    <keyword>NSH</keyword>
    <keyword>Context Header</keyword>
    <keyword>timestamp</keyword>
    
    <abstract>
      <t>The Network Service Header (NSH) specification defines two possible
      methods of including metadata (MD): MD Type 0x1 and MD Type 0x2. MD Type
      0x1 uses a fixed-length Context Header. The allocation of this Context
      Header, i.e., its structure and semantics, has not been standardized.
      This memo presents an allocation for the fixed Context Headers of NSH,
      which incorporates the packet's timestamp, a sequence number, and a
      source interface identifier.</t>
      <t>Although the allocation that is presented in this document has not
      been standardized by the IETF it has been implemented in silicon by
      several manufacturers and is published here to allow other interoperable
      implementations and to facilitate debugging if it is seen in the
      network.</t>
    </abstract>
  </front>
  <middle>
    <section numbered="true" toc="default">
      <name>Introduction</name>
      <t>The Network Service Header (NSH), defined in <xref target="RFC8300" format="default"/>, is an encapsulation header that is used as the
      service encapsulation in the Service Function Chains (SFC) architecture
      <xref target="RFC7665" format="default"/>.</t>
      <t>In order to share metadata along a service path, the NSH
      specification <xref target="RFC8300" format="default"/> supports two methods: a
      fixed-length Context Header (MD Type 0x1) and a variable-length Context
      Header (MD Type 0x2). When using MD Type 0x1 the NSH includes 16 octets
      of Context Header fields.</t>
      <t>The NSH specification <xref target="RFC8300" format="default"/> has not defined the
      semantics of the 16-octet Context Header, nor how it is used by
      NSH-aware service functions, SFFs and proxies. Several context header
      formats are defined in <xref target="NSH-TLV" format="default"/>.
      Furthermore, some allocation schemes were proposed in the past to
      acoommodate specific use cases, e.g., <xref target="NSH-DC-ALLOC"/>, <xref target="I-D.ietf-sfc-nsh-broadband-allocation" format="default"/>, and <xref target="RFC8592" format="default"/>.</t>
      <t>This memo presents an allocation for the MD Type 0x1 Context Header,
      which incorporates the timestamp of the packet, a sequence number, and a
      source interface identifier. It is noted that other MD Type 0x1
      allocations might be specified in the future. Although MD Type 0x1
      allocations are currently not being standardized by the SFC working
      group, a consistent format (allocation) should be used in an SFC-enabled
      domain in order to allow interoperability.</t>
      <t>In a nutshell, packets that enter the SFC-enabled domain are
      timestamped by a Classifier <xref target="RFC7665" format="default"/>. Thus, the
      timestamp, sequence number and source interface are incorporated in the
      NSH Context Header. As defined in <xref target="RFC8300" format="default"/>, if
      reclassification is used, it may result in an update to the NSH
      metadata. Specifically, when the Timestamp Context Header is used, a
      reclassifier may either leave it unchanged, or update the three fields:
      timestamp, sequence number and source interface.</t>
      <t>The Timestamp Context Header includes three fields that may be used
      for various purposes. The timestamp field may be used for logging,
      troubleshooting, delay measurement, packet marking for performance
      monitoring, and timestamp-based policies. The source interface
      identifier indicates the interface through which the packet was received
      at the classifier. This identifier may specify a physical or a virtual
      interface. The sequence numbers can be used by Service Functions (SFs)
      to detect out-of-order delivery or duplicate transmissions. Note that
      out-of-order and duplicate packet detection is possible when packets are
      received by the same SF, but is not necessarily possible when there are
      multiple instances of the same SF and multiple packets are spread across
      different instances of the SF. The sequence number is maintained on a
      per-source-interface basis.</t>
      <t>This document presents the Timestamp Context Header, but does not
      specify the functionality of the SFs that receive the Context Header.
      Although a few possible use cases are described in the document, the SF
      behavior and application are outside the scope of this document.</t>
      <t>KPI-stamping <xref target="RFC8592" format="default"/> defines an NSH timestamping
      mechanism that uses the MD Type 0x2 format. The current memo defines a
      compact MD Type 0x1 Context Header that does not require the packet to
      be extended beyond the NSH header. Furthermore, the mechanisms of <xref target="RFC8592" format="default"/> and of this memo can be used in concert, as further
      discussed in <xref target="SecAnalytics" format="default"/>.</t>
      <t>Although the allocation that is presented in this document has not
      been standardized by the IETF it has been implemented in silicon by
      several manufacturers and is published here to allow other interoperable
      implementations and to facilitate debugging if it is seen in the
      network.</t>
    </section>
    <section numbered="true" toc="default">
      <name>Terminology</name>
      <section numbered="true" toc="default">
        <name>Requirements Language</name>
         <t>The key words "<bcp14>MUST</bcp14>", "<bcp14>MUST NOT</bcp14>",
         "<bcp14>REQUIRED</bcp14>", "<bcp14>SHALL</bcp14>",
         "<bcp14>SHALL NOT</bcp14>", "<bcp14>SHOULD</bcp14>",
         "<bcp14>SHOULD NOT</bcp14>",
         "<bcp14>RECOMMENDED</bcp14>", "<bcp14>NOT RECOMMENDED</bcp14>",
         "<bcp14>MAY</bcp14>", and "<bcp14>OPTIONAL</bcp14>" in this document
         are to be interpreted as described in BCP&nbsp;14
         <xref target="RFC2119"/> <xref target="RFC8174"/> when, and only
         when, they appear in all capitals, as shown here.</t>
      </section>
      <section numbered="true" toc="default">
        <name>Abbreviations</name>
        <t>The following abbreviations are used in this document: </t>
        <dl newline="false" spacing="normal" indent="14">
          <dt>KPI</dt>
          <dd>Key Performance Indicators <xref target="RFC8592" format="default"/></dd>
          <dt>NSH</dt>
          <dd>Network Service Header <xref target="RFC8300" format="default"/></dd>
          <dt>MD</dt>
          <dd>Metadata <xref target="RFC8300" format="default"/></dd>
          <dt>SF</dt>
          <dd>Service Function <xref target="RFC7665" format="default"/></dd>
          <dt>SFC</dt>
          <dd>Service Function Chaining <xref target="RFC7665" format="default"/></dd>
        </dl>
      </section>
    </section>
    <section anchor="allocation" numbered="true" toc="default">
      <name>NSH Timestamp Context Header Allocation</name>
      <t>This memo defines the following fixed-length Context Header
      allocation, as presented in <xref target="AllocationFormat" format="default"/>.</t>
      <figure anchor="AllocationFormat">
        <name>NSH Timestamp Allocation.</name>
        <artwork align="left" name="" type="ascii-art" alt=""><![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
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
   |                        Sequence Number                        |
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
   |                        Source Interface                       |
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
   |                           Timestamp                           |
   |                                                               |
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
           ]]></artwork>
      </figure>
      <!-- This PI places the pagebreak correctly (before the section title) in the text output. -->

      <t>The NSH Timestamp Allocation that is defined in this memo <bcp14>MUST</bcp14>
      include the following fields:</t>
      <dl spacing="normal">
        <dt>Sequence Number -</dt><dd>a 32-bit sequence number. The sequence number
          is maintained on a per-source-interface basis. Sequence numbers can
          be used by SFs to detect out-of-order delivery, or duplicate
          transmissions. The Classifier increments the sequence number by 1
          for each packet received through the source interface. This requires
          the classifier to maintain a per-source-interface counter. The
          sequence number is initialized to a random number on startup. After
          it reaches its maximal value (2^32-1) the sequence number wraps
          around back to zero.</dd>
        <dt>Source Interface -</dt><dd>a 32-bit source interface identifier that is
          assigned by the Classifier. The combination of the source interface
          and the classifier identity is unique within the context of an
          SFC-enabled domain. Thus, in order for an SF to be able to use the
          source interface as a unique identifier, the identity of the
          classifier needs to be known for each packet. The source interface
          is unique in the context of the given classifier.</dd>
        <dt>Timestamp -</dt><dd>this field is 64 bits long, and specifies the time at
          which the packet was received by the Classifier. Two possible
          timestamp formats can be used for this field: the two 64-bit
          recommended formats specified in <xref target="RFC8877" format="default"/>. One of
          the formats is based on the <xref target="IEEE1588" format="default"/> timestamp
          format, and the other is based on the <xref target="RFC5905" format="default"/>
          format.</dd>
      </dl>
      <t>The NSH specification <xref target="RFC8300" format="default"/> does not specify the
      possible coexistence of multiple MD Type 0x1 Context Header formats in a
      single SFC-enabled domain. It is assumed that the Timestamp Context
      Header will be deployed in an SFC-enabled domain that uniquely uses this
      Context Header format. Thus, operators <bcp14>SHOULD</bcp14> ensure that either a
      consistent Context Header format is used in the SFC-enabled domain, or
      that there is a clear policy that allows SFs to know the Context Header
      format of each packet. Specifically, operators are expected to ensure
      the consistent use of a timestamp format across the whole SFC-enabled
      domain.</t>
      <t>The two timestamp formats that can be used in the timestamp field
      are:</t>
      <dl spacing="normal">
        <dt>IEEE 1588 Truncated Timestamp Format:</dt><dd>this format is specified in
          <xref target="RFC8877" sectionFormat="of" section="4.3"/>. For the reader's
          convenience this format is illustrated in <xref target="TimestampFormat" format="default"/>.</dd>
      </dl>
      <figure anchor="TimestampFormat">
        <name>IEEE 1588 Truncated Timestamp Format [IEEE1588].</name>
        <artwork align="left" name="" type="ascii-art" alt=""><![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
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
   |                            Seconds                            |
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
   |                           Nanoseconds                         |
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
           ]]></artwork>
      </figure>
      <dl spacing="normal">
        <dt>NTP <xref target="RFC5905" format="default"/> 64-bit Timestamp Format:</dt><dd>this format
          is specified in <xref target="RFC8877" sectionFormat="of" section="4.4"/>. For the
          reader's convenience this format is illustrated in <xref target="NTPFormat" format="default"/>.</dd>
      </dl>
      <figure anchor="NTPFormat">
        <name>NTP [RFC5905] 64-bit Timestamp Format</name>
        <artwork align="left" name="" type="ascii-art" alt=""><![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
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
   |                            Seconds                            |
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
   |                            Fraction                           |
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
           ]]></artwork>
      </figure>
      <t>Synchronization aspects of the timestamp format in the context of the
      NSH timestamp allocation are discussed in <xref target="Sync" format="default"/>.</t>
    </section>
    <section numbered="true" toc="default">
      <name>Timestamping Use Cases</name>
      <section anchor="SecAnalytics" numbered="true" toc="default">
        <name>Network Analytics</name>
        <t>Per-packet timestamping enables coarse-grained monitoring of the
        network delay along the Service Function Chain. Once a potential
        problem or bottleneck is detected, for example when the delay exceeds
        a certain policy, a highly-granular monitoring mechanism can be
        triggered, for example using the hop-by-hop measurement data of <xref target="RFC8592" format="default"/> or <xref target="RFCYYY1" format="default"/>,
        allowing to analyze and localize the problem.</t>
        <t>Timestamping is also useful for logging, troubleshooting and for
        flow analytics. It is often useful to maintain the timestamp of the
        first and last packet of the flow. Furthermore, traffic mirroring and
        sampling often requires a timestamp to be attached to analyzed
        packets. Attaching the timestamp to the NSH provides an in-band common
        time reference that can be used for various network analytics
        applications.</t>
      </section>
      <section numbered="true" toc="default">
        <name>Alternate Marking</name>
        <t>A possible approach for passive performance monitoring is to use an
        alternate marking method <xref target="RFC8321" format="default"/>. This method
        requires data packets to carry a field that marks (colors) the
        traffic, and enables passive measurement of packet loss, delay, and
        delay variation. The value of this marking field is periodically
        toggled between two values.</t>
        <t>When the timestamp is incorporated in the NSH, it can natively be
        used for alternate marking. For example, the least significant bit of
        the timestamp Seconds field can be used for this purpose, since the
        value of this bit is inherently toggled every second.</t>
      </section>
      <section numbered="true" toc="default">
        <name>Consistent Updates</name>
        <t>The timestamp can be used for taking policy decisions such as
        'Perform action A if timestamp&gt;=T_0'. This can be used for
        enforcing time-of-day policies or periodic policies in service
        functions. Furthermore, timestamp-based policies can be used for
        enforcing consistent network updates, as discussed in <xref target="DPT" format="default"/>. It should be noted that, as in the case of Alternate
        Marking, this use case alone does not require a full 64-bit timestamp,
        but could be implemented with a significantly smaller number of
        bits.</t>
      </section>
    </section>
    <!-- Possibly a 'Contributors' section ... -->

    <section anchor="Sync" numbered="true" toc="default">
      <name>Synchronization Considerations</name>
      <t>Some of the applications that make use of the timestamp require the
      Classifier and SFs to be synchronized to a common time reference, for
      example using the Network Time Protocol <xref target="RFC5905" format="default"/> or the
      Precision Time Protocol <xref target="IEEE1588" format="default"/>. Although it is not a
      requirement to use a clock synchronization mechanism, it is expected
      that depending on the applications that use the timestamp, such
      synchronization mechanisms will be used in most deployments that use the
      timestamp allocation.</t>
    </section>
    <section anchor="IANA" numbered="true" toc="default">
      <name>IANA Considerations</name>
      <t>This memo includes no request to IANA.</t>
    </section>
    <section anchor="Security" numbered="true" toc="default">
      <name>Security Considerations</name>
      <t>The security considerations of NSH in general are discussed in <xref target="RFC8300" format="default"/>. NSH is typically run within a confined trust domain.
      However, if a trust domain is not enough to provide the operator with
      the protection against the timestamp threats described below, then the
      operator <bcp14>SHOULD</bcp14> use transport-level protection between SFC processing
      nodes as described in <xref target="RFC8300" format="default"/>.</t>
      <t>The security considerations of in-band timestamping in the context of
      NSH is discussed in <xref target="RFC8592" format="default"/>, and the current section is
      based on that discussion.</t>
      <t>The use of in-band timestamping, as defined in this document, can be
      used as a means for network reconnaissance. By passively eavesdropping
      to timestamped traffic, an attacker can gather information about network
      delays and performance bottlenecks. A man-in-the-middle attacker can
      maliciously modify timestamps in order to attack applications that use
      the timestamp values, such as performance monitoring applications.</t>
      <t>Since the timestamping mechanism relies on an underlying time
      synchronization protocol, by attacking the time protocol an attack can
      potentially compromise the integrity of the NSH timestamp. A detailed
      discussion about the threats against time protocols and how to mitigate
      them is presented in <xref target="RFC7384" format="default"/>.</t>
    </section>
    <section anchor="Acknowledgments" numbered="true" toc="default">
      <name>Acknowledgments</name>
      <t>The authors thank <contact fullname="Mohamed Boucadair"/> and <contact fullname="Greg Mirsky"/> for their thorough reviews and detailed comments.</t>
    </section>
  </middle>
  <!--  *****BACK MATTER ***** -->

  <back>

<displayreference target="I-D.ietf-sfc-nsh-broadband-allocation"  to="NSH-BROADBAND-ALLOC"/>

    <references>
      <name>References</name>
      <references>
        <name>Normative References</name>
        <xi:include href="https://xml2rfc.ietf.org/public/rfc/bibxml/reference.RFC.2119.xml"/>
        <xi:include href="https://xml2rfc.ietf.org/public/rfc/bibxml/reference.RFC.8174.xml"/>
        <xi:include href="https://xml2rfc.ietf.org/public/rfc/bibxml/reference.RFC.8300.xml"/>
        <xi:include href="https://xml2rfc.ietf.org/public/rfc/bibxml/reference.RFC.8877.xml"/>
        <xi:include href="https://xml2rfc.ietf.org/public/rfc/bibxml/reference.RFC.7665.xml"/>
      </references>
      <references>
        <name>Informative References</name>
        <!-- Here we use entities that we defined at the beginning. -->

      <reference anchor="IEEE1588" target="https://standards.ieee.org/standard/1588-2008.html">
          <front>
            <title>IEEE 1588 Standard for a Precision Clock Synchronization
          Protocol for Networked Measurement and Control Systems Version
          2</title>
            <author>
              <organization>IEEE</organization>
            </author>
            <date year="2008"/>
          </front>
        </reference>

     <reference anchor="DPT" target="https://arxiv.org/pdf/1602.03342.pdf">
       <front>
         <title>The Case for Data Plane Timestamping in SDN</title>
         <author initials='T' surname='Mizrahi' fullname='Tal Mizrahi'></author>
         <author initials='Y' surname='Moses' fullname='Yoram Moses'></author>
       <date year="2016"/>
       </front>
       <refcontent>IEEE INFOCOM Workshop on Software-Driven Flexible and Agile Networking (SWFAN)</refcontent>
        </reference>

        <xi:include href="https://xml2rfc.ietf.org/public/rfc/bibxml/reference.RFC.7384.xml"/>
        <xi:include href="https://xml2rfc.ietf.org/public/rfc/bibxml/reference.RFC.5905.xml"/>
        <xi:include href="https://xml2rfc.ietf.org/public/rfc/bibxml/reference.RFC.8321.xml"/>
        <xi:include href="https://xml2rfc.ietf.org/public/rfc/bibxml/reference.RFC.8592.xml"/>

<!-- draft-ietf-ippm-ioam-data (EDIT) Revert to draftstr if not pub'ed in time
     NOTE:  All authors are editors, so have to do "long way" regardless -->
<reference anchor='RFCYYY1' target="https://www.rfc-editor.org/info/rfcYYY1">
<front>
<title>Data Fields for In-situ OAM</title>
<author initials='F' surname='Brockners' fullname='Frank Brockners' role="editor">
<organization />
</author>
<author initials='S' surname='Bhandari' fullname='Shwetha Bhandari' role="editor">
<organization />
</author>
<author initials='T' surname='Mizrahi' fullname='Tal Mizrahi' role="editor">
<organization />
</author>
<date year='2022' month='January'/>
</front>
<seriesInfo name="RFC" value="YYY1"/>
<seriesInfo name="DOI" value="10.17487/RFCYYY1"/>
</reference>

<!-- draft-ietf-sfc-nsh-dc-allocation (Expired)
     Have to do "long way"; one author is editor -->
<reference anchor="NSH-DC-ALLOC">
   <front>
      <title>Network Service Header (NSH) MD Type 1: Context Header Allocation (Data Center)</title>
      <author fullname="Jim Guichard" role="editor"></author>
      <author fullname="Michael Smith"></author>
      <author fullname="Surendra Kumar"></author>
      <author fullname="Sumandra Majee"></author>
      <author fullname="Tal Mizrahi"></author>
      <date month="September" day="25" year="2018" />
   </front>
   <seriesInfo name="Internet-Draft" value="draft-ietf-sfc-nsh-dc-allocation-02" />
</reference>

<!-- draft-ietf-sfc-nsh-broadband-allocation (Expired) -->
        <xi:include href="https://datatracker.ietf.org/doc/bibxml3/reference.I-D.ietf-sfc-nsh-broadband-allocation.xml"/>

<!-- draft-ietf-sfc-nsh-tlv (ESG Evaluation::AD Followup)
     Have to do "long way"; one author is editor -->
 <reference anchor="NSH-TLV">
   <front>
      <title>Network Service Header Metadata Type 2 Variable-Length Context Headers</title>
      <author fullname="Yuehua Wei" role="editor"></author>
      <author fullname="Uri Elzur"></author>
      <author fullname="Sumandra Majee"></author>
      <author fullname="Carlos Pignataro"></author>
      <author fullname="Donald E. Eastlake"></author>
      <date month="December" day="3" year="2021" />
   </front>
   <seriesInfo name="Internet-Draft" value="draft-ietf-sfc-nsh-tlv-10" />
 </reference>
</references>
</references>
    <!-- Change Log

v00 2016-08-02  TM   Initial version

v01 2016-08-10  TM   Minor updates including: timestamp format change, added Flow ID.

   -->
  </back>
</rfc>
