<?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-ietf-netconf-adaptive-subscription-08"
     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="2025"/>

    <area>OPS Area</area>

    <workgroup>NETCONF Working Group</workgroup>

    <abstract>
      <t>This document defines a YANG data model and associated mechanism that
      enable adaptive subscription to YANG notifications. The periodic update
      interval for the stream can be set adaptively. Applying adaptive
      subscription allows publishers to adjust the subscription period
      dynamically based on pre-defined threshold for finer-grained network
      telemetry data sent to receivers.</t>
    </abstract>

    <note title="Editorial Note (To be removed by RFC Editor)">
      <t>Note to the RFC Editor: This section is to be removed prior to
      publication. Please also remove <xref target="implementation"/>.</t>

      <t>This document contains placeholder values that need to be replaced
      with finalized values at the time of publication. This note summarizes
      all of the substitutions that are needed. No other RFC Editor
      instructions are specified elsewhere in this document.</t>

      <t>Please apply the following replacements:<list style="symbols">
          <t>XXXX --&gt; the assigned RFC number for this document</t>

          <t>2025-04-16 --&gt; the actual date of the publication of this
          document</t>
        </list></t>
    </note>
  </front>

  <middle>
    <section anchor="intro" title="Introduction">
      <t>YANG-Push subscriptions <xref target="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 subscription are introduced in <xref
      target="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 time 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 deployments where an increased data collection rate
      is used, it becomes more likely that both clients and servers could be
      temporarily overwhelmed with a burst of streamed data, and network and
      computation resources could be excessively consumed. Therefore, it may
      be expensive to continuously monitor operational data at a high
      collection rate. Conversely, if a stream of data is collected at a lower
      rate or some low priority data is allowed to be dropped, insufficient
      data might not be able to detect and diagnose service problems.</t>

      <t>A client might choose to monitor the operational state and send a
      request to modify the data collection rate on the server as needed. 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. In addition,
      when tens of thousands of network devices need to be managed, frequent
      follow-up modification requests are prone to errors.</t>

      <t>This document defines a YANG data model and associated mechanism that
      enable adaptive subscription to YANG notifications. Servers can be
      configured with multiple different period intervals and corresponding
      period update conditions which allow servers/publishers to automatically
      switch to different period intervals according to the network condition
      changes without the interaction with the client for policy update
      instructions. Applying adaptive subscription allows publishers to adjust
      the subscription period dynamically based on pre-defined threshold for
      finer-grained network telemetry data sent 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 <xref target="RFC2119"/> <xref target="RFC8174"/> when, and only
        when, they appear in all capitals, as shown here.</t>

        <t>The following terms are defined in <xref target="RFC5277"/>, <xref
        target="RFC7950"/>, <xref target="RFC8342"/>, <xref
        target="RFC8639"/>, <xref target="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:">A subscription that specifies
            subscription period update policy on the servers when the
            subscription is initialized and allows servers/publishers to
            automatically switch to different period intervals according to
            network condition changes without interacting with the client for
            update policy instructions.</t>
          </list></t>
      </section>
    </section>

    <!-- intro -->

    <section title="Solution Overview">
      <section anchor="model" title="Adaptive Subscription Parameters">
        <t>Adaptive subscription can be implemented through the use of either
        dynamic or configured subscription. Regardless of the type of adaptive
        subscription, triggered updates always occur at the boundaries of
        specified time intervals when the corresponding trigger condition is
        evaluated to be satisfied. These boundaries can be calculated from the
        following parameters: <list style="symbols">
            <t>"name": represents the unique name of each adaptive period.</t>

            <t>"eval-expression": represents a standard XPath evaluation
            expression (<xref section="6.4" sectionFormat="of"
            target="RFC7950"/>) that is applied against the targeted data
            node, which is used to trigger/control the update interval
            switching within the server. It follows the rules defined in
            Section 3.4 of <xref target="XPATH1.0"/> and contains a comparison
            of a targeted node instance to the specific threshold in the XPath
            format. Different from selection filter defined in <xref
            target="RFC8641"/>, it monitors a specific data node instance
            change and evaluates the trigger condition associated with the
            specified threshold value to be true or false using XPath rules
            and does not affect the even/update record output generation from
            a publisher. The updates are only pushed as the corresponding
            period interval when the XPath expression is evaluated to
            "true".<vspace blankLines="1"/>It is not always trivial for a
            subscriber to determine the threshold used in an XPath expression
            criterion. Sometimes the threshold needs to be adjusted during the
            lifecycle of an adaptive subscription, depending on historical
            fluctuation range and how rapid the targeted value of the node
            changes, distribution characteristics of the targeted node value
            or even the generated volume of telemetry traffic.<vspace
            blankLines="1"/>The represented expression defined in
            "eval-expression" 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 "eval-expression" 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 <xref target="XPATH1.0"/> and the function defined in <xref
                section="10" sectionFormat="of" target="RFC7950"/>.</t>

                <t>The context node is the root node in the accessible tree
                which is the operational state data in the server.</t>
              </list>For the cases where the "eval-expression" parameter
            refers to multiple list/leaf-list instances, 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 align="center">/if:interfaces/if:interface[if:name="eth0"]/if:in-errors&gt;1000.</artwork>
              </figure>The server MUST convert the XPath evaluation expression
            defined in "eval-expression" to a boolean value and internally
            apply the "boolean" function defined in Section 4.3 in <xref
            target="XPATH1.0"/> if the evaluated result is not a boolean
            value. It MUST evaluates to "false" if the target node instance to
            be compared is deleted. Only if the XPath expression is evaluated
            to "true", does the publisher switch to the corresponding period
            with which push updates are reported.</t>

            <t>"eval-interval": defines how often the XPath condition
            expression as defined in "eval-expression" is evaluated to decide
            whether to switch to another period interval. If an
            "eval-interval" is not provided, then the "eval-interval" MUST be
            set with the minimum time interval that the server is able to
            detect wherever changes to the targeted data node occur.</t>

            <t>"period": defines the duration between push updates, in units
            of 0.01 seconds. The "period" has the same definition as the
            yp:period for periodic subscription defined in <xref
            target="RFC8641"/>, while it must be present with the
            "eval-expression" parameter so that update interval can be
            switched based on trigger conditions indicated by the
            "eval-expression" parameter;</t>

            <t>"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 inside each
            periodic timeframe. The "anchor-time" parameter, together with the
            "eval-interval" value, specifies when the initial update is to be
            pushed within each adaptive periodic timeframe.</t>
          </list>Note that the adaptive subscription may not be supported by
        every YANG datastore node. The solution presented in this document
        augments the "ietf-notification-capabilities" YANG module defined in
        <xref target="RFC9196"/> to enable a subscriber to discover adaptive
        subscription capabilities. A publisher MAY decide to simply reject an
        adaptive subscription with "adaptive-unsupported" (defined in <xref
        target="errors"/>) if the subscription contains selected data nodes
        for which adaptive subscription is not supported.</t>
      </section>

      <section anchor="errors" title="RPC Failures">
        <t>RPC error responses from the publisher are used to indicate a
        rejection of an RPC for any reason. In addition to the RPC failures
        defined in <xref target="RFC8639"/> and <xref target="RFC8641"/>, this
        document introduces following RPC errors for "establish-subscription"
        and "modify-subscription" RPCs.</t>

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

modify-subscription
-----------------------------
xpath-evaluation-unsupported
evaluation-interval-unsupported
multi-xpath-criteria-conflict</artwork>
        </figure>

        <t>The "adaptive-unsupported" RPC error is used to indicate that the
        adaptive subscription is not supported for the targeted set of data
        nodes that are selected by the filter.</t>

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

        <t>The "evaluation-interval-unsupported" RPC error is used to indicate
        that the requested XPath evaluation interval represented by
        "eval-interval" is too short. Hints suggesting alternative intervals
        may be returned as supplemental information.</t>

        <t>When specified, multiple XPath evaluation criteria inside
        "adaptive-periodic" container MUST be mutually exclusive. The
        "multi-xpath-criteria-conflict" error is used to indicate that the
        multiple XPath evaluation criteria represented by "eval-expression"
        are evaluated as conflicting, i.e., more than one condition
        expressions may be evaluated to "true" at the same time.</t>

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

        <t>Note that existing RPC errors defined in <xref target="RFC8639"/>
        and <xref target="RFC8641"/> are still supported by this document. For
        example, if any configured period for adaptive subscription is not
        supported by the publisher, a "period-unsupported" error response
        could be used.</t>
      </section>

      <section title="Subscription State Change Notifications">
        <t>This document reuses subscription state change notifications and
        mechanisms from <xref target="RFC8639"/> and <xref target="RFC8641"/>.
        Notifications "subscription-started" and "subscription-modified" have
        been augmented to include the adaptive subscription specific
        parameters.</t>
      </section>

      <section title="Notifications for Adaptive Subscribed Content ">
        <t>This document also defines a new subscription state change
        notification called "adaptive-period-update", to indicate that an
        adaptive subscription period interval has been switched based on its
        trigger condition. Similar to subscription state change notifications
        defined in <xref target="RFC8639"/>, the adaptive period 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 the adaptive update notification
        is easy to separate from other notification messages through the use
        of the YANG extension "subscription-state-notification" defined in
        <xref target="RFC8639"/>. This extension tags a notification as a
        subscription state change notification.</t>

        <t>The elements in the "adaptive-period-update" notification
        include:<list style="symbols">
            <t>A subscription ID of the subscription for which the update
            record was generated.</t>

            <t>A "period" that defines the duration between push updates, the
            period can be changed based on trigger conditions.</t>

            <t>A "period-update-time" that designates a timestamp when the
            server starts to switch to another period interval because the
            evaluated "eval-expression" result changed.</t>

            <t>A chunk of data defined as an anydata node called
            "satisfied-criteria-data" to include the instance nodes and values
            specified in "eval-expression" that satisfy the condition and thus
            trigger the period interval switching within the server. This node
            could be useful for troubleshooting.</t>

            <t>A selection filter 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 <xref section="6.4" sectionFormat="of"
            target="RFC7950"/> evaluation criteria. 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 the "eval-expression" parameter defined by the update
            trigger.</t>
          </list></t>
      </section>
    </section>

    <section title="XPath Complexity Evaluation">
      <t>YANG-Push subscriptions <xref target="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 also uses
      similar selection filters to express a standard XPath evaluation
      criterion that is applied against the targeted data node(s).</t>

      <t>The following complex implementation and use choices need to be
      cautious, although they have already been well supported by the Section
      3.4 of <xref target="XPATH1.0"/>:<list style="symbols">
          <t>Support XPath evaluation criteria for all "config true" and
          "config false" data nodes;</t>

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

          <t>Support any type of node value 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>Targeted data 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 <xref section="6.4" sectionFormat="of"
      target="RFC7950"/>, Numbers in XPath 1.0 are IEEE 754 <xref
      target="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 targeted data to be compared are in different data types, a
      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 implementation and use
      principles are recommended:<list style="symbols">
          <t>XPath evaluation criteria are applied against a minimal set of
          data nodes in the data model, the minimal set of data nodes can be
          advertised using "ietf-notification-capabilities" module defined in
          <xref target="RFC9196"/>;</t>

          <t>Both targets in the XPath evaluation criterion to be compared are
          in the same data type;</t>

          <t>One target to be compared in the XPath evaluation criterion is a
          leaf/leaf-list data node with numerical data type (e.g.,
          signed/unsigned integer) and the other is a numerical threshold
          value.</t>
        </list></t>

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

    <section title="Adaptive Subscription Data Model">
      <t>This document defines a YANG data model named
      "ietf-adaptive-subscription" which augments the "update-trigger" choice
      defined in the "ietf-yang-push" module <xref target="RFC8641"/> with
      subscription configuration parameters that are specific to a
      subscriber's adaptive subscription.</t>

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

      <t>Additionally, it augments the "ietf-notification-capabilities" data
      model defined in <xref target="RFC9196"/> so that the adaptive
      subscription capabilities could be discovered beforehand.</t>

      <section title="YANG Tree Diagram">
        <t>The following tree diagrams <xref target="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:
    +--:(adaptive-periodic) {adaptive-subscription}?
       +--rw adaptive-periodic
          +--rw periodic* [name]
             +--rw name               string
             +--rw eval-expression    yang:xpath1.0
             +--rw eval-interval?     yp:centiseconds
             +--rw period             yp:centiseconds
             +--rw anchor-time?       yang:date-and-time
  augment /sn:establish-subscription/sn:input/yp:update-trigger:
    +--:(adaptive-periodic) {adaptive-subscription}?
       +-- adaptive-periodic
          +-- periodic* [name]
             +-- name               string
             +-- eval-expression    yang:xpath1.0
             +-- eval-interval?     yp:centiseconds
             +-- period             yp:centiseconds
             +-- anchor-time?       yang:date-and-time
  augment /sn:modify-subscription/sn:input/yp:update-trigger:
    +--:(adaptive-periodic) {adaptive-subscription}?
       +-- adaptive-periodic
          +-- periodic* [name]
             +-- name               string
             +-- eval-expression    yang:xpath1.0
             +-- eval-interval?     yp:centiseconds
             +-- period             yp:centiseconds
             +-- anchor-time?       yang:date-and-time
  augment /sn:subscription-started/yp:update-trigger:
    +--:(adaptive-periodic) {adaptive-subscription}?
       +-- adaptive-periodic
          +-- periodic* [name]
             +-- name               string
             +-- eval-expression    yang:xpath1.0
             +-- eval-interval?     yp:centiseconds
             +-- period             yp:centiseconds
             +-- anchor-time?       yang:date-and-time
  augment /sn:subscription-modified/yp:update-trigger:
    +--:(adaptive-periodic) {adaptive-subscription}?
       +-- adaptive-periodic
          +-- periodic* [name]
             +-- name               string
             +-- eval-expression    yang:xpath1.0
             +-- eval-interval?     yp:centiseconds
             +-- period             yp:centiseconds
             +-- anchor-time?       yang:date-and-time
  augment /sysc:system-capabilities/notc:subscription-capabilities:
    +--ro adaptive-notifications-supported?   notification-support
  augment /sysc:system-capabilities/sysc:datastore-capabilities
            /sysc:per-node-capabilities
            /notc:subscription-capabilities:
    +--ro adaptive-notifications-supported?   notification-support

  notifications:
    +---n adaptive-period-update {adaptive-subscription}?
       +--ro id?
       |       sn:subscription-id
       +--ro period                                  yp:centiseconds
       +--ro period-update-time?
       |       yang:date-and-time
       +--ro satisfied-criteria-data?                &lt;anydata&gt;
       +--ro datastore                               identityref
       +--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>

      <section anchor="adaptive"
               title="The &quot;ietf-adaptive-subscription&quot; Module">
        <t>This YANG module imports modules from <xref
        target="RFC6991"/>,<xref target="RFC8639"/>, <xref target="RFC8641"/>,
        and <xref target="RFC9196"/>.</t>

        <figure>
          <artwork>&lt;CODE BEGINS&gt; file "ietf-adaptive-subscription@2025-04-16.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;
    reference
      "RFC 8639: Subscription to YANG Notifications";
  }
  import ietf-yang-push {
    prefix yp;
    reference
      "RFC 8641: Subscription to YANG Notifications for Datastore
       Updates";
  }
  import ietf-yang-types {
    prefix yang;
    reference
      "RFC 6991: Common YANG Data Types";
  }
  import ietf-system-capabilities {
    prefix sysc;
    reference
      "RFC 9196: YANG Modules Describing Capabilities for
       Systems and Datastore Update Notifications";
  }
  import ietf-notification-capabilities {
    prefix notc;
    reference
      "RFC 9196: YANG Modules Describing Capabilities for
       Systems and Datastore Update Notifications";
  }

  organization
    "IETF NETCONF (Network Configuration) Working Group";
  contact
    "WG Web:   &lt;http://tools.ietf.org/wg/netconf&gt;
     WG List:  &lt;netconf@ietf.org&gt;

     Author: Qin Wu
           &lt;mailto:bill.wu@huawei.com&gt;
     Author: Wei Song
           &lt;mailto: songwei80@huawei.com&gt;
     Author: Peng Liu
           &lt;mailto: liupengyjy@chinamobile.com&gt;
     Author: Qiufang Ma
           &lt;mailto: maqiufang1@huawei.com&gt;
     Author: Wei Wang
          &lt;mailto: wangw36@chinatelecom.cn&gt;
     Author: Zhixiong Niu
          &lt;mailto: Zhixiong.Niu@microsoft.com&gt;";
  description
    "This module extends the YANG data module defined in
     YANG-push to enable the subscriber's adaptive
     subscriptions to a publisher's event streams with various
     different period intervals to report updates.

     Copyright (c) 2025 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 Revised
     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 XXXX
     (https://www.rfc-editor.org/info/rfcXXXX); see the RFC
     itself for full legal notices.

     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 (RFC 2119)
     (RFC 8174) when, and only when, they appear in all
     capitals, as shown here.";

  revision 2025-04-16 {
    description
      "Initial revision";
    reference
      "RFC XXXX: Adaptive Subscription to YANG Notification.";
  }

  feature adaptive-subscription {
    description
      "This feature indicates that adaptive-subscriptions are
       supported.";
  }

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

  identity xpath-evaluation-unsupported {
    base sn:establish-subscription-error;
    base sn:modify-subscription-error;
    description
      "Unable to parse the XPath evaluation criteria defined in
       'eval-expression' because of a syntax error or some XPath
       1.0 syntax not supported against the specific data node.";
  }

  identity evaluation-interval-unsupported {
    base sn:establish-subscription-error;
    base sn:modify-subscription-error;
    description
      "The requested XPath evaluation interval represented by
       'eval-interval' is too short. Hints suggesting alternative
       intervals may be returned as supplemental information.";
  }

  identity multi-xpath-criteria-conflict {
    base sn:establish-subscription-error;
    base sn:modify-subscription-error;
    description
      "Multiple XPath evaluation criteria represented by
       'eval-expression' are evaluated as a conflict. I.e.,
       more than one condition expression is 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.";
    container adaptive-periodic {
      description
        "The publisher is requested to periodically notify the
         receiver regarding the current values of the datastore
         as defined by the selection filter. The publisher supports
         to switch to different period intervals adaptively based
         on pre-defined condition expressions.";
      list periodic {
        key "name";
        description
          "A list of adaptive period which defines a push update
           interval and trigger conditions to switch to the update
           interval for sending an event record to the subscriber.";
        leaf name {
          type string {
            length "1..64";
          }
          description
            "The unique name of adaptive period.";
        }
        leaf eval-expression {
          type yang:xpath1.0;
          mandatory true;
          description
            "A standard XPath evaluation expression that is applied
             against the targeted data node, which is used to
             trigger/control the update interval switching within
             the server. The updates are only pushed as the
             corresponding period interval when the XPath expression
             is evaluated to 'true'.

             The expression is evaluated in the following XPath
             context:
             -  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.

             -  If the leaf is encoded in XML, all namespace
                declarations in scope on the 'eval-expression' 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.

             -  The set of variable bindings is empty.

             -  The function library is the core function library
                defined in XPath1.0 and the functions defined in
                Section 10 in RFC 7950.

             -  The context node is the root node in the accessible
                tree which is the operational state data in the
                server.";
          reference
            "XML Path Language (XPath) Version 1.0
             (https://www.w3.org/TR/1999/REC-xpath-19991116)
             RFC 7950: The YANG 1.1 Data Modeling Language,
                       Section 10";
        }
        leaf eval-interval {
          type yp:centiseconds;
          description
            "How often the Xpath condition expression is evaluated
             to decide whether to switch to another period
             interval.";
        }
        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 is 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.";
        }
      }
    }
  }

  augment "/sn:subscriptions/sn:subscription/yp:update-trigger" {
    description
      "This augmentation adds additional subscription parameters
       that apply specifically to adaptive subscription.";
    case adaptive-periodic {
      if-feature "adaptive-subscription";
      description
        "The publisher is requested to periodically notify the
         receiver regarding the current values of the datastore
         as defined by the selection filter. The periodicity of
         these notifications is determined by adaptive criteria.";
      uses adaptive-subscription-modifiable;
    }
  }

  augment "/sn:establish-subscription/sn:input/yp:update-trigger" {
    description
      "This augmentation adds additional establish-subscription
       parameters that apply specifically to datastore updates to
       RPC input.";
    case adaptive-periodic {
      if-feature "adaptive-subscription";
      description
        "The publisher is requested to periodically notify the
         receiver regarding the current values of the datastore
         as defined by the selection filter. The periodicity of
         these notifications is determined by adaptive criteria.";
      uses adaptive-subscription-modifiable;
    }
  }

  augment "/sn:modify-subscription/sn:input/yp:update-trigger" {
    description
      "This augmentation adds additional modify-subscription
       parameters that apply specifically to datastore updates to
       RPC input.";
    case adaptive-periodic {
      if-feature "adaptive-subscription";
      description
        "The publisher is requested to periodically notify the
         receiver regarding the current values of the datastore
         as defined by the selection filter. The periodicity of
         these notifications is determined by adaptive criteria.";
      uses adaptive-subscription-modifiable;
    }
  }

  augment "/sn:subscription-started/yp:update-trigger" {
    description
      "This augmentation adds additional adaptive subscription
       parameters to the notification that a subscription has
       started.";
    case adaptive-periodic {
      if-feature "adaptive-subscription";
      description
        "The publisher is requested to periodically notify the
         receiver regarding the current values of the datastore
         as defined by the selection filter. The periodicity of
         these notifications is determined by adaptive criteria.";
      uses adaptive-subscription-modifiable;
    }
  }

  augment "/sn:subscription-modified/yp:update-trigger" {
    description
      "This augmentation adds additional adaptive subscription
       parameters to the notification that a subscription has been
       modified.";
    case adaptive-periodic {
      if-feature "adaptive-subscription";
      description
        "The publisher is requested to periodically notify the
         receiver regarding the current values of the datastore
         as defined by the selection filter. The periodicity of
         these notifications is determined by adaptive criteria.";
      uses adaptive-subscription-modifiable;
    }
  }

  notification adaptive-period-update {
    if-feature "adaptive-subscription";
    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 period-update-time {
      type yang:date-and-time;
      description
        "Designates a timestamp when the server starts to switch
         to another period interval because the evaluated
         'eval-expression' expression result changed.";
    }
    anydata satisfied-criteria-data {
      description
        "The corresponding instance nodes and values specified in
         'eval-expression' that satisfy the condition and thus
         trigger the update interval switching within the server.";
    }
    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.";
      }
    }
  }

  grouping adaptive-subscription-capabilities {
    description
      "Capabilities related to adaptive subscription and
       notification.";
    typedef notification-support {
      type bits {
        bit config-changes {
          description
            "The publisher is capable of sending
             notifications for 'config true' nodes for the
             relevant scope and subscription type.";
        }
        bit state-changes {
          description
            "The publisher is capable of sending
             notifications for 'config false' nodes for the
             relevant scope and subscription type.";
        }
      }
      description
        "Type for defining whether 'on-change' or
         'periodic' notifications are supported for all data nodes,
         'config false' data nodes, 'config true' data nodes, or
         no data nodes.

         The bits config-changes or state-changes have no effect
         when they are set for a datastore or for a set of nodes
         that does not contain nodes with the indicated config
         value.  In those cases, the effect is the same as if no
         support was declared.  One example of this is indicating
         support for state-changes for a candidate datastore that
         has no effect.";
    }

    leaf adaptive-notifications-supported {
      type notification-support;
      description
        "Specifies whether the publisher is capable of sending
         'adaptive' notifications for the selected data nodes,
         including any subtrees that may exist below them.";
    }
  }

  augment "/sysc:system-capabilities"
        + "/notc:subscription-capabilities" {
    description
      "Add system level capabilities of adaptive subscription.";
    uses adaptive-subscription-capabilities;
  }

  augment
    "/sysc:system-capabilities/sysc:datastore-capabilities/"
  + "sysc:per-node-capabilities/notc:subscription-capabilities" {
    description
      "Add node-level capabilities of adaptive subscription.";
    uses adaptive-subscription-capabilities;
  }
}
&lt;CODE ENDS&gt;</artwork>
        </figure>
      </section>
    </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 <xref
        target="RFC3688"/>. Following the format in <xref target="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 <xref target="RFC7950"/>. Following the format in <xref
        target="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="implementation" title="Implementation Status">
      <t>Note to the RFC Editor: Please remove this section before
      publication, as well as the reference to <xref target="RFC7942"/>.</t>

      <t>This section records the status of known implementations of the
      mechanism defined by this specification at the time of posting of this
      Internet-Draft, and is based on a proposal described in <xref
      target="RFC7942"/>. The description of implementations in this section
      is intended to assist the IETF in its decision processes in progressing
      drafts to RFCs. Please note that the listing of any individual
      implementation here does not imply endorsement by the IETF. Furthermore,
      no effort has been spent to verify the information presented here that
      was supplied by IETF contributors. This is not intended as, and must not
      be construed to be, a catalog of available implementations or their
      features. Readers are advised to note that other implementations may
      exist.</t>

      <t>According to <xref target="RFC7942"/>, "this will allow reviewers and
      working groups to assign due consideration to documents that have the
      benefit of running code, which may serve as evidence of valuable
      experimentation and feedback that have made the implemented protocols
      more mature. It is up to the individual working groups to use this
      information as they see fit".</t>

      <t>There is a demo implementation of gRPC-based adaptive telemetry to
      collect data from access points (APs) in a campus network. The radio
      signals of an AP can cover only a limited area, Wi-Fi roaming is what
      happens when a wireless client disconnects from one AP because it
      receives weak signals (i.e., the Received Signal Strength Indicator
      (RSSI) lower than the threshold) and connects to another as the client
      moves from the coverage area of an AP to that of another AP.</t>

      <t>One objective of telemetry in this scenario is to collect the RSSI
      values of a specific client as it moves and detect real-time Wi-Fi
      roaming events. We also collect the bytes sent from the AP uplink so as
      to detect the possible uplink congestion. Three data collection ways are
      evaluated:<list style="symbols">
          <t>Periodic subscriptions with periods of 2 seconds for RSSI
          collection and 1 minute for upbytes collection.</t>

          <t>Periodic subscriptions with periods of 30 seconds for RSSI
          collection and 10 minutes for upbytes collection.</t>

          <t>Adaptive subscriptions: <list style="symbols">
              <t>For the RSSI collection, if the RSSI value is greater than or
              equal to -65 dB, switch to 30 seconds for publication;
              otherwise, switch to 2 seconds for publication; threshold
              detection occurs every 2 seconds.</t>

              <t>For the upbytes collection, if the upbytes value is greater
              than or equal to 60000 bytes, switch to 1 minute for
              publication; otherwise, switch to 10 minutes for publication;
              threshold detection occurs every minute.</t>
            </list></t>
        </list></t>

      <t>The results show adaptive telemetry can greatly reduce the data
      volume but still ensure network events can be captured at the same time.
      When the specific value does not reach the threshold, a lower frequency
      data publication can greatly reduce the amount of collected data; when
      it does exceed the threshold, the device detects the change and switches
      to a higher frequency data publication so that sufficient data will not
      be missed to diagnose network events. Adaptive subscription can be
      served as a compromise between data management resource cost and data
      fidelity for network diagnosis. However, the selection of threshold is
      crucial to adaptive subscription and should be based on operational
      experience and adjusted as needed. In extreme cases, a too high or low
      threshold may make adaptive subscription degenerated to periodic
      subscription.</t>
    </section>

    <section anchor="security" title="Security Considerations">
      <t>This section is modeled after the template described in <xref
      section="3.7" sectionFormat="of"
      target="I-D.ietf-netmod-rfc8407bis"/>.</t>

      <t>The "ietf-adaptive-subscription" YANG module defines a data model
      that is designed to be accessed via YANG-based management protocols,
      such as NETCONF <xref target="RFC6241"/> and RESTCONF <xref
      target="RFC8040"/>. These protocols have to use a secure transport layer
      (e.g., SSH <xref target="RFC4252"/>, TLS <xref target="RFC8446"/>, and
      QUIC <xref target="RFC9000"/>) and have to use mutual
      authentication.</t>

      <t>The Network Configuration Access Control Model (NACM) <xref
      target="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). All writable data nodes are likely to be reasonably sensitive
      or vulnerable in some network environments. Write operations (e.g.,
      edit-config) and delete operations to these nodes without proper
      protection or authentication can have a negative effect on network
      operations. The following subtrees and data nodes have particular
      sensitivities/vulnerabilities:<list style="symbols">
          <t>"periodic": By modifying this list, an attacker might alter the
          updates that are being sent in order to confuse a receiver, withhold
          certain updates to be sent to the receiver, and/or overwhelm a
          receiver. For example, an attacker might modify the period with
          which updates are reported and/or the XPath evaluation expression,
          resulting in certain updates not being published or a high volume of
          updates being published to exhaust receiver resources.</t>
        </list></t>
    </section>

    <section title="Contributors">
      <t>Thanks Michael Wang for his major contribution to the initial
      modeling and use cases.</t>

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

    <section title="Acknowledges">
      <t>We would like to thank Rob Wilton, Thomas Graf, Andy Bierman, Michael
      Richardson, Henk Birkholz, Chong Feng, Adrian Farrel, and Joe Clarke 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.5277.xml"?>

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

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

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

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

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

      <?rfc include="reference.RFC.8639.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.4252.xml"?>

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

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

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

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

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

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

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

      <xi:include href="https://datatracker.ietf.org/doc/bibxml3/reference.I-D.ietf-netmod-rfc8407bis.xml"
                  xmlns:xi="http://www.w3.org/2001/XInclude"/>

      <reference anchor="IEEE754-2008"
                 target="http://standards.ieee.org/findstds/standard/754-2008.html">
        <front>
          <title>IEEE Standard for Floating-Point Arithmetic</title>

          <author>
            <organization>IEEE</organization>
          </author>

          <date year="2008"/>
        </front>

        <seriesInfo name="" value="DOI 10.1109/IEEESTD.2008.4610935"/>
      </reference>

      <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="Use Cases">
      <section title="Wireless Network Performance Monitoring">
        <t>Wireless signal strength is a critical factor in determining the
        quality and reliability of a wireless network connection. In practical
        scenarios, when the wireless signal strength drops below a specific
        threshold, the network may experience issues such as increased
        latency, packet loss, or even disconnections, which would require more
        frequent monitoring of network and service performance metrics to
        detect anomalies in a timely manner. Conversely, when the wireless
        signal strength exceeds a specific threshold, indicating a stable and
        strong connection, the data streaming rate can be reduced to a
        reasonable value to help conserve network bandwidth and computational
        resources.</t>

        <t>To optimize the process, adaptive subscription can be employed.
        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 that might indicate continuous
        service degeneration or anomalies; while when the wireless signal
        strength crosses a configured threshold, the subscribed data can be
        streamed at a lower rate to maintain efficient resource
        utilization.</t>
      </section>

      <section title="Reducing Impact on High CPU Utilization">
        <t>Continuous monitoring of some metrics is essential for maintaining
        network and service health, however, this can place a significant
        burden on the device's CPU utilization, especially when the device is
        running resource-intensive tasks and is overloaded. When the CPU
        utilization on the device exceeds a certain high-level value, it is
        crucial to manage the network monitoring process in a way that
        minimizes its impact on overall system performance.</t>

        <t>In such cases, adaptive subscription can dynamically adjust the
        period interval with which to report streaming update and help balance
        monitoring needs with computational demands. When the CPU utilization
        on the device exceeds a certain high-level value, the subscriber can
        specify a longer period interval for some less critical statistics to
        make room and save more resources. Conversely, When the CPU
        utilization falls below a specified threshold, indicating the device
        has sufficient idle resources, the subscriber can revert to a shorter
        period interval for streaming data without exhausting the CPU
        resources at the same time.</t>
      </section>
    </section>

    <section title="Example YANG Module">
      <t>This section presents an example YANG module so that <xref
      target="usage"/> can give examples of how the YANG module defined in
      <xref target="adaptive"/> is used to perform adaptive subscription. The
      example YANG module used in this section represents a Wi-Fi Network
      Diagnostics data specified in <xref target="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
  +--ro server
  |  +--ro bssid?                       yang:mac-address
  |  +--ro security-type?               enumeration
  |  +--ro wifi-version?                enumeration
  |  +--ro channel-num?                 int8
  |  +--ro rssi?                        int8
  |  +--ro beacon-lost-count?           int8
  |  +--ro beacon-rx-count?             int8
  |  +--ro packet-multicast-rx-count?   int8
  |  +--ro packet-multicast-tx-count?   int8
  |  +--ro packet-unicast-rx-count?     int8
  |  +--ro packet-unicast-tx-count?     int8
  |  +--ro current-max-rate?            int8
  |  +--ro overrun-count?               int8
  +--ro events
     +--ro event* [name]
        +--ro name                   string
        +--ro disconnection?         enumeration
        +--ro association-failure?   enumeration
        +--ro connection-status?     enumeration</artwork>
        </figure></t>

      <section anchor="example-module"
               title="&quot;example-wifi-network-diagnostic&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 {
    config false;
    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'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 {
    config false;
    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'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 anchor="usage"
             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 <xref target="example-module"/>.</t>

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

      <section title="Configured Subscription 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, 20
        seconds) and report updates every 20 seconds if the RSSI value is
        greater than or equal to -65 dB; If the RSSI value is less than -65
        dB, switch to 5 seconds period value to report updates. The server
        compares the rssi value with -65 dB every 2 seconds. <xref
        target="edit-config"/> specifies an example of configured subscription
        with the &lt;edit-config&gt; operation.</t>

        <figure anchor="edit-config">
          <artwork>&lt;rpc xmlns="urn:ietf:params:xml:ns:netconf:base:1.0" message-id="101"&gt;
 &lt;edit-config&gt;
  &lt;target&gt;
   &lt;running/&gt;
  &lt;/target&gt;
  &lt;config&gt;
   &lt;subscriptions 
    xmlns="urn:ietf:params:xml:ns:yang:ietf-subscribed-notifications"
    xmlns:yp="urn:ietf:params:xml:ns:yang:ietf-yang-push"&gt;
    &lt;subscription&gt;
     &lt;id&gt;1011&lt;/id&gt;
     &lt;yp:datastore 
      xmlns:ds="urn:ietf:params:xml:ns:yang:ietf-datastores"&gt;
      ds:operational
     &lt;/yp:datastore&gt;
     &lt;yp:datastore-xpath-filter 
      xmlns:wnd="http://example.com/yang/wifi-network-diagnostic"&gt;
      /wnd:server
     &lt;/yp:datastore-xpath-filter&gt;
     &lt;as:adaptive-periodic 
     xmlns:as="urn:ietf:params:xml:ns:yang:ietf-adaptive-subscription"&gt;
      &lt;as:periodic&gt;
       &lt;as:name&gt;adaptive-period-1&lt;/as:name&gt;
       &lt;as:eval-expression&gt;
        /wnd:server/wnd:rssi&amp;lt;-65
       &lt;/as:eval-expression&gt;
       &lt;as:eval-interval&gt;200&lt;/as:eval-interval&gt;
       &lt;as:period&gt;500&lt;/as:period&gt;
       &lt;as:anchor-time&gt;2025-04-11T08:00:00Z&lt;/as:anchor-time&gt;
      &lt;/as:periodic&gt;
      &lt;as:periodic&gt;
       &lt;as:name&gt;adaptive-period-2&lt;/as:name&gt;
       &lt;as:eval-expression&gt;
        /wnd:server/wnd:rssi&amp;gt;=-65
       &lt;/as:eval-expression&gt;
       &lt;as:eval-interval&gt;200&lt;/as:eval-interval&gt;
       &lt;as:period&gt;2000&lt;/as:period&gt;
       &lt;as:anchor-time&gt;2025-04-11T08:00:00Z&lt;/as:anchor-time&gt;
      &lt;/as:periodic&gt;
     &lt;/as:adaptive-periodic&gt;
     &lt;receivers&gt;
      &lt;receiver&gt;
       &lt;name&gt;host.example.com&lt;/name&gt;
      &lt;/receiver&gt;
     &lt;/receivers&gt;
    &lt;/subscription&gt;
   &lt;/subscriptions&gt;
  &lt;/config&gt;
 &lt;/edit-config&gt;
&lt;/rpc&gt;</artwork>
        </figure>
      </section>

      <section title="Dynamic Subscription Example">
        <t>Alternatively, the subscriber may send 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 -65 dB; If the RSSI value is
        greater than or equal to -65 dB, switch to 20 seconds period value.
        The server compares the RSSI value with -65 dB every 2 seconds. <xref
        target="establish-subscription"/> specifies an example of the
        "establish-subscription" RPC request.</t>

        <figure anchor="establish-subscription">
          <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:operational
  &lt;/yp:datastore&gt;
  &lt;yp:datastore-xpath-filter
   xmlns:wnd="http://example.com/yang/wifi-network-diagnostic"&gt;
   /wnd:server
  &lt;/yp:datastore-xpath-filter&gt;
  &lt;as:adaptive-periodic
   xmlns:as="urn:ietf:params:xml:ns:yang:ietf-adaptive-subscription"&gt;
   &lt;as:periodic&gt;
    &lt;as:name&gt;adaptive-period-1&lt;/as:name&gt;
    &lt;as:eval-expression&gt;
     /wnd:server/wnd:rssi&amp;lt;-65
    &lt;/as:eval-expression&gt;
    &lt;as:eval-interval&gt;200&lt;/as:eval-interval&gt;
    &lt;as:period&gt;500&lt;/as:period&gt;
    &lt;as:anchor-time&gt;2025-04-11T08:00:00Z&lt;/as:anchor-time&gt;
   &lt;/as:periodic&gt;
   &lt;as:periodic&gt;
    &lt;as:name&gt;adaptive-period-2&lt;/as:name&gt;
    &lt;as:eval-expression&gt;
     /wnd:server/wnd:rssi&amp;gt;=-65
    &lt;/as:eval-expression&gt;
    &lt;as:eval-interval&gt;200&lt;/as:eval-interval&gt;
    &lt;as:period&gt;2000&lt;/as:period&gt;
    &lt;as:anchor-time&gt;2025-04-11T08:00:00Z&lt;/as:anchor-time&gt;
   &lt;/as:periodic&gt;
  &lt;/as:adaptive-periodic&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
        node defined in "eval-expression" is not supported by the server' s
        implementation, the server returns a reply indicating a failure. <xref
        target="establish-subscription"/> illustrates an example of RPC error
        response with this.</t>

        <figure anchor="error-example">
          <artwork>&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;rpc-reply message-id="101"
 xmlns="urn:ietf:params:xml:ns:netconf:base:1.0"&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="http://example.com/yang/wifi-network-diagnostic"&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>Suppose initially the RSSI value is below -65dB, the server pushes
        updates every 5 seconds starting at 2025-04-11T08:00:00Z and
        continuing through 2025-04-11T08:02:05Z. The server evaluates the RSSI
        value against -65 dB every 2 seconds and from 2025-04-11T08:02:06Z it
        detects that the RSSI value exceeds -65 dB continuously. As the
        "anchor-time" is set to 2025-04-11T08:00:00Z for adaptive-period-2,
        which means updates can only be sent at the top of every 00, 20, 40
        second, the server sends the next update record at
        2025-04-11T08:02:20Z and adjust the update interval to 20 seconds.
        Before this, the server generates and sends an
        "adaptive-period-update" notification to inform receivers of the new
        period interval value. An example of "adaptive-period-update"
        notification is indicated in <xref target="state-change-notif"/>.</t>

        <figure anchor="state-change-notif">
          <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;2025-04-11T08:02:19.33Z&lt;/eventTime&gt;
 &lt;adaptive-period-update
  xmlns="urn:ietf:params:xml:ns:yang:ietf-adaptive-subscription"&gt;
  &lt;id&gt;1011&lt;/id&gt;
  &lt;period&gt;20000&lt;/period&gt;
  &lt;period-update-time&gt;2025-04-11T08:02:20Z&lt;/period-update-time&gt;
  &lt;satisfied-criteria-data&gt;
   &lt;path&gt;/wnd:server/wnd:rssi&lt;/path&gt;
   &lt;value&gt;-40&lt;/value&gt;
  &lt;/satisfied-criteria-data&gt;
  &lt;yp:datastore
   xmlns:ds="urn:ietf:params:xml:ns:yang:ietf-datastores"&gt;
       ds:operational
  &lt;/yp:datastore&gt;
  &lt;yp:datastore-xpath-filter
   xmlns:wnd="http://example.com/yang/wifi-network-diagnostic"&gt;
       /wnd:server
  &lt;/yp:datastore-xpath-filter&gt;
 &lt;/adaptive-period-update&gt;
&lt;/notification&gt;</artwork>
        </figure>
      </section>
    </section>
  </back>
</rfc>
