module ietf-te-packet-types {
  yang-version 1.1;
  namespace "urn:ietf:params:xml:ns:yang:ietf-te-packet-types";
  prefix te-packet-types;

  /* Import TE generic types */

  import ietf-te-types {
    prefix te-types;
    reference
      "RFC 8776: Common YANG Data Types for Traffic Engineering";
  }

  organization
    "IETF Traffic Engineering Architecture and Signaling (TEAS)
     Working Group";
  contact
    "WG Web:   <https://datatracker.ietf.org/wg/teas/>
     WG List:  <mailto:teas@ietf.org>

     Editor:   Tarek Saad
               <mailto:tsaad@juniper.net>

     Editor:   Rakesh Gandhi
               <mailto:rgandhi@cisco.com>

     Editor:   Vishnu Pavan Beeram
               <mailto:vbeeram@juniper.net>

     Editor:   Xufeng Liu
               <mailto:xufeng.liu.ietf@gmail.com>

     Editor:   Igor Bryskin
               <mailto:i_bryskin@yahoo.com>";
  description
    "This YANG module contains a collection of generally useful YANG
     data type definitions specific to MPLS TE.  The model fully
     conforms to the Network Management Datastore Architecture
     (NMDA).

     Copyright (c) 2020 IETF Trust and the persons identified as
     authors of the code.  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
     (https://trustee.ietf.org/license-info).

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

  revision 2020-06-10 {
    description
      "Latest revision of TE MPLS types.";
    reference
      "RFC 8776: Common YANG Data Types for Traffic Engineering";
  }

  /**
   * Typedefs
   */

  typedef te-bandwidth-requested-type {
    type enumeration {
      enum specified {
        description
          "Bandwidth is explicitly specified.";
      }
      enum auto {
        description
          "Bandwidth is automatically computed.";
      }
    }
    description
      "Enumerated type for specifying whether bandwidth is
       explicitly specified or automatically computed.";
  }

  typedef te-class-type {
    type uint8;
    description
      "Diffserv-TE Class-Type.  Defines a set of Traffic Trunks
       crossing a link that is governed by a specific set of
       bandwidth constraints.  Class-Type is used for the purposes
       of link bandwidth allocation, constraint-based routing, and
       admission control.";
    reference
      "RFC 4124: Protocol Extensions for Support of Diffserv-aware
       MPLS Traffic Engineering";
  }

  typedef bc-type {
    type uint8 {
      range "0..7";
    }
    description
      "Diffserv-TE bandwidth constraints as defined in RFC 4124.";
    reference
      "RFC 4124: Protocol Extensions for Support of Diffserv-aware
       MPLS Traffic Engineering";
  }

  typedef bandwidth-kbps {
    type uint64;
    units "Kbps";
    description
      "Bandwidth values, expressed in kilobits per second.";
  }

  typedef bandwidth-mbps {
    type uint64;
    units "Mbps";
    description
      "Bandwidth values, expressed in megabits per second.";
  }

  typedef bandwidth-gbps {
    type uint64;
    units "Gbps";
    description
      "Bandwidth values, expressed in gigabits per second.";
  }

  identity backup-protection-type {
    description
      "Base identity for the backup protection type.";
  }

  identity backup-protection-link {
    base backup-protection-type;
    description
      "Backup provides link protection only.";
  }

  identity backup-protection-node-link {
    base backup-protection-type;
    description
      "Backup offers node (preferred) or link protection.";
  }

  identity bc-model-type {
    description
      "Base identity for the Diffserv-TE Bandwidth Constraints
       Model type.";
    reference
      "RFC 4124: Protocol Extensions for Support of Diffserv-aware
       MPLS Traffic Engineering";
  }

  identity bc-model-rdm {
    base bc-model-type;
    description
      "Russian Dolls Bandwidth Constraints Model type.";
    reference
      "RFC 4127: Russian Dolls Bandwidth Constraints Model for
                 Diffserv-aware MPLS Traffic Engineering";
  }

  identity bc-model-mam {
    base bc-model-type;
    description
      "Maximum Allocation Bandwidth Constraints Model type.";
    reference
      "RFC 4125: Maximum Allocation Bandwidth Constraints Model for
                 Diffserv-aware MPLS Traffic Engineering";
  }

  identity bc-model-mar {
    base bc-model-type;
    description
      "Maximum Allocation with Reservation Bandwidth Constraints
       Model type.";
    reference
      "RFC 4126: Max Allocation with Reservation Bandwidth
       Constraints Model for Diffserv-aware MPLS Traffic Engineering
       & Performance Comparisons";
  }

  grouping performance-metrics-attributes-packet {
    description
      "Contains PM attributes.";
    uses te-types:performance-metrics-attributes {
      augment "performance-metrics-one-way" {
        leaf one-way-min-delay {
          type uint32 {
            range "0..16777215";
          }
          description
            "One-way minimum delay or latency in microseconds.";
        }
        leaf one-way-min-delay-normality {
          type te-types:performance-metrics-normality;
          default "normal";
          description
            "One-way minimum delay or latency normality.";
        }
        leaf one-way-max-delay {
          type uint32 {
            range "0..16777215";
          }
          description
            "One-way maximum delay or latency in microseconds.";
        }
        leaf one-way-max-delay-normality {
          type te-types:performance-metrics-normality;
          default "normal";
          description
            "One-way maximum delay or latency normality.";
        }
        leaf one-way-delay-variation {
          type uint32 {
            range "0..16777215";
          }
          description
            "One-way delay variation in microseconds.";
          reference
            "RFC 5481: Packet Delay Variation Applicability
             Statement, Section 4.2";
        }
        leaf one-way-delay-variation-normality {
          type te-types:performance-metrics-normality;
          default "normal";
          description
            "One-way delay variation normality.";
          reference
            "RFC 7471: OSPF Traffic Engineering (TE) Metric
             Extensions
             RFC 7823: Performance-Based Path Selection for
             Explicitly Routed Label Switched Paths (LSPs) Using
             TE Metric Extensions
             RFC 8570: IS-IS Traffic Engineering (TE) Metric
             Extensions";
        }
        leaf one-way-packet-loss {
          type decimal64 {
            fraction-digits 6;
            range "0..50.331642";
          }
          description
            "One-way packet loss as a percentage of the total traffic
             sent over a configurable interval.  The finest precision
             is 0.000003%, where the maximum is 50.331642%.";
          reference
            "RFC 8570: IS-IS Traffic Engineering (TE) Metric
             Extensions, Section 4.4";
        }
        leaf one-way-packet-loss-normality {
          type te-types:performance-metrics-normality;
          default "normal";
          description
            "Packet loss normality.";
          reference
            "RFC 7471: OSPF Traffic Engineering (TE) Metric
             Extensions
             RFC 7823: Performance-Based Path Selection for
             Explicitly Routed Label Switched Paths (LSPs) Using
             TE Metric Extensions
             RFC 8570: IS-IS Traffic Engineering (TE) Metric
             Extensions";
        }
        description
          "PM one-way packet-specific augmentation for a generic PM
           grouping.";
      }
      augment "performance-metrics-two-way" {
        leaf two-way-min-delay {
          type uint32 {
            range "0..16777215";
          }
          default "0";
          description
            "Two-way minimum delay or latency in microseconds.";
        }
        leaf two-way-min-delay-normality {
          type te-types:performance-metrics-normality;
          default "normal";
          description
            "Two-way minimum delay or latency normality.";
          reference
            "RFC 7471: OSPF Traffic Engineering (TE) Metric
             Extensions
             RFC 7823: Performance-Based Path Selection for
             Explicitly Routed Label Switched Paths (LSPs) Using
             TE Metric Extensions
             RFC 8570: IS-IS Traffic Engineering (TE) Metric
             Extensions";
        }
        leaf two-way-max-delay {
          type uint32 {
            range "0..16777215";
          }
          default "0";
          description
            "Two-way maximum delay or latency in microseconds.";
        }
        leaf two-way-max-delay-normality {
          type te-types:performance-metrics-normality;
          default "normal";
          description
            "Two-way maximum delay or latency normality.";
          reference
            "RFC 7471: OSPF Traffic Engineering (TE) Metric
             Extensions
             RFC 7823: Performance-Based Path Selection for
             Explicitly Routed Label Switched Paths (LSPs) Using
             TE Metric Extensions
             RFC 8570: IS-IS Traffic Engineering (TE) Metric
             Extensions";
        }
        leaf two-way-delay-variation {
          type uint32 {
            range "0..16777215";
          }
          default "0";
          description
            "Two-way delay variation in microseconds.";
          reference
            "RFC 5481: Packet Delay Variation Applicability
             Statement, Section 4.2";
        }
        leaf two-way-delay-variation-normality {
          type te-types:performance-metrics-normality;
          default "normal";
          description
            "Two-way delay variation normality.";
          reference
            "RFC 7471: OSPF Traffic Engineering (TE) Metric
             Extensions
             RFC 7823: Performance-Based Path Selection for
             Explicitly Routed Label Switched Paths (LSPs) Using
             TE Metric Extensions
             RFC 8570: IS-IS Traffic Engineering (TE) Metric
             Extensions";
        }
        leaf two-way-packet-loss {
          type decimal64 {
            fraction-digits 6;
            range "0..50.331642";
          }
          default "0";
          description
            "Two-way packet loss as a percentage of the total traffic
             sent over a configurable interval.  The finest precision
             is 0.000003%.";
        }
        leaf two-way-packet-loss-normality {
          type te-types:performance-metrics-normality;
          default "normal";
          description
            "Two-way packet loss normality.";
        }
        description
          "PM two-way packet-specific augmentation for a generic PM
           grouping.";
        reference
          "RFC 7471: OSPF Traffic Engineering (TE) Metric Extensions
           RFC 7823: Performance-Based Path Selection for
           Explicitly Routed Label Switched Paths (LSPs) Using
           TE Metric Extensions
           RFC 8570: IS-IS Traffic Engineering (TE) Metric
           Extensions";
      }
    }
  }

  grouping one-way-performance-metrics-packet {
    description
      "One-way packet PM throttle grouping.";
    leaf one-way-min-delay {
      type uint32 {
        range "0..16777215";
      }
      default "0";
      description
        "One-way minimum delay or latency in microseconds.";
    }
    leaf one-way-max-delay {
      type uint32 {
        range "0..16777215";
      }
      default "0";
      description
        "One-way maximum delay or latency in microseconds.";
    }
    leaf one-way-delay-variation {
      type uint32 {
        range "0..16777215";
      }
      default "0";
      description
        "One-way delay variation in microseconds.";
    }
    leaf one-way-packet-loss {
      type decimal64 {
        fraction-digits 6;
        range "0..50.331642";
      }
      default "0";
      description
        "One-way packet loss as a percentage of the total traffic
         sent over a configurable interval.  The finest precision is
         0.000003%.";
    }
  }

  grouping two-way-performance-metrics-packet {
    description
      "Two-way packet PM throttle grouping.";
    leaf two-way-min-delay {
      type uint32 {
        range "0..16777215";
      }
      default "0";
      description
        "Two-way minimum delay or latency in microseconds.";
    }
    leaf two-way-max-delay {
      type uint32 {
        range "0..16777215";
      }
      default "0";
      description
        "Two-way maximum delay or latency in microseconds.";
    }
    leaf two-way-delay-variation {
      type uint32 {
        range "0..16777215";
      }
      default "0";
      description
        "Two-way delay variation in microseconds.";
    }
    leaf two-way-packet-loss {
      type decimal64 {
        fraction-digits 6;
        range "0..50.331642";
      }
      default "0";
      description
        "Two-way packet loss as a percentage of the total traffic
         sent over a configurable interval.  The finest precision is
         0.000003%.";
    }
  }

  grouping performance-metrics-throttle-container-packet {
    description
      "Packet PM threshold grouping.";
    uses te-types:performance-metrics-throttle-container {
      augment "throttle/threshold-out" {
        uses one-way-performance-metrics-packet;
        uses two-way-performance-metrics-packet;
        description
          "PM threshold-out packet augmentation for a
           generic grouping.";
      }
      augment "throttle/threshold-in" {
        uses one-way-performance-metrics-packet;
        uses two-way-performance-metrics-packet;
        description
          "PM threshold-in packet augmentation for a
           generic grouping.";
      }
      augment "throttle/threshold-accelerated-advertisement" {
        uses one-way-performance-metrics-packet;
        uses two-way-performance-metrics-packet;
        description
          "PM accelerated advertisement packet augmentation for a
           generic grouping.";
      }
    }
  }
}