netconfcentral logo

ietf-twamp@2017-10-16



  module ietf-twamp {

    yang-version 1;

    namespace
      'urn:ietf:params:xml:ns:yang:ietf-twamp';

    prefix ietf-twamp;

    import ietf-inet-types {
      prefix inet;
    }

    organization
      "IETF IPPM (IP Performance Metrics) Working Group";

    contact
      'draft-ietf-ippm-twamp-yang@tools.ietf.org';

    description
      "This YANG module specifies a vendor-independent data
    model for the Two-Way Active Measurement Protocol (TWAMP).

    The data model covers four TWAMP logical entities, namely,
    Control-Client, Server, Session-Sender, and Session-Reflector,
    as illustrated in the annotated TWAMP logical model (Fig. 1
    of draft-ietf-ippm-twamp-yang).

    This YANG module uses features to indicate which of the four
    logical entities are supported by a TWAMP implementation.";

    revision "2017-10-16" {
      description
        "Revision appearing in draft-ietf-ippm-twamp-yang-05.

      Covers RFC 5357, RFC 5618, RFC 5938, RFC 6038, RFC 7717, and
      draft-ietf-ippm-metric-registry";
      reference
        "draft-ietf-ippm-twamp-yang";

    }


    typedef twamp-modes {
      type bits {
        bit unauthenticated {
          position 0;
          description
            "Unauthenticated mode, in which no encryption or
          authentication is applied in TWAMP-Control and TWAMP-Test.
          KeyID, Token, and Client-IV are not used in the
          Set-Up-Response message. See Section 3.1 of RFC 4656.";
          reference
            "RFC 4656: A One-way Active Measurement Protocol (OWAMP)";

        }
        bit authenticated {
          position 1;
          description
            "Authenticated mode, in which the Control-Client and Server
          possess a shared secret thus prohibiting 'theft of service'.
          As per Section 6 of RFC 4656, in 'authenticated mode, the
          timestamp is in the clear and is not protected
          cryptographically in any way, while the rest of the message
          has the same protection as in encrypted mode. This mode
          allows one to trade off cryptographic protection against
          accuracy of timestamps.'";
          reference
            "RFC 4656: A One-way Active Measurement Protocol (OWAMP)";

        }
        bit encrypted {
          position 2;
          description
            "Encrypted mode 'makes it impossible to alter
          timestamps undetectably.' See also Section 4 of RFC 7717
          and Section 6 of RFC 4656.";
          reference
            "RFC 4656: A One-way Active Measurement Protocol (OWAMP)";

        }
        bit unauth-test-encrpyt-control {
          position 3;
          description
            "When using the Mixed Security Mode, the TWAMP-Test
          protocol follows the Unauthenticated mode and the
          TWAMP-Control protocol the Encrypted mode.";
          reference
            "RFC 5618: Mixed Security Mode for the Two-Way Active
            Measurement Protocol (TWAMP)";

        }
        bit individual-session-control {
          position 4;
          description
            "This mode enables individual test sessions using
          Session Identifiers.";
          reference
            "RFC 5938: Individual Session Control Feature
            for the Two-Way Active Measurement Protocol (TWAMP)";

        }
        bit reflect-octets {
          position 5;
          description
            "This mode indicates the reflect octets capability.";
          reference
            "RFC 6038: Two-Way Active Measurement Protocol (TWAMP)
            Reflect Octets and Symmetrical Size Features";

        }
        bit symmetrical-size {
          position 6;
          description
            "This mode indicates support for the symmetrical size
          sender test packet format.";
          reference
            "RFC 6038: Two-Way Active Measurement Protocol (TWAMP)
            Reflect Octets and Symmetrical Size Features";

        }
        bit IKEv2Derived {
          position 7;
          description
            "In this mode the the shared key is derived
          from an IKEv2 security association (SA).";
          reference
            "RFC 7717: IKEv2-Derived Shared Secret Key for
            the One-Way Active Measurement Protocol (OWAMP)
            and Two-Way Active Measurement Protocol (TWAMP)";

        }
      }
      description
        "Specifies the configurable TWAMP-Modes supported during a
      TWAMP-Control Connection setup between a Control-Client
      and a Server. Section 7 of RFC 7717 summarizes the
      TWAMP-Modes registry and points to their formal
      specification.";
    }

    typedef control-client-connection-state {
      type enumeration {
        enum "active" {
          value 0;
          description
            "Indicates an active TWAMP-Control connection to Server.";
        }
        enum "idle" {
          value 1;
          description
            "Indicates an idle TWAMP-Control connection to Server.";
        }
      }
      description
        "Indicates the Control-Client TWAMP-Control connection state.";
    }

    typedef test-session-state {
      type enumeration {
        enum "accepted" {
          value 0;
          description
            "Indicates that accepted TWAMP-Test session request.";
        }
        enum "failed" {
          value 1;
          description
            "Indicates a TWAMP-Test session failure due to
          some unspecified reason (catch-all).";
        }
        enum "internal-error" {
          value 2;
          description
            "Indicates a TWAMP-Test session failure due to
          an internal error.";
        }
        enum "not-supported" {
          value 3;
          description
            "Indicates a TWAMP-Test session failure because
          some aspect of the TWAMP-Test session request
          is not supported.";
        }
        enum "permanent-resource-limit" {
          value 4;
          description
            "Indicates a TWAMP-Test session failure due to
          permanent resource limitations.";
        }
        enum "temp-resource-limit" {
          value 5;
          description
            "Indicates a TWAMP-Test session failure due to
          temporary resource limitations.";
        }
      }
      description
        "Indicates the Control-Client TWAMP-Test session state.";
    }

    typedef server-ctrl-connection-state {
      type enumeration {
        enum "active" {
          value 0;
          description
            "Indicates an active TWAMP-Control connection
          to the Control-Client.";
        }
        enum "servwait" {
          value 1;
          description
            "Indicates that the TWAMP-Control connection to the
          Control-Client is in SERVWAIT as per the definition of
          Section 3.1 of RFC 5357.";
        }
      }
      description
        "Indicates the Server TWAMP-Control connection state.";
    }

    typedef sender-session-state {
      type enumeration {
        enum "active" {
          value 0;
          description
            "Indicates that the TWAMP-Test session is active.";
        }
        enum "failure" {
          value 1;
          description
            "Indicates that the TWAMP-Test session has failed.";
        }
      }
      description
        "Indicates the Session-Sender TWAMP-Test session state.";
    }

    typedef padding-fill-mode {
      type enumeration {
        enum "zero" {
          value 0;
          description
            "TWAMP-Test packets are padded with all zeros.";
        }
        enum "random" {
          value 1;
          description
            "TWAMP-Test packets are padded with pseudo-random
          numbers.";
        }
      }
      description
        "Indicates what type of packet padding is used in the
      TWAMP-Test packets.";
    }

    typedef dynamic-port-number {
      type inet:port-number {
        range "49152..65535";
      }
      description
        "Dynamic range for port numbers.";
    }

    feature control-client {
      description
        "Indicates that the device supports configuration of the
      TWAMP Control-Client logical entity.";
    }

    feature server {
      description
        "Indicates that the device supports configuration of the
      TWAMP Server logical entity.";
    }

    feature session-sender {
      description
        "Indicates that the device supports configuration of the
      TWAMP Session-Sender logical entity.";
    }

    feature session-reflector {
      description
        "Indicates that the device supports configuration of the
      TWAMP Session-Reflector logical entity.";
    }

    grouping key-management {
      description
        "Used by the Control-Client and Server for TWAMP-Control
        key management.";
      list key-chain {
        key "key-id";
        description
          "Relates KeyIDs with their respective secret keys
          in a TWAMP-Control connection.";
        leaf key-id {
          type string {
            length "1..80";
          }
          description
            "KeyID used for a TWAMP-Control connection. As per
          Section 3.1 of RFC 4656, KeyID is 'a UTF-8 string, up to
          80 octets in length' and is used to select which 'shared
          shared secret the [Control-Client] wishes to use to
          authenticate or encrypt'.";
        }

        leaf secret-key {
          type binary;
          description
            "The secret key corresponding to the KeyID for this
            TWAMP-Control connection.";
        }
      }  // list key-chain
    }  // grouping key-management

    grouping maintenance-statistics {
      description
        "Used for TWAMP-Test maintenance statistics.";
      leaf sent-packets {
        type uint32;
        config false;
        description
          "Indicates the number of packets sent.";
      }

      leaf rcv-packets {
        type uint32;
        config false;
        description
          "Indicates the number of packets received.";
      }

      leaf last-sent-seq {
        type uint32;
        config false;
        description
          "Indicates the last sent sequence number.";
      }

      leaf last-rcv-seq {
        type uint32;
        config false;
        description
          "Indicates the last received sequence number.";
      }
    }  // grouping maintenance-statistics

    grouping count {
      description
        "Reusable data structure for count which is used both in the
     Server container.";
      leaf count {
        type uint8 {
          range "10..31";
        }
        default '10';
        description
          "Parameter communicated to the Control-Client as part of the
        Server Greeting message and used for deriving a key from a
        shared secret as per Section 3.1 of  RFC 4656:  MUST be a
        power of 2 and at least 1024. It is configured by providing
        said power. For example, configuring 15 here means count
        2^15 = 32768. The default is 10, meaning 2^10 = 1024.";
      }
    }  // grouping count

    grouping max-count {
      description
        "Reusable data structure for max-count which is used both at
      the Control-Client and the Server containers.";
      leaf max-count {
        type uint8 {
          range "10..31";
        }
        default '15';
        description
          "This parameter limits the maximum Count value, which MUST
        be a power of 2 and at least 1024 as per RFC 5357. It is
        configured by providing said power. For example,
        configuring 10 here means max count 2^10 = 1024.
        The default is 15, meaning 2^15 = 32768.
        A TWAMP Server uses this configured value in the
        Server-Greeting message sent to the Control-Client.

        A TWAMP Control-Client uses this configured value to prevent
        denial-of-service (DOS) attacks by closing the control
        connection to the Server if it 'receives a Server-Greeting
        message with Count greater that its maximum configured value',
        as per Section 6 of RFC 5357.

        Further, note that according to Section 6 of RFC 5357:

          'If an attacking system sets the maximum value in
          Count (2**32), then the system under attack would stall
          for a significant period of time while it attempts to
          generate keys.

          TWAMP-compliant systems SHOULD have a configuration
          control to limit the maximum count value. The default
          max-count value SHOULD be 32768.'

        RFC 5357 does not qualify 'significant period' in terms of
        time, but it is clear that this depends on the processing
        capacity available and operators need to pay attention to
        this security consideration.";
      }
    }  // grouping max-count

    container twamp {
      description
        "TWAMP logical entity configuration grouping of four models
        which correspond to the four TWAMP logical entities
        Control-Client, Server, Session-Sender, and Session-Reflector
        as illustrated in Fig. 1 of draft-ietf-ippm-twamp-yang.";
      container client {
        if-feature control-client;
        presence
          "Enables TWAMP Control-Client functionality.";
        description
          "Configuration of the TWAMP Control-Client logical entity.";
        leaf admin-state {
          type boolean;
          mandatory true;
          description
            "Indicates whether the device is allowed to operate as a
          TWAMP Control-Client.";
        }

        list mode-preference-chain {
          key "priority";
          unique "mode";
          description
            "Indicates the Control-Client preferred order of use of
            the supported TWAMP Modes.

            Depending on the Modes available in the TWAMP Server
            Greeting message (see Fig. 2 of RFC 7717), the
            this Control-Client MUST choose the highest priority Mode
            from the configured mode-preference-chain list.";
          leaf priority {
            type uint16;
            description
              "Indicates the Control-Client Mode preference priority
            expressed as a 16-bit unsigned integer, where zero is the
            highest priority and subsequent values monotonically
            increasing.";
          }

          leaf mode {
            type twamp-modes;
            description
              "The supported TWAMP Mode matching the corresponding
            priority.";
          }
        }  // list mode-preference-chain

        uses key-management;

        list ctrl-connection {
          key "name";
          description
            "List of TWAMP Control-Client control connections.
          Each item in the list describes a control connection
          that will be initiated by this Control-Client";
          leaf name {
            type string;
            description
              "A unique name used as a key to identify this individual
            TWAMP-Control connection on the Control-Client device.";
          }

          leaf client-ip {
            type inet:ip-address;
            description
              "The IP address of the local Control-Client device,
            to be placed in the source IP address field of the
            IP header in TWAMP-Control (TCP) packets belonging
            to this control connection. If not configured, the
            device SHALL choose its own source IP address.";
          }

          leaf server-ip {
            type inet:ip-address;
            mandatory true;
            description
              "The IP address of the remote Server device, which the
            TWAMP-Control connection will be initiated to.";
          }

          leaf server-tcp-port {
            type inet:port-number;
            default '862';
            description
              "This parameter defines the TCP port number that is
            to be used by this outgoing TWAMP-Control connection.
            Typically, this is the well-known TWAMP-Control
            port number (862) as per RFC 5357 However, there are known
            realizations of TWAMP in the field that were implemented
            before this well-known port number was allocated. These
            early implementations allowed the port number to be
            configured. This parameter is therefore provided for
            backward compatibility reasons.";
          }

          leaf control-packet-dscp {
            type inet:dscp;
            default '0';
            description
              "The DSCP value to be placed in the IP header of
            TWAMP-Control (TCP) packets generated by this
            Control-Client.";
          }

          leaf key-id {
            type string {
              length "1..80";
            }
            description
              "Indicates the KeyID value selected for this
           TWAMP-Control connection.";
          }

          uses max-count;

          leaf client-tcp-port {
            type inet:port-number;
            config false;
            description
              "Indicates the source TCP port number used in the
            TWAMP-Control packets belonging to this control
            connection.";
          }

          leaf server-start-time {
            type uint64;
            config false;
            description
              "Indicates the Start-Time advertized by the Server in the
            Server-Start message (RFC 4656, Section 3.1),
            representing the time when the current
            instantiation of the Server started operating.
            The timestamp format follows RFC 1305
            according to Section 4.1.2 of RFC 4656.";
          }

          leaf state {
            type control-client-connection-state;
            config false;
            description
              "Indicates the current state of the TWAMP-Control
            connection state.";
          }

          leaf selected-mode {
            type twamp-modes;
            config false;
            description
              "The TWAMP Mode that the Control-Client has chosen for
            this control connection as set in the Mode field of the
            Set-Up-Response message (RFC 4656, Section 3.1).";
          }

          leaf token {
            type binary {
              length "64";
            }
            config false;
            description
              "This parameter holds the 64 octets containing the
            concatenation of a 16-octet Challenge, a 16-octet AES
            Session-key used for encryption, and a 32-octet
            HMAC-SHA1 Session-key used for authentication; see also
            the last paragraph of Section 6 in RFC 4656.

            If the Mode defined in RFC 7717 is selected (selected-mode),
            Token is limited to 16 octets.";
            reference
              "RFC 4086: Randomness Requirements for Security
               
               RFC 7717: IKEv2-Derived Shared Secret Key for the One-Way
              Active Measurement Protocol (OWAMP) and Two-Way Active
              Measurement Protocol (TWAMP)";

          }

          leaf client-iv {
            type binary {
              length "16";
            }
            config false;
            description
              "Indicates the Control-Client Initialization Vector
            (Client-IV), that is generated randomly by the
            Control-Client. As per RFC 4656:

              Client-IV merely needs to be unique (i.e., it MUST
              never be repeated for different sessions using the
              same secret key; a simple way to achieve that without
              the use of cumbersome state is to generate the
              Client-IV values using a cryptographically secure
              pseudo-random number source.

            If the Mode defined in RFC 7717 is selected (selected-mode),
            Client-IV is limited to 12 octets.";
            reference
              "RFC 4656: A One-way Active Measurement Protocol (OWAMP)
               
               RFC 7717: IKEv2-Derived Shared Secret Key for the One-Way
              Active Measurement Protocol (OWAMP) and Two-Way Active
              Measurement Protocol (TWAMP)";

          }

          list test-session-request {
            key "name";
            description
              "Information associated with the Control-Client
            for this test session";
            leaf name {
              type string;
              description
                "A unique name to be used for identification of
              this TWAMP-Test session on the Control-Client.";
            }

            leaf sender-ip {
              type inet:ip-address;
              description
                "The IP address of the Session-Sender device,
              which is to be placed in the source IP address
              field of the IP header in TWAMP-Test (UDP) packets
              belonging to this test session. This value will be
              used to populate the sender address field of the
              Request-TW-Session message.

              If not configured, the device SHALL choose its own
              source IP address.";
            }

            leaf sender-udp-port {
              type union {
                type dynamic-port-number;
                type enumeration {
                  enum "autoallocate" {
                    value 0;
                    description
                      "Indicates that the Contol-Client will
                    auto-allocate the TWAMP-Test (UDP) port number
                    from the dynamic port range.";
                  }
                }
              }
              default 'autoallocate';
              description
                "The UDP port number that is to be used by
              the Session-Sender for this TWAMP-Test session.
              The number is restricted to the dynamic port range.

              By default the Control-Client SHALL auto-allocate a
              UDP port number for this TWAMP-Test session.

              The configured (or auto-allocated) value is advertized
              in the Sender Port field of the Request-TW-session
              message (see Section 3.5 of RFC 5357). Note that
              in the scenario where a device auto-allocates a UDP
              port number for a session, and the repeat parameter
              for that session indicates that it should be
              repeated, the device is free to auto-allocate a
              different UDP port number when it negotiates the
              next (repeated) iteration of this session.";
            }

            leaf reflector-ip {
              type inet:ip-address;
              mandatory true;
              description
                "The IP address belonging to the remote
              Session-Reflector device to which the TWAMP-Test
              session will be initiated. This value will be
              used to populate the receiver address field of
              the Request-TW-Session message.";
            }

            leaf reflector-udp-port {
              type dynamic-port-number;
              description
                "This parameter defines the UDP port number that
              will be used by the Session-Reflector for
              this TWAMP-Test session. The number is restricted
              to the dynamic port range and is to be placed in
              the Receiver Port field of the Request-TW-Session
              message.";
            }

            leaf timeout {
              type uint64;
              units "seconds";
              default '2';
              description
                "The length of time (in seconds) that the
                Session-Reflector should continue to respond to
                packets belonging to this TWAMP-Test session after
                a Stop-Sessions TWAMP-Control message has been
                received (RFC 5357, Section 3.8).

                This value will be placed in the Timeout field of
                the Request-TW-Session message.";
            }

            leaf padding-length {
              type uint32 {
                range "64..4096";
              }
              description
                "The number of padding bytes to be added to the
                TWAMP-Test (UDP) packets generated by the
                Session-Sender.

                This value will be placed in the Padding Length
                field of the Request-TW-Session message
                (RFC 4656, Section 3.5).";
            }

            leaf test-packet-dscp {
              type inet:dscp;
              default '0';
              description
                "The DSCP value to be placed in the IP header
                of TWAMP-Test packets generated by the
                Session-Sender, and in the UDP header of the
                TWAMP-Test response packets generated by the
                Session-Reflector for this test session.

                This value will be placed in the Type-P Descriptor
                field of the Request-TW-Session message (RFC 5357).";
            }

            leaf start-time {
              type uint64;
              default '0';
              description
                "Time when the session is to be started
                (but not before the TWAMP Start-Sessions command
                is issued; see Section 3.4 of RFC 5357).

                The start-time value is placed in the Start Time
                field of the Request-TW-Session message.

                The timestamp format follows RFC 1305 as per
                Section 3.5 of RFC 4656.

                The default value of 0 indicates that the session
                will be started as soon as the Start-Sessions message
                is received.";
            }

            leaf repeat {
              type union {
                type uint32 {
                  range "0..4294967294";
                }
                type enumeration {
                  enum "forever" {
                    value 0;
                    description
                      "Indicates that the test session SHALL be
                    repeated *forever* using the information in
                    repeat-interval parameter, and SHALL NOT
                    decrement the value.";
                  }
                }
              }
              default '0';
              description
                "This value determines if the TWAMP-Test session must
                be repeated. When a test 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 SHALL be repeated using the
                information in repeat-interval parameter, and the
                parent TWAMP-Control connection for this test
                session is restarted to negotiate a new instance
                of this TWAMP-Test session. The implementation
                MUST decrement the value of repeat after
                determining a repeated session is expected.";
            }

            leaf repeat-interval {
              when "../repeat!='0'" {
                description
                  "This parameter determines the timing of repeated
                TWAMP-Test sessions when repeat is more than 0.

                When the value of repeat-interval is 0, the
                negotiation of a new test session SHALL begin
                immediately after the previous test session
                completes. Otherwise, the Control-Client will
                wait for the number of seconds specified in the
                repeat-interval parameter before negotiating the
                new instance of this TWAMP-Test session.";
              }
              type uint32;
              units "seconds";
              default '0';
              description
                "Repeat interval (in seconds).";
            }

            list pm-reg-list {
              key "pm-index";
              description
                "A list of one or more Performance Metric Registry
                Index values, which communicate packet stream
                characteristics along with one or more metrics
                to be measured.

                All members of the pm-reg-list MUST have the same
                stream characteristics, such that they combine
                to specify all metrics that shall be measured on
                a single stream.";
              reference
                "ietf-ippm-metric-registry:
                 Registry for Performance Metrics";

              leaf pm-index {
                type uint16;
                description
                  "Numerical index value of a Registered Metric
                in the Performance Metric Registry
                (see ietf-ippm-metric-registry). Output statistics
                are specified in the corresponding Registry entry.";
              }
            }  // list pm-reg-list

            leaf repeat-count {
              type uint64;
              config false;
              description
                "Indicates how many times the test session has been
                 repeated. When a test is running, this value will be
                 greater than 0. If the repeat parameter is non-zero,
                 this value is smaller than or equal to the repeat
                 parameter.";
            }

            leaf state {
              type test-session-state;
              config false;
              description
                "Indicates the TWAMP-Test session state (accepted or
                indication of an error); see Section 3.5 of
                RFC 5357.";
            }

            leaf sid {
              type string;
              config false;
              description
                "The SID allocated by the Server for this TWAMP-Test
                session, and communicated back to the Control-Client
                in the SID field of the Accept-Session message;
                see Section 4.3 of RFC 6038.";
            }
          }  // list test-session-request
        }  // list ctrl-connection
      }  // container client

      container server {
        if-feature server;
        presence
          "Enables TWAMP Server functionality.";
        description
          "Configuration of the TWAMP Server logical entity.";
        leaf admin-state {
          type boolean;
          mandatory true;
          description
            "Indicates whether the device is allowed to operate
            as a TWAMP Server.";
        }

        leaf server-tcp-port {
          type inet:port-number;
          default '862';
          description
            "This parameter defines the well known TCP port number
            that is used by TWAMP-Control. The Server will listen
            on this port number for incoming TWAMP-Control
            connections. Although this is defined as a fixed value
            (862) in RFC 5357, there are several realizations of
            TWAMP in the field that were implemented before this
            well-known port number was allocated. These early
            implementations allowed the port number to be
            configured. This parameter is therefore provided for
            backward compatibility reasons.";
        }

        leaf servwait {
          type uint32 {
            range "1..604800";
          }
          units "seconds";
          default '900';
          description
            "TWAMP-Control (TCP) session timeout, in seconds.
          According to Section 3.1 of RFC 5357,
            Server MAY discontinue any established control
            connection when no packet associated with that
            connection has been received within SERVWAIT seconds.";
        }

        leaf control-packet-dscp {
          type inet:dscp;
          description
            "The DSCP value to be placed in the IP header of
            TWAMP-Control (TCP) packets generated by the Server.

            Section 3.1 of  RFC 5357 specifies that the server
            SHOULD use the DSCP value from the Control-Client's
            TCP SYN. However, for practical purposes TWAMP will
            typically be implemented using a general purpose TCP
            stack provided by the underlying operating system,
            and such a stack may not provide this information to the
            user. Consequently, it is not always possible to
            implement the behavior described in RFC 5357 in an
            OS-portable version of TWAMP.

            The default behavior if this item is not set is to use
            the DSCP value from the Control-Client's TCP SYN,
            as per Section 3.1 of RFC 5357.";
        }

        uses count;

        uses max-count;

        leaf modes {
          type twamp-modes;
          description
            "The bit mask of TWAMP Modes this Server instance
            is willing to support; see IANA TWAMP Modes Registry.";
        }

        uses key-management;

        list ctrl-connection {
          key "client-ip client-tcp-port server-ip server-tcp-port";
          config false;
          description
            "List of all incoming TWAMP-Control (TCP) connections.";
          leaf client-ip {
            type inet:ip-address;
            description
              "The IP address on the remote Control-Client device,
            which is the source IP address used in the
            TWAMP-Control (TCP) packets belonging to this control
            connection.";
          }

          leaf client-tcp-port {
            type inet:port-number;
            description
              "The source TCP port number used in the TWAMP-Control
            (TCP) packets belonging to this control connection.";
          }

          leaf server-ip {
            type inet:ip-address;
            description
              "The IP address of the local Server device, which is
            the destination IP address used in the
            TWAMP-Control (TCP) packets belonging to this control
            connection.";
          }

          leaf server-tcp-port {
            type inet:port-number;
            description
              "The destination TCP port number used in the
            TWAMP-Control (TCP) packets belonging to this
            control connection. This will usually be the
            same value as the server-tcp-port configured
            under twamp/server. However, in the event that
            the user re-configured server/server-tcp-port
            after this control connection was initiated, this
            value will indicate the server-tcp-port that is
            actually in use for this control connection.";
          }

          leaf state {
            type server-ctrl-connection-state;
            description
              "Indicates the Server TWAMP-Control connection state.";
          }

          leaf control-packet-dscp {
            type inet:dscp;
            description
              "The DSCP value used in the IP header of the
            TWAMP-Control (TCP) packets sent by the Server
            for this control connection. This will usually
            be the same value as is configured in the
            control-packet-dscp parameter under the twamp/server
            container.  However, in the event that the user
            re-configures server/dscp after this control
            connection is already in progress, this read-only
            value will show the actual dscp value in use by this
            TWAMP-Control connection.";
          }

          leaf selected-mode {
            type twamp-modes;
            description
              "The Mode that was chosen for this TWAMP-Control
            connection as set in the Mode field of the
            Set-Up-Response message.";
          }

          leaf key-id {
            type string {
              length "1..80";
            }
            description
              "The KeyID value that is in use by this TWAMP-Control
            connection as selected by Control-Client.";
          }

          uses count {
            description
              "The count value that is in use by this TWAMP-Control
            connection. This will usually be the same value
            as is configured under twamp/server. However, in the
            event that the user re-configured server/count
            after this control connection is already in progress,
            this read-only value will show the actual count that
            is in use for this TWAMP-Control connection.";
          }

          uses max-count {
            description
              "This read-only value indicates the actual max-count in use
            for this control connection. Usually this would be the
            same value as configured under twamp/server.";
          }

          leaf salt {
            type binary {
              length "16";
            }
            description
              "A parameter used in deriving a key from a
            shared secret as described in Section 3.1 of RFC 4656.
            It is communicated to the Control-Client as part of
            the Server Greeting message.";
          }

          leaf server-iv {
            type binary {
              length "16";
            }
            description
              "The Server Initialization Vector
            (IV) generated randomly by the Server.";
          }

          leaf challenge {
            type binary {
              length "16";
            }
            description
              "A random sequence of octets generated by the Server.
            As described in client/token, Challenge is used
            by the Control-Client to prove possession of a
            shared secret.";
          }
        }  // list ctrl-connection
      }  // container server

      container session-sender {
        if-feature session-sender;
        presence
          "Enables TWAMP Session-Sender functionality.";
        description
          "Configuration of the TWAMP Session-Sender logical entity";
        leaf admin-state {
          type boolean;
          mandatory true;
          description
            "Indicates whether the device is allowed to operate
            as a TWAMP Session-Sender.";
        }

        list test-session {
          key "name";
          description
            "List of TWAMP Session-Sender test sessions.";
          leaf name {
            type string;
            description
              "A unique name for this TWAMP-Test session to be used
            for identifying this test session by the Session-Sender
            logical entity.";
          }

          leaf ctrl-connection-name {
            type string;
            config false;
            description
              "The name of the parent TWAMP-Control connection that
            is responsible for negotiating this TWAMP-Test session.";
          }

          leaf fill-mode {
            type padding-fill-mode;
            default 'zero';
            description
              "Indicates whether the padding added to the
            TWAMP-Test (UDP) packets will contain pseudo-random
            numbers, or whether it should consist of all zeroes,
            as per Section 4.2.1 of RFC 5357.";
          }

          leaf number-of-packets {
            type uint32;
            mandatory true;
            description
              "The overall number of TWAMP-Test (UDP) packets to be
            transmitted by the Session-Sender for this test session.";
          }

          choice packet-distribution {
            description
              "Indicates the distribution to be used for transmitting
            the TWAMP-Test (UDP) packets.";
            leaf periodic-interval {
              type decimal64 {
                fraction-digits 5;
              }
              units "seconds";
              mandatory true;
              description
                "Indicates the time to wait (in seconds) between the
                first bits of TWAMP-Test (UDP) packet transmissions for
                this test session";
              reference
                "RFC 3432: Network performance measurement
                	  with periodic streams";

            }

            case poisson {
              leaf lambda {
                type decimal64 {
                  fraction-digits 5;
                }
                units "seconds";
                mandatory true;
                description
                  "Indicates the average time interval (in seconds)
                between packets in the Poisson distribution.
                The packet is calculated using the reciprocal of lambda
                and the TWAMP-Test packet size (which depends on the
                selected Mode and the packet padding).";
                reference
                  "RFC 2330: Framework for IP Performance Metrics";

              }

              leaf max-interval {
                type decimal64 {
                  fraction-digits 5;
                }
                units "seconds";
                description
                  "Indicates the maximum time (in seconds)
                between packet transmissions.";
                reference
                  "RFC 7312: Advanced Stream and Sampling Framework
                  	  for IP Performance Metrics (IPPM)";

              }
            }  // case poisson
          }  // choice packet-distribution

          leaf state {
            type sender-session-state;
            config false;
            description
              "Indicates the Session-Sender test session state.";
          }

          uses maintenance-statistics;
        }  // list test-session
      }  // container session-sender

      container session-reflector {
        if-feature session-reflector;
        presence
          "Enables TWAMP Session-Reflector functionality.";
        description
          "Configuration of the TWAMP Session-Reflector logical entity";
        leaf admin-state {
          type boolean;
          mandatory true;
          description
            "Indicates whether the device is allowed to operate
          as a TWAMP Session-Reflector.";
        }

        leaf refwait {
          type uint32 {
            range "1..604800";
          }
          units "seconds";
          default '900';
          description
            "The Session-Reflector MAY discontinue any session that has
          been started when no packet associated with that session has
          been received for REFWAIT seconds. As per Section 3.1 of
          RFC 5357, this timeout allows a Session-Reflector to free up
          resources in case of failure.";
        }

        list test-session {
          key "sender-ip sender-udp-port reflector-ip reflector-udp-port";
          config false;
          description
            "TWAMP Session-Reflectortest sessions.";
          leaf sid {
            type string;
            description
              "An auto-allocated identifier for this TWAMP-Test
            session that is unique within the context of this
            Server/Session-Reflector device only. This value
            is communicated to the Control-Client that
            requested the test session in the SID field of the
            Accept-Session message.";
          }

          leaf sender-ip {
            type inet:ip-address;
            description
              "The IP address on the remote device, which is the
            source IP address used in the TWAMP-Test (UDP) packets
            belonging to this test session.";
          }

          leaf sender-udp-port {
            type dynamic-port-number;
            description
              "The source UDP port used in the TWAMP-Test packets
            belonging to this test session.";
          }

          leaf reflector-ip {
            type inet:ip-address;
            description
              "The IP address of the local Session-Reflector
            device, which is the destination IP address used
            in the TWAMP-Test (UDP) packets belonging to this test
            session.";
          }

          leaf reflector-udp-port {
            type dynamic-port-number;
            description
              "The destination UDP port number used in the
            TWAMP-Test (UDP) test packets belonging to this
            test session.";
          }

          leaf parent-connection-client-ip {
            type inet:ip-address;
            description
              "The IP address on the Control-Client device, which
            is the source IP address used in the TWAMP-Control
            (TCP) packets belonging to the parent control
            connection that negotiated this test session.";
          }

          leaf parent-connection-client-tcp-port {
            type inet:port-number;
            description
              "The source TCP port number used in the TWAMP-Control
            (TCP) packets belonging to the parent control connection
            that negotiated this test session.";
          }

          leaf parent-connection-server-ip {
            type inet:ip-address;
            description
              "The IP address of the Server device, which is the
            destination IP address used in the TWAMP-Control
            (TCP) packets belonging to the parent control
            connection that negotiated this test session.";
          }

          leaf parent-connection-server-tcp-port {
            type inet:port-number;
            description
              "The destination TCP port number used in the TWAMP-Control
            (TCP) packets belonging to the parent control connection
            that negotiated this test session.";
          }

          leaf test-packet-dscp {
            type inet:dscp;
            description
              "The DSCP value present in the IP header of
            TWAMP-Test (UDP) packets belonging to this session.";
          }

          uses maintenance-statistics;
        }  // list test-session
      }  // container session-reflector
    }  // container twamp
  }  // module ietf-twamp