Network Working Group                                          G. Mirsky
Internet-Draft                                                    X. Min
Intended status: Standards Track                               ZTE Corp.
Expires: September 2, 2018 March 11, 2019                                           W. Luo
                                                                Ericsson
                                                           March 1,
                                                       September 7, 2018

     Simple Two-way Active Measurement Protocol (STAMP) Data Model
                     draft-ietf-ippm-stamp-yang-01
                     draft-ietf-ippm-stamp-yang-02

Abstract

   This document specifies the data model for implementations of
   Session-Sender and Session-Reflector for Simple Two-way Active
   Measurement Protocol (STAMP) mode using YANG.

Status of This Memo

   This Internet-Draft is submitted in full conformance with the
   provisions of BCP 78 and BCP 79.

   Internet-Drafts are working documents of the Internet Engineering
   Task Force (IETF).  Note that other groups may also distribute
   working documents as Internet-Drafts.  The list of current Internet-
   Drafts is at https://datatracker.ietf.org/drafts/current/.

   Internet-Drafts are draft documents valid for a maximum of six months
   and may be updated, replaced, or obsoleted by other documents at any
   time.  It is inappropriate to use Internet-Drafts as reference
   material or to cite them other than as "work in progress."

   This Internet-Draft will expire on September 2, 2018. March 11, 2019.

Copyright Notice

   Copyright (c) 2018 IETF Trust and the persons identified as the
   document authors.  All rights reserved.

   This document is subject to BCP 78 and the IETF Trust's Legal
   Provisions Relating to IETF Documents
   (https://trustee.ietf.org/license-info) in effect on the date of
   publication of this document.  Please review these documents
   carefully, as they describe your rights and restrictions with respect
   to this document.  Code Components extracted from this document must
   include Simplified BSD License text as described in Section 4.e of
   the Trust Legal Provisions and are provided without warranty as
   described in the Simplified BSD License.

Table of Contents

   1.  Introduction  . . . . . . . . . . . . . . . . . . . . . . . .   2
     1.1.  Conventions used in this document . . . . . . . . . . . .   2
       1.1.1.  Requirements Language . . . . . . . . . . . . . . . .   2
   2.  Scope, Model, and Applicability . . . . . . . . . . . . . . .   3
     2.1.  Data Model Parameters . . . . . . . . . . . . . . . . . .   3
       2.1.1.  STAMP-Sender  . . . . . . . . . . . . . . . . . . . .   3
       2.1.2.  STAMP-Reflector . . . . . . . . . . . . . . . . . . .   4
   3.  Data Model  . . . . . . . . . . . . . . . . . . . . . . . . .   4
     3.1.  Tree Diagrams . . . . . . . . . . . . . . . . . . . . . .   4
     3.2.  YANG Module . . . . . . . . . . . . . . . . . . . . . . .   9  10
   4.  IANA Considerations . . . . . . . . . . . . . . . . . . . . .  30
   5.  Security Considerations . . . . . . . . . . . . . . . . . . .  30  31
   6.  Acknowledgements  Acknowledgments . . . . . . . . . . . . . . . . . . . . . . .  32
   7.  Normative  References  . . . . . . . . . . . . . . . . . . . . . . . . .  32
     7.1.  Normative References  . . . . . . . . . . . . . . . . . .  32
     7.2.  Informative References  . . . . . . . . . . . . . . . . .  33
   Appendix A.  Example of STAMP Session Configuration . . . . . . .  33  34
   Authors' Addresses  . . . . . . . . . . . . . . . . . . . . . . .  35

1.  Introduction

   The Simple Two-way Active Measurement Protocol (STAMP)
   [I-D.ietf-ippm-stamp] can be used to measure performance parameters
   of IP networks such as latency, jitter, and packet loss by sending
   test packets and monitoring their experience in the network.  The
   STAMP protocol [Editor:ref to STAMP draft] [I-D.ietf-ippm-stamp] in unauthenticated mode is
   on-wire on-
   wire compatible with STAMP Light, discussed in Appendix I [RFC5357].
   The STAMP Light is known to have many implementations though no
   common management framework being defined, thus leaving some aspects
   of test packet processing to interpretation.  As one of the goals of
   STAMP is to support these variations, this document presents their
   analysis; describes common STAMP and STAMP model while allowing for
   STAMP extensions in the future.  This document defines the STAMP data
   model and specifies it formally formally, using the YANG data modeling
   language [RFC6020]. [RFC7950].

   This version of the interfaces data model confirms conforms to the Network
   Management Datastore Architecture (NMDA) defined in
   [I-D.ietf-netmod-revised-datastores]. [RFC8342].

1.1.  Conventions used in this document

1.1.1.  Requirements Language

   The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT",
   "SHOULD", "SHOULD NOT", "RECOMMENDED", "NOT RECOMMENDED", "MAY", and
   "OPTIONAL" in this document are to be interpreted as described in BCP
   14 [RFC2119] [RFC8174] when, and only when, they appear in all
   capitals, as shown here.

2.  Scope, Model, and Applicability

   The scope of this document includes a model of the STAMP as defined
   in
   [Editor:ref to STAMP draft]. [I-D.ietf-ippm-stamp].

         o----------------------------------------------------------o
         |                        Config client                     |
         o----------------------------------------------------------o
               ||                                          ||
               ||             NETCONF/RESTCONF             ||
               ||                                          ||
     o----------------------o                o-------------------------o
     |    Config server     |                |      Config server      |
     |                      |                |                         |
     +----------------------+                +-------------------------+
     | STAMP Session-Sender | <--- STAMP---> | STAMP Session-Reflector |
     +----------------------+                +-------------------------+

                      Figure 1: STAMP Reference Model

2.1.  Data Model Parameters

   This section describes all the parameters of the containers within the stamp STAMP data model.

2.1.1.  STAMP-Sender

   The stamp-session-sender container holds items that are related to
   the configuration of the stamp Session-Sender logical entity.

   The stamp-session-sender-state container holds information about the
   state of the particular STAMP test session.

   RPCs stamp-sender-start and stamp-sender-stop respectively start and
   stop the referenced session by the session-id STAMP test session. of the STAMP.

2.1.1.1.  Controls for Test Session and Performance Metric Calculation

   The data model supports several scenarios for a STAMP Session-Sender
   to execute test sessions and calculate performance metrics:

      The test mode in which the test packets are sent unbound in time
      at
      as defined by the parameter 'interval' in the stamp-session-sender
      container frequency is referred to as continuous mode.

      Performance metrics in the continuous mode are calculated at a
      period defined by the parameter 'measurement-interval'.

      The test mode that has a specific number of the test packets
      configured for the test session in the 'number-of-packets'
      parameter is referred to as a periodic mode.  The STAMP-Sender MAY
      repeat the test session may be
      repeated by the STAMP-Sender with the same parameters.  The 'repeat'
      parameter defines the number of tests and the 'repeat-
      interval' 'repeat-interval' -
      the interval between the consecutive tests.  The performance
      metrics are calculated after each test session when the interval
      defined by the 'session-timeout' expires.

2.1.2.  STAMP-Reflector

   The stamp-session-reflector container holds items that are related to
   the configuration of the STAMP Session-Reflector logical entity.

   The stamp-session-refl-state container holds Session-Reflector state
   data for the particular STAMP test session.

3.  Data Model

   Creating STAMP data model presents a number of challenges and among
   them is the identification of a test-session at Session-Reflector.  A
   Session-Reflector MAY require only as little as its IP and UDP port
   number in received STAMP-Test packet to spawn new test session.  More
   so, to test processing of Class-of-Service along the same route in
   Equal Cost Multi-Path environment Session-Sender may run perform STAMP
   test sessions concurrently using the same source IP address, source
   UDP port number, destination IP address, and destination UDP port
   number.  Thus the only parameter that can be used to differentiate
   these test sessions would be DSCP value.  The DSCP field may get re-marked re-
   marked along the path path, and without the use of [RFC7750] that will go
   undetected, but by using five-tuple instead of four-tuple as a key key,
   we can ensure that STAMP test packets that are considered as
   different test sessions follow the same path even in ECMP
   environments.

3.1.  Tree Diagrams

   This section presents a simplified graphical representation of the
   STAMP data model using a YANG tree diagram [RFC8340].

module: ietf-stamp
    +--rw stamp
    |  +--rw stamp-session-sender {session-sender}?
    |  |  +--rw sender-enable?   enable   boolean
    |  |  +--rw test-session* [session-id]
    |  |     +--rw session-id                     uint32
    |  |     +--rw test-session-enable?           enable           boolean
    |  |     +--rw number-of-packets?             union
    |  |     +--rw packet-padding-size?           uint32
    |  |     +--rw interval?                      uint32
    |  |     +--rw session-timeout?               uint32
    |  |     +--rw measurement-interval?          uint32
    |  |     +--rw repeat?                        union
    |  |     +--rw repeat-interval?               uint32
    |  |     +--rw dscp-value?                    inet:dscp
    |  |     +--rw test-session-reflector-mode?   session-reflector-mode
    |  |     +--rw sender-ip                      inet:ip-address
    |  |     +--rw sender-udp-port                inet:port-number
    |  |     +--rw reflector-ip                   inet:ip-address
    |  |     +--rw reflector-udp-port?            inet:port-number
    |  |     +--rw sender-timestamp-format?       timestamp-format
    |  |     +--rw security! {stamp-security}?
    |  |     |  +--rw key-chain?   kc:key-chain-ref
    |  |     +--rw first-percentile?              percentile
    |  |     +--rw second-percentile?             percentile
    |  |     +--rw third-percentile?              percentile
    |  +--rw stamp-session-reflector {session-reflector}?
    |     +--rw reflector-enable?       enable       boolean
    |     +--rw ref-wait?               uint32
    |     +--rw reflector-mode-state?   session-reflector-mode
    |     +--rw test-session* [session-id]
    |        +--rw session-id                    uint32
    |        +--rw dscp-handling-mode?           session-dscp-mode
    |        +--rw dscp-value?                   inet:dscp
    |        +--rw sender-ip?                    union
    |        +--rw sender-udp-port?              union
    |        +--rw reflector-ip?                 union
    |        +--rw reflector-udp-port?           inet:port-number
    |        +--rw reflector-timestamp-format?   timestamp-format
    |        +--rw security! {stamp-security}?
    |           +--rw key-chain?   kc:key-chain-ref

                Figure 2: STAMP Configuration Tree Diagram

  module: ietf-stamp
      +--ro stamp-state
         +--ro stamp-session-sender-state {session-sender}?
         |  +--ro test-session-state* [session-id]
         |     +--ro session-id              uint32
         |     +--ro sender-session-state?   enumeration
         |     +--ro current-stats
         |     |  +--ro start-time                    yang:date-and-time
         |     |  +--ro packet-padding-size?          uint32
         |     |  +--ro interval?                     uint32
         |     |  +--ro duplicate-packets?            uint32
         |     |  +--ro reordered-packets?            uint32
         |     |  +--ro sender-ip                     inet:ip-address
         |     |  +--ro sender-udp-port               inet:port-number
         |     |  +--ro reflector-ip                  inet:ip-address
         |     |  +--ro reflector-udp-port?           inet:port-number
         |     |  +--ro sender-timestamp-format?      timestamp-format
         |     |  +--ro reflector-timestamp-format?   timestamp-format
         |     |  +--ro dscp?                         inet:dscp
         |     |  +--ro sent-packets?                 uint32
         |     |  +--ro rcv-packets?                  uint32
         |     |  +--ro sent-packets-error?           uint32
         |     |  +--ro rcv-packets-error?            uint32
         |     |  +--ro last-sent-seq?                uint32
         |     |  +--ro last-rcv-seq?                 uint32
         |     |  +--ro two-way-delay
         |     |  |  +--ro delay
         |     |  |  |  +--ro min?   yang:gauge32
         |     |  |  |  +--ro max?   yang:gauge32
         |     |  |  |  +--ro avg?   yang:gauge32
         |     |  |  +--ro delay-variation
         |     |  |     +--ro min?   uint32
         |     |  |     +--ro max?   uint32
         |     |  |     +--ro avg?   uint32
         |     |  +--ro one-way-delay-far-end
         |     |  |  +--ro delay
         |     |  |  |  +--ro min?   yang:gauge32
         |     |  |  |  +--ro max?   yang:gauge32
         |     |  |  |  +--ro avg?   yang:gauge32
         |     |  |  +--ro delay-variation
         |     |  |     +--ro min?   uint32
         |     |  |     +--ro max?   uint32
         |     |  |     +--ro avg?   uint32
         |     |  +--ro one-way-delay-near-end
         |     |  |  +--ro delay
         |     |  |  |  +--ro min?   yang:gauge32
         |     |  |  |  +--ro max?   yang:gauge32
         |     |  |  |  +--ro avg?   yang:gauge32
         |     |  |  +--ro delay-variation
         |     |  |     +--ro min?   uint32
         |     |  |     +--ro max?   uint32
         |     |  |     +--ro avg?   uint32
         |     |  +--ro low-percentile
         |     |  |  +--ro delay-percentile
         |     |  |  |  +--ro rtt-delay?        percentile
         |     |  |  |  +--ro near-end-delay?   percentile
         |     |  |  |  +--ro far-end-delay?    percentile
         |     |  |  +--ro delay-variation-percentile
         |     |  |     +--ro rtt-delay-variation?        percentile
         |     |  |     +--ro near-end-delay-variation?   percentile
         |     |  |     +--ro far-end-delay-variation?    percentile
         |     |  +--ro mid-percentile
         |     |  |  +--ro delay-percentile
         |     |  |  |  +--ro rtt-delay?        percentile
         |     |  |  |  +--ro near-end-delay?   percentile
         |     |  |  |  +--ro far-end-delay?    percentile
         |     |  |  +--ro delay-variation-percentile
         |     |  |     +--ro rtt-delay-variation?        percentile
         |     |  |     +--ro near-end-delay-variation?   percentile
         |     |  |     +--ro far-end-delay-variation?    percentile
         |     |  +--ro high-percentile
         |     |  |  +--ro delay-percentile
         |     |  |  |  +--ro rtt-delay?        percentile
         |     |  |  |  +--ro near-end-delay?   percentile
         |     |  |  |  +--ro far-end-delay?    percentile
         |     |  |  +--ro delay-variation-percentile
         |     |  |     +--ro rtt-delay-variation?        percentile
         |     |  |     +--ro near-end-delay-variation?   percentile
         |     |  |     +--ro far-end-delay-variation?    percentile
         |     |  +--ro two-way-loss
         |     |  |  +--ro loss-count?         int32
         |     |  |  +--ro loss-ratio?         percentage
         |     |  |  +--ro loss-burst-max?     int32
         |     |  |  +--ro loss-burst-min?     int32
         |     |  |  +--ro loss-burst-count?   int32
         |     |  +--ro one-way-loss-far-end
         |     |  |  +--ro loss-count?         int32
         |     |  |  +--ro loss-ratio?         percentage
         |     |  |  +--ro loss-burst-max?     int32
         |     |  |  +--ro loss-burst-min?     int32
         |     |  |  +--ro loss-burst-count?   int32
         |     |  +--ro one-way-loss-near-end
         |     |  |  +--ro loss-count?         int32
         |     |  |  +--ro loss-ratio?         percentage
         |     |  |  +--ro loss-burst-max?     int32
         |     |  |  +--ro loss-burst-min?     int32
         |     |  |  +--ro loss-burst-count?   int32
         |     +--ro history-stats* [id]     |  +--ro id                            uint32 sender-ip                     inet:ip-address
         |     |  +--ro end-time                      yang:date-and-time sender-udp-port               inet:port-number
         |     |  +--ro number-of-packets?            uint32 reflector-ip                  inet:ip-address
         |     |  +--ro packet-padding-size?          uint32 reflector-udp-port?           inet:port-number
         |     |  +--ro interval? sent-packets?                 uint32
         |     |  +--ro duplicate-packets? rcv-packets?                  uint32
         |     |  +--ro reordered-packets? sent-packets-error?           uint32
         |     |  +--ro loss-packets? rcv-packets-error?            uint32
         |        +--ro sender-ip                     inet:ip-address     |  +--ro sender-udp-port               inet:port-number last-sent-seq?                uint32
         |        +--ro reflector-ip                  inet:ip-address     |  +--ro reflector-udp-port?           inet:port-number last-rcv-seq?                 uint32
         |     +--ro sender-timestamp-format?      timestamp-format history-stats* [session-id]
         |        +--ro reflector-timestamp-format?   timestamp-format session-id                    uint32
         |        +--ro dscp?                         inet:dscp end-time                      yang:date-and-time
         |        +--ro sent-packets? packet-padding-size?          uint32
         |        +--ro rcv-packets? interval?                     uint32
         |        +--ro sent-packets-error? duplicate-packets?            uint32
         |        +--ro rcv-packets-error? reordered-packets?            uint32
         |        +--ro last-sent-seq?                uint32 sender-timestamp-format?      timestamp-format
         |        +--ro last-rcv-seq?                 uint32 reflector-timestamp-format?   timestamp-format
         |        +--ro dscp?                         inet:dscp
         |        +--ro two-way-delay
         |        |  +--ro delay
         |        |  |  +--ro min?   yang:gauge32
         |        |  |  +--ro max?   yang:gauge32
         |        |  |  +--ro avg?   yang:gauge32
         |        |  +--ro delay-variation
         |        |     +--ro min?   uint32
         |        |     +--ro max?   uint32
         |        |     +--ro avg?   uint32
         |        +--ro one-way-delay-far-end
         |        |  +--ro delay
         |        |  |  +--ro min?   yang:gauge32
         |        |  |  +--ro max?   yang:gauge32
         |        |  |  +--ro avg?   yang:gauge32
         |        |  +--ro delay-variation
         |        |     +--ro min?   uint32
         |        |     +--ro max?   uint32
         |        |     +--ro avg?   uint32
         |        +--ro one-way-delay-near-end
         |        |  +--ro delay
         |        |  |  +--ro min?   yang:gauge32
         |        |  |  +--ro max?   yang:gauge32
         |        |  |  +--ro avg?   yang:gauge32
         |        |  +--ro delay-variation
         |        |     +--ro min?   uint32
         |        |     +--ro max?   uint32
         |        |     +--ro avg?   uint32
         |        +--ro stamp-session-refl-state {session-reflector}? low-percentile
         |        |  +--ro reflector-light-admin-status    boolean delay-percentile
         |        |  |  +--ro test-session-state* [session-id] rtt-delay?        percentile
         |        |  |  +--ro session-id                    uint32 near-end-delay?   percentile
         |        |  |  +--ro far-end-delay?    percentile
         |        |  +--ro delay-variation-percentile
         |        |     +--ro rtt-delay-variation?        percentile
         |        |     +--ro near-end-delay-variation?   percentile
         |        |     +--ro far-end-delay-variation?    percentile
         |        +--ro mid-percentile
         |        |  +--ro delay-percentile
         |        |  |  +--ro rtt-delay?        percentile
         |        |  |  +--ro near-end-delay?   percentile
         |        |  |  +--ro far-end-delay?    percentile
         |        |  +--ro delay-variation-percentile
         |        |     +--ro rtt-delay-variation?        percentile
         |        |     +--ro near-end-delay-variation?   percentile
         |        |     +--ro far-end-delay-variation?    percentile
         |        +--ro high-percentile
         |        |  +--ro delay-percentile
         |        |  |  +--ro rtt-delay?        percentile
         |        |  |  +--ro near-end-delay?   percentile
         |        |  |  +--ro far-end-delay?    percentile
         |        |  +--ro delay-variation-percentile
         |        |     +--ro rtt-delay-variation?        percentile
         |        |     +--ro near-end-delay-variation?   percentile
         |        |     +--ro far-end-delay-variation?    percentile
         |        +--ro two-way-loss
         |        |  +--ro loss-count?         int32
         |        |  +--ro loss-ratio?         percentage
         |        |  +--ro loss-burst-max?     int32
         |        |  +--ro loss-burst-min?     int32
         |        |  +--ro loss-burst-count?   int32
         |        +--ro one-way-loss-far-end
         |        |  +--ro loss-count?         int32
         |        |  +--ro loss-ratio?         percentage
         |        |  +--ro loss-burst-max?     int32
         |        |  +--ro loss-burst-min?     int32
         |        |  +--ro loss-burst-count?   int32
         |        +--ro one-way-loss-near-end
         |        |  +--ro loss-count?         int32
         |        |  +--ro loss-ratio?         percentage
         |        |  +--ro loss-burst-max?     int32
         |        |  +--ro loss-burst-min?     int32
         |        |  +--ro loss-burst-count?   int32
         |        +--ro sender-ip                     inet:ip-address
         |        +--ro sender-udp-port               inet:port-number
         |        +--ro reflector-ip                  inet:ip-address
         |        +--ro reflector-udp-port?           inet:port-number
         |        +--ro sent-packets?                 uint32
         |        +--ro rcv-packets?                  uint32
         |        +--ro sent-packets-error?           uint32
         |        +--ro rcv-packets-error?            uint32
         |        +--ro last-sent-seq?                uint32
         |        +--ro last-rcv-seq?                 uint32
         +--ro stamp-session-refl-state {session-reflector}?
            +--ro reflector-light-admin-status?   boolean
            +--ro test-session-state* [session-id]
               +--ro session-id                    uint32
               +--ro reflector-timestamp-format?   timestamp-format
               +--ro sender-ip                     inet:ip-address
               +--ro sender-udp-port               inet:port-number
               +--ro reflector-ip                  inet:ip-address
               +--ro reflector-udp-port?           inet:port-number

                    Figure
               +--ro sent-packets?                 uint32
               +--ro rcv-packets?                  uint32
               +--ro sent-packets-error?           uint32
               +--ro rcv-packets-error?            uint32
               +--ro last-sent-seq?                uint32
               +--ro last-rcv-seq?                 uint32

                    Figure 3: STAMP State Tree Diagram

     rpcs:
       +---x stamp-sender-start
       |  +---w input
       |     +---w session-id    uint32
       +---x stamp-sender-stop
          +---w input
             +---w session-id    uint32

                     Figure 4: STAMP RPC Tree Diagram

3.2.  YANG Module

   <CODE BEGINS> file "ietf-stamp@2018-03-01.yang" "ietf-stamp@2018-09-07.yang"

   module ietf-stamp {
     yang-version 1.1;
     namespace "urn:ietf:params:xml:ns:yang:ietf-stamp";
     //namespace need to be assigned by IANA
     prefix "ietf-stamp";

   import ietf-inet-types {
   prefix inet;
   reference "RFC 6991"; 6991: Common YANG Types.";
   }
   import ietf-yang-types {
        prefix yang;
   reference "RFC 6991"; 6991: Common YANG Types.";
   }
   import ietf-key-chain {
   prefix kc;
   reference "RFC 8177"; 8177: YANG Data Model for Key Chains.";
   }
     organization
       "IETF IPPM (IP Performance Metrics) Working Group";

     contact
     "draft-ietf-ippm-stamp-yang@tools.ietf.org";
       "WG Web: http://tools.ietf.org/wg/ippm/
        WG List: ippm@ietf.org

        Editor: Greg Mirsky
             gregimirsky@gmail.com
        Editor: Xiao Min
             xiao.min2@zte.com.cn
        Editor: Wei S Luo
             wei.s.luo@ericsson.com";

     description "STAMP Data Model";
       "This YANG module specifies a vendor-independent model
        for the Simple Two-way Active Measurement Protocol (STAMP).

        The data model covers two STAMP logical entities -
        Session-Sender and Session-Reflector; characteristics
        of the STAMP test session, as well as measured and
        calculated performance metrics.

           Copyright (c) 2018 IETF Trust and the persons identified as
           the document authors.  All rights reserved.
           Redistribution and use in source and binary forms, with or
           without modification, is permitted pursuant to, and subject
           to the license terms contained in, the Simplified BSD
           License set forth in Section 4.c of the IETF Trust's Legal
           Provisions Relating to IETF Documents
           (http://trustee.ietf.org/license-info).

           This version of this YANG module is part of RFC XXXX; see
           the RFC itself for full legal notices.";

     revision "2018-03-01" "2018-09-07" {
       description
     "00 version.
         "Initial Revision. Base STAMP specification is covered";
       reference "";
         "RFC XXXX: STAMP YANG Data Model.";
     }

   /*
    * Feature definitions. Typedefs
    */
     feature session-sender {
     description
     "This feature relates to the device functions as the
     STAMP Session-Sender";
   }

   feature session-reflector {
     description
     "This feature relates to the device functions as the
     STAMP Session-Reflector";
   }

   feature stamp-security {
     description "Secure STAMP supported";
   }

   typedef enable {
      type boolean;
      description "enable";
   }
   typedef session-reflector-mode {
     type enumeration {
       enum stateful {
         description
           "When the Session-Reflector is stateful,
           i.e. is aware of STAMP-Test session state.";
         }
         enum stateless {
           description
             "When the Session-Reflector is stateless,
             i.e. is not aware of the state of
             STAMP-Test session.";
         }
       }
       description "State of the Session-Reflector";
   }

   typedef session-dscp-mode {
     type enumeration {
       enum copy-received-value {
         description
           "Use DSCP value copied from received
           STAMP test packet of the test session.";
       }
       enum use-configured-value {
         description
           "Use DSCP value configured for this
           test session on the Session-Reflector.";
       }
     }
     description
       "DSCP handling mode by Session-Reflector.";
   }

   typedef timestamp-format {
     type enumeration {
       enum ntp-format {
         description
           "NTP 64 bit format of a timestamp";
       }
       enum ptp-format {
         description
           "PTPv2 truncated format of a timestamp";
       }
     }
     description
       "Timestamp format used by Session-Sender
       or Session-Reflector.";
   }

   typedef percentage {
     type decimal64 {
       fraction-digits 5;
     }
     description "Percentage";
   }

   typedef percentile {
     type decimal64 {
       fraction-digits 2;
     }
     description
       "Percentile is a measure used in statistics
       indicating the value below which a given
       percentage of observations in a group of
       observations fall.";
   }

   /*
    * Feature definitions.
    */
   feature session-sender {
     description
       "This feature relates to the device functions as the
       STAMP Session-Sender";
   }

   feature session-reflector {
     description
       "This feature relates to the device functions as the
       STAMP Session-Reflector";
   }

   feature stamp-security {
     description "Secure STAMP supported";
   }

   /*
    * Reusable node groups
    */

   grouping maintenance-statistics {
     description "Maintenance statistics grouping";
     leaf sent-packets {
       type uint32;
       description "Packets sent";
     }
     leaf rcv-packets {
       type uint32;
       description "Packets received";
     }
     leaf sent-packets-error {
       type uint32;
       description "Packets sent error";
     }
     leaf rcv-packets-error {
       type uint32;
       description "Packets received error";
     }
     leaf last-sent-seq {
       type uint32;
       description "Last sent sequence number";
     }
     leaf last-rcv-seq {
       type uint32;
       description "Last received sequence number";
     }
   }

   grouping stamp-session-percentile test-session-statistics {
     description "Percentile grouping";
       "Performance metrics calculated for
       a STAMP test session.";

     leaf first-percentile packet-padding-size {
       type percentile;
      default 95.00; uint32;
       description
      "First percentile
         "Size of the Packet Padding. Suggested to report";
   }
   leaf second-percentile {
      type percentile;
      default 99.00;
      description
      "Second percentile to report";
   }
   leaf third-percentile {
      type percentile;
      default 99.90;
      description
      "Third percentile run
         Path MTU Discovery to report";
   } avoid packet fragmentation
         in IPv4 and packet blackholing in IPv6";
     }

   grouping delay-statistics {
     description "Delay statistics grouping";
     container delay {
       description "Packets transmitted delay";

     leaf min interval  {
       type yang:gauge32; uint32;
       units microseconds;
       description
                   "Min
               "Time interval between transmission of Packets transmitted delay"; two
         consecutive packets in the test session";
       }

       leaf max duplicate-packets  {
         type yang:gauge32;
                    units microseconds; uint32;
         description
                    "Max of Packets transmitted delay"; "Duplicate packets";
       }

       leaf avg reordered-packets  {
         type yang:gauge32;
                    units microseconds; uint32;
         description
                    "Avg of Packets transmitted delay";
                 } "Reordered packets";
       }

         container delay-variation {
                 description
                 "Packets transmitted delay variation";

       leaf min sender-timestamp-format {
         type uint32;
                   units microseconds; timestamp-format;
         description
                   "Min of Packets transmitted
                   delay variation"; "Sender Timestamp format";
       }

       leaf max reflector-timestamp-format {
         type uint32;
                   units microseconds; timestamp-format;
         description
                   "Max of Packets transmitted
                   delay variation"; "Reflector Timestamp format";
       }

       leaf avg dscp {
         type uint32;
                   units microseconds; inet:dscp;
         description
                   "Avg
           "The DSCP value that was placed in the header of Packets transmitted
                   delay variation";
                 }
          }
           STAMP UDP test packets by the Session-Sender.";
       }
     grouping time-percentile-report

       container two-way-delay {
         description "Delay percentile report grouping";
           "two way delay result of the test session";
         uses delay-statistics;
       }

       container delay-percentile one-way-delay-far-end {
         description
                "Report round-trip, near- and
           "one way delay far-end delay";
                leaf rtt-delay {
                        type percentile;
                        description
                        "Percentile of round-trip delay"; the test session";
         uses delay-statistics;
       }
                leaf near-end-delay

       container one-way-delay-near-end {
                        type percentile;
         description
                        "Percentile of
           "one way delay near-end delay"; of the test session";
         uses delay-statistics;
       }
                leaf far-end-delay

           container low-percentile {
             when "/stamp/stamp-session-sender/"
               +"test-session[session-id]/"
                           +"first-percentile != '0.00'" {
                        type percentile;
                   description
                        "Percentile of far-end delay";
                 "Only valid if the
                 the first-percentile is not NULL";
             }
             description
               "Low percentile report";
             uses time-percentile-report;
           }

                container delay-variation-percentile mid-percentile {
                description
                "Report round-trip, near- and far-end delay variation";
                leaf rtt-delay-variation
             when "/stamp/stamp-session-sender/"
               +"test-session[session-id]/"
               +"second-percentile != '0.00'" {
                        type percentile;
               description
                        "Percentile of round-trip delay-variation";
                 "Only valid if the
                 the first-percentile is not NULL";
             }
                leaf near-end-delay-variation {
                        type percentile;
             description
                        "Percentile of near-end delay variation";
               "Mid percentile report";
             uses time-percentile-report;
           }
                leaf far-end-delay-variation

           container high-percentile {
             when "/stamp/stamp-session-sender/"
               +"test-session[session-id]/"
               +"third-percentile != '0.00'" {
                        type percentile;
               description
                        "Percentile of far-end delay-variation";
                }
        }
                 "Only valid if the
                 the first-percentile is not NULL";
             }

     grouping packet-loss-statistics {
             description
        "Grouping for Packet Loss statistics";
        leaf loss-count
               "High percentile report";
             uses time-percentile-report;
           }

           container two-way-loss {
                type int32;
             description
                "Number
               "two way loss count and ratio result of lost packets
                during
               the test interval."; session";
             uses packet-loss-statistics;
           }
        leaf loss-ratio

           container one-way-loss-far-end {
             when "/stamp/stamp-session-sender/"
               +"test-session[session-id]/"
               +"test-session-reflector-mode = 'stateful'" {
                type percentage;
               description
                "Ratio of packets lost to packets
                sent during
                 "One-way statistic is only valid if the test interval.";
                 session-reflector is in stateful mode.";
             }
        leaf loss-burst-max {
                type int32;
             description
                "Maximum number
               "one way loss count and ratio far-end of consecutively
                lost packets during
               the test interval."; session";

             uses packet-loss-statistics;
           }
        leaf loss-burst-min

           container one-way-loss-near-end {
             when "/stamp/stamp-session-sender/"
               +"test-session[session-id]/"
               +"test-session-reflector-mode = 'stateful'" {
                type int32;
               description
                "Minimum number of consecutively
                lost packets during
                 "One-way statistic is only valid if the test interval.";
                 session-reflector is in stateful mode.";
             }
                leaf loss-burst-count {
                type int32;
             description
                "Number of occasions with packet
               "one way loss during count and ratio near-end of
               the test interval."; session";
             uses packet-loss-statistics;
           }
           uses session-parameters;
           uses maintenance-statistics;
   }

   grouping session-parameters stamp-session-percentile {
     description
     "Parameters common among
     Session-Sender and Session-Reflector"; "Percentile grouping";
     leaf sender-ip first-percentile {
       type inet:ip-address;
       mandatory true; percentile;
       default 95.00;
       description "Sender IP address";
         "First percentile to report";
     }
     leaf sender-udp-port second-percentile {
       type inet:port-number {
         range "49152..65535";
       }
       mandatory true;
       description "Sender UDP port number";
     }
     leaf reflector-ip {
       type inet:ip-address;
       mandatory true; percentile;
       default 99.00;
       description "Reflector IP address";
         "Second percentile to report";
     }
     leaf reflector-udp-port third-percentile {
       type inet:port-number{
         range "862 | 49152..65535";
       } percentile;
       default 862; 99.90;
       description "Reflector UDP port number";
         "Third percentile to report";
     }
   }

   grouping session-security delay-statistics {
     description
      "Grouping for STAMP security and related parameters"; "Delay statistics grouping";
     container security delay {
         if-feature stamp-security;
         presence "Enables secure STAMP";
     description
         "Parameters for STAMP authentication or encryption"; "Packets transmitted delay";
       leaf key-chain min {
         type kc:key-chain-ref; yang:gauge32;
         units microseconds;
         description "Name
           "Min of key-chain";
         }
      } Packets transmitted delay";
       }

   /* Configuration Data */
   container stamp {
     description
     "Top level container for stamp configuration";

    container stamp-session-sender
       leaf max {
       if-feature session-sender;
         type yang:gauge32;
         units microseconds;
         description "stamp Session-Sender container";
           "Max of Packets transmitted delay";
       }
       leaf sender-enable avg {
       type enable;
         default "true"; yang:gauge32;
       units microseconds;
       description
         "Whether this network element is enabled to
         act as STAMP Session-Sender";
         "Avg of Packets transmitted delay";
       }

       list test-session
     }

     container delay-variation {
         key "session-id";
               unique "sender-ip sender-udp-port reflector-ip"
         +" reflector-udp-port dscp-value";
       description
         "This structure is a container of test session
         managed objects";
         "Packets transmitted delay variation";
       leaf session-id min {
         type uint32;
         units microseconds;
         description "Session ID";
           "Min of Packets transmitted
           delay variation";
       }
       leaf test-session-enable max {
         type enable;
           default "true"; uint32;
         units microseconds;
         description
           "Whether this STAMP Test session is enabled";
           "Max of Packets transmitted
           delay variation";
       }
       leaf number-of-packets {
           type union avg {
         type uint32 {
                        range 1..4294967294 { uint32;
         units microseconds;
                   description
                                "The overall number
           "Avg of UDP test packet
                                to be Packets transmitted by the sender for this
                                test session";
           delay variation";
       }
     }
                type enumeration
   }

   grouping time-percentile-report {
                        enum forever
     description "Delay percentile report grouping";
     container delay-percentile {
       description
                                "Indicates that the test session SHALL
                                be run *forever*.";
                        }
                }
           }
           default 10;
         "Report round-trip, near- and far-end delay";
       leaf rtt-delay {
         type percentile;
         description
           "This value determines if the STAMP-Test session is
              bound by number
           "Percentile of test packets or not."; round-trip delay";
       }
       leaf packet-padding-size near-end-delay {
         type uint32;
           default 27; percentile;
           description
           "Size
             "Percentile of the Packet Padding. Suggested to run
           Path MTU Discovery to avoid packet fragmentation in
           IPv4 and packet blackholing in IPv6"; near-end delay";
       }
       leaf interval far-end-delay {
         type uint32;
           units microseconds; percentile;
         description
           "Time interval between transmission
           "Percentile of two
           consecutive packets in the test session in
           microseconds"; far-end delay";
       }

            leaf session-timeout
     }

     container delay-variation-percentile {
              when "../number-of-packets != 'forever'"
       description
         "Report round-trip, near- and far-end delay variation";
       leaf rtt-delay-variation {
         type percentile;
         description
                "Test session timeout only valid if the
                test mode is periodic.";
           "Percentile of round-trip delay-variation";
       }
       leaf near-end-delay-variation {
         type uint32;
           units "seconds";
           default 900; percentile;
         description
           "The timeout value for the Session-Sender to
           collect outstanding reflected packets.";
           "Percentile of near-end delay variation";
       }
       leaf measurement-interval far-end-delay-variation {
           when "../number-of-packets = 'forever'"
         type percentile;
         description
           "Percentile of far-end delay-variation";
       }
     }
   }

   grouping packet-loss-statistics {
     description
                "Valid only when
       "Grouping for Packet Loss statistics";
     leaf loss-count {
       type int32;
       description
         "Number of lost packets
         during the test to run forever,
                i.e. continuously."; interval.";

     }
     leaf loss-ratio {
       type uint32;
           units "seconds";
           default 60; percentage;
       description
           "Interval
         "Ratio of packets lost to calculate performance metric when packets
         sent during the test mode is 'continuous'."; interval.";
     }
     leaf repeat {
              type union loss-burst-max {
       type uint32 {
                        range 0..4294967294; int32;
       description
         "Maximum number of consecutively
         lost packets during the test interval.";
     }
                type enumeration {
                        enum forever
     leaf loss-burst-min {
       type int32;
       description
                                "Indicates that
         "Minimum number of consecutively
                 lost packets during the test session SHALL
                                be repeated *forever* using the
                                information in repeat-interval
                                parameter, and SHALL NOT decrement
                                the value.";
                        }
                } interval.";
     }
              default 0;
     leaf loss-burst-count {
       type int32;
       description
              "This value determines if the STAMP-Test session must
              be repeated. When a test session has completed, the
              repeat parameter is checked. The default value
       "Number of 0 indicates that the session MUST NOT be repeated.
              If the repeat value is 1 through 4,294,967,294
              then occasions with packet
       loss during the test session SHALL be repeated using the
              information in repeat-interval parameter.
              The implementation MUST decrement the value of repeat
              after determining a repeated session is expected."; interval.";
     }
   }

   grouping session-parameters {
     description
       "Parameters Session-Sender";
     leaf repeat-interval sender-ip {
                when "../repeat != '0'";
       type uint32;
                units seconds;
                default 0; inet:ip-address;
       mandatory true;
       description
                "This parameter determines the timing of repeated
                STAMP-Test sessions when repeat is more than 0."; "Sender IP address";
     }
     leaf dscp-value sender-udp-port {
       type inet:dscp;
              default 0; inet:port-number {
         range "49152..65535";
       }
       mandatory true;
       description
              "DSCP value to be set in the test packet."; "Sender UDP port number";
     }
       leaf test-session-reflector-mode reflector-ip {
       type session-reflector-mode;
                 default "stateless"; inet:ip-address;
       mandatory true;
       description
                 "The mode of STAMP-Reflector for the test session."; "Reflector IP address";
     }

         uses session-parameters;
     leaf sender-timestamp-format reflector-udp-port {
       type timestamp-format; inet:port-number{
         range "862 | 49152..65535";
       }
       default ntp-format; 862;
       description "Sender Timestamp format";
     }
         uses session-security;
         uses stamp-session-percentile; "Reflector UDP port number";
     }
   }

   grouping session-security {
     description
       "Grouping for STAMP security and related parameters";
     container stamp-session-reflector security {
       if-feature session-reflector; stamp-security;
       presence "Enables secure STAMP";
       description
       "stamp Session-Reflector container";
         "Parameters for STAMP authentication or encryption";
       leaf reflector-enable key-chain {
         type enable;
           default "true"; kc:key-chain-ref;
         description
           "Whether this network element is enabled to
           act as stamp Session-Reflector"; "Name of key-chain";
       }

         leaf ref-wait {
         type uint32 {
           range 1..604800;
     }
         units seconds;
         default 900;
         description
         "REFWAIT(STAMP test session timeout in seconds),
         the default value is 900";
   }

   /*
    * Configuration Data
    */
   container stamp {
     description
       "Top level container for STAMP configuration";

     container stamp-session-sender {
       if-feature session-sender;
       description "STAMP Session-Sender container";

       leaf reflector-mode-state sender-enable {
         type session-reflector-mode; boolean;
         default stateless; "true";
         description
         "The state of the mode of the stamp
         Session-Reflector";
           "Whether this network element is enabled to
           act as STAMP Session-Sender";
       }

       list test-session {
         key "session-id";
         unique "sender-ip sender-udp-port reflector-ip"
           +" reflector-udp-port"; reflector-udp-port dscp-value";
         description
           "This structure is a container of test session
           managed objects";

         leaf session-id {
           type uint32;
           description "Session ID";
         }

         leaf dscp-handling-mode {
          type session-dscp-mode;
          default copy-received-value;
          description
          "Session-Reflector handling of DSCP:
                 - use value copied from received STAMP-Test packet;
                 - use value explicitly configured";
           }

           leaf dscp-value test-session-enable {
             when "../dscp-handling-mode = 'use-configured-value'";
           type inet:dscp; boolean;
           default 0; "true";
           description
             "DSCP value to be set in the reflected packet
                if dscp-handling-mode
             "Whether this STAMP Test session is set to use-configured-value."; enabled";
         }

         leaf sender-ip number-of-packets {
           type union {
             type inet:ip-address;
                type enumeration uint32 {
                        enum any
               range 1..4294967294 {
               description
                                "Indicates that the Session-Reflector
                                accepts STAMP test packets from
                                any Session-Sender";
                        }

                }
              }
              default any;
              description
              "This value determines whether specific
              IPv4/IPv6 address
                 "The overall number of UDP test packet
                 to be transmitted by the Session-Sender
              or the wildcard, i.e. any address"; sender for this
                 test session";
               }

     leaf sender-udp-port {
        type union {
          type inet:port-number {
          range "49152..65535";
             }
             type enumeration {
               enum any forever {
                 description
                   "Indicates that the Session-Reflector
              accepts STAMP test packets from
              any Session-Sender"; session SHALL
                   be run *forever*.";
               }
             }
           }
           default any; 10;
           description
             "This value determines whether specific
              port if the STAMP-Test session is
             bound by number of the Session-Sender test packets or the wildcard, i.e. any"; not.";
         }

         leaf reflector-ip {
              type union packet-padding-size {
           type inet:ip-address;
                type enumeration {
                        enum any { uint32;
           default 27;
           description
                                "Indicates that the Session-Reflector
                                accepts STAMP test packets on
                                any of its interfaces";
                        }
                }
              }
              default any;
              description
              "This value determines whether specific
              IPv4/IPv6 address of the Session-Reflector
              or the wildcard, i.e. any address";
     }
     leaf reflector-udp-port {
       type inet:port-number{
         range "862 | 49152..65535";
       }
       default 862;
       description "Reflector UDP port number";
     }
     leaf reflector-timestamp-format {
       type timestamp-format;
       default ntp-format;
       description "Reflector Timestamp format";
     }
        uses session-security;
       }
     }
   }

 /* Operational state data nodes */
 container stamp-state {
   config false;
   description
   "Top level container for stamp state data";

   container stamp-session-sender-state {
     if-feature session-sender;
     description
     "Session-Sender container for state data";
     list test-session-state{
       key "session-id";
       description
       "This structure is a container of test session
       managed objects";

       leaf session-id {
         type uint32;
         description "Session ID";
       }

       leaf sender-session-state {
         type enumeration {
           enum active {
             description "Test session is active";
           }
           enum ready {
             description "Test session is idle";
           }
         }
         description
         "State of the particular stamp test
         session at the sender";
       }

       container current-stats {
         description
         "This container contains the results for the current
          Measurement Interval in a Measurement session ";
          leaf start-time {
            type yang:date-and-time;
            mandatory true;
            description
            "The time that the current Measurement Interval started";
          }

          leaf packet-padding-size {
            type uint32;
            default 27;
            description
            "Size
             "Size of the Packet Padding. Suggested to run
             Path MTU Discovery to avoid packet fragmentation in
             IPv4 and packet blackholing in IPv6";
          }

         leaf interval  {
           type uint32;
           units microseconds;
           description
             "Time interval between transmission of two
             consecutive packets in the test session"; session in
             microseconds";
         }

         leaf duplicate-packets session-timeout {
           when "../number-of-packets != 'forever'" {
            type uint32;
             description "Duplicate packets";
               "Test session timeout only valid if the
               test mode is periodic.";
           }
          leaf reordered-packets  {
           type uint32;
           units "seconds";
           default 900;
           description "Reordered packets";
             "The timeout value for the Session-Sender to
             collect outstanding reflected packets.";
         }

          uses session-parameters;

         leaf sender-timestamp-format measurement-interval {
           when "../number-of-packets = 'forever'" {
       type timestamp-format;
       default ntp-format;
             description "Sender Timestamp format";
               "Valid only when the test to run forever,
               i.e. continuously.";
           }
     leaf reflector-timestamp-format {
           type timestamp-format; uint32;
           units "seconds";
           default ntp-format; 60;
           description "Reflector Timestamp format";
             "Interval to calculate performance metric when
             the test mode is 'continuous'.";
         }

         leaf dscp repeat {
           type inet:dscp; union {
             type uint32 {
               range 0..4294967294;
             }
             type enumeration {
               enum forever {
                 description
            "The DSCP value
                   "Indicates that was placed in the header of
            STAMP UDP test packets by session SHALL
                   be repeated *forever* using the Session-Sender.";
          }
          uses maintenance-statistics;

          container two-way-delay {
            description
            "two way delay result of
                   information in repeat-interval
                   parameter, and SHALL NOT decrement
                   the test session";
            uses delay-statistics; value.";
               }

          container one-way-delay-far-end {
             }
           }
           default 0;
           description
            "one way delay far-end of
             "This value determines if the STAMP-Test session must
             be repeated. When a test session";
            uses delay-statistics;
          }

          container one-way-delay-near-end {
            description
            "one way delay near-end session has completed, the
             repeat parameter is checked. The default value
             of 0 indicates that the session MUST NOT be repeated.
             If the repeat value is 1 through 4,294,967,294
             then the test session";
            uses delay-statistics;
          }

          container low-percentile {
                when "/stamp/stamp-session-sender/"
                +"test-session[session-id]/"
                +"first-percentile != '0.00'" {
                        description
                        "Only valid if session SHALL be repeated using the
             information in repeat-interval parameter.
             The implementation MUST decrement the first-percentile value of repeat
             after determining a repeated session is not NULL";
                }
                description
                "Low percentile report";
                uses time-percentile-report; expected.";
         }

          container mid-percentile

         leaf repeat-interval {
           when "/stamp/stamp-session-sender/"
                +"test-session[session-id]/"
                +"second-percentile "../repeat != '0.00'" { '0'";
           type uint32;
           units seconds;
           default 0;
           description
                        "Only valid if the
             "This parameter determines the first-percentile timing of repeated
             STAMP-Test sessions when repeat is not NULL"; more than 0.";
         }

         leaf dscp-value {
           type inet:dscp;
           default 0;
           description
                "Mid percentile report";
                uses time-percentile-report;
             "DSCP value to be set in the test packet.";
         }

          container high-percentile {
                when "/stamp/stamp-session-sender/"
                +"test-session[session-id]/"
                +"third-percentile != '0.00'"

         leaf test-session-reflector-mode {
           type session-reflector-mode;
           default "stateless";
           description
                        "Only valid if the
             "The mode of STAMP-Reflector for the first-percentile is not NULL"; test session.";
         }
                description
                "High percentile report";

         uses time-percentile-report;
          }

          container two-way-loss session-parameters;
         leaf sender-timestamp-format {
           type timestamp-format;
           default ntp-format;
           description
            "two way loss count and ratio result of
            the test session"; "Sender Timestamp format";
         }
         uses packet-loss-statistics; session-security;
         uses stamp-session-percentile;
       }
     }

     container one-way-loss-far-end stamp-session-reflector {
            when "/stamp/stamp-session-sender/"
            +"test-session[session-id]/"
            +"test-session-reflector-mode = 'stateful'"
       if-feature session-reflector;
       description
         "STAMP Session-Reflector container";
       leaf reflector-enable {
         type boolean;
         default "true";
         description
                "One-way statistic
           "Whether this network element is only valid if enabled to
           act as STAMP Session-Reflector";
       }

       leaf ref-wait {
         type uint32 {
           range 1..604800;
         }
         units seconds;
         default 900;
             description
           "REFWAIT(STAMP test session timeout in seconds),
           the
                session-reflector default value is in stateful mode."; 900";
       }

       leaf reflector-mode-state {
         type session-reflector-mode;
               default stateless;
         description
            "one way loss count and ratio far-end
           "The state of the test session";
            uses packet-loss-statistics; mode of the STAMP
           Session-Reflector";
       }

       list test-session {
         key "session-id";
         unique "sender-ip sender-udp-port reflector-ip"
         +" reflector-udp-port";
         description
           "This structure is a container one-way-loss-near-end of test session
           managed objects";

         leaf session-id {
           type uint32;
           description "Session ID";
         }
         leaf dscp-handling-mode {
           type session-dscp-mode;
           default copy-received-value;
           description
             "Session-Reflector handling of DSCP:
             - use value copied from received STAMP-Test packet;
             - use value explicitly configured";
         }

         leaf dscp-value {
           when "/stamp/stamp-session-sender/"
            +"test-session[session-id]/"
            +"test-session-reflector-mode "../dscp-handling-mode = 'stateful'" { 'use-configured-value'";
           type inet:dscp;
           default 0;
           description
                "One-way statistic is only valid if
           "DSCP value to be set in the
                session-reflector reflected packet
           if dscp-handling-mode is in stateful mode."; set to use-configured-value.";
         }

         leaf sender-ip {
           type union {
             type inet:ip-address;
             type enumeration {
               enum any {
                 description
            "one way loss count and ratio near-end of
                   "Indicates that the Session-Reflector
                   accepts STAMP test session";
            uses packet-loss-statistics; packets from
                   any Session-Sender";
               }
             }

       list history-stats {
         key id;
           }
           default any;
           description
             "This container contains value determines whether specific
             IPv4/IPv6 address of the results for Session-Sender
             or the history
          Measurement Interval in a Measurement session "; wildcard, i.e. any address";
         }

         leaf id sender-udp-port {
           type uint32; union {
             type inet:port-number {
               range "49152..65535";
             }
             type enumeration {
               enum any {
                 description
            "The identifier for
                   "Indicates that the Measurement Interval
            within this session"; Session-Reflector
                   accepts STAMP test packets from
                   any Session-Sender";

               }
             }
           }
           default any;
           description
             "This value determines whether specific
             port number of the Session-Sender
             or the wildcard, i.e. any";
         }

         leaf end-time reflector-ip {
           type yang:date-and-time;
            mandatory true; union {
             type inet:ip-address;
             type enumeration {
               enum any {
                 description
            "The time
                   "Indicates that the Measurement Interval ended"; Session-Reflector
                   accepts STAMP test packets on
                   any of its interfaces";
               }
          leaf number-of-packets {
            type uint32;
             }
           }
           default any;
           description
            "The overall number
             "This value determines whether specific
             IPv4/IPv6 address of UDP test packets to be
            transmitted by the sender for this test session"; Session-Reflector
             or the wildcard, i.e. any address";
         }

         leaf packet-padding-size reflector-udp-port {
           type uint32; inet:port-number{
             range "862 | 49152..65535";
           }
           default 27; 862;
           description
            "Size of the Packet Padding. Suggested to run
            Path MTU Discovery to avoid packet fragmentation
            in IPv4 and packet blackholing in IPv6"; "Reflector UDP port number";
         }

         leaf interval reflector-timestamp-format {
           type uint32;
            units microseconds; timestamp-format;
           default ntp-format;
           description
           "Time interval between transmission "Reflector Timestamp format";
         }
         uses session-security;
       }
     }
   }

    /*
    * Operational state data nodes
    */
   container stamp-state {
     config false;
     description
       "Top level container for STAMP state data";

     container stamp-session-sender-state {
       if-feature session-sender;
       description
         "Session-Sender container for state data";
       list test-session-state{
         key "session-id";
         description
           "This structure is a container of two
           consecutive packets in the test session";
          } session
           managed objects";

         leaf duplicate-packets session-id {
           type uint32;
           description "Duplicate packets"; "Session ID";
         }

         leaf reordered-packets sender-session-state {
           type uint32; enumeration {
             enum active {
               description "Reordered packets"; "Test session is active";
             }
          leaf loss-packets
             enum ready {
            type uint32;
               description "Loss packets"; "Test session is idle";
             }
           }

          uses session-parameters;
      leaf sender-timestamp-format {
       type timestamp-format;
       default ntp-format;
           description "Sender Timestamp format";
             "State of the particular STAMP test
             session at the sender";
         }
     leaf reflector-timestamp-format

         container current-stats {
       type timestamp-format;
       default ntp-format;
           description "Reflector Timestamp format";
     }
             "This container contains the results for the current
             Measurement Interval in a Measurement session ";
           leaf dscp start-time {
             type inet:dscp; yang:date-and-time;
             mandatory true;
             description
               "The DSCP value time that was placed in the header of
            STAMP UDP test packets by the Session-Sender."; current Measurement Interval started";
           }

           uses maintenance-statistics;

          container two-way-delay{
            description
            "two way delay result of the test session";
            uses delay-statistics; test-session-statistics;

         }

         list history-stats {
           key session-id;
           description
             "This container one-way-delay-far-end{ contains the results for the history
             Measurement Interval in a Measurement session ";
           leaf session-id {
             type uint32;
             description
            "one way delay far end of
               "The identifier for the test Measurement Interval
               within this session";
            uses delay-statistics;
           }
          container one-way-delay-near-end{

           leaf end-time {
             type yang:date-and-time;
             mandatory true;
             description
            "one way delay near end of
               "The time that the test session";
            uses delay-statistics; Measurement Interval ended";
           }

           uses test-session-statistics;
         }
       }
     }

     container stamp-session-refl-state {
       if-feature session-reflector;
       description
      "stamp
         "STAMP Session-Reflector container for
         state data";
       leaf reflector-light-admin-status {
         type boolean;
        mandatory "true";
         description
           "Whether this network element is enabled to
           act as stamp STAMP Session-Reflector";
       }

       list test-session-state {
         key "session-id";
         description
           "This structure is a container of test session
           managed objects";

         leaf session-id {
           type uint32;
           description "Session ID";
         }

       uses maintenance-statistics;
         leaf reflector-timestamp-format {
           type timestamp-format;
       default ntp-format;
           description "Reflector Timestamp format";
         }
         uses session-parameters;
         uses maintenance-statistics;

       }
     }
   }

   rpc stamp-sender-start {
     description
       "start the configured sender session";
     input {
       leaf session-id {
         type uint32;
         mandatory true;
         description
           "The STAMP session to be started";
       }
     }
   }

   rpc stamp-sender-stop {
     description
       "stop the configured sender session";
     input {
       leaf session-id {
         type uint32;
         mandatory true;
         description
           "The session to be stopped";
       }
     }
   }
   }

    <CODE ENDS>

4.  IANA Considerations

   This document registers a URI in the IETF XML registry [RFC3688].
   Following the format in [RFC3688], the following registration is
   requested to be made.

   URI: urn:ietf:params:xml:ns:yang:ietf-stamp
   Registrant Contact: The IPPM WG of the IETF.

   XML: N/A, the requested URI is an XML namespace.

   This document registers a YANG module in the YANG Module Names
   registry [RFC6020]. [RFC7950].

   name: ietf-stamp

   namespace: urn:ietf:params:xml:ns:yang:ietf-stamp

   prefix: stamp

   reference: RFC XXXX

5.  Security Considerations

   The YANG module specified in this document defines a schema for data
   that is designed to be accessed via network management protocols such
   as NETCONF [RFC6241] or RESTCONF [RFC8040].  The lowest NETCONF layer
   is the secure transport layer, and the mandatory-to-implement secure
   transport is Secure Shell (SSH) [RFC6242].  The lowest RESTCONF layer
   is HTTPS, and the mandatory-to-implement secure transport is TLS
   [RFC5246].
   [RFC8446].

   The NETCONF access control model [RFC6536] [RFC8341] provides the means to
   restrict access for particular NETCONF or RESTCONF users to a
   preconfigured pre-
   configured subset of all available NETCONF or RESTCONF protocol
   operations and content.

   There are a number of data nodes defined in this YANG module that are
   writable/creatable/deletable (i.e., config true, which is the
   default).  These data nodes may be considered sensitive or vulnerable
   in some network environments.  Write operations (e.g., edit-config)
   to these data nodes without proper protection can have a negative an adverse
   effect on network operations.  These are the subtrees and data nodes
   and their sensitivity/vulnerability:

   TBD

   Unauthorized access to any data node of these subtrees can adversely
   affect the routing subsystem of both the local device and the
   network.  This may lead to corruption of the measurement that may
   result in false corrective action, e.g. e.g., false negative or false
   positive.  That could be, for example, prolonged and undetected
   deterioration of the quality of service or actions to improve the
   quality unwarranted by the real network conditions.

   Some of the readable data nodes in this YANG module may be considered
   sensitive or vulnerable in some network environments.  It is thus
   important to control read access (e.g., via get, get-config, or
   notification) to these data nodes.  These are the subtrees and data
   nodes and their sensitivity/vulnerability:

   /ietf-vrrp:stamp

   TBD

   Unauthorized access to any data node of these subtrees can disclose
   the operational state information of VRRP on this device.

   Some of the RPC operations in this YANG module may be considered
   sensitive or vulnerable in some network environments.  It is thus
   important to control access to these operations.  These are the
   operations and their sensitivity/vulnerability:

   TBD

6.  Acknowledgements  Acknowledgments

   Authors recognize and appreciate valuable comments provided by Adrian
   Pan.

7.  References

7.1.  Normative References

   [I-D.ietf-ippm-stamp]
              Mirsky, G., Jun, G., and H. Nydell, H., and R. Foote, "Simple
              Two-way Active Measurement Protocol", draft-ietf-ippm-stamp-00 (work in
              progress), January 2018.

   [I-D.ietf-netmod-revised-datastores]
              Bjorklund, M., Schoenwaelder, J., Shafer, P., Watsen, K.,
              and R. Wilton, "Network Management Datastore
              Architecture", draft-ietf-netmod-revised-datastores-10 draft-ietf-ippm-
              stamp-01 (work in progress), January March 2018.

   [RFC2119]  Bradner, S., "Key words for use in RFCs to Indicate
              Requirement Levels", BCP 14, RFC 2119,
              DOI 10.17487/RFC2119, March 1997,
              <https://www.rfc-editor.org/info/rfc2119>.

   [RFC3688]  Mealling, M., "The IETF XML Registry", BCP 81, RFC 3688,
              DOI 10.17487/RFC3688, January 2004,
              <https://www.rfc-editor.org/info/rfc3688>.

   [RFC5246]  Dierks, T. and E. Rescorla, "The Transport Layer Security
              (TLS) Protocol Version 1.2", RFC 5246,
              DOI 10.17487/RFC5246, August 2008,
              <https://www.rfc-editor.org/info/rfc5246>.

   [RFC5357]  Hedayat, K., Krzanowski, R., Morton, A., Yum, K., and J.
              Babiarz, "A Two-Way Active Measurement Protocol (TWAMP)",
              RFC 5357, DOI 10.17487/RFC5357, October 2008,
              <https://www.rfc-editor.org/info/rfc5357>.

   [RFC6020]  Bjorklund, M., Ed., "YANG - A Data Modeling Language for
              the Network Configuration Protocol (NETCONF)", RFC 6020,
              DOI 10.17487/RFC6020, October 2010,
              <https://www.rfc-editor.org/info/rfc6020>.

   [RFC6241]  Enns, R., Ed., Bjorklund, M., Ed., Schoenwaelder, J., Ed.,
              and A. Bierman, Ed., "Network Configuration Protocol
              (NETCONF)", RFC 6241, DOI 10.17487/RFC6241, June 2011,
              <https://www.rfc-editor.org/info/rfc6241>.

   [RFC6242]  Wasserman, M., "Using the NETCONF Protocol over Secure
              Shell (SSH)", RFC 6242, DOI 10.17487/RFC6242, June 2011,
              <https://www.rfc-editor.org/info/rfc6242>.

   [RFC6536]  Bierman, A. and M. Bjorklund, "Network Configuration
              Protocol (NETCONF) Access Control Model", RFC 6536,
              DOI 10.17487/RFC6536, March 2012,
              <https://www.rfc-editor.org/info/rfc6536>.

   [RFC7750]  Hedin, J., Mirsky, G., and S. Baillargeon, "Differentiated
              Service Code Point and Explicit Congestion Notification
              Monitoring in the Two-Way Active Measurement Protocol
              (TWAMP)", RFC 7750, DOI 10.17487/RFC7750, February 2016,
              <https://www.rfc-editor.org/info/rfc7750>.

   [RFC7950]  Bjorklund, M., Ed., "The YANG 1.1 Data Modeling Language",
              RFC 7950, DOI 10.17487/RFC7950, August 2016,
              <https://www.rfc-editor.org/info/rfc7950>.

   [RFC8040]  Bierman, A., Bjorklund, M., and K. Watsen, "RESTCONF
              Protocol", RFC 8040, DOI 10.17487/RFC8040, January 2017,
              <https://www.rfc-editor.org/info/rfc8040>.

   [RFC8174]  Leiba, B., "Ambiguity of Uppercase vs Lowercase in RFC
              2119 Key Words", BCP 14, RFC 8174, DOI 10.17487/RFC8174,
              May 2017, <https://www.rfc-editor.org/info/rfc8174>.

   [RFC8341]  Bierman, A. and M. Bjorklund, "Network Configuration
              Access Control Model", STD 91, RFC 8341,
              DOI 10.17487/RFC8341, March 2018,
              <https://www.rfc-editor.org/info/rfc8341>.

   [RFC8342]  Bjorklund, M., Schoenwaelder, J., Shafer, P., Watsen, K.,
              and R. Wilton, "Network Management Datastore Architecture
              (NMDA)", RFC 8342, DOI 10.17487/RFC8342, March 2018,
              <https://www.rfc-editor.org/info/rfc8342>.

   [RFC8446]  Rescorla, E., "The Transport Layer Security (TLS) Protocol
              Version 1.3", RFC 8446, DOI 10.17487/RFC8446, August 2018,
              <https://www.rfc-editor.org/info/rfc8446>.

7.2.  Informative References

   [RFC8340]  Bjorklund, M. and L. Berger, Ed., "YANG Tree Diagrams",
              BCP 215, RFC 8340, DOI 10.17487/RFC8340, March 2018,
              <https://www.rfc-editor.org/info/rfc8340>.

Appendix A.  Example of STAMP Session Configuration

   Figure 5 shows a configuration example for of a STAMP-Sender.

      <?xml version="1.0" encoding="utf-8"?>
      <data xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
       <stamp xmlns="urn:ietf:params:xml:ns:yang:ietf-stamp">
           <stamp-session-sender>
             <session-enable>enable</session-enable>
               <session-id>10</session-id>
               <test-session-enable>enable<test-session-enable>
               <number-of-packets>forever</number-of-packets>
               <packet-padding-size/> <!-- use default 27 octets -->
               <interval>10</interval> <!-- 10 microseconds -->
               <measurement-interval/> <!-- use default 60 seconds -->
               <!-- use default 0 repetitions,
                     i.e. do not repeat this session -->
               <repeat/>
               <dscp-value/> <!-- use deafult 0 (CS0) -->
               <!-- use default 'stateless' -->
               <test-session-reflector-mode/>
               <sender-ip></sender-ip>
               <sender-udp-port></sender-udp-port>
               <reflector-ip></reflector-ip>
               <reflector-udp-port/> <!-- use default 862 -->
               <sender-timestamp-format/>
               <!-- No authentication or encryption -->
               <first-percentile/> <!-- use default 95 -->
               <second-percentile/> <!-- use default 99 -->
               <third-percentile/> <!-- use default 99.9 -->
           </stamp-session-sender>
        </stamp>
      </data>

       Figure 5: XML instance of STAMP Session-Sender configuration

      <?xml version="1.0" encoding="utf-8"?>
      <data xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
       <stamp xmlns="urn:ietf:params:xml:ns:yang:ietf-stamp">
           <stamp-session-reflector>
             <session-enable>enable</session-enable>
             <ref-wait/> <!-- use default 900 seconds -->
             <!-- use default 'stateless' -->
             <reflector-mode-state/>
             <session-id></session-id>
             <!-- use default 'copy-received-value' -->
             <dscp-handling-mode/>
             <!-- not used because of dscp-hanling-mode
                   being 'copy-received-value' -->
             <dscp-value/>
             <sender-ip/> <!-- use default 'any' -->
             <sender-udp-port/>  <!-- use default 'any' -->
             <reflector-ip/> <!-- use default 'any' -->
             <reflector-udp-port/>  <!-- use default 862 -->
             <reflector-timestamp-format/>
             <!-- No authentication or encryption -->
           </stamp-session-reflector>
        </stamp>
      </data>

      Figure 6: XML instance of STAMP Session-Reflector configuration

Authors' Addresses

   Greg Mirsky
   ZTE Corp.

   Email: gregimirsky@gmail.com

   Xiao Min
   ZTE Corp.

   Email: xiao.min2@zte.com.cn

   Wei S Luo
   Ericsson

   Email: wei.s.luo@ericsson.com