<?xml version="1.0" encoding="UTF-8"?>
<!-- This is built from a template for a generic Internet Draft. Suggestions for
     improvement welcome - write to Brian Carpenter, brian.e.carpenter @ gmail.com -->
<!-- This can be converted using the Web service at http://xml.resource.org/experimental.html
     (which supports the latest, sometimes undocumented and under-tested, features.) -->
<!DOCTYPE rfc SYSTEM "rfc2629.dtd">[
<!ENTITY I-D.ietf-i2rs-yang-network-topo SYSTEM "http://xml.resource.org/public/rfc/bibxml3/reference.I-D.ietf-i2rs-yang-network-topo.xml">
<!ENTITY I-D.zhuang-i2rs-yang-dc-fabric-network-topology "http://xml.resource.org/public/rfc/bibxml3/reference.I-D.zhuang-i2rs-yang-dc-fabric-network-topology.xml">
 <!ENTITY I-D.ietf-i2rs-usecase-reqs-summary SYSTEM "https://xml2rfc.tools.ietf.org/public/rfc/bibxml3/reference.I-D.ietf-i2rs-usecase-reqs-summary.xml">
<!-- used by XSLT processors -->
<!-- For a complete list and description of processing instructions (PIs), 
     please see http://xml.resource.org/authoring/README.html. -->
]>     
<?rfc strict="yes" ?>
<!-- give errors regarding ID-nits and DTD validation -->
<!-- control the table of contents (ToC) -->
<?rfc toc="yes"?>
<!-- generate a ToC -->
<?rfc tocdepth="4"?>
<!-- the number of levels of subsections in ToC. default: 3 -->
<!-- control references -->
<?rfc symrefs="yes"?>
<!-- use symbolic references tags, i.e, [RFC2119] instead of [1] -->
<?rfc sortrefs="yes" ?>
<!-- sort the reference entries alphabetically -->
<!-- control vertical white space 
     (using these PIs as follows is recommended by the RFC Editor) -->
<?rfc compact="yes" ?>
<!-- do not start each main section on a new page -->
<?rfc subcompact="no" ?>
<!-- keep one blank line between list items -->
<!-- end of list of popular I-D processing instructions -->

<rfc category="info" docName="draft-zheng-netconf-fragmentation-02" ipr="trust200902">

 <front>

  <!-- The abbreviated title is used in the page header- it is only
       necessary if the full title is longer than 39 characters -->
  <title abbrev="Netconf Fragmentation">
A NETCONF Extension for Data Fragmentation</title>
  <author initials="G." surname="Zheng" fullname="Guangying Zheng">
      <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>zhengguangying@huawei.com</email>
      </address>
  </author>
 
   <author initials="M." surname="Wang" fullname="Michael Wang">
      <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>wangzitao@huawei.com</email>
      </address>
  </author>
 
  <date month="June" year="2018"></date>
  <!-- If the month and year are both specified and are the current ones,
       xml2rfc will fill in the current day for you. If only the current
       year is specified, xml2rfc will fill in the current day and month
       for you. If the year is not the current one, it is necessary to
       specify at least a month (xml2rfc assumes day="1" if not specified
       for the purpose of calculating the expiry date).  With drafts it is
       normally sufficient to specify just the year. -->

  <!-- Meta-data Declarations -->

  <area>OPS Area</area>
  <workgroup>Netconf</workgroup>

  <abstract>
<t>
   This document introduces an extension to NETCONF (Network Configuration) protocol. 
   The extension allows NETCONF to handle large size data as fragmented RPC messages. 
   Specifically, this document defines a new &lt;get-block&gt; capability and relevant operations to handle the fragmentations.</t>
  </abstract>

 </front>

 <middle>

  <!-- BEGIN 1. Introduction -->
  <section title="Introduction">
<t>
NETCONF <xref target="RFC6241"/> is the next generation network management protocol for configuring devices.  
It is becoming more and more popular, and some NMS (Network Management System) only use NETCONF as its southbound interface. 
The message procedures of NETCONF are based on RPC (Remote Procedure Call) interactions.  
A NETCONF client/server sends a &lt;rpc&gt; message to the counterpart and then receives a replying &lt;rpc-reply&gt; message.</t>
<t>
In some situations, the &lt;rpc-reply&gt; message might be very large.  
For example, when NMS is retrieving a large amount of routes in a core router or doing a full-synchronizing with a device, 
the &lt;rpc-reply&gt; data might exceed Mega-Byte amount.  And also in some scenarios, 
the client may retrieve a continuous stream of operational data from the operational datastore <xref target="I-D.ietf-netmod-revised-datastores"/>
to perform network analytics. Then there comes the problem of how to handle the large size data.  
This document briefly introduces two typical ways of current handling on this issue; and analyzes the problems of them.</t>

<t>
To fix the problems, in Section 4, this document proposes a method of extending the NETCONF protocol to allow handling large size data 
as fragmented &lt;rpc-reply&gt; messages.  The fragmentation is done at the NETCONF level, 
so it allows the NETCONF client to terminate the large size data processing momentarily by protocol interactions; 
and also allows the fragmented messages to be instantly parsed piece by piece. 
Specifically, the fragmentation is achieved through a newly defined &lt;get-block&gt; capability and relevant operations.
</t>

</section>
  <!-- END 1. Introduction -->

<!-- BEGIN 2. Terminology -->
 <section title="Concept and Terminology">
    <t>
The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", 
"SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" 
in this document are to be interpreted as described  
in <xref target="RFC2119" />.
    </t>
	<section title="Terminology">
        <t>DOM: Document Object Model, which is a cross-platform and language-independent convention for representing and interacting with objects in HTML, 
		XHTML and XML documents. Objects in the DOM tree may be addressed and manipulated by using methods on the objects.  </t>
		<t>SAX: Simple API for XML, which is an event sequential access parser API developed by the XML-DEV mailing list for XML documents. 
		SAX provides a mechanism for reading data from an XML document that is an alternative to that provided by the DOM. 
		Where the DOM operates on the document as a whole, SAX parsers operate on each piece of the XML document sequentially.</t>
		<t>libxml: a software library for parsing XML documents.</t>
		<t>&lt;get-block&gt;: a capability and operation defined in this document to handle large size</t>
   </section>
  <!-- END 2. Terminology -->  
</section>
  
<section title="Current Large size Handling Methods and Problems">

<section title="Stream-Oriented Handling">
<t>Stream-Oriented handling mainly includes the following two aspects:
<list style="none"> 
<t>o  The server encapsulates the large size replying data in a &lt;rpc-reply&gt; message and streams it to the client through TCP protocol.</t>
<t>o  The client parses the received &lt;rpc-reply&gt; content in a stream-oriented way.  
More specifically, the client could utilize SAX to instantly parse the received content without waiting for the whole message been transported.</t>
</list>
</t>

<t>Problems:
<list style="none"> 
<t>o  Stream-Oriented method lacks the capability of discontinuing large size processing in the server. 
It would cause unnecessary resource/performance cost in the devices if the NMS has already got the intended portion or just canceled by the administrators.</t>
<t>o  Another problem is the implementation of SAX parsing is more complex than DOM parsing in the Netconf client. 
More computing burden will be taken in Netconf client to support SAX parsing.</t>
</list>
</t>
 
</section>
<section title="Requesting a Portion of Data">
<t>
The clients actively limit the search range of the data so that the servers only need to reply with a part of the large size data. 
Thus the clients could control the replies in a reasonable size. 
One example is that the clients get a list of the content, and provide a start offset and a max-count, to get a portion at a time.
</t>

<t>Problems:
<list style="none"> 
<t>o  This method has an implication that the client needs to know the list/index of the intended large size data in advance before 
it starting the search request. It can't fit the scenarios of real-time on-demand data retrieving. 
And there is no standard to specify the list/index format in a uniform way. 
Thus it is only suitable for private implementation, thus multi-vendor interaction is not supported.</t>
<t>o  More important, it is just an indirect way to solve the problem. 
It could not fit the scenarios where the client just needs the whole large size data in the server.</t>
</list>
</t>
</section>

<section title ="Using tools to extract data respectively">
<t>
There are some tools/functions which can handle the iteration. For example, the XPATH's position() function can help to do this work. The following examples show some instances:
      <figure>
        <artwork><![CDATA[
<filter type="xpath" select="/interfaces/interface[position() >= 0 and position() < 25]" />

<filter type="xpath" select="/interfaces/interface[position() >= 25 and position() < 50]" />

]]> </artwork>
      </figure>	
</t>

<t>
Problems:
<list style="none"> 
<t>o  Xpath function just can meet the "xpath filter" case, which cannot cover the "subtree filter" case. </t>
<t>o  Different encoding format request different tools, and there is no standard to process the received data in a uniform way.  Thus it is only suitable for private implementation, thus multi-vendor interaction is not supported.</t>
</list>
</t>
</section>

</section>


<section title="Netconf Fragmentation Mechanism">

<section title="Fragmentation Requirements">
<t>
this document proposes an RPC fragmentation mechanism to handle the large size data.  Two essential requirements of the fragmentation are:
<list style="none"> 
<t>o  It needs to allow the NETCONF client to terminate the large size data processing momentarily by protocol interactions. 
In the proposed mechanisms in this draft, when the NETCONF server replies the client an &lt;rpc-reply&gt; fragmentation, 
it will wait the response from the client that whether it needs to send the next fragmentation. 
So if the initiator has got the intended portion, it could terminate the large size process immediately.</t>

<t>o  It needs to allow the NETCONF client to instantly parse the fragmentations piece by piece through the more widely supported DOM parsing. 
So in this document, it specifies that each &lt;rpc-reply&gt; fragmentation MUST be in a complete XML form.</t>
</list>
</t>

</section>
<section title="&lt;get-block&gt; extention">

<t>
o Function
</t>
<t>The devices can only use &lt;get-block&gt; operation when the Get-block capability was announced.</t>
<t>
The &lt;get-block&gt; fragmentation rules are:

<list style="none"> 
<t>A.  There should be a Max-Size for fragmentation.  [Ope Question]Should there be a clear specification of the size? E.g. 64K bytes.</t>

<t>B.  When the message reaches the Max-Size, it is sent to the client and the next message could be created in advance.</t>

<t>C.  Different records from one same table could be put into different &lt;rpc-reply&gt; messages</t>

<t>D.  All of the fields in one record MUST be put into one &lt;rpc-reply&gt; message.</t>

<t>E.  XML syntax MUST be complete in each fragmented message, so that each fragmentation could be parsed individually.</t>

<t>F.  If the record(s) of the child node(s)/table(s) and the parent node(s)/table(s) are replied in different fragmentations, 
the child node/table fragmentations MUST include the path and index information of all the ancestor node(s)/table(s) in a hierarchical mode.</t>

</list>
</t>

<t>
o Parameters
</t>
<t>&lt;discard-fragmentation&gt;: in &lt;get-block&gt; operation, if the &lt;discard-fragmentation&gt; parameter is conveyed, 
it means the operation is terminated.  Then it doesn't need to reply the remaining fragmentations.</t>

<t>
o Successful Operation Reply
</t>
<t>A &lt;rpc-reply&gt; message conveying a &lt;data&gt; element indicates the operation is successful. 
If there exists a next fragment, then an set-id attribute MUST be included in the &lt;rpc-reply&gt; messge. 
The attribute set-id is used to identify different fragment sets.</t>

<t>
o Exception Handling
</t>
<t>After the NETCONF server replies a fragment, if there is no corresponding Get-block request from the client 
in a reasonable period (the time valued to be specified in the future), then the server release the offset of the replying data 
and cannot use &lt;get-block&gt; operation anymore, and the remaining data needs to be replied.</t>
<t>Please refer to Appendix A.1 for an example.</t>
</section>

</section>
	
<section title="YANG data model">
         <t><figure>
          <artwork>&lt;CODE BEGINS&gt; file "ietf-netconf-fragmentation@2018-06-20.yang"
 module ietf-netconf-fragmentation {
     yang-version 1.1;
     namespace "urn:ietf:params:xml:ns:yang:ietf-netconf-fragmentation";
     prefix fgm;
     
	 import ietf-datastores{
	  prefix ds;
	 }
	  
     import ietf-yang-types {
       prefix yang;
     }
	 
     import ietf-netconf {
       prefix nc;
     }

     organization
       "IETF NETCONF Working Group";
     contact
       "WG Web:  &lt;https://datatracker.ietf.org/wg/netconf/&gt;

        WG List:  &lt;mailto:netconf@ietf.org&gt;

        Author:   Guangying Zheng 
		          &lt;zhengguangying@huawei.com&gt;
				  
        Author:   Zitao Wang
		          &lt;wangzitao@huawei.com&gt;";
     description
       "This document introduces an extension to NETCONF (Network Configuration) protocol.  
	   The extension allows NETCONF to handle large size data as fragmented RPC messages.  
	   Specifically, this document defines a new get-block capability and relevant 
	   operations to handle the fragmentations.";

     revision 2018-06-20 {
       description
         "Initial revision.";
       reference "draft-zheng-netconf-fragmentation-01";
     }
	 
	 
	 rpc get-block {
       description
         "Retrieve data from an NMDA datastore.";
       input {
         leaf source {
           type identityref {
            base ds:datastore;
           }
           mandatory true;
           description
             "Datastore from which to retrieve data.";
         }

         choice filter-spec {
           description
             "The content filter specification for this request.";

           anydata subtree-filter {
             description
               "This parameter identifies the portions of the
                target datastore to retrieve.";
             reference "RFC 6241, Section 6.";
           }
           leaf xpath-filter {
             if-feature nc:xpath;
             type yang:xpath1.0;
             description
               "This parameter contains an XPath expression
                identifying the portions of the target
                datastore to retrieve.";
           }
         }
     }
	}
	rpc discard-fragmentation {
	    description
        "Discard the netconf fragmentation, if the discard parameter is conveyed, 
		it means the operation is terminated.  
		Then it doesn't need to reply the remaining fragmentations.";
    }

}
&lt;CODE ENDS&gt;</artwork>
          </figure>
		 </t>

</section>	 

    
  

  <section title="Security Considerations">
    <t>
      TBD.
    </t>
  </section>



  <section title="IANA Considerations">
    <t>
      TBD.
    </t>
  </section>


 </middle>

 <back>

  <references title="Normative References">

   <?rfc include="reference.RFC.2119"?>

   <?rfc include="reference.RFC.6241"?>
   
   <?rfc include="reference.I-D.ietf-netmod-revised-datastores"?>

  </references>

    <section title="Appendix A: Examples of the Candidate Solutions">
      <t>A.1.  &lt;get-block&gt; (RPC Fragmentation) Example:</t>
      <t>Example 1: Get the next fragment</t>
       <figure>
        <artwork><![CDATA[
     <rpc message-id="101"
          xmlns="urn:ietf:params:xml:ns:NETCONF:base:1.0">
       <get-config>
         <source>
           <running/>
         </source>
         <filter type="subtree">
           <top xmlns="http://example.com/schema/1.2/config">
             <users/>
           </top>
         </filter>
       </get-config>
     </rpc>

     <rpc-reply message-id="101"
          xmlns="urn:ietf:params:xml:ns:NETCONF:base:1.0"
          xmlns:hw=http://www.huawei.com/NETCONF/capability/base/1.0
hw:set-id="101">
       <data>
         <top xmlns="http://example.com/schema/1.2/config">
           <users>
             <user>
               <name>root</name>
               <type>superuser</type>
               <full-name>Charlie Root</full-name>
               <company-info>
                 <dept>1</dept>
                 <id>1</id>
               </company-info>
             </user>
             <!-- additional <user> elements appear here... -->
           </users>
         </top>
       </data>
     </rpc-reply>

<rpc message-id="102"
          xmlns="urn:ietf:params:xml:ns:NETCONF:base:1.0">
       <get-block xmlns="http://www.huawei.com/NETCONF/capability/base/1.0"
set-id="101">
       </get-block>
     </rpc>
     <rpc-reply message-id="102"
          xmlns="urn:ietf:params:xml:ns:NETCONF:base:1.0"
          xmlns:hw=http://www.huawei.com/NETCONF/capability/base/1.0
hw:set-id="101">
       <data>
         <top xmlns="http://example.com/schema/1.2/config">
           <users>
             <user>
               <name>admin</name>
               <type>commonuser</type>
               <full-name>Jim Green</full-name>
               <company-info>
                 <dept>9</dept>
                 <id>90</id>
               </company-info>
             </user>
             <!-- additional <user> elements appear here... -->
           </users>
         </top>
       </data>
     </rpc-reply>
]]></artwork> 
</figure> 

<t>Example 2: Abandon the remaining fragments</t>
 <figure>
  <artwork><![CDATA[
     <rpc message-id="103"
          xmlns="urn:ietf:params:xml:ns:NETCONF:base:1.0">
       <get-block xmlns=http://www.huawei.com/NETCONF/capability/base/1.0 set-id="1">
         <discard-fragmentation/>
       </get-block>
     </rpc>

     <rpc-reply message-id="103"
       xmlns="urn:ietf:params:xml:ns:NETCONF:base:1.0">
       <ok/>
     </rpc-reply>

]]></artwork> 
</figure> 

   </section>
 </back>

</rfc>
