<?xml version="1.0" encoding="US-ASCII"?>
<!-- This template is for creating an Internet Draft using xml2rfc,               
    which is available here: http://xml.resource.org. -->
<!DOCTYPE rfc SYSTEM "rfc2629.dtd" [
<!-- One method to get references from the online citation libraries.             
    There has to be one entity for each item to be referenced.                    
    An alternate method (rfc include) is described in the references. -->
<!ENTITY RFC2119 SYSTEM "http://xml.resource.org/public/rfc/bibxml/reference.RFC.2119.xml">
<!ENTITY RFC2697 SYSTEM "http://xml.resource.org/public/rfc/bibxml/reference.RFC.2697.xml">
<!ENTITY RFC2698 SYSTEM "http://xml.resource.org/public/rfc/bibxml/reference.RFC.2698.xml">
<!ENTITY RFC6020 SYSTEM "http://xml.resource.org/public/rfc/bibxml/reference.RFC.6020.xml">
]>
<?xml-stylesheet type='text/xsl' href='rfc2629.xslt' ?>
<?rfc toc="yes" ?>
<?rfc tocompact="yes"?>
<?rfc tocindent="yes"?>
<?rfc symrefs="yes" ?>
<?rfc sortrefs="yes"?>
<?rfc iprnotified="no" ?>
<?rfc strict="yes" ?>
<?rfc compact="yes"?>
<?rfc subcompact="no"?>
<rfc category="exp" docName="draft-wang-netconf-adaptive-subscription-10"
     ipr="trust200902">
  <front>
    <title abbrev="Adaptive Subscription">Adaptive Subscription to YANG
    Notification</title>

    <author fullname="Qin Wu" initials="Q." surname="Wu">
      <organization>Huawei</organization>

      <address>
        <postal>
          <street>101 Software Avenue, Yuhua District</street>

          <city>Nanjing</city>

          <region>Jiangsu</region>

          <code>210012</code>

          <country>China</country>
        </postal>

        <email>bill.wu@huawei.com</email>
      </address>
    </author>

    <author fullname="Wei Song" initials="W." surname="Song">
      <organization>Huawei</organization>

      <address>
        <postal>
          <street>101 Software Avenue, Yuhua District</street>

          <city>Nanjing</city>

          <region>Jiangsu</region>

          <code>210012</code>

          <country>China</country>
        </postal>

        <email>songwei80@huawei.com</email>
      </address>
    </author>

    <author fullname="Peng Liu" initials="P." surname="Liu">
      <organization>China Mobile</organization>

      <address>
        <postal>
          <street>32 Xuanwumen West St, Xicheng District</street>

          <city>Beijing</city>

          <code>10053</code>
        </postal>

        <email>liupengyjy@chinamobile.com</email>
      </address>
    </author>

    <author fullname="Qiufang Ma" initials="Q." surname="Ma">
      <organization>Huawei</organization>

      <address>
        <postal>
          <street>101 Software Avenue, Yuhua District</street>

          <city>Nanjing</city>

          <region>Jiangsu</region>

          <code>210012</code>

          <country>China</country>
        </postal>

        <email>maqiufang1@huawei.com</email>
      </address>
    </author>

    <author fullname="Wei Wang" initials="W." surname="Wang">
      <organization>China Telecom</organization>

      <address>
        <postal>
          <street>32 Xuanwumen West St, Xicheng District</street>

          <city>Beijing</city>

          <code>102209</code>
        </postal>

        <email>wangw36@chinatelecom.cn</email>
      </address>
    </author>

	<author fullname="Zhixiong Niu" initials="Z." surname="Niu">
      <organization>Microsoft</organization>

      <address>
        <email>Zhixiong.Niu@microsoft.com</email>
      </address>
    </author>
	
    <date year="2022"/>

    <area>OPS Area</area>

    <workgroup>NETCONF Working Group</workgroup>

    <abstract>
      <t>This document defines a YANG data model and associated mechanism
      enabling the subscriber's adaptive subscriptions to a publisher's event
      streams with various different period intervals to report updates.
      Applying these elements allows servers automatically adjust the rate and
      volume of telemetry traffic sent from a publisher to receivers.</t>
    </abstract>
  </front>

  <middle>
    <section anchor="intro" title="Introduction">
      <t>YANG-Push subscriptions [RFC8641] allow subscriber applications to
      request a continuous customized stream of updates from a YANG datastore
      without needing to poll. It defines a mechanism (i.e., update trigger)
      to determine when an update record needs to be generated. Two types of
      subscriptions are introduced in [RFC8641], distinguished by how updates
      are triggered: periodic and on-change.<list style="symbols">
          <t>Periodic subscription allows subscribed data to be streamed to
          the destination at a configured fixed periodic interval;</t>

          <t>On-change subscription allows update to be triggered whenever a
          change in the subscribed information is detected.</t>
        </list></t>

      <t>However in some large scale deployments (e.g., massive data
      collection for wireless network performance monitoring) where an
      increased data collection rate is used, it becomes more likely that both
      clients and servers are temporarily overwhelmed with a burst of streamed
      data and consumes expensive network resource (e.g., bandwidth resource,
      radio resource) and computation resource, therefore hard to continuously
      monitor operational data, especially values that fall outside normal
      operational ranges. If the rate at which we can collect a stream of data
      is set too low or chosen to get low priority telemetry data dropped,
      these telemetry data are not sufficient to detect and diagnose problems
      and verify correct network behavior.</t>

      <t>A client might choose to monitor the operational state and send a
      request to modify the data collection rate on the server. But how often
      the client evaluates if the modification of the data collection rate is
      required highly depends on the current collection rate, collecting a
      stream of data at a low rate prevents the subscriber from capturing
      sufficient data for timely decision-making, which may result in service
      discontinuity. In addition, when tens of thousands of network devices
      need to be managed, frequent follow-up modification requests are prone
      to errors.</t>

      <t>There is a need for a service to balance between data management cost
      and real time streaming telemetry. To achieve this, servers can be
      configured with multiple different period intervals and corresponding
      subscription update policy which allows servers/publishers automatically
      switch to different period intervals according to the network condition
      change without the interaction with the client for policy update
      instruction, e.g., when the wireless signal strength falls below a
      configured threshold, the subscribed data can be streamed at a higher
      rate to capture potentially important data and events (e.g., continuous
      service degeneration); while when the wireless signal strength crosses a
      configured threshold, the subscribed data can be streamed at a lower
      rate.</t>

      <t>This document defines a YANG data model and associated mechanism
      enabling the subscriber's adaptive subscriptions to a publisher's event
      streams. Applying these elements allows servers to automatically adjust
      the rate and volume of telemetry traffic sent from a publisher to
      receivers.</t>

      <section title="Terminology">
        <t>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.</t>

        <t>The following terms are defined in [RFC5277] [RFC7950] [RFC3198]
        [RFC8342] [RFC8639] [RFC8641] and are not redefined here:<list
            style="symbols">
            <t>Event</t>

            <t>Client</t>

            <t>Configuration</t>

            <t>Configured subscription</t>

            <t>Configuration datastore</t>

            <t>Notification message</t>

            <t>Publisher</t>

            <t>Receiver</t>

            <t>Subscriber</t>

            <t>Subscription</t>

            <t>On-change subscription</t>

            <t>Periodic subscription</t>

            <t>Selection filter</t>
          </list></t>

        <t>This document defines the following term:<list style="hanging">
            <t hangText="Adaptive Subscription:">Apply subscription update
            policy on the servers and allow servers/publishers automatically
            switch to different period intervals according to the network
            condition change without the interaction with the client for
            update policy instruction.</t>
          </list></t>
      </section>
    </section>

    <!-- intro -->

    <section anchor="model" title="Model Overview">
      <t>This document defines a YANG module "ietf-adaptive-subscription",
      which augments the "update-trigger" choice defined in the
      "ietf-yang-push" module [RFC8641] with subscription configuration
      parameters that are specific to a subscriber's adaptive
      subscription.</t>

      <t>In addition to subscription state notifications defined in [RFC8639]
      and notifications for subscribed content defined in [RFC8641],
      "ietf-adaptive-subscription" YANG module also defines
      "adaptive-period-update" notification to report the update interval
      change.</t>

      <t>The following tree diagrams [RFC8340] provide an overview of the data
      model for "ietf-adaptive-subscription" module.</t>

      <figure>
        <artwork>module: ietf-adaptive-subscription
  augment /sn:subscriptions/sn:subscription/yp:update-trigger:
    +--rw (adaptive-subscription)?
       +--:(adaptive-subscriptions)
          +--rw adaptive-subscriptions
              +--rw adaptive-period* [name]
                +--rw name                    string
                +--rw xpath-external-eval     string
                +--rw period                  yp:centiseconds
                +--rw anchor-time?            yang:date-and-time
  augment /sn:establish-subscription/sn:input/yp:update-trigger:
    +-- (adaptive-subscription)?
       +--:(adaptive-subscriptions)
          +--rw adaptive-subscriptions
             +--rw adaptive-period* [name]
                +--rw name                    string
                +--rw xpath-external-eval     string
                +--rw period                  yp:centiseconds
                +--rw anchor-time?            yang:date-and-time
  notifications:
    +---n adaptive-period-update
       +--ro id?                                     sn:subscription-id
       +--ro period                                  yp:centiseconds
       +--ro anchor-time?                            yang:date-and-time
       +--ro (selection-filter)?
          +--:(by-reference)
          |  +--ro selection-filter-ref              selection-filter-ref
          +--:(within-subscription)
             +--ro (filter-spec)?
                +--:(datastore-subtree-filter)
                |  +--ro datastore-subtree-filter?   &lt;anydata&gt; {sn:subtree}?
                +--:(datastore-xpath-filter)
                   +--ro datastore-xpath-filter?     yang:xpath1.0 {sn:xpath}?</artwork>
      </figure>

      <section anchor="sub" title="Subscription Configuration">
        <t>For adaptive subscriptions, triggered updates will occur at the
        boundaries of specified time intervals when a trigger condition is
        satisfied. These boundaries can be calculated from the following
        adaptive periodic parameters: <list style="symbols">
            <t>a "name" represents the name of each adaptive period;</t>

            <t>a "period" that defines the new duration between push updates.
            The period can be switched based on trigger conditions;</t>

            <t>an "anchor-time"; update intervals fall on the points in time
            that are a multiple of a "period" from an "anchor-time". If an
            "anchor-time" is not provided, then the "anchor-time" MUST be set
            with the creation time of the initial update record.</t>

            <t>an "xpath-external-eval" represents a standard XPath evaluation
            expression (See section 6.4 of [RFC7950]) that is applied against
            the targeted data object, which is used to trigger/control the
            update interval switching within the server. It follows the rules
            defined in section 3.4 of [XPATH1.0] and contains comparisons of
            the targeted datastore node with its value to the specific
            threshold in the XPath format. Different from selection filter
            defined in [RFC8641], <list style="symbols">
                <t>it is applied against a single targeted object rather than
                a set of target objects.</t>

                <t>it monitors a specific data object change and evaluates the
                trigger condition associated with the targeted object to be
                true or false using XPATH rules and does not influence the
                event records output generation from a publisher.</t>
              </list>How often the XPath expression criterion is evaluated is
            up to the publisher's implementation. With minimal delay, the
            expression can be evaluated whenever changes to targeted object
            occur, or at the end of each high-frequency streaming update
            period. To reduce the frequency of evaluation, the server can
            choose to check targeted object change at every multiple (e.g.,2
            or 3) high-frequency streaming update periods.<vspace
            blankLines="1"/>The represented expression defined in
            "xpath-external-eval" is evaluated in the following XPath
            context:<list style="symbols">
                <t>The set of namespace declarations is the set of prefix and
                namespace pairs for all YANG modules implemented by the
                server, where the prefix is the YANG module name and the
                namespace is as defined by the "namespace" statement in the
                YANG module.</t>

                <t>If the leaf is encoded in XML, all namespace declarations
                in scope on the "xpath-external-eval" leaf element are added
                to the set of namespace declarations. If a prefix found in the
                XML is already present in the set of namespace declarations,
                the namespace in the XML is used.</t>

                <t>The set of variable bindings is empty.</t>

                <t>The function library is the core function library defined
                in [XPATH1.0] and the function defined in Section 10 in RFC
                7950.</t>

                <t>The context node is the root node.</t>
              </list>For the cases where multiple list instances are needed to
            handle in "xpath-external-eval", XPath abbreviated syntax can be
            used to identify a particular instance, e.g., to represent a
            comparison for a leaf in a list entry: <figure align="center">
                <artwork>   /if:interfaces/if:interface[if:name="eth0"]/if:in-errors&gt;1000.</artwork>
              </figure>The server MUST convert the XPath expression defined in
            "xpath-external-eval" to a boolean value and internally apply the
            "boolean" function defined in Section 4.3 in [XPATH1.0] if the
            evaluated result is not a boolean.</t>
          </list>Note that the adaptive subscription may not be supported by
        every YANG datastore nodes. A publisher MAY decide to simply reject an
        adaptive subscription with "adaptive-unsupported" (defined in <xref
        target="errors"/>) if the scope of the subscription contains selected
        data nodes for which adaptive subscription is not supported.</t>
      </section>

      <section title="YANG RPC">
        <section title="&quot;establish-subscription&quot; RPC">
          <t>The augmentation of YANG module "ietf-yang-push" made to RPCs
          specified in YANG module "ietf-subscribed-notifications" [RFC8639]
          is introduced. This augmentation concerns the
          "establish-subscription" RPC, which is augmented with parameters
          that are needed to specify a subscriber's adaptive subscriptions.
          These parameters are the same as ones defined in <xref
          target="sub"/>.</t>

          <section anchor="errors" title="RPC Failures">
            <t>As specified in [RFC8639] and [RFC8641], RPC error responses
            from the publisher are used to indicate a rejection of an RPC for
            any reason. This document introduces three new RPC errors for
            "establish-subscription" RPC.</t>

            <figure>
              <artwork>establish-subscription
-----------------------------
adaptive-unsupported
xpath-evaluation-unsupported
multi-xpath-criteria-conflict</artwork>
            </figure>

            <t>Adaptive-unsupported is used to indicate that the adaptive
            subscription is not supported for any objects that are selectable
            by the filter.</t>

            <t>Xpath-evaluation-unsupported is used to indicate that a server
            fails to parse syntax defined in "xpath-external-eval". The
            failure can be caused by either a syntax error or some XPath 1.0
            syntax not supported against the specific object.</t>

            <t>Multi-xpath-criteria-conflict is used to indicate that the
            multiple Xpath evaluation criteria represented by
            "xpath-external-eval" is evaluated as conflict, i.e., more than
            one condition expressions are evaluated to "true". Such a conflict
            may also cause an ongoing adaptive-subscription terminated.</t>

            <t>For an example of how above RPC errors can be returned, see the
            "xpath-evaluation-unsupported" error response illustrated in <xref
            target="failure_example"/>.</t>
          </section>
        </section>
      </section>

      <section title="Notifications for Adaptive Subscribed Content ">
        <t>The adaptive update notification is similar to subscription state
        change notifications defined in [RFC8639]. It is inserted into the
        sequence of notification messages sent to a particular receiver. The
        adaptive update notification cannot be dropped or filtered out, it
        cannot be stored in replay buffers, and it is delivered only to
        impacted receivers of a subscription. The identification of adaptive
        update notification is easy to separate from other notification
        messages through the use of the YANG extension
        "subscription-state-notif". This extension tags a notification as a
        subscription state change notification.</t>

        <t>The objects in the 'adaptive-period-update' notification
        include:<list style="symbols">
            <t>a "period" that defines the duration between push updates, the
            period can be changed based on trigger conditions.</t>

            <t>an "anchor-time"; update intervals fall on the points in time
            that are a multiple of a "period" from an "anchor-time". If an
            "anchor-time" is not provided, then the "anchor-time" MUST be set
            with the creation time of the initial update record.</t>

            <t>A selection filter is to identify YANG nodes of interest in a
            datastore. Filter contents are specified via a reference to an
            existing filter or via an in-line definition for only that
            subscription based on XPath Evaluation criteria defined in section
            6.4 of [RFC7950]. Referenced filters allow an implementation to
            avoid evaluating filter acceptability during a dynamic
            subscription request. The "case" statement differentiates the
            options. Note that filter contents are not affected by
            "xpath-external-eval" parameter defined by the update trigger.</t>
          </list></t>
      </section>
    </section>

    <section title="XPath Complexity Evaluation">
      <t>YANG-Push subscriptions [RFC8641] specify selection filters to
      identify targeted YANG datastore nodes and/or datastore subtrees for
      which updates are to be pushed. In addition, it specifies update
      policies which contain conditions that trigger generation and pushing of
      new update records. To support a subscriber's adaptive subscription
      defined in this document, the trigger condition can also use similar
      selection filters to express a standard XPath Evaluation criterion
      (section 6.4 of [RFC7950]) against targeted data objects.</t>

      <t>Similar to on-change subscriptions, adaptive subscriptions are
      particularly effective for data that changes infrequently, the following
      complex design choices need to be cautious, although these designs have
      already been well supported by the section 3.4 of [XPATH1.0]:<list
          style="symbols">
          <t>Support XPath Evaluation criteria against every data object;</t>

          <t>Support more than one target object selection and operation(e.g.,
          addition, subtraction, division and multiplication) in the XPath
          evaluation criterion;</t>

          <t>Support any type of node set in the XPath evaluation criterion,
          e.g., string,int64, uint64, and decimal64 types;</t>

          <t>Both objects in the XPath Evaluation criterion to be compared are
          node-sets;</t>

          <t>Two objects to be compared are in different data types, e.g., one
          is an integer, the other is a string</t>
        </list></t>

      <t>As described in section 6.4 of RFC7950, Numbers in XPath 1.0 are IEEE
      754 [IEEE754-2008] double-precision floating-point values; some values
      of int64, uint64, and decimal64 types cannot be exactly represented in
      XPath expressions.</t>

      <t>If two objects to be compared are in different data types, conversion
      function is needed to convert different data types into numbers.</t>

      <t>If both objects in XPath Evaluation criteria to be compared are
      node-sets, more computation resources are required which add
      complexity.</t>

      <t>To reduce these complexities, the following design principles are
      recommended:<list style="symbols">
          <t>XPath Evaluation criteria against a minimal set of data objects
          in the data model, the minimal set of data objects can be advertised
          using Notification capabilities model defined in [RFC9196].</t>

          <t>XPath Evaluation criteria only support condition expressions that
          filter updates based on numbers.</t>

          <t>One object to be compared in the XPath Evaluation criteria MUST
          be a leaf data node.</t>

          <t>The other object to be compared in the XPath Evaluation criteria
          MUST be a number data type.</t>
        </list></t>

      <t>If a server receives an XPath Evaluation criterion with some XPath
      syntax unsupported against the specific object, an RPC error with
      "xpath-evaluation-unsupported" should be returned.</t>
    </section>

    <section anchor="adaptive" title="Adaptive Subscription YANG Module">
      <figure>
        <artwork>&lt;CODE BEGINS&gt; file "ietf-adaptive-subscription@2020-02-14.yang"
module ietf-adaptive-subscription {
  yang-version 1.1;
  namespace "urn:ietf:params:xml:ns:yang:ietf-adaptive-subscription";
  prefix as;
  import ietf-subscribed-notifications {
    prefix sn;
  }
  import ietf-yang-push {
    prefix yp;
  }
  import ietf-yang-types {
    prefix yang;
  }

  organization
    "IETF NETCONF (Network Configuration) Working Group";
  contact
    "";
  description
    "NETCONF Protocol Data Types and Protocol Operations.
     Copyright (c) 2020 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 2020-02-14 {
    description
      "Initial revision";
    reference
      "RFCxxx Adaptive subscription to YANG notification.";
  }

  identity adaptive-unsupported {
    base sn:establish-subscription-error;
    description
      "Adaptive-subscription is not supported for any objects
       that are selectable by the filter.";
  }

  identity xpath-evaluation-unsupported {
    base sn:establish-subscription-error;
    description 
      "Unable to parse the xpath evaluation criteria defined in 
      &lsquo;xpath-external-eval&rsquo; because of a syntax error or some 
       XPath 1.0 syntax not supported against the specific object.";
  }

  identity multi-xpath-criteria-conflict {
    base sn:establish-subscription-error;
    base sn:subscription-terminated-reason;
    description
      "Multiple Xpath evaluation criteria represented by 
       'xpath-external-eval' is evaluated as conflict, i.e.,
       more than one condition expressions are evaluated to 
      'true'.";
}

  grouping adaptive-subscription-modifiable {
    description
      "This grouping describes the datastore-specific adaptive subscription
       conditions that can be changed during the lifetime of the
       subscription.";
    choice adaptive-subscription {
      description
        "Defines necessary conditions for sending an event record to
               the subscriber.";
      container adaptive-subscriptions {
        list adaptive-period {
          key "name";
          description
            "Defines necessary conditions to switch update interval for 
            sending an event record to the subscriber. The event record output
            generation will not be influenced these conditions.";
          leaf name {
            type string {
          length "1..64";
           }
        description
          "The name of the condition to be matched.  A device MAY further
           restrict the length of this name; space and special
           characters are not allowed.";
         }
          leaf xpath-external-eval {
            type string;
            description
              "A XPath string, representing a logical expression,
               which can contain comparisons of datastore values
               and logical operations in the XPath format.";
          }
          leaf period {
            type yp:centiseconds;
            mandatory true;
            description
              "Duration of time that should occur between periodic
               push updates, in units of 0.01 seconds.";
          }
          leaf anchor-time {
            type yang:date-and-time;
            description
              "Designates a timestamp before or after which a series
               of periodic push updates are determined.  The next
               update will take place at a point in time that is a
               multiple of a period from the 'anchor-time'.
               For example, for an 'anchor-time' that is set for the
               top of a particular minute and a period interval of a
               minute, updates will be sent at the top of every
               minute that this subscription is active.";
          }
        }
        description
          "Container for adaptive subscription.";
      }
    }
  }

  augment "/sn:subscriptions/sn:subscription/yp:update-trigger" {
    description
      "This augmentation adds additional subscription parameters
       that apply specifically to adaptive subscription.";
    uses adaptive-subscription-modifiable;
  }
  augment "/sn:establish-subscription/sn:input/yp:update-trigger" {
    description
      "This augmentation adds additional subscription parameters
         that apply specifically to datastore updates to RPC input.";
    uses adaptive-subscription-modifiable;
  }

  notification adaptive-period-update {
    sn:subscription-state-notification;
    description
      "This notification contains a push update that in turn contains
       data subscribed to via a subscription.  In the case of a
       periodic subscription, this notification is sent for periodic
       updates.  It can also be used for synchronization updates of
       an on-change subscription.  This notification shall only be
       sent to receivers of a subscription.  It does not constitute
       a general-purpose notification that would be subscribable as
       part of the NETCONF event stream by any receiver.";
    leaf id {
      type sn:subscription-id;
      description
        "This references the subscription that drove the
         notification to be sent.";
    }
    leaf period {
      type yp:centiseconds;
      mandatory true;
      description
        "New duration of time that should occur between periodic
         push updates, in units of 0.01 seconds.";
    }
    leaf anchor-time {
      type yang:date-and-time;
      description
        "Designates a timestamp before or after which a series
         of periodic push updates are determined.  The next
         update will take place at a point in time that is a
         multiple of a period from the 'anchor-time'.
         For example, for an 'anchor-time' that is set for the
         top of a particular minute and a period interval of a
         minute, updates will be sent at the top of every
         minute that this subscription is active.";
    }
    uses yp:datastore-criteria {
      refine "selection-filter/within-subscription" {
        description
          "Specifies the selection filter and where it originated
           from.  If the 'selection-filter-ref' is populated, the
           filter in the subscription came from the 'filters'
           container.  Otherwise, it is populated in-line as part
           of the subscription itself.";
      }
    }
  }
}
&lt;CODE ENDS&gt;</artwork>
      </figure>
    </section>

    <section title="IANA Considerations">
      <section anchor="xml" title="Updates to the IETF XML Registry">
        <t>This document registers one URI in the IETF XML registry [RFC3688].
        Following the format in [RFC3688], the following registration is
        requested to be made:</t>

        <figure>
          <artwork>   ---------------------------------------------------------------------
      URI: urn:ietf:params:xml:ns:yang:ietf-adaptive-subscription
      Registrant Contact: The IESG.
      XML: N/A, the requested URI is an XML namespace.
   ---------------------------------------------------------------------</artwork>
        </figure>
      </section>

      <section anchor="module"
               title="Updates to the YANG Module Names Registry">
        <t>This document registers one YANG module in the YANG Module Names
        registry [RFC7950]. Following the format in [RFC6020], the following
        registration is requested to be made:</t>

        <figure>
          <artwork>   ---------------------------------------------------------------------
      Name:         ietf-adaptive-subscription
      Namespace:    urn:ietf:params:xml:ns:yang:ietf-adaptive-subscription
      Prefix:       as
      Reference:    RFC xxxx
   ---------------------------------------------------------------------</artwork>
        </figure>
      </section>
    </section>

    <section anchor="security" title="Security Considerations">
      <t>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 [RFC8446].</t>

      <t>The NETCONF Configuration Access Control Model (NACM) [RFC8341]
      provides the means to restrict access for particular NETCONF or RESTCONF
      users to a preconfigured subset of all available NETCONF or RESTCONF
      protocol operations and content.</t>

      <t>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 in some network
      environments. Write operations (e.g., edit-config) to these data nodes
      without proper protection can have a negative effect on network
      operations. These are the subtrees and data nodes and their
      sensitivity/vulnerability:<list style="symbols">
          <t>/sn:subscriptions/sn:subscription/yp:update-trigger/as:adaptive-subscriptions/as:adaptive-period/as:period</t>

          <t>/sn:subscriptions/sn:subscription/yp:update-trigger/as:adaptive-subscriptions/as:adaptive-period/as:anchor-time</t>

          <t>/sn:establish-subscription/sn:input/yp:update-trigger/as:adaptive-subscriptions/as:adaptive-period/as:period</t>

          <t>/sn:establish-subscription/sn:input/yp:update-trigger/as:adaptive-subscriptions/as:adaptive-period/as:anchor-time</t>
        </list></t>
    </section>

    <section title="Contributors">
      <t>Thanks Michael Wang, Liang Geng for their major contributions to the
      initial modeling and use cases.</t>

      <figure>
        <artwork>   Michael Wang
   Email: wangzitao@huawei.com

   Liang Geng
   China Mobile
   32 Xuanwumen West St, Xicheng District
   Beijing  10053

   Email: gengliang@chinamobile.com
</artwork>
      </figure>
    </section>

    <section title="Acknowledges">
      <t>We would like to thank Rob Wilton, Thomas Graf, Andy Bierman, Michael
      Richardson, Henk Birkholz for valuable review on this document, special
      thanks to Thomas and Michael for organizing the discussion on several
      relevant drafts and reach the common understanding on the concept and
      ideas. Thanks Michael for providing CHIP/Matter WIFI statistics
      reference.</t>
    </section>

    <!---->
  </middle>

  <back>
    <references title="Normative References">
      <?rfc include="reference.RFC.2119.xml"?>

      <?rfc include="reference.RFC.8174.xml"?>

      <?rfc include="reference.RFC.7950.xml"?>

      <?rfc include="reference.RFC.8342.xml"?>

      <?rfc include="reference.RFC.8407.xml"?>

      <?rfc include="reference.RFC.8126.xml"?>

      <?rfc include="reference.RFC.8040.xml"?>

      <?rfc include="reference.RFC.6241.xml"?>

      <?rfc include="reference.RFC.6242.xml"?>

      <?rfc include="reference.RFC.8341.xml"?>

      <?rfc include="reference.RFC.8446.xml"?>

      <?rfc include="reference.RFC.8641.xml"?>

      <?rfc include="reference.RFC.9196.xml"?>
    </references>

    <references title="Informative References">
      <?rfc include="reference.RFC.3688.xml"?>

      <?rfc include="reference.RFC.6020.xml"?>

      <?rfc include="reference.RFC.8340.xml"?>

      <reference anchor="CHIP">
        <front>
          <title>Connected Home over IP Specification</title>

          <author>
            <organization>CSA</organization>
          </author>

          <date month="April" year="2021"/>
        </front>
      </reference>

      <reference anchor="XPATH1.0">
        <front>
          <title>https://www.w3.org/TR/1999/REC-xpath-19991116/</title>

          <author>
            <organization>W3C</organization>
          </author>

          <date day="11" month="November" year="1999"/>
        </front>
      </reference>
    </references>

    <section title="Example YANG Module">
      <t>The example YANG module used in this document represents a Wi-Fi
      Network Diagnostics data specified in [CHIP] which can be used by a Node
      to assist a user or Administrative Node in diagnosing potential
      problems.</t>

      <t>YANG tree diagram for the "example-wifi-network-diagnostic"
      module:<figure>
          <artwork>module: example-wifi-network-diagnostic
  +--rw server
  |  +--rw bssid?                       yang:mac-address
  |  +--rw security-type?               enumeration
  |  +--rw wifi-version?                enumeration
  |  +--rw channel-num?                 int8
  |  +--rw rssi?                        int8
  |  +--rw beacon-lost-count?           int8
  |  +--rw beacon-rx-count?             int8
  |  +--rw packet-multicast-rx-count?   int8
  |  +--rw packet-multicast-tx-count?   int8
  |  +--rw packet-unicast-rx-count?     int8
  |  +--rw packet-unicast-tx-count?     int8
  |  +--rw current-max-rate?            int8
  |  +--rw overrun-count?               int8
  +--rw events
     +--rw event* [name]
        +--rw name                   string
        +--rw disconnection?         enumeration
        +--rw association-failure?   enumeration
        +--rw connection-status?     enumeration</artwork>
        </figure></t>

      <section title="&quot;example-wifi-mac&quot; YANG Module ">
        <figure>
          <artwork>module example-wifi-network-diagnostic {
  yang-version 1;
  namespace "http://example.com/yang/wifi-network-diagnostic";
  prefix wnd;

  import ietf-yang-types {
    prefix yang;
  }

  container server {
    description
      "Configuration of the WiFi Server logical entity.";
    leaf bssid {
      type yang:mac-address;
      description
        "The MAC address of a wireless access point.";
    }
    leaf security-type {
      type enumeration {
        enum unspecified {
          value 0;
        }
        enum none {
          value 1;
        }
        enum wep {
          value 2;
        }
        enum wpa {
          value 3;
        }
        enum wpa2 {
          value 4;
        }
        enum wpa3 {
          value 5;
        }
      }
      description
        "The type of Wi-Fi security used. A value of 0
         indicate that the interface is not currently
         configured or operational.";
    }
    leaf wifi-version {
      type enumeration {
        enum 80211a {
          value 0;
        }
        enum 80211b {
          value 1;
        }
        enum 80211g {
          value 2;
        }
        enum 80211n {
          value 3;
        }
        enum 80211ac {
          value 4;
        }
        enum 80211ax {
          value 5;
        }
      }
      description
        "The highest 802.11 standard version usable
         by the Node.";
    }
    leaf channel-num {
      type int8;
      description
        "The channel that Wi-Fi communication is currently
         operating on. A value of 0indicates that the interface
         is not currently configured or operational.";
    }
    leaf rssi {
      type int8;
      description
        "The RSSI of the Node&rsquo;s Wi-Fi radio in dBm.";
    }
    leaf beacon-lost-count {
      type int8;
      description
        "The count of the number of missed beacons the
         Node has detected.";
    }
    leaf beacon-rx-count {
      type int8;
      description
        "The count of the number of received beacons. The
         total number of expected beacons that could have been
         received during the interval since association SHOULD
         match the sum of BeaconRxCount and BeaconLostCount. ";
    }
    leaf packet-multicast-rx-count {
      type int8;
      description
        "The number of multicast packets received by
         the Node.";
    }
    leaf packet-multicast-tx-count {
      type int8;
      description
        "The number of multicast packets transmitted by
         the Node.";
    }
    leaf packet-unicast-rx-count {
      type int8;
      description
        "The number of multicast packets received by
         the Node.";
    }
    leaf packet-unicast-tx-count {
      type int8;
      description
        "The number of multicast packets transmitted by
         the Node.";
    }
    leaf current-max-rate {
      type int8;
      description
        "The current maximum PHY rate of transfer of
         data in bytes-per-second.";
    }
    leaf overrun-count {
      type int8;
      description
        "The number of packets dropped either at ingress or
         egress, due to lack of buffer memory to retain all
         packets on the ethernet network interface. The
         OverrunCount attribute SHALL be reset to 0 upon a
         reboot of the Node..";
    }
  }
  container events {
    description
      "Configuration of WIFI Network Diagnostic events.";
    list event {
      key "name";
      description
        "The list of event sources configured on the
         server.";
      leaf name {
        type string;
        description
          "The unique name of an event source.";
      }
      leaf disconnection {
        type enumeration {
          enum de-authenticated {
            value 1;
          }
          enum dis-association {
            value 2;
          }
        }
        description
          "A Node&rsquo;s Wi-Fi connection has been disconnected as a
           result of de-authenticated or dis-association and
           indicates the reason.";
      }
      leaf association-failure {
        type enumeration {
          enum unknown {
            value 0;
          }
          enum association-failed {
            value 1;
          }
          enum authentication-failed {
            value 2;
          }
          enum ssid-not-found {
            value 3;
          }
        }
        description
          "A Node has attempted to connect, or reconnect, to
           a Wi-Fi access point, but is unable to successfully
           associate or authenticate, after exhausting all
           internal retries of its supplicant.";
      }
      leaf connection-status {
        type enumeration {
          enum connected {
            value 1;
          }
          enum notconnected {
            value 2;
          }
        }
        description
          "A Node's connection status to a Wi-Fi network has
           changed. Connected, in this context, SHALL mean that
           a Node acting as a Wi-Fi station is successfully
           associated to a Wi-Fi Access Point.";
      }
    }
  }
}
</artwork>
        </figure>
      </section>
    </section>

    <section title="Adaptive Subscription and Notification Example">
      <t>The examples within this document use the normative YANG module
      "ietf-adaptive-subscription" defined in <xref target="adaptive"/> and
      the non-normative example YANG module "example-wifi-network-diagnostic"
      defined in Appendix A.1.</t>

      <t>This section shows some typical adaptive subscription and
      notification message exchanges.</t>

      <section title="&quot;edit-config&quot; Example">
        <t>The client configures adaptive subscription policy parameters on
        the server. The adaptive subscription configuration parameters require
        the server to support two update intervals (i.e., 5 seconds, 60
        seconds) and report updates every 60 seconds if the rssi value is
        greater than or equal to -65dB; If the rssi value is less than -65dB,
        switch to 5 seconds period value to report updates.</t>

        <figure>
          <artwork> &lt;rpc message-id="101"
  xmlns="urn:ietf:params:xml:ns:netconf:base:1.0"&gt;
  &lt;edit-config&gt;
   &lt;target&gt;
    &lt;running/&gt;
   &lt;/target&gt;
   &lt;config
    xmlns:xc="urn:ietf:params:xml:ns:netconf:base:1.0"&gt;
    &lt;top
     xmlns="http://example.com/schema/1.2/config"
     xmlns:yp="urn:ietf:params:xml:ns:yang:ietf-yang-push"&gt;
     &lt;yp:datastore
      xmlns:ds="urn:ietf:params:xml:ns:yang:ietf-datastores"&gt;
              ds:running
     &lt;/yp:datastore&gt;
     &lt;yp:datastore-xpath-filter
      xmlns:wnd="https://example.com/sample-data/1.0"&gt;
             /wnd:example-wifi-network-diagnostic
     &lt;/yp:datastore-xpath-filter&gt;
     &lt;as:adaptive-subscriptions
      xmlns:as="urn:ietf:params:xml:ns:yang:ietf-adaptive-subscription"&gt;
      &lt;as:adaptive-period&gt;
       &lt;as:xpath-external-eval&gt;
        /wnd:server/wnd:rssi&amp;lt;-65
       &lt;/as:xpath-external-eval&gt;
       &lt;as:period&gt;5&lt;/as:period&gt;
      &lt;/as:adaptive-period&gt;
      &lt;as:adaptive-period&gt;
       &lt;as:xpath-external-eval&gt;
        /wnd:server/wnd:rssi&amp;gt;=-65
       &lt;/as:xpath-external-eval&gt;
       &lt;as:period&gt;60&lt;/as:period&gt;
     &lt;/as:adaptive-period&gt;
     &lt;/as:adaptive-subscriptions&gt;
    &lt;/top&gt;
   &lt;/config&gt;
  &lt;/edit-config&gt;
 &lt;/rpc&gt;</artwork>
        </figure>
      </section>

      <section title="Create Adaptive Subscription Example">
        <t>The subscriber sends an "establish-subscription" RPC with the
        parameters listed in <xref target="model"> to request the creation of
        an adaptive subscription. The adaptive subscription configuration
        parameters require the server to report updates every 5 seconds if the
        rssi value is less than -65dB; If the rssi value is greater than or
        equal to -65dB, switch to 60 seconds period value.</xref></t>

        <figure>
          <artwork>&lt;netconf:rpc message-id="101"
 xmlns:netconf="urn:ietf:params:xml:ns:netconf:base:1.0"&gt;
 &lt;establish-subscription
  xmlns="urn:ietf:params:xml:ns:yang:ietf-subscribed-notifications"
  xmlns:yp="urn:ietf:params:xml:ns:yang:ietf-yang-push"&gt;
  &lt;yp:datastore
   xmlns:ds="urn:ietf:params:xml:ns:yang:ietf-datastores"&gt;
          ds:running
  &lt;/yp:datastore&gt;
  &lt;yp:datastore-xpath-filter
   xmlns:wnd="https://example.com/sample-data/1.0"&gt;
       /wnd:example-wifi-network-diagnostic
  &lt;/yp:datastore-xpath-filter&gt;
  &lt;as:adaptive-subscriptions
   xmlns:as="urn:ietf:params:xml:ns:yang:ietf-adaptive-subscription"&gt;
   &lt;as:adaptive-period&gt;
    &lt;as:xpath-external-eval&gt;
     wnd:server/wnd:rssi&amp;lt;-65
    &lt;/as:xpath-external-eval&gt;
    &lt;as:period&gt;5&lt;/as:period&gt;
   &lt;/as:adaptive-period&gt;
   &lt;as:adaptive-period&gt;
    &lt;as:xpath-external-eval&gt;
     wnd:server/wnd:rssi&amp;gt;=-65
    &lt;/as:xpath-external-eval&gt;
    &lt;as:period&gt;60&lt;/as:period&gt;
   &lt;/as:adaptive-period&gt;
  &lt;/as:adaptive-subscriptions&gt;
 &lt;/establish-subscription&gt;
&lt;/netconf:rpc&gt;</artwork>
        </figure>
      </section>

      <section anchor="failure_example"
               title="&quot;xpath-evaluation-unsupported&quot; error response example">
        <t>If the subscriber has authorization to establish the subscription
        with a server, but the server had not been able to fully satisfy the
        request from the subscriber, the server should send an RPC error
        response.</t>

        <t>For instance, if the XPATH 1.0 syntax against the targeted data
        object defined in "xpath-external-eval" is not supported by the
        server' s implementation, the server returns a reply indicating a
        failure. The following &lt;rpc-reply&gt; illustrates an example:</t>

        <figure>
          <artwork>&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;rpc-reply xmlns="urn:ietf:params:xml:ns:netconf:base:1.0" message-id="101"&gt;  
  &lt;rpc-error&gt; 
    &lt;error-type&gt;application&lt;/error-type&gt;  
    &lt;error-tag&gt;invalid-value&lt;/error-tag&gt;  
    &lt;error-severity&gt;error&lt;/error-severity&gt;  
    &lt;error-app-tag&gt;
      ietf-adaptive-subscription:xpath-evaluation-unsupported
    &lt;/error-app-tag&gt;  
    &lt;error-path xmlns:wnd="https://example.com/sample-data/1.0"&gt; 
      /wnd:server/wnd:rssi
    &lt;/error-path&gt; 
  &lt;/rpc-error&gt; 
&lt;/rpc-reply&gt;</artwork>
        </figure>

        <t>Since adaptive subscription allows a server to be configured with
        multiple different period intervals and corresponding XPath evaluation
        criteria to trigger update interval switch in the server, it may be
        possible for the server to return multiple &lt;rpc-error&gt; elements
        with "xpath-evaluation-unsupported" failure specified by different
        error paths. The subscriber can use this information in future
        attempts to establish a subscription.</t>
      </section>

      <section title="&quot;adaptive-period-update&quot; notification example">
        <t>Upon the server switches from the update interval 5 seconds to the
        new update interval 60 seconds, before sending event records to
        receivers, the "adaptive-period-update" notification should be
        generated and sent to the receivers to inform the receivers that the
        update interval value is switched to the new value.</t>

        <figure>
          <artwork>&lt;notification
 xmlns="urn:ietf:params:xml:ns:netconf:notification:1.0"
 xmlns:yp="urn:ietf:params:xml:ns:yang:ietf-yang-push"&gt;
 &lt;eventTime&gt;2016-11-21T13:51:00Z&lt;/eventTime&gt;
 &lt;adaptive-period-update
  xmlns="http://example.com/ietf-adaptive-subscription"&gt;
  &lt;id&gt;0&lt;/id&gt;
  &lt;period&gt;60&lt;/period&gt;
  &lt;yp:datastore
   xmlns:ds="urn:ietf:params:xml:ns:yang:ietf-datastores"&gt;
       ds:running
  &lt;/yp:datastore&gt;
  &lt;yp:datastore-xpath-filter
   xmlns:ex="https://example.com/sample-data/1.0"&gt;
       /ex:example-wifi-network-diagnostic
  &lt;/yp:datastore-xpath-filter&gt;
 &lt;/adaptive-period-update&gt;
&lt;/notification&gt;</artwork>
        </figure>
      </section>

      <section title="Changes between Revisions">
        <t>v09 -v10<list style="symbols">
            <t>Change the draft intended status to "experimental"</t>

            <t>Problem statement refinement</t>
          </list></t>

        <t>v08 -v09<list style="symbols">
            <t>Define two new RPC errors to report when adaptive subscription
            unsupported or multiple XPath criteria conflict.</t>

            <t>Remove the "watermark" parameter.</t>

            <t>Add clarification about how to evaluate the XPath expression
            defined in "xpath-external-eval".</t>

            <t>Add clarification about how to compare a targeted data object
            in a specific list entry.</t>
          </list></t>

        <t>v07 -v08<list style="symbols">
            <t>Define a new RPC error to report when an XPath syntax defined
            in "xpath-external-eval" is unsupported by a server.</t>

            <t>Add a new example showing how the RPC error being returned by a
            publisher.</t>

            <t>The usage examples fixed in the Appendix.</t>

            <t>Grammatical errors correction(missing articles, plurality
            mismatches, etc).</t>
          </list></t>

        <t>v06 -v07<list style="symbols">
            <t>The usage examples typo fixed in the Appendix.</t>

            <t>Add reference to RFC7950 XPATH Evaluation section and XPATH
            1.0</t>

            <t>Clarify the definitions of 'xpath-external-eval' and
            'selection-filter' by reusing XPATH Evaluation rules in
            RFC7950.</t>

            <t>Add a new terminology "adaptive subscription".</t>

            <t>Add one section to discuss Arbitrary XPath Complexity.</t>
          </list></t>

        <t>v05 -v06<list style="symbols">
            <t>Replace example-wifi-mac module with
            example-wifi-network-diagnostic using WIFI statistics specified in
            CHIP specification.</t>

            <t>Update adaptive subscription Example to align with WIFI example
            module change.</t>

            <t>Add one more reference to CHIP Specification.</t>
          </list></t>

        <t>v04 -v05<list style="symbols">
            <t>Remove "modify-subscption" RPC usage.</t>

            <t>Module update to fix the nits.</t>

            <t>Update adaptive subscription Example.</t>

            <t>Other Editorial changes.</t>
          </list></t>

        <t>v03 - v04<list style="symbols">
            <t>Add missing subtrees and data nodes in the security
            section;</t>

            <t>Change "adaptive-update" notification into
            "adaptive-period-update" notification;</t>

            <t>Other Editorial changes.</t>
          </list></t>

        <t>v02 - v03<list style="symbols">
            <t>Clarify the difference between low priority telemetry data
            dropping and collection rate switching in the introduction
            section;</t>

            <t>Update the abstract and introduction section to focus on
            collection rate switching in the server without interaction with
            the remote client;</t>

            <t>Format usage example and change ssid into rssi in the
            appendix;</t>

            <t>Use boilerplate and reuse the terms in the terminology
            section.</t>
          </list></t>
      </section>
    </section>
  </back>
</rfc>
