<?xml version="1.0"?>
<!DOCTYPE rfc SYSTEM 'rfc2629.dtd'[
<!ENTITY RFC1213 SYSTEM "http://xml.resource.org/public/rfc/bibxml/reference.RFC.1213.xml">
<!ENTITY RFC2119 SYSTEM "http://xml.resource.org/public/rfc/bibxml/reference.RFC.2119.xml">
<!ENTITY RFC2863 SYSTEM "http://xml.resource.org/public/rfc/bibxml/reference.RFC.2863.xml">
<!ENTITY RFC2578 SYSTEM "http://xml.resource.org/public/rfc/bibxml/reference.RFC.2578.xml">
<!ENTITY RFC3410 SYSTEM "http://xml.resource.org/public/rfc/bibxml/reference.RFC.3410.xml">
<!ENTITY RFC3411 SYSTEM "http://xml.resource.org/public/rfc/bibxml/reference.RFC.3411.xml">
<!ENTITY RFC3414 SYSTEM "http://xml.resource.org/public/rfc/bibxml/reference.RFC.3414.xml">
<!ENTITY RFC3416 SYSTEM "http://xml.resource.org/public/rfc/bibxml/reference.RFC.3416.xml">
<!ENTITY RFC3418 SYSTEM "http://xml.resource.org/public/rfc/bibxml/reference.RFC.3418.xml">
<!ENTITY RFC3986 SYSTEM "http://xml.resource.org/public/rfc/bibxml/reference.RFC.3986.xml">
<!ENTITY RFC4088 SYSTEM "http://xml.resource.org/public/rfc/bibxml/reference.RFC.4088.xml">
<!ENTITY RFC4113 SYSTEM "http://xml.resource.org/public/rfc/bibxml/reference.RFC.4113.xml">
<!ENTITY RFC4291 SYSTEM "http://xml.resource.org/public/rfc/bibxml/reference.RFC.4291.xml">
<!ENTITY RFC4293 SYSTEM "http://xml.resource.org/public/rfc/bibxml/reference.RFC.4293.xml">
<!ENTITY RFC4944 SYSTEM "http://xml.resource.org/public/rfc/bibxml/reference.RFC.4944.xml">
<!ENTITY RFC6020 SYSTEM "http://xml.resource.org/public/rfc/bibxml/reference.RFC.6020.xml">
<!ENTITY RFC6241 SYSTEM "http://xml.resource.org/public/rfc/bibxml/reference.RFC.6241.xml">
<!ENTITY RFC6347 SYSTEM "http://xml.resource.org/public/rfc/bibxml/reference.RFC.6347.xml">
<!ENTITY RFC6643 SYSTEM "http://xml.resource.org/public/rfc/bibxml/reference.RFC.6643.xml">
<!ENTITY RFC6650 SYSTEM "http://xml.resource.org/public/rfc/bibxml/reference.RFC.6650.xml">
<!ENTITY RFC6775 SYSTEM "http://xml.resource.org/public/rfc/bibxml/reference.RFC.6775.xml">
<!ENTITY RFC6690 SYSTEM "http://xml.resource.org/public/rfc/bibxml/reference.RFC.6690.xml">
<!ENTITY RFC7049 SYSTEM "http://xml.resource.org/public/rfc/bibxml/reference.RFC.7049.xml">
<!ENTITY RFC7252 SYSTEM "http://xml.resource.org/public/rfc/bibxml/reference.RFC.7252.xml">
<!ENTITY RFC7317 SYSTEM "http://xml.resource.org/public/rfc/bibxml/reference.RFC.7317.xml">
<!ENTITY I-D.ietf-core-block SYSTEM "http://xml.resource.org/public/rfc/bibxml3/reference.I-D.ietf-core-block.xml">
<!ENTITY I-D.ietf-core-groupcomm SYSTEM "http://xml.resource.org/public/rfc/bibxml3/reference.I-D.ietf-core-groupcomm.xml">
<!ENTITY I-D.ietf-core-interfaces SYSTEM "http://xml.resource.org/public/rfc/bibxml3/reference.I-D.ietf-core-interfaces.xml">
<!ENTITY I-D.ietf-core-observe SYSTEM "http://xml.resource.org/public/rfc/bibxml3/reference.I-D.ietf-core-observe.xml">
<!ENTITY I-D.ietf-json-rfc4627bis SYSTEM "http://xml.resource.org/public/rfc/bibxml3/reference.I-D.ietf-json-rfc4627bis.xml">
<!ENTITY I-D.becker-core-coap-sms-gprs SYSTEM "http://xml.resource.org/public/rfc/bibxml3/reference.I-D.becker-core-coap-sms-gprs.xml">
<!ENTITY I-D.ersue-constrained-mgmt SYSTEM "http://xml.resource.org/public/rfc/bibxml3/reference.I-D.ersue-constrained-mgmt.xml">
<!ENTITY I-D.ietf-netmod-yang-json SYSTEM "http://xml.resource.org/public/rfc/bibxml3/reference.I-D.ietf-netmod-yang-json.xml">
<!ENTITY I-D.ietf-6lo-lowpan-mib SYSTEM "http://xml.resource.org/public/rfc/bibxml3/reference.I-D.ietf-6lo-lowpan-mib.xml">
<!ENTITY I-D.ietf-netconf-restconf SYSTEM "http://xml.resource.org/public/rfc/bibxml3/reference.I-D.ietf-netconf-restconf.xml">
<!ENTITY I-D.ietf-lwig-coap SYSTEM "http://xml.resource.org/public/rfc/bibxml3/reference.I-D.ietf-lwig-coap.xml">
]>


<?rfc toc="yes"?>
<?rfc symrefs="yes" ?>

<rfc category="std" ipr="trust200902" docName="draft-vanderstok-core-comi-05">
  <front>
    <title abbrev="CoMI">CoAP Management Interface</title>
    <author initials="P." surname="van der Stok" fullname="Peter van der Stok">
      <organization abbrev="consultant">consultant</organization>
      <address>
        <phone>+31-492474673 (Netherlands), +33-966015248 (France)</phone>
        <email>consultancy@vanderstok.org</email>
        <uri>www.vanderstok.org</uri>
      </address>
    </author>
    <author initials="B." surname="Greevenbosch" fullname="Bert Greevenbosch">
        <organization abbrev="Huawei Technologies">Huawei Technologies Co., Ltd.</organization>
         <address>
              <postal>
                   <street>Huawei Industrial Base</street>
                   <street>Bantian, Longgang District</street>
                   <city>Shenzhen</city>
                   <code>518129</code>
                   <country>P.R. China</country>
               </postal>
               <email>bert.greevenbosch@huawei.com</email>
          </address>
      </author>

   <author initials="A" surname="Bierman" fullname='Andy Bierman' >
      <organization>YumaWorks</organization>
      <address>
        <email>andy@yumaworks.com</email>
      </address>
    </author>


    <author fullname="Juergen Schoenwaelder" initials="J"
            surname="Schoenwaelder">
      <organization>Jacobs University</organization>
      <address>
        <postal>
          <street>Campus Ring 1</street>
          <city>Bremen</city>
          <code>28759</code>
          <country>Germany</country>
        </postal>
        <email>j.schoenwaelder@jacobs-university.de</email>
      </address>
    </author>
    
    <author fullname="Anuj Sehgal" initials="A"
            surname="Sehgal">
      <organization>Jacobs University</organization>
      <address>
        <postal>
          <street>Campus Ring 1</street>
          <city>Bremen</city>
          <code>28759</code>
          <country>Germany</country>
        </postal>
        <email>s.anuj@jacobs-university.de</email>
      </address>
    </author>


    <date day="27" month="October" year="2014"/>
    <area>Applications</area>
    <workgroup>core</workgroup>
    <abstract>
      <t>
        This document describes a network management interface for constrained devices, called CoMI.
        CoMI is an adaptation of the RESTCONF protocol for use in constrained devices and networks.
        It is designed to reduce the message sizes, server code size, and application development complexity.
        The Constrained Application Protocol (CoAP) is used to access management data resources specified in YANG,
        or SMIv2 converted to YANG. The payload of the CoMI message is encoded in Concise Binary Object Representation (CBOR).
      </t>
    </abstract>
    <note title="Note">
      <t>
        Discussion and suggestions for improvement are requested,
        and should be sent to core@ietf.org.
      </t>
    </note>
  </front>
  <middle>

<section anchor="introduction" title="Introduction">
<t>
The Constrained Application Protocol (CoAP) <xref target="RFC7252"/> is designed for 
Machine to Machine (M2M) applications such as smart energy and building control.
Constrained devices need to be managed in an automatic fashion to handle the large quantities of devices that are expected in
future installations. The messages between devices need to be as small and infrequent as possible. The implementation
complexity and runtime resources need to be as small as possible.
</t><t>
The draft <xref target="I-D.ietf-netconf-restconf"/> describes a REST-like interface called RESTCONF,
which uses HTTP methods to access structured data defined in YANG <xref target="RFC6020"/>.
RESTCONF allows access to data resources contained in NETCONF <xref target="RFC6241"/> datastores.
RESTCONF messages can be encoded in XML <xref target="XML"/> or JSON. The GET method is used
to retrieve data resources and the POST, PUT, PATCH, and DELETE methods are used to create, replace,
merge, and delete data resources.
</t><t>
A large amount of  Management Information Base (MIB) <xref target="RFC3418"/> specifications already
exist for monitoring purposes. This data can be accessed in RESTCONF if the server converts the
SMIv2 modules to YANG, using the mapping rules defined in <xref target="RFC6643"/>.
</t><t>
The CoRE Management Interface (CoMI) is intended to work on standardized data-sets in a stateless client-server fashion.
The RESTCONF protocol is adapted and optimized for use in constrained environments, using
CoAP instead of HTTP.
Standardized data sets promote interoperability between small devices and applications from different manufacturers.
Stateless communication is encouraged to keep communications simple and the amount of state information small in
line with the design objectives of 6lowpan <xref target="RFC4944"/> <xref target="RFC6775"/>, RPL <xref target="RFC6650"/>, and CoAP <xref target="RFC7252"/>.
</t><t>
RESTCONF uses the HTTP methods HEAD, OPTIONS, and PATCH, which are not available in CoAP.
The use of TCP is also a problem in HTTP. The transport protocols available fo CoAP are
much better suited to constrained networks.
</t><t>
CoMI is low resource oriented, uses CoAP,
and only supports the methods GET, PUT, POST and DELETE. CoMI uses CBOR as the data format.
To support small payloads, CoMI use an additional data identifier string to number conversion to minimise CBOR payloads.
It is assumed that the managed device is the most constrained entity. The client might be more capable,
however this is not necessarily the case.
</t><t>
Currently, small managed devices need to support at least two protocols: CoAP and SNMP.
When the MIB can be accessed with the CoAP protocol, the SNMP protocol can be replaced with the CoAP protocol. Although the SNMP server size is not huge (see <xref target="code-sizes"/>), the code for the security aspects of SMIv3 is not negligible.
Using CoAP to access secured management objects reduces the code complexity of the stack in the constrained device, and harmonizes applications development.
</t>
<t>
The objective of CoMI is to provide a CoAP based Function Set that reads and sets values of managed objects in devices to (1) initialize parameter values at start-up, (2) acquire statistics during operation, and (3) maintain nodes by adjusting parameter values during operation.
</t><t>
The payload of CoMI is encoded in CBOR <xref target="RFC7049"/> which is automatically generated from JSON <xref target="JSON"/>.
CBOR has a binary format and hence has more coding efficiency than JSON.
</t>
<t>
The end goal of CoMI is to provide information exchange over the CoAP transport protocol in a uniform manner as a first step to the full management functionality as specified in <xref target="I-D.ersue-constrained-mgmt"/>.
</t>

<section anchor="design" title="Design considerations">
<t>
CoMI supports discovery of resources, accompanied by reading, writing and notification of resource values.

<!--
As such it is close to the device management of the Open Mobile Alliance described in <xref target="OMA"/>.
However, the structure of the YANG modules does not reflect the structure of the OMA management objects.
It is assumed that the structure and semantics of the management data are the most important aspect of a
standardized YANG module. The right path forward to integrate OMA management with CoMI is the adaptation
of YANG-based data specifications by OMA.
 -->

CoMI supports MIB modules which have been translated from SMIv2 to YANG, using <xref target="RFC6643"/>.
This mapping is read-only so writable SMIv2 objects need to be converted to YANG using an
implementation-specific mapping.

</t>
<t>
CoMI uses a simple URI to access the management object resources. Complexity introduced by module name, context specification, or row selection, is expressed with uri-query attributes. The choice for uri-query attributes makes the URI structure less context dependent.
</t>
</section>

<section anchor="terminology" title="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>
<t>
Readers of this specification should be familiar with all the terms and concepts discussed in <xref target="RFC3410"/>, <xref target="RFC3416"/>, and <xref target="RFC2578"/>.
</t>
<t>
  The following terms are defined in the NETCONF protocol <xref target="RFC6241"/>:
  <list>
    <t>client</t>
    <t>configuration data</t>
    <t>datastore</t>
    <t>server</t>
  </list>
</t>
<t>
  The following terms are defined in the YANG data modeling language <xref target="RFC6020"/>:
  <list>
    <t>container</t>
    <t>data node</t>
    <t>key</t>
    <t>key leaf</t>
    <t>leaf</t>
    <t>leaf-list</t>
    <t>list</t>
  </list>
</t>
<t>
  The following terms are defined in RESTCONF protocol <xref target="I-D.ietf-netconf-restconf"/>:
  <list>
    <t>data resource</t>
    <t>datastore resource</t>
    <t>edit operation</t>
    <t>query parameter</t>
    <t>target resource</t>
    <t>unified datastore</t>
  </list>
</t>
<t>
  The following terms are defined in this document:
  <list style="hanging">
    <t hangText="YANG hash:"> CoMI object identifier, which is a 32-bit numeric hash of the YANG object identifier
      string for the object. When a YANG hash value is printed in a request target URI, error-path or
      other string, then the lowercase hexadecimal representation is used. Leading zeros are used so the
      value uses 8 hex characters.
    </t>
  </list>
</t>
<t>
  The following list contains the abbreviations used in this document.
  <list style="hanging">
    <t hangText="XXXX:">TODO, and others to follow.</t>
  </list>
</t>
<section anchor="tree-diagrams" title="Tree Diagrams">
<t>
A simplified graphical representation of the data model is used in
this document.  The meaning of the symbols in these
diagrams is as follows:
</t>
<t>
<list>
<t>Brackets "[" and "]" enclose list keys.</t>
<t>Abbreviations before data node names: "rw" means configuration
data (read-write) and "ro" state data (read-only).</t>
<t>Symbols after data node names: "?" means an optional node, "!" means
a presence container, and "*" denotes a list and leaf-list.</t>
<t>Parentheses enclose choice and case nodes, and case nodes are also
marked with a colon (":").</t>
<t>Ellipsis ("...") stands for contents of subtrees that are not shown.</t>
</list>
</t>
</section>

</section>  <!-- Terminology -->

</section>  <!-- Introduction -->


<section anchor="comi-architecture" title="CoMI Architecture">
<t>
This section describes the CoMI architecture to use CoAP for the reading and modifying of instrumentation variables used for the management of the instrumented node.
</t>
<figure><artwork align="left"><![CDATA[

Client
+--------------------------------------------------------------+
| +--------------+    +--------------+                         |
| |    SMIv2     | >  |      YANG    |    >       COAP         |
| |description(2)|    |description(1)|          Request(3)     |
| ----------------    +--------------+    [         *          |
+-----------------------------*-----------[---------*----------+
                              *           [         *
                              *           [    +-----------+
                      mapping *   security[    |  Network  |
                              *      (8)  [    | packet(4) |
                              *           [    +-----------+
Server                        *           [         *
+-----------------------------*-----------[---------*----------+
|                             *           [         *          |
|                             *                 Retrieval,     |
|                             *               Modification(5)  |
|                            \*/                    *          |
| +-------------------------------------------------*--------+ |
| | +--------------+   +--------------+       +------------+ | |
| | | statistics   |   |configuration |       |Operational | | |
| | |    (6c)      |   |     (6b)     |       |  state(6a) | | |
| | +--------------+   +--------------+       +------------+ | |
| |                    variable store (6)           *        | |
| +-------------------------------------------------*--------+ |
|                                                   *          |
|                                                Variable      |
|                                            Instrumentation(7)|
+--------------------------------------------------------------+

]]></artwork></figure>
<t>
Figure 1 is a high level representation of the main elements of the CoAP management architecture. A client sends requests as payload in packets over the network to a managed constrained node. 
</t>
<t>
Objectives are:
<list style="symbols">
<t>Equip a constrained node with a management server that provides information about the operational characteristics of the code running in the constrained node.</t>
<t>The server provides this information in a variable store that contains values describing the performance characteristics and the code parameter values.</t>
<t>The client receives the performance characteristics on a regular basis or on request.</t>
<t>The client sets the parameter values in the server at bootstrap and intermittently when operational conditions change.</t>
<t>The constrained network requires the payload to be as small as possible, and the constrained server memory
requirements should be as small as possible.</t>
</list>
</t>

<t>
The components in Figure 1 have the following high-level functionality.
<list style="symbols">
<t>The instrumentation variables and parameters are described in the YANG or SMIv2 language.</t>
<t>Descriptions in the SMIv2 language are translated into the YANG language.</t>
<t>The YANG description serves as input to the writers of application and instrumentation code and the humans analysing the returned values (arrow from YANG description to Variable store). The description is used to check the correctness of the CoAP request and do the CBOR
encoding.</t>
<t>The CoAP request packs the request to read or set variables in the packet payload, which is transmitted over the network using IP. The CoAP request also receives values returned by the server in the payload of a packet. On arrival of the packet in the server, the payload is retrieved and decoded.</t>
<t>Values are stored in the appropriate variables in the Variable store, and or values are returned from the Variable store into the payload of the packet. The Variable instrumentation code stores the values of the parameters into the appropriate places in the operational code. The variable instrumentation code reads current execution values from the operational code and stores them in the Variable store.</t>
<t>The network communication must be secured.</t>
</list>
</t>
<t>
For interoperability it is required that in addition to using the Internet Protocol for data transport:
<list style="symbols">
<t>The names, type, and semantics of the instrumentation variables are standardized.</t>
<t>The instrumentation variables are described in a standard language. </t>
<t>The signature of the CoAP request in the server is standardized.</t>
<t>The format of the packet payload is standardized.</t>
<t>The notification from server to client is standardized.</t>
</list>
</t>
<t>
The different numbered components of Figure 1 are discussed according to component number.
<list style="hanging"> 
<t hangText="(1) YANG description:"> A description contains a set of named and versioned modules. A module contains a hierarchy of named and typed resources. A resource is uniquely identified by a sequence of its name and the names of the enveloping resources following the hierarchy order. 
</t>
<t hangText="(2) SMIv2 description:"> A named module contains a set of variables and "conceptual tables". Named variables have simple types. Conceptual tables are composed of typed named columns. The variable name and module name identify the variable uniquely. There is an algorithm to translate SMIv2 specifications to YANG specifications.
</t>
<t hangText="(3) CoAP request:"> The CoAP request needs a Universal Resource Identifier (URI) and the payload of the packet to send a request. The URI is composed of the schema, server, path and query and looks like coap://entry.example.com/&lt;path&gt;?&lt;query&gt;. Fragments are not supported. Allowed operations are PUT, GET, DELETE, and POST. New variables can be created with POST when they exist in the YANG specification. The Observe option can be used to return variable values regularly or on event occurrence (notification).
</t>
<t hangText="(3.1) CoAP &lt;path&gt;:"> The path identifies the variable in the form "/mg/data/&lt;identifier&gt;.</t>
<t hangText="(3.2) CoAP &lt;query&gt;:"> The query parameter is used to specify additional (optional) aspects like the module name, the smi context, and others. The idea is to keep the path simple and put variations on variable specification in the query.
</t>
<t hangText="(3.3) CoAP discovery:"> Discovery of the variables is done with standard CoAP resource discovery using /.well-known/core with ?rt=/core/mg.
</t>
<t hangText="(4) Network packet:"> The payload contains the CBOR encoding of a single JSON object.
This object corresponds to the converted RESTCONF message payload.
</t>
<t hangText="(5) Retrieval, modification:"> The server needs to parse the CBOR encoded message 
and identify the corresponding entries in the Variable store. In addition, this component
includes the code for CoAP Observe and block options.
</t>
<t hangText="(6) Variable store:"> The store is composed of three parts: Operational state, Configuration datastore, and Statistics (see <xref target= "restconf-architecture"/>.
</t>
<t hangText="(7) Variable instrumentation:"> This code depends on implementation of drivers and other node specific aspects.
</t>
<t hangText="(8) Security:"> The server MUST prevent unauthorized users from reading or writing
any data resources, however a standard access control model for CoMI should be specified in a
separate document. DTLS is specified to secure CoAP communication.
</t>
</list>
</t>

<section anchor="restconf-architecture" title="RESTCONF/YANG Architecture">
<t>
CoMI adapts the RESTCONF architecture so data exchange and implementation requirements
are optimized for constrained devices.
</t>
<t>
The RESTCONF protocol uses a unified datastore to edit conceptual data structures
supported by the server. The details of transaction preparation and non-volatile
storage of the data are hidden from the RESTCONF client. CoMI also uses a unified datastore,
to allow stateless editing of any configuration variables.
</t>
<t>
The child schema nodes of the unified datastore include all the top-level YANG data nodes
in all the YANG modules supported by the server. The YANG data structures represent
a hierarchy of data resources. The client discovers the list of YANG
modules, and important conformance information such as the module revision dates,
YANG features supported, and YANG deviations required.  The individual data nodes are
discovered indirectly by parsing the YANG modules supported by the server.
</t>
<t>
The YANG data definition statements contain a lot of information that can help automation
tools, developers, and operators use the data model correctly and efficiently.  The YANG definitions
and server YANG module capability advertisements provide an "API contract" that allow a client
to determine the detailed server management capabilities very quickly.  CoMI allows access
to the same data resources as a RESTCONF server, except the messages are optimized
to reduce identifier and payload size.
</t>
<t>
RESTCONF uses a simple algorithmic mapping from YANG to URI syntax to identify the target resource
of a retrieval or edit operation. A client can construct operations or scripts using a
predictable syntax, based on the YANG data definitions. The target resource URI can
reference a data resource instance, or the datastore itself (to retrieve the entire datastore
or create a top-level data resource instance).  CoMI uses a 32-bit YANG hash value (based
on the YANG data node path identifier strings) to identify schema nodes
in the target resource URI.
</t>
<t>
Any message payload data is relative to the node specified in the target resource URI
in a request message. Each message is a well-formed XML instance document or JSON object,
corresponding to the YANG schema definition specified by the target resource node.
CoMI uses the hash value for the data node identifier in the message payloads,
instead of the module-name prefixed identifier name like RESTCONF.
CoMI message payloads are based on the JSON encoding of a RESTCONF message payload.
The JSON identifier names are first converted to their 32-bit YANG hash values and
then the payload is converted to CBOR.
</t>
</section>
</section>  <!-- CoMI Architecture  -->


<section anchor="coap-interface" title="CoAP Interface">
<t>

In CoRE a group of links can constitute a Function Set. The format of the links is specified in <xref target="I-D.ietf-core-interfaces"/>.
  This note specifies a Management Function Set. CoMI end-points that implement the CoMI management protocol support
 at least one discoverable management resource of resource type (rt): core.mg, with path: /mg, where mg is short-hand for management.
</t>
<t>
The mg resource has three sub-resources accessible with the paths:
<list style="hanging">
<t hangText="/mg/data:">YANG-based data with path "/mg/data" and using CBOR content encoding format.
This path represents a datastore resource which contains YANG data resources as its descendant nodes.
All identifiers referring to YANG data nodes within this path are encoded as YANG hash values.</t>
<t hangText="/mg/moduri:">URI indicating the location of the server module information, with path "/mg/moduri" and CBOR content format. This YANG data is encoded with plain identifier strings, not YANG hash values.</t>
<t hangText="/mg/yang-hash:">URI indicating the location of the server YANG hash information if any objects needed
to be re-hashed by the server. It has path "/mg/yang-hash" and is encoded in CBOR format.
The "ietf-yang-hash" module in <xref target="YANGMOD"/> is used to define the syntax and semantics
of this data structure.
This YANG data is encoded with plain identifier strings, not YANG hash values. The server will only have
this resource if there are any objects that needed to be re-hashed due to a hash collision.</t>
</list>
</t>
<t>
The "/mg/data" resource provides access to the YANG data resources as described in <xref target="mgFS"/>.
The "/mg/moduri" resource provides access to a URI that can be used to retrieve an instance of
the "ietf-yang-library" module, defined in the RESTCONF draft.
This module lists the name, revision, and conformance information for each YANG module, which
a client needs to determine the YANG data model objects that are supported by a server.
This URI can be reference a local data resource within the server, or reference a remote data resource, such as a shared file server.
The data resource identifiers are YANG hash values, as described in <xref target="HASH-GEN"/>.
</t>
<t>
The profile of the management function set, with IF=core.mg, is shown in the table below,
following the guidelines of <xref target="I-D.ietf-core-interfaces"/>:
</t>

<texttable>
  <ttcol align="left">name</ttcol>
  <ttcol align="left">path</ttcol>
  <ttcol align="left">rt</ttcol>
  <ttcol align="left">Data Type</ttcol>

  <c> Management  </c>   <c> /mg </c> <c> core.mg </c> <c> n/a </c>
  <c> Data  </c>   <c> /mg/data </c> <c> core.mg.data </c> <c> application/cbor </c>
  <c> Module Set URI </c>   <c> /mg/moduri </c> <c> core.mg.moduri </c> <c> application/cbor </c>
  <c> YANG Hash Info </c>   <c> /mg/yang-hash </c> <c> core.mg.yang-hash </c> <c> application/cbor </c>
</texttable>

</section>   <!-- CoAP Interface -->

<section anchor="mgFS" title="MG Function Set">
<t>
The MG Function Set provides a CoAP interface to perform a subset of the functions provided by RESTCONF.
</t>

<t>
A subset of the operations defined in RESTCONF are used in CoMI:
</t>
<texttable>
  <ttcol align="left">Operation</ttcol>
  <ttcol align="left">Description</ttcol>
  <c> GET </c>   <c> Retrieve the datastore resource or a data resource </c>
  <c> POST </c>   <c> Create a data resource </c>
  <c> PUT </c>   <c> Create or replace a data resource </c>
  <c> DELETE </c>   <c> Delete a data resource </c>
</texttable>

<section anchor="DataRetrieval" title="Data Retrieval">
<section anchor="GetOperation" title="GET">
<t>
Data resources are retrieved by the client with the GET method.
The RESTCONF GET operation is supported in CoMI.
The same constraints apply as defined in section 3.3 of <xref target="I-D.ietf-netconf-restconf"/>.
The operation is mapped to the GET method defined in section 5.8.1 of <xref target="RFC7252"/>.
</t>
<t>
It is possible that the size of the payload is too large to fit in a single message.
In the case that management data is bigger than the maximum supported payload size,
the Block mechanism from <xref target="I-D.ietf-core-block"/> is used.
Notice that the Block mechanism splits the data at fixed positions,
such that individual data fields may become fragmented.
Therefore,  assembly of multiple blocks may be required to process the complete data field.
</t>
<t>
There are optional query parameters for the GET method.
A CoMI server MAY implement these query parameters in order to allow common data retrieval
filtering functionality.
</t>
<texttable>
  <ttcol align="left">Query Parameter</ttcol>
  <ttcol align="left">Description</ttcol>
  <c> content </c>   <c> Select config and/or non-config data resources </c>
  <c> depth </c>   <c> Request limited sub-tree depth in the reply content </c>
  <c> select </c>   <c> Request selected sub-trees from the target resource </c>
</texttable>
</section>

<section anchor="SelectParam" title="Mapping of the 'select' Parameter">
<t>
TODO: discuss how only a limited subset of the select parameter is used, and how
the node names are changed to YANG hashes.
</t>
</section>

<section anchor="RetrievalExamples" title="Retrieval Examples">

<t>
The examples in this section use a JSON payload with one or more entries describing the pair (objectID, value). CoMI transports the CBOR format to transport the equivalent contents. The CBOR syntax of the payloads is specified in <xref target="mapping"/>.
</t>

<section anchor="single" title="Single object values">

<t>
A request to read the value of a management object or the leaf of an object is sent with a confirmable CoAP GET message. A single object is specified in the URI path prefixed with /mg/data. 
</t>
<t>
A request to set the value of an object/leaf is sent with a confirmable CoAP PUT message.
The Response is piggybacked to the CoAP ACK message corresponding with the Request.
</t>

<!--
<t>
TODO: for multicast send unconfirmed PUT
</t>
  -->

<t>
Using for example the clock container from <xref target="RFC7317"/>, a request is sent to retrieve the value of clock/current-datetime specified in module system-state. The answer to the request returns a (ObjectID, value) pair.
</t><t>
In all examples: (1) the payload is expressed in JSON, although the operational payload is specified to be in CBOR, and (2) the path is expressed in readable names although the transported path is expressed in numbers.
</t>

 <figure>
    <artwork align="left"><![CDATA[

REQ: GET example.com/mg/data/system-state/clock/current-datetime

RES: 2.05 Content (Content-Format: application/cbor)
{
    "current-datetime" : "2014-10-26T12:16:31Z"
}
]]></artwork>
    </figure>
<t>
TODO: convert the example above so it uses YANG hash values instead of the string "current-datetime".
Convert the target resource URI string "system-state/clock/current-datetime" to a YANG hash value.
</t>

<t>
The specified object can be an entire object. Accordingly, the returned payload is composed of all the leaves associated with the object. Each leaf is returned as a (YANG hash, value) pair. For example, the GET of the clock object, sent by the client, results in the following returned payload sent by the managed entity:
      </t>

<figure><artwork align="left">
<![CDATA[
REQ: GET example.com/mg/data/system-state/clock
   (Content-Format: application/cbor)

RES: 2.05 Content (Content-Format: application/cbor)
{
   "clock" : {
      "current-datetime" : "2014-10-26T12:16:51Z",
      "boot-datetime" : "2014-10-21T03:00:00Z"
      "timezone" : {
         "timezone-location" : "Europe/Stockholm",
         "timezone-utc-offset" : -60
      }
   }
}

]]></artwork></figure>

<t>
TODO: convert the example above so it uses YANG hash values instead of the strings
"clock", "current-datetime", "boot-datetime", "timezone", and "timezone-utc-offset".
Convert the target resource URI string "system-state/clock" to a YANG hash value.
</t>
<t>
The specified object can be a list. Accordingly, the returned payload is composed of all the entries associated with the list. Each entry is returned as a (entry name, value) pair. For example, the GET of the ietf-ip/ipv6/neighbor list, sent by the client, results in the following returned payload sent by the managed entity:
      </t>

<figure><artwork align="left">
<![CDATA[
REQ: GET example.com/mg/data/ietf-ip/ipv6/neighbor
   (Content-Format: application/cbor)


RES: 2.05 Content (Content-Format: application/cbor)
{
   "neighbor" : [
     {
	"ip" : "fe80::200:f8ff:fe21:67cf",
	"link-layer-address" : "00:00::10:01:23:45"
	},
     {
	"ip" : "fe80::200:f8ff:fe21:6708",
	"link-layer-address" : "00:00::10:54:32:10"
	},
     {
	"ip" : "fe80::200:f8ff:fe21:88ee",
	"link-layer-address" : "00:00::10:98:76:54"
	}
    ]
}
]]></artwork></figure>

<t>
TODO: convert the example above so it uses YANG hash values instead of the strings
"neighbor", "ip", and "link-layer-address". Convert the target resource URI
string "ietf-ip/ipv6/neighbor" to a YANG hash value.
</t>

<t>
TODO: show examples using the "keys" parameter to select a specific instance
of a list entry.
</t>

</section>

</section>   <!-- Retrieval Examples -->

</section>  <!-- Data Retrieval -->

<section anchor="DataEditing" title="Data Editing">
<t>
CoMI allows datastore contents to be created, modified and deleted using CoAP methods.
</t>
<t>
TODO: Should this be an optional feature?  A server can choose to only support
YANG modules with read-only objects. MIN-ACCESS conformance does not exist in YANG.
</t>

<section anchor="PostOperation" title="POST">
<t>
Data resource instances are created with the POST method.
The RESTCONF POST operation is supported in CoMI, however it is only allowed
for creation of data resources.
The same constraints apply as defined in section 3.4.1 of <xref target="I-D.ietf-netconf-restconf"/>.
The operation is mapped to the POST method defined in section 5.8.2 of <xref target="RFC7252"/>.
</t>

<!--
<t>
There are optional query parameters for the POST method.
A CoMI server MAY implement these query parameters in order to allow control over
instance ordering of user-ordered data (YANG ordered-by user).
</t>
<texttable>
  <ttcol align="left">Query Parameter</ttcol>
  <ttcol align="left">Description</ttcol>
  <c> insert </c>   <c> Specify the type of user-ordered data insertion for the new data </c>
  <c> point </c>   <c> Specify the insertion point if the 'insert' parameter is set to 'before' or 'after'. </c>
</texttable>
  -->

<t>
There are no query parameters for the POST method.
</t>
<t>
TODO: how to support user-ordered lists in YANG?  This is done with the 'insert' and 'point'
parameters in RESTCONF. In CoMI, a client will have to replace the all list or leaf-list
entries (e.g. PUT parent container) to change the order or insert anywhere but last.
</t>


</section>

<section anchor="PutOperation" title="PUT">
<t>
Data resource instances are created or replaced with the PUT method.
The PUT operation is supported in CoMI.
The same constraints apply as defined in section 3.5 of <xref target="I-D.ietf-netconf-restconf"/>.
The operation is mapped to the PUT method defined in section 5.8.3 of <xref target="RFC7252"/>.
</t>

<!--
<t>
There are optional query parameters for the PUT method.
A CoMI server MAY implement these query parameters in order to allow control over
instance ordering of user-ordered data (YANG ordered-by user).
</t>
<texttable>
  <ttcol align="left">Query Parameter</ttcol>
  <ttcol align="left">Description</ttcol>
  <c> insert </c>   <c> Specify the type of user-ordered data insertion for the new or replacement data </c>
  <c> point </c>   <c> Specify the insertion point if the 'insert' parameter is set to 'before' or 'after'. </c>
</texttable>
 -->

<t>
There are no query parameters for the PUT method.
</t>
<t>
TODO: how to support user-ordered lists in YANG?  Same issue as for POST.
</t>

</section>


<section anchor="DeleteOperation" title="DELETE">
<t>
Data resource instances are deleted with the DELETE method.
The RESTCONF DELETE operation is supported in CoMI.
The same constraints apply as defined in section 3.7 of <xref target="I-D.ietf-netconf-restconf"/>.
The operation is mapped to the DELETE method defined in section 5.8.4 of <xref target="RFC7252"/>.
</t>
<t>
There are no optional query parameters for the PUT method.
</t>
</section>

<!--
<section anchor="PointParam" title="Mapping of the 'point' Parameter">
<t>
TODO: discuss how the point parameter is encoded to use a YANG hash instead of an
YANG node absolute path identifier.
</t>
</section>
 -->
</section>   <!-- Edit Operations -->

<section anchor="discovery" title="Module Discovery">
<t>
Management objects are discovered in a manner similar to the RESTCONF protocol,
not with the standard CoAP resource discovery.  Only the YANG module information needs
to be retrieved by the client. The YANG modules contain all the data resource
schema and naming information.
</t>
<t>
The "rt" attribute is used to filter resource queries as specified in <xref target="RFC6690"/>.
</t>
<t>
The resource "/mg/moduri" is used to retrieve the location of the YANG module library information
for the server.  This data structure is defined in the "ietf-yang-library" module in the RESTCONF
draft.
</t>
<t>
Since many constrained servers within a deployment are likely to be similar,
the module list can be stored locally on each server, or remotely on a different server.
</t>
<t>
TODO: Example:

<figure><artwork align="left"><![CDATA[

  Local:

  REQ: GET example.com/mg/moduri

  RES: 2.05 Content (Content-Format: application/cbor)
  {
    "moduri" : "example.com/mg/data/modules"
  }


  Remote:

  REQ: GET example.com/mg/moduri

  RES: 2.05 Content (Content-Format: application/cbor)
  {
    "moduri" : "example-remote-server.com/mg/data/group17/modules"
  }


]]></artwork>
    </figure>

</t>
</section>


<section anchor="error" title="Error Return Codes">
<t>
The RESTCONF return status codes defined in section 6 of the RESTCONF draft are used
in CoMI error responses, except they are converted to CoAP error codes.
</t>
<t>TODO: complete RESTCONF to CoAP error code mappings</t>

<texttable>
  <ttcol align="left">RESTCONF Status Line</ttcol>
  <ttcol align="left">CoAP Status Code</ttcol>
  <c> 100 Continue </c>   <c> none? </c>
  <c> 200 OK </c>   <c> 2.05 </c>
  <c> 201 Created </c>   <c> 2.01 </c>
  <c> 202 Accepted </c>   <c> none? </c>
  <c> 204 No Content </c>   <c> ? </c>
  <c> 304 Not Modified </c>   <c> 2.03 </c>
  <c> 400 Bad Request </c>   <c> 4.00 </c>
  <c> 403 Forbidden </c>   <c> 4.03 </c>
  <c> 404 Not Found </c>   <c> 4.04 </c>
  <c> 405 Method Not Allowed </c>   <c> 4.05 </c>
  <c> 409 Conflict </c>   <c> none? </c>
  <c> 412 Precondition Failed </c>   <c> 4.12 </c>
  <c> 413 Request Entity Too Large </c>   <c> 4.13 </c>
  <c> 414 Request-URI Too Large </c>   <c> 4.00 </c>
  <c> 415 Unsupported Media Type </c>   <c> 4.15 </c>
  <c> 500 Internal Server Error </c>   <c> 5.00 </c>
  <c> 501 Not Implemented </c>   <c> 5.01 </c>
  <c> 503 Service Unavailable </c>   <c> 5.03 </c>
</texttable>
</section>

</section>  <!-- MG Function Set -->

<section anchor="mapping" title="Mapping YANG to CoMI payload">
<t>
A mapping for the encoding of YANG data in CBOR is necessary for the efficient
transport of management data in the CoAP payload.
Since object names may be rather long and may occur repeatedly,
CoMI allows for association of a given object path identifier string value with an integer,
called a "YANG hash".
</t>

<section anchor="HASH-GEN" title="YANG Hash Generation">
<t>
The association between string value and string number is done through a hash algorithm.
The "murmur3" 32-bit hash algorithm is used.  This hash algorithm is 
described online at http://en.wikipedia.org/wiki/MurmurHash.
Implementation are available online, including at
https://code.google.com/p/smhasher/wiki/MurmurHash.
</t>
<t>
The hash is generated for the string representing the object path identifier.
A canonical representation of the path identifier is used.
<list>
 <t>
   Prefix values are used on every node.
 </t>
 <t>
   The prefix values defined in the YANG module containing the data object are used
   for the path expression.  For external modules, this is the value of the 'prefix'
   sub-statement in the 'import' statement for each external module.
 </t>
<t>
  Path expressions for objects which augment data nodes in external modules are calculated
  in the augmenting module, using the prefix values in the augmenting module.
</t>
<t>
  Choice and case node names are not included in the path expression. Only 'container', 'list',
  'leaf', 'leaf-list', and 'anyxml' nodes are listed in the path expression.
</t>
</list>
</t>
<t>
The "murmur3_32" hash function is executed for the entire path string.
The value '42' is used as the seed for the hash function.
</t>
<t>
The resulting 32-bit number is used by the server, unless the value is already being
used for a different object by the server. In this case, the re-hash procedure
in the following section is executed.
</t>
</section>

<section anchor="REHASH-GEN" title="Re-Hash Procedure">
<t>
A hash collision occurs if two different path identifier strings have the same hash value.
If the server has over 77,000 objects in its YANG modules, then the probability
of a collision is fairly high.
If a hash collision occurs on the server, then the object that is causing the
conflict has to be altered, such that the new hash value does not conflict
with any value already in use by the server.
</t>
<t>
In most cases, the hash function is expected to produce unique values for all the objects
supported by a constrained device. Given a known set of YANG modules, both server and client
can calculate the YANG hashes independently, and offline.
</t>
<t>
Even though collisions are expected to happen rather rarely, they needs to be considered.
Collisions can be detected before deployment, if the vendor knows which modules are supported
by the server, and hence all YANG hashes can be calculated.
Collisions are only an issue when they occur at the same server. The client needs to
discover any re-hash mappings on a per server basis.
</t>
<t>
If the server needs to re-hash any object identifiers, then it MUST create a "rehash-map"
entry for the altered identifier, as described in the following YANG module.
</t>
</section>

<section anchor="YANGMOD" title="ietf-yang-hash YANG Module">
<t>
The "ietf-yang-hash" YANG module is used by the server to report any objects that
have been mapped to produce a new hash value that does not conflict with any other
YANG hash values used by the server.
</t>
<t>
YANG tree diagram for "ietf-yang-hash" module:
</t>

 <figure>
    <artwork align="left"><![CDATA[

   +--ro yang-hash
      +--ro rehash* [hash]
         +--ro hash      uint32
         +--ro path?     string
         +--ro append?   string

]]></artwork>
 </figure>


<figure><artwork align="left"><![CDATA[

module ietf-yang-hash {
  namespace "urn:ietf:params:xml:ns:yang:ietf-yang-hash";
  prefix "yh";

  organization
    "IETF CORE (Constrained RESTful Environments) Working Group";

  contact
    "WG Web:   <http://tools.ietf.org/wg/core/>
     WG List:  <mailto:core@ietf.org>

     WG Chair: Carsten Bormann
               <mailto:cabo@tzi.org>

     WG Chair: Andrew McGregor
               <mailto:andrewmcgr@google.com>

     Editor:   Peter van der Stok
               <mailto:consultancy@vanderstok.org>

     Editor:   Bert Greevenbosch
               <mailto:andy@bert.greevenbosch@huawei.com>

     Editor:   Andy Bierman
               <mailto:andy@yumaworks.com>

     Editor:   Juergen Schoenwaelder
               <mailto:j.schoenwaelder@jacobs-university.de>

     Editor:   Anuj Sehgal
               <mailto:s.anuj@jacobs-university.de>";

  description
    "This module contains re-hash information for the CoMI protocol.

     Copyright (c) 2014 IETF Trust and the persons identified as
     authors of the code.  All rights reserved.

     Redistribution and use in source and binary forms, with or
     without modification, is permitted pursuant to, and subject
     to the license terms contained in, the Simplified BSD License
     set forth in Section 4.c of the IETF Trust's Legal Provisions
     Relating to IETF Documents
     (http://trustee.ietf.org/license-info).

     This version of this YANG module is part of RFC XXXX; see
     the RFC itself for full legal notices.";

  // RFC Ed.: replace XXXX with actual RFC number and remove this
  // note.

  // RFC Ed.: remove this note
  // Note: extracted from draft-vanderstok-core-comi-05.txt

  // RFC Ed.: update the date below with the date of RFC publication
  // and remove this note.
  revision 2014-10-27 {
    description
      "Initial revision.";
    reference
      "RFC XXXX: CoMI Protocol.";
  }

  container yang-hash {
    config false;
    description
      "Contains information on the YANG Hash values used by
       the server.";

    list rehash {
      key hash;
      description
        "Each entry describes an re-hash mapping in use by
         the server.";

      leaf hash {
        type uint32;
        description "The hash value that has a collision";
      }
      leaf path {
        type string;
        description
          "The YANG identifier path expression that caused the
           collision and is being remapped";
      }
      leaf append {
        type string;
        description
          "The string that the server appended to the path
           expression contained in the 'path' leaf to produce
           a new path expression and therefore new hash value.
           The YANG hash value for the new string (identified
           by 'path' + 'append') is used to identify the
           'path' object.";
      }
    }
  }

}

]]></artwork>
    </figure>

<section anchor="rehashExample" title="YANG Re-Hash Example">
<t>
In this example the server has an object that is already registered
when the "/foo:A/foo:B/foo:col1" object is processed.  This object
path string hashes to value "a9abdcca".  The server has appended the
string "_" to the path to produce a new hash ("ea7a2044") which does not
collide with any other objects.
</t>
<t>
The server would return the following information if the client
retrieved the "/mg/yang-hash" resource.
</t>

 <figure>
    <artwork align="left"><![CDATA[

REQ: GET example.com/mg/yang-hash

RES: 2.05 Content (Content-Format: application/cbor)
{
   "ietf-yang-hash:yang-hash" : {
      "rehash" : [
         {
            "hash" : 3933872196,
            "path" :"/foo:A/foo:B/foo:col1",
            "append" : "_"
         }
      ]
   }
}

]]></artwork>
    </figure>


</section>
</section>

<section anchor="keysParm" title="The 'keys' Query Parameter">
<t>
There is a mandatory query parameter that MUST be supported by servers called "keys".
This parameter is used to specify the key values for an instance of an object
identified by a YANG hash value.  Any key leaf values for the object are passed
in order. The first key leaf in the top-most list is the first key encoded in
the 'keys' parameter.
</t>
<t>
Example:
In this example the following YANG module is used:
</t>

<figure>
   <artwork align="left"><![CDATA[

  module foo-mod {
    namespace foo-mod-ns;
    prefix foo;

    list A {
      key "key1 key2";
      leaf key1 { type string; }
      leaf key2 { type int32; }
      list B {
        key "key3";
        leaf key3 { type string; }
        leaf col1 { type uint32; }
      }
    }
  }

]]></artwork>
</figure>

<t>
The path identifier for the leaf "col1" is the following string:
</t>
<figure>
   <artwork align="left"><![CDATA[

   /foo:A/foo:B/foo:col1

]]></artwork>
</figure>
<t>
The YANG has value for this identifier string "2846612682" (hex "a9abdcca").
</t>
<t>
The following string represents the RESTCONF target resource URI expression for the "col1"
leaf for the key values "top", 17, and "group1":
</t>
<figure>
   <artwork align="left"><![CDATA[

   /restconf/data/foo-mod:A=top,17/B=group1/col1

]]></artwork>
</figure>

<t>
The following string represents the CoMI target resource identifier for the same instance
of the "col1" leaf:
</t>
<figure>
   <artwork align="left"><![CDATA[

   /mg/data/a9abdcca?keys=top,17,group1

]]></artwork>
</figure>

</section>

</section>  <!-- Mapping YANG to CoMI Payload -->


<section anchor="CBOR-mapping" title="Mapping YANG to CBOR">

  <section anchor="YANGtoCBOR" title="Conversion from YANG datatypes to CBOR datatypes">
    <t>
      <xref target="YANG-CBOR"/> defines the mapping between YANG datatypes and CBOR datatypes.
    </t>
    <t>    
      Elements of types not in this table,
      and of which the type cannot be inferred from a type in this table,
      are ignored in the CBOR encoding by default.
      Examples include the "description" and "key" elements.
      However, conversion rules for some elements to CBOR MAY be defined elsewhere.
    </t>
  <texttable anchor="YANG-CBOR" title="Conversion of YANG datatypes to CBOR">
    <ttcol align="left">YANG type</ttcol>
    <ttcol align="left">CBOR type</ttcol>
    <ttcol align="left">Specification</ttcol>
    
    <c>int8, int16, int32, int64, uint16, uint32, uint64, decimal64</c>
    <c>unsigned int (major type 0) or negative int (mayor type 1)</c>
    <c>The CBOR integer type depends on the sign of the actual value.</c>
    
    <c>boolean</c>
    <c>either "true" (major type 7, simple value 21) or "false" (major type 7, simple value 20)</c>
    <c></c>
    
    <c>string</c>
    <c>text string (major type 3)</c>
    <c></c>
    
    <c>enumeration</c>
    <c>unsigned int (major type 0)</c>
    <c></c>
    
    <c>bits</c>
    <c>array of text strings</c>
    <c>Each text string contains the name of a bit value that is set.</c>
    
    <c>binary</c>
    <c>byte string (major type 2)</c>
    <c></c>
    
    <c>empty</c>
    <c>null (major type 7, simple value 22)</c>
    <c>TBD: This MAY not be applicable to true MIBs, as SNMP may not support empty variables...</c>
    
    <c>union</c>
    <c></c>
    <c>
      Similar ot the JSON transcription from <xref target="I-D.ietf-netmod-yang-json"/>,
      the elements in a union MUST be determined using the procedure specified in section 9.12 of <xref target="RFC6020"/>.
    </c>
   
    <c>leaf-list</c>
    <c>array (major type 4)</c>
    <c>The array is encapsulated in the map associated with the descriptor.</c>
    
    <c>list</c>
    <c>map (major type 5)</c>
    <c>      
      Like the higher level map,
      the lower level map contains descriptor number - value pairs of the elements in the list.
    </c>
    
    <c>container</c>
    <c>map (major type 5)</c>
    <c>The map contains descriptor number - value pairs corresponding to the elements in the container.</c>
    
    <c>smiv2:oid</c>
    <c>array of integers</c>
    <c>
      Each integer contains an element of the OID,
      the first integer in the array corresponds to the most left element in the OID.
    </c>


  </texttable>    
  </section>
  </section>


<section title="Examples">
<t>TODO: add examples back with YANG hash values and a YANG module.</t>

<!--
    <section title="ipNetToMediaTable to JSON/CBOR">
      <t>
        The YANG translation of the SMI specifying the ipNetToMediaTable yields:
</t>
<figure><artwork align="left">
<![CDATA[
container ipNetToMediaTable {
    list ipNetToMediaEntry {
       leaf ipNetToMediaIfIndex {
          type: int32;
       }
       leaf ipNetToPhysAddress {
          type: phys-address;
       }
       leaf ipNetToMediaNetAddress {
          type: ipv4-address;
       }
       leaf ipNetToMediaType {
          type: int32;
       }
    }
 }
]]></artwork></figure>
      <t>
        The corresponding JSON looks like:
</t>
<figure><artwork align="left">
<![CDATA[
{ 
"ipNetToMediaTable" : {
	"ipNetToMediaEntry" : [
		{
		"ipNetToMediaIfIndex" : 1.
		"ipNetToMediaPhysAddress" : "00:00::10:01:23:45",
		"ipNetToMediaNetAddress" : "10.0.0.51",
		"ipNetToMediaType" : "static"
		},
		{
		"ipNetToMediaIfIndex " : 1,
		"ipNetToMediaPhysAddress " : "00:00::10:54:32:10",
		"ipNetToMediaNetAddress" : "9.2.3.4",
		"ipNetToMediaType " : "dynamic"
		}
	]
	}
}
]]></artwork></figure>        
      <t>
        An example CBOR instance of the MIB can be found in <xref target="ExInterfaceIndex"/>.
        The names "ipNetToMediaTable", "ipNetToMediaEntry", and "ipNetToMediaIfIndex" are represented with the string numbers  00, 01, and 02 as described in <xref target="HASH-GEN"/>.
      </t>
<figure anchor="ExInterfaceIndex" title="Example CBOR encoding for ifTable"><artwork align="left">
<![CDATA[
82                         # two element array
   74 49 50 2d 4d 49 42 5f 
   32 30 30 36 30 32 30 32
   30 30 30 30 5a          # "IP-MIB_200602020000Z"
   BF                      # indefinite length map
     00                    # descriptor number related to 
                           # ipNetToMediaTable
     BF                    # indefinite length map related to
                           # ipNetToMediaTable
        01                 # descriptor number related to
                           # ipNetToMediaEntry
        BF                 # map related to ipNetToMediaEntry
           02              # descriptor number associated with
                           # ipNetToMediaIfIndex
           1A 00 00 00 01  # associated value as 32-bit integer
           # ...
        FF
     FF
   FF
]]></artwork></figure>
<t>
The associated "descriptor string" to "string number" conversion table is given in <xref target="conv_InterfaceIndex"/>.
</t>
<figure anchor="conv_InterfaceIndex" title="Conversion table for ifTable"><artwork align="left">
<![CDATA[
82                         # two element array
   74 49 50 2d 4d 49 42 5f 
   32 30 30 36 30 32 30 32
   30 30 30 30 5a          # "IP-MIB_200602020000Z"
   BF                      # indefinite length map
      00                   # descriptor number related to 
                           # ipNetToMediaTable
      72 69 70 50 65 74 57
      6F 51 65 64 61 57 61
      62 6C 65             # "ipNetToMediaTable"
      01                   # descriptor number related to
                           # ipNetToMediaEntry
      72 69 70 50 65 74 57
      6F 51 65 64 61 45 6E
      74 72 78 			       # "ipNetToMediaEntry"
      02                   # descriptor number related to
                           # ipNetToMediaIfIndex
      75 69 70 50 65 74 57
      6F 51 65 64 61 61 49
      66 49 6E 64 65 77    # "ipNetToMediaIfIndex"
      # ...
   FF
]]></artwork></figure>
      
    </section>

  -->

<!--
  <section title="6LoWPAN MIB">
    <t>
      A MIB for 6LoWPAN is defined in <xref target="I-D.ietf-6lo-lowpan-mib"/> with an example JSON representation in its Appendix A.
      <xref target="LOWPAN-MIB"/> shows the associated CBOR representation with string number, and the corresponding string to string number conversion table.
    </t><t>
      In this example,
      a GET to /mg/mib/lowpanOutFragFails would give:      
    </t>  
<figure><artwork align="left">
<![CDATA[
82                         # two element array
   78 18 4c 4f 57 50 41 4e
   2d 4d 49 42 5f 32 30 31
   34 30 34 30 38 30 30 30
   30 5a                   # conversion table id:
                           # "LOWPAN-MIB_201404080000Z"
   BF                      # indefinite length map
     18 1B                 # "lowpanOutFragFails"
     00                    # 0
   FF
]]></artwork></figure>    

 -->
</section>

<section anchor="MIB-trap" title="Trap functions">
<t>
  A trap can be set through the CoAP Observe <xref target="I-D.ietf-core-observe"/> function.
  As regular with Observe,
  the client subscribes to the variable by sending a GET request with an "Observe" option.
</t><t>
TODO: Observe example
</t><t>
  In the registration request,
  the client MAY include a "Response-To-Uri-Host" and optionally "Response-To-Uri-Port" option as defined in
  <xref target="I-D.becker-core-coap-sms-gprs"/>.
  In this case,
  the observations SHOULD be sent to the address and port indicated in these options.
  This can be useful when the client wants the managed device to send the trap information to a multicast address.
</t>
</section>

<section anchor="MIB-access" title="Object access management">
<t>
Two topics are relevant: (1) the definition of the destination of Notify messages, and (2) the creation and maintenance of "string to number" tables.
</t>
<section anchor="NOT-DEST" title="Notify destinations">
<t>
The destination of notifications need to be communicated to the applications sending them.
Draft <xref target="I-D.ietf-core-interfaces"/> describes the binding of end-points to end-points on remote devices.
The object with type "binding table" contains a sequence of bindings. The contents of bindings contains the methods, location, the interval specifications, and
the step value as suggested in <xref target="I-D.ietf-core-interfaces"/>.
The method "notify" has been added to the binding methods "poll", "obs" and "push", to cater for the binding of notification source to the receiver.
</t><t>
TODO: describe interface for NOTIFY destination definition. 
</t>
</section>

</section>

<section anchor="ERRORS" title="Error Handling">
  <t>
    In case a request is received which cannot be processed properly,
    the managed entity MUST return an error message.
    This error message MUST contain a CoAP 4.xx or 5.xx response code,
    and SHOULD include additional information in the payload.
  </t>
  <t>
    Such an error message payload is encoded in CBOR,
    using the following structure:
  </t>
  <t>
    TODO: Adapt RESTCONF &lt;errors&gt; data structure for use in CoMI. Need
    to select the most important fields like &lt;error-path&gt;.
  </t>

<figure><artwork align="left">
<![CDATA[
errorMsg     : ErrorMsg;

*ErrorMsg {
  errorCode  : uint;
  ?errorText : tstr;
}
]]></artwork></figure>
  <t>
    The variable "errorCode" has one of the values from the table below,
    and the OPTIONAL "errorText" field contains a human readable explanation of the error.
  </t>
  
    <texttable>
      <ttcol align="left">CoMI Error Code</ttcol>
      <ttcol align="left">CoAP Error Code</ttcol>
      <ttcol align="left">Description</ttcol>
      
      <c>0</c>
      <c>4.00</c>
      <c>General error</c>

      <c>1</c>
      <c>4.00</c>
      <c>Malformed CBOR data</c>
      
      <c>2</c>
      <c>4.00</c>
      <c>Incorrect CBOR datatype</c>
      
      <c>3</c>
      <c>4.00</c>
      <c>Unknown MIB variable</c>
      
      <c>4</c>
      <c>4.00</c>
      <c>Unknown conversion table</c>

      <c>5</c>
      <c>4.05</c>
      <c>Attempt to write read-only variable</c>

  	<c>0..2</c>
      <c>5.01</c>
      <c>Access exceptions</c>

	<c>0..18</c>
	<c>5.00</c>
	<c> SMI error status </c>
    </texttable>

<t>
The CoAP error code 5.01 is associated with the exceptions defined in <xref target="RFC3416"/> and CoAP error code 5.00 is associated with the error-status defined in <xref target="RFC3416"/>.
</t>
  
</section>

<section title="Security Considerations">
  <t>
    For secure network management,
    it is important to restrict access to MIB variables only to authorised parties.
    This requires integrity protection of both requests and responses,
    and depending on the application encryption.
  </t>
  <t>
    CoMI re-uses the security mechanisms already available to CoAP as much as possible.
    This includes DTLS for protected access to resources,
    as well suitable authentication and authorisation mechanisms.
  </t>
  <t>
    Among the security decisions that need to be made are
    selecting security modes and encryption mechanisms (see <xref target="RFC7252"/>).
    This requires a trade-off,
    as the NoKey mode gives no protection at all,
    but is easy to implement,
    whereas the X.509 mode is quite secure, 
    but may be too complex for constrained devices.
  </t>
  <t>
    In addition,
    mechanisms for authentication and authorisation may need to be selected.
  </t>
  <t>
    CoMI avoids defining new security mechanisms as much as possible.
    However some adaptations may still be required,
    to cater for CoMI's specific requirements.
  </t>
</section>

<section  title="IANA Considerations">  
  <t>
    'rt="core.mg.data"' needs registration with IANA.
  </t>
  <t>
    'rt="core.mg.moduri"' needs registration with IANA.
  </t>
  <t>
    'rt="core.mg.yang-hash"' needs registration with IANA.
  </t>

  <t>
    Content types to be registered:
    <list style="symbols">
      <t>application/comi+cbor</t>
    </list>
  </t>
</section>

<section title="Acknowledgements">
<t>
Mehmet Ersue and Bert Wijnen explained the encoding aspects of PDUs transported under SNMP. Carsten Bormann has given feedback on the use of CBOR.
<!--
 Juergen Schoenwalder has commented on inconsistencies and missing aspects of SNMP in earlier versions of the draft.
 -->
The draft has benefited from comments (alphabetical order) by Dee Denteneer, Esko Dijk, Michael van Hartskamp, Zach Shelby, Michael Verschoor, and Thomas Watteyne.
The CBOR encoding borrows extensively from Ladislav Lhotka's description on conversion from YANG to JSON.
</t>
</section>

<section title="Changelog">
<t>
Changes from version 00 to version 01
<list style="symbols">
<t> Focus on MIB only</t>
<t> Introduced CBOR, JSON, removed BER </t>
<t> defined mappings from SMI to xx </t>
<t> Introduced the concept of addressable table rows </t>
</list>
</t>
<t>
Changes from version 01 to version 02
<list style="symbols">
<t> Focus on CBOR, used JSON for examples, removed XML and EXI</t>
<t> added uri-query attributes mod and con to specify modules and contexts </t>
<t> Definition of CBOR string conversion tables for data reduction </t>
<t> use of Block for multiple fragments </t>
<t> Error returns generalized </t>
<t> SMI - YANG - CBOR conversion </t>
</list>
</t>
<t>
Changes from version 02 to version 03
<list style="symbols">
<t> Added security considerations</t>
</list>
</t>
<t>
Changes from version 03 to version 04
<list style="symbols">
<t> Added design considerations section</t>
<t> Extended comparison of management protocols in introduction </t>
<t> Added automatic generation of CBOR tables </t>
<t> Moved lowpan table to Appendix </t>
</list>
Changes from version 04 to version 05
<list style="symbols">
<t> Merged SNMP access with RESTCONF access to management objects in small devices </t>
<t> Added CoMI architecture section</t>
<t> Added RESTCONf NETMOD description </t>
<t> Rewrote section 5 with YANG examples </t>
<t> Added server and payload size appendix</t>
<t> Removed Appendix C for now. It will be replaced with a YANG example. </t>
</list>
</t>

</section>

</middle>
  <back>
    <references title="Normative References">
      &RFC2119;
      &RFC6020;
      &RFC7049;
	&RFC7252;
      &I-D.becker-core-coap-sms-gprs;
      &I-D.ietf-core-block;
      &I-D.ietf-core-observe;
      &I-D.ietf-json-rfc4627bis;
      &I-D.ietf-netmod-yang-json;
      &I-D.ietf-netconf-restconf;
    </references>
    <references title="Informative References">
	    &RFC1213;
      &RFC2578;
      &RFC2863;
      &RFC3410;
	    &RFC3411;
      &RFC3414;
      &RFC3416;
      &RFC3418;
	    &RFC3986;
	    &RFC4088;
      &RFC4113;
      &RFC4291;
      &RFC4293;
      &RFC4944;
      &RFC6241;
      &RFC6347;
      &RFC6643;
      &RFC6650;
      &RFC6690;
      &RFC6775;
	 &RFC7317;            
      &I-D.ietf-core-groupcomm;
      &I-D.ietf-core-interfaces;
      &I-D.ersue-constrained-mgmt;
      &I-D.ietf-6lo-lowpan-mib;

	&I-D.ietf-lwig-coap;

       <reference anchor="STD0001">
        <front>
          <title>Official Internet Protocols Standard</title>
    <author />
        <date />
          </front>
          <seriesInfo name="Web" value="http://www.rfc-editor.org/rfcxx00.html"/>
        </reference>


  <reference anchor="XML">
        <front>
          <title>Extensible Markup Language (XML)</title>
        <author />
        <date />
          </front>
          <seriesInfo name="Web" value="http://www.w3.org/xml"/>
        </reference>

  <reference anchor="JSON">
        <front>
          <title>JavaScript Object Notation (JSON)</title>
	  <author />
        <date />
          </front>
          <seriesInfo name="Web" value="http://www.json.org"/>
        </reference>

  <reference anchor="OMA">
        <front>
          <title>OMA-TS-LightweightM2M-V1_0-20131210-C</title>
	  <author fullname="Open Mobile Alliance (OMA)"/>
        <date />
          </front>
          <seriesInfo name="Web" value="http://technical.openmobilealliance.org/Technical/current_releases.aspx"/>
        </reference>


  <reference anchor="DTLS-size">
        <front>
          <title>Delegation-based Authentication and Authorization for the IP-based Internet of Things</title>
<author fullname="R.Hummen" initials="R." surname="Hummen"/>
<author fullname="H.Shafagh" initials="H." surname="Shafagh"/>
<author fullname="S.Raza" initials="S." surname="Raza"/>
<author fullname="T.Voigt" initials="T." surname="Voigt"/>
<author fullname="K.Wehrle" initials="K." surname="Wehrle"/>
        <date />
          </front>
          <seriesInfo name="Web" value="http://www.vs.inf.ethz.ch/publ/papers/mshafagh_secon14.pdf"/>
        </reference>


<reference anchor="dcaf">
        <front>
          <title>Delegated Authenticated Authorization for
Constrained Environments </title>
        <author fullname="Carsten Bormann" initials="C." surname="Bormann"/>
        <author fullname="Olaf Bergmann" initials="O." surname="Bergmann"/>
        <author fullname="Stefanie Gerdes" initials="S." surname="Gerdes"/>
        <date />
          </front>
          <seriesInfo name="Private Information" value=""/>
        </reference>

<reference anchor="openwsn">
        <front>
          <title>Coap size in Openwsn
</title>
        <author fullname="Thomas Watteijne" initials="T." surname="Watteijne"/>
        <date />
          </front>
          <seriesInfo name="Web" value="http://builder.openwsn.org/" />
        </reference>


<reference anchor="Erbium">
        <front>
          <title>Erbium Memory footprint for coap-18</title>
        <author fullname="Matthias Kovatsch" initials="M." surname="Kovatsch"/>
        <date />
          </front>
          <seriesInfo name="Private Communication" value=""/>
        </reference>

  <reference anchor="management">
        <front>
          <title>Management of the Internet of Things</title>
        <author fullname="Juergen Schoenwalder" initials="J." surname="Schoenwalder"/>
<author fullname="Anuj Sehgal" initials="A." surname="Sehgal"/>
        <date year="2013"/>
          </front>
          <seriesInfo name="Web" value="http://cnds.eecs.jacobs-university.de/slides/2013-im-iot-management.pdf"/>
        </reference>




    </references>

<section title="Payload and Server sizes" anchor="code-sizes">
<t>
This section provides information on code sizes and payload sizes for a set of management servers. Approximate code sizes are:
</t>
  <texttable>
  <ttcol align="left">Code</ttcol>
  <ttcol align="left">processor</ttcol>
   <ttcol align="left">Text</ttcol>
  <ttcol align="left">Data</ttcol>
  <ttcol align="left">reference</ttcol>

  <c> Observe agent</c>   <c> erbium </c> <c> 800 </c> <c> n/a </c> <c> <xref target="Erbium"/> </c>
  <c> CoAP server     </c>   <c> MSP430 </c> <c> 1K </c> <c> 6 </c> <c> <xref target="openwsn"/> </c>
<c> SNMP server </c>   <c> ATmega128 </c> <c> 9K </c> <c> 700 </c> <c> <xref target="management"/> </c>
<c> Secure SNMP </c>   <c> ATmega128</c> <c> 30K </c> <c> 1.5K </c> <c> <xref target="management"/>  </c>
<c> DTLS server </c>   <c> ATmega128</c> <c> 37K </c> <c> 2K </c> <c> <xref target="management"/>  </c>
<c> NETCONF </c>   <c> ATmega128</c> <c> 23K </c> <c> 627 </c> <c> <xref target="management"/>  </c>
<c> JSON parser </c>   <c> CC2538</c> <c> 4.6K </c> <c> 8 </c> <c> <xref target="dcaf"/> </c>
<c> CBOR parser </c>   <c> CC2538</c> <c> 1.5K </c> <c> 2.6K </c> <c> <xref target="dcaf"/> </c>
<c> DTLS server </c>   <c> ARM7</c> <c> 15K </c> <c> 4 </c> <c> <xref target="I-D.ietf-lwig-coap"/> </c>
<c> DTLS server </c>   <c> MSP430</c> <c> 15K </c> <c> 4 </c> <c><xref target="DTLS-size"/> </c>
<c> Certificate </c>   <c> MSP430</c> <c> 23K </c> <c>  </c> <c> <xref target="DTLS-size"/>  </c>
<c> Crypto </c>   <c> MSP430</c> <c> 2-8K </c> <c>  </c> <c> <xref target="DTLS-size"/>  </c>
</texttable>
<t>
Thomas says that the size of the CoAP server is rather arbitrary, as its size depends mostly on the implementation of the underlying library modules and interfaces. 
</t><t>
Payload sizes are compared for the following request payloads, where each attribute value is null (N.B. these sizes are educated guesses, will be replaced with generated data). The identifier are assumed to be a string representation of the OID. Sizes for SysUpTime differ due to preambles of payload. "CBOR opt" stands for CBOR payload where the strings are replaced by table numbers.
</t>
  <texttable>
  <ttcol align="left">Request</ttcol>
  <ttcol align="left">BERR SNMP</ttcol>
   <ttcol align="left">JSON</ttcol>
  <ttcol align="left">CBOR</ttcol>
  <ttcol align="left">CBOR opt</ttcol>

  <c> IPnetTOMediaTable</c>   <c> 205 </c> <c> 327 </c> <c> ~327</c> <c> ~51 </c>
  <c> lowpanIfStatsTable     </c>   <c>  </c> <c> 710 </c> <c> 614 </c> <c> 121 </c>
<c> sysUpTime </c>   <c> 29 </c> <c> 13 </c> <c> ~13 </c> <c> 20 </c>
<c> RESTconf example </c>   <c> </c> <c> </c> <c>  </c> <c> </c>
</texttable>

</section>


<section title="Notational Convention for CBOR data" anchor="notConv">
  <t>
    To express CBOR structures <xref target="RFC7049"/>,
    this document uses the following conventions:
  </t>
  <t>
    A declaration of a CBOR variable has the form:
<figure><artwork align="left"><![CDATA[
   name : datatype;
]]></artwork></figure>
    where "name" is the name of the variable,
    and "datatype" its CBOR datatype.
  </t>
  <t>
    The name of the variable has no encoding in the CBOR data.
  </t>
  <t>
    "datatype" can be a CBOR primitive such as:
    <list style="hanging">    
      <t hangText="tstr:">A text string (major type 3)</t>
      <t hangText="uint:">An unsigned integer (major type 0)</t>
      <t hangText="map(x,y):">
        A map (major type 5), where each first element of a pair is of datatype x, and each second element of datatype y.
        A '.' character for either x or y means that all datatypes for that element are valid.
      </t>
    </list>
  </t>
  <t>
    A datatype can also be a CBOR structure,
    in which case the variable's "datatype" field contains the name of the CBOR structure.
    Such CBOR structure is defined by a character sequence consisting of first its name,
    then a '{' character,
    then its subfields
    and finally a '}' character.
  </t>
  <t>
    A CBOR structure can be encapsulated in an array,
    in which case its name in its definition is preceded by a '*' character.
    Otherwise the structure is just a grouping of fields,
    but without actual encoding of such grouping.
  </t>
  <t>
    The name of an optional field is preceded by a '?' character.
    This means,
    that the field may be omitted if not required.
  </t>
</section>

<!--
  <section anchor="ConvT-LOWPAN-MIB" title="Example conversion table and instance for the LOWPAN MIB">
    <t>
      The conversion table of the 6LoWPAN MIB <xref target="I-D.ietf-6lo-lowpan-mib"/> is generated as described in this section.      
    </t>
    <section title="Generating the convTableId">
      <t>
        The module name is "LOWPAN-MIB",
        and the LAST-UPDATED field in the MODULE-IDENTITY has the value "201404080000Z".
        Hence the convId has the value "LOWPAN-MIB_201404080000Z".
      </t>
    </section>
    <section anchor="StrN-LOWPAN-MIB" title="Generating the string numbers">
      <t>
        The following table shows how the string numbers are associated with the related strings and object IDs.
      </t>
      <texttable>
      
        <ttcol align="left">Object ID</ttcol>
        <ttcol align="left">Descriptor</ttcol>
        <ttcol align="right">String number</ttcol>
      
        <c>1.3.6.1.2.1</c>
        <c>mib-2</c>
        <c>1</c>
        
        <c>1.3.6.1.2.1.2.2.1.1</c>
        <c>ifIndex</c>
        <c>2</c>
      
        <c>1.3.6.1.2.1.XXXX</c>
        <c>lowpanMib</c>
        <c>3</c>
        
        <c>1.3.6.1.2.1.XXXX.0</c>
        <c>lowpanNotifications</c>
        <c>4</c>
        
        <c>1.3.6.1.2.1.XXXX.1</c>
        <c>lowpanObjects</c>
        <c>5</c>
        
        <c>1.3.6.1.2.1.XXXX.2</c>
        <c>lowpanConformance</c>
        <c>6</c>
        
        <c>1.3.6.1.2.1.XXXX.1.1</c>
        <c>lowpanStats</c>
        <c>7</c>
        
        <c>1.3.6.1.2.1.XXXX.1.1.1</c>
        <c>lowpanReasmTimeout</c>
        <c>8</c>
        
        <c>1.3.6.1.2.1.XXXX.1.1.2</c>
        <c>lowpanInReceives</c>
        <c>9</c>
        
        <c>1.3.6.1.2.1.XXXX.1.1.3</c>
        <c>lowpanInHdrErrors</c>
        <c>10</c>
        
        <c>1.3.6.1.2.1.XXXX.1.1.4</c>
        <c>lowpanInMeshReceives</c>
        <c>11</c>
        
        <c>1.3.6.1.2.1.XXXX.1.1.5</c>
        <c>lowpanInMeshForwds</c>
        <c>12</c>
        
        <c>1.3.6.1.2.1.XXXX.1.1.6</c>
        <c>lowpanInMeshDelivers</c>
        <c>13</c>
        
        <c>1.3.6.1.2.1.XXXX.1.1.7</c>
        <c>lowpanInReasmReqds</c>
        <c>14</c>
        
        <c>1.3.6.1.2.1.XXXX.1.1.8</c>
        <c>lowpanInReasmFails</c>
        <c>15</c>
        
        <c>1.3.6.1.2.1.XXXX.1.1.9</c>
        <c>lowpanInReasmOKs</c>
        <c>16</c>
        
        <c>1.3.6.1.2.1.XXXX.1.1.10</c>
        <c>lowpanInCompReqds</c>
        <c>17</c>
        
        <c>1.3.6.1.2.1.XXXX.1.1.11</c>
        <c>lowpanInCompFails</c>
        <c>18</c>
        
        <c>1.3.6.1.2.1.XXXX.1.1.12</c>
        <c>lowpanInCompOKs</c>
        <c>19</c>
        
        <c>1.3.6.1.2.1.XXXX.1.1.13</c>
        <c>lowpanInDiscards</c>
        <c>20</c>
        
        <c>1.3.6.1.2.1.XXXX.1.1.14</c>
        <c>lowpanInDelivers</c>
        <c>21</c>
        
        <c>1.3.6.1.2.1.XXXX.1.1.15</c>
        <c>lowpanOutRequests</c>
        <c>22</c>
        
        <c>1.3.6.1.2.1.XXXX.1.1.16</c>
        <c>lowpanOutCompReqds</c>
        <c>23</c>
        
        <c>1.3.6.1.2.1.XXXX.1.1.17</c>
        <c>lowpanOutCompFails</c>
        <c>24</c>
        
        <c>1.3.6.1.2.1.XXXX.1.1.18</c>
        <c>lowpanOutCompOKs</c>
        <c>25</c>
        
        <c>1.3.6.1.2.1.XXXX.1.1.19</c>
        <c>lowpanOutFragReqds</c>
        <c>26</c>
        
        <c>1.3.6.1.2.1.XXXX.1.1.20</c>
        <c>lowpanOutFragFails</c>
        <c>27</c>
        
        <c>1.3.6.1.2.1.XXXX.1.1.21</c>
        <c>lowpanOutFragOKs</c>
        <c>28</c>
        
        <c>1.3.6.1.2.1.XXXX.1.1.22</c>
        <c>lowpanOutFragCreates</c>
        <c>29</c>
        
        <c>1.3.6.1.2.1.XXXX.1.1.23</c>
        <c>lowpanOutMeshHopLimitExceeds</c>
        <c>30</c>
        
        <c>1.3.6.1.2.1.XXXX.1.1.24</c>
        <c>lowpanOutMeshNoRoutes</c>
        <c>31</c>
        
        <c>1.3.6.1.2.1.XXXX.1.1.25</c>
        <c>lowpanOutMeshRequests</c>
        <c>32</c>
        
        <c>1.3.6.1.2.1.XXXX.1.1.26</c>
        <c>lowpanOutMeshForwds</c>
        <c>33</c>
        
        <c>1.3.6.1.2.1.XXXX.1.1.27</c>
        <c>lowpanOutMeshTransmits</c>
        <c>34</c>
        
        <c>1.3.6.1.2.1.XXXX.1.1.28</c>
        <c>lowpanOutDiscards</c>
        <c>35</c>
        
        <c>1.3.6.1.2.1.XXXX.1.1.29</c>
        <c>lowpanOutTransmits</c>
        <c>36</c>
        
        <c>1.3.6.1.2.1.XXXX.1.2</c>
        <c>lowpanIfStatsTable</c>
        <c>37</c>
        
        <c>1.3.6.1.2.1.XXXX.1.2.1</c>
        <c>lowpanIfStatsEntry</c>
        <c>38</c>
        
        <c>1.3.6.1.2.1.XXXX.1.2.1.1</c>
        <c>lowpanIfReasmTimeout</c>
        <c>39</c>
        
        <c>1.3.6.1.2.1.XXXX.1.2.1.2</c>
        <c>lowpanIfInReceives</c>
        <c>40</c>
        
        <c>1.3.6.1.2.1.XXXX.1.2.1.3</c>
        <c>lowpanIfInHdrErrors</c>
        <c>41</c>
        
        <c>1.3.6.1.2.1.XXXX.1.2.1.4</c>
        <c>lowpanIfInMeshReceives</c>
        <c>42</c>
        
        <c>1.3.6.1.2.1.XXXX.1.2.1.5</c>
        <c>lowpanIfInMeshForwds</c>
        <c>43</c>
        
        <c>1.3.6.1.2.1.XXXX.1.2.1.6</c>
        <c>lowpanIfInMeshDelivers</c>
        <c>44</c>
        
        <c>1.3.6.1.2.1.XXXX.1.2.1.7</c>
        <c>lowpanIfInReasmReqds</c>
        <c>45</c>
        
        <c>1.3.6.1.2.1.XXXX.1.2.1.8</c>
        <c>lowpanIfInReasmFails</c>
        <c>46</c>
        
        <c>1.3.6.1.2.1.XXXX.1.2.1.9</c>
        <c>lowpanIfInReasmOKs</c>
        <c>47</c>
        
        <c>1.3.6.1.2.1.XXXX.1.2.1.10</c>
        <c>lowpanIfInCompReqds</c>
        <c>48</c>
        
        <c>1.3.6.1.2.1.XXXX.1.2.1.11</c>
        <c>lowpanIfInCompFails</c>
        <c>49</c>
        
        <c>1.3.6.1.2.1.XXXX.1.2.1.12</c>
        <c>lowpanIfInCompOKs</c>
        <c>50</c>
        
        <c>1.3.6.1.2.1.XXXX.1.2.1.13</c>
        <c>lowpanIfInDiscards</c>
        <c>51</c>
        
        <c>1.3.6.1.2.1.XXXX.1.2.1.14</c>
        <c>lowpanIfInDelivers</c>
        <c>52</c>
        
        <c>1.3.6.1.2.1.XXXX.1.2.1.15</c>
        <c>lowpanIfOutRequests</c>
        <c>53</c>
        
        <c>1.3.6.1.2.1.XXXX.1.2.1.16</c>
        <c>lowpanIfOutCompReqds</c>
        <c>54</c>
        
        <c>1.3.6.1.2.1.XXXX.1.2.1.17</c>
        <c>lowpanIfOutCompFails</c>
        <c>55</c>
        
        <c>1.3.6.1.2.1.XXXX.1.2.1.18</c>
        <c>lowpanIfOutCompOKs</c>
        <c>56</c>
        
        <c>1.3.6.1.2.1.XXXX.1.2.1.19</c>
        <c>lowpanIfOutFraqRegds</c>
        <c>57</c>
        
        <c>1.3.6.1.2.1.XXXX.1.2.1.20</c>
        <c>lowpanIfOutFragFails</c>
        <c>58</c>
        
        <c>1.3.6.1.2.1.XXXX.1.2.1.21</c>
        <c>lowpanIfOutFragOKs</c>
        <c>59</c>
        
        <c>1.3.6.1.2.1.XXXX.1.2.1.22</c>
        <c>lowpanIfOutFragCreates</c>
        <c>60</c>
        
        <c>1.3.6.1.2.1.XXXX.1.2.1.23</c>
        <c>lowpanIfOutMeshHopLimitExceeds</c>
        <c>61</c>
        
        <c>1.3.6.1.2.1.XXXX.1.2.1.24</c>
        <c>lowpanIfOutMeshNoRoutes</c>
        <c>62</c>
        
        <c>1.3.6.1.2.1.XXXX.1.2.1.25</c>
        <c>lowpanIfOutMeshRequests</c>
        <c>63</c>
        
        <c>1.3.6.1.2.1.XXXX.1.2.1.26</c>
        <c>lowpanIfOutMeshForwds</c>
        <c>64</c>
        
        <c>1.3.6.1.2.1.XXXX.1.2.1.27</c>
        <c>lowpanIfOutMeshTransmits</c>
        <c>65</c>
        
        <c>1.3.6.1.2.1.XXXX.1.2.1.28</c>
        <c>lowpanIfOutDiscards</c>
        <c>66</c>
        
        <c>1.3.6.1.2.1.XXXX.1.2.1.29</c>
        <c>lowpanIfOutTransmits</c>
        <c>67</c>
        
        <c>1.3.6.1.2.1.XXXX.2.1</c>
        <c>lowpanGroups</c>
        <c>68</c>
        
        <c>1.3.6.1.2.1.XXXX.2.1.1</c>
        <c>lowpanStatsGroup</c>
        <c>69</c>
        
        <c>1.3.6.1.2.1.XXXX.2.1.2</c>
        <c>lowpanStatsMeshGroup</c>
        <c>70</c>
        
        <c>1.3.6.1.2.1.XXXX.2.1.3</c>
        <c>lowpanIfStatsGroup</c>
        <c>71</c>
        
        <c>1.3.6.1.2.1.XXXX.2.1.4</c>
        <c>lowpanIfStatsMeshGroup</c>
        <c>72</c>
        
        <c>1.3.6.1.2.1.XXXX.2.2</c>
        <c>lowpanCompliances</c>
        <c>73</c>
        
        <c>1.3.6.1.2.1.XXXX.2.2.1</c>
        <c>lowpanCompliance</c>
        <c>74</c>          
      
      </texttable>
      <t>
        Notes:
        <list style="symbols">
          <t>
            The IMPORTS "MODULE-IDENTITY", "OBJECT-TYPE", "Unsigned32", "Counter32", "OBJECT-GROUP" and "MODULE-COMPLIANCE" do not have associated Object IDs,
            and hence do not show up in the table.
          </t>
          <t>
            The OBJECT-GROUPs lowpanStatsGroup, lowpanIfStatsGroup, lowpanIfStatsMeshGroup cannot appear in the CBOR instance,
            as they are lost in the intermediate MIB to YANG conversion step.
            However,
            as they have been defined in the original MIB,
            they still appear in the conversion table.
          </t>
          <t>
            (FOR THE EDITOR:) the value XXXX is defined to be the RFC number once <xref target="I-D.ietf-6lo-lowpan-mib"/> becomes an RFC.
            It is logically greater than 7000.
          </t>
        </list>
      </t>
    </section>
  -->

  <!-- 
  <section anchor="LOWPAN-MIB" title="Example instance">
    <t>
      A MIB for 6LoWPAN is defined in <xref target="I-D.ietf-6lo-lowpan-mib"/>.
      The document also provides an example JSON representation in its Appendix A.
      <xref target="Ex6LOWPAN"/> shows the associated CBOR representation with string number,
      using the string numbers derived in <xref target="StrN-LOWPAN-MIB"/>.
    </t>
    <t>
      The request would have been as follows:
    </t>      
<figure><artwork align="left"><![CDATA[
GET /mg/mib/lowpanIfStatsTable
]]></artwork></figure>    
    <t>
      The resulting table would be as follows:
    </t>
 -->
<!--
BERT: the below is the conversion from the JSON representation to CBOR.
It seems that Juergen has used a list with name "LOWPAN-MIB:LOWPAN-MIB"
to represent all 6LoWPAN MIB variables.
However, I cannot find which rule form the SMIv2 -> YANG draft he applied.
We may need to request his feedback on this.
-->
<!--
<figure anchor="Ex6LOWPAN" title="Example CBOR encoding for the 6LoWPAN MIB"><artwork align="left"><![CDATA[
82                         # two element array
   78 18 4c 4f 57 50 41 4e
   2d 4d 49 42 5f 32 30 31
   34 30 34 30 38 30 30 30
   30 5a                   # conversion table id:
                           # "LOWPAN-MIB_201404080000Z"
   BF                      # indefinite length map
     18 25                 # "lowpanIfStatsTable"
     BF                    # indefinite length map related 
                           # to lowpanIfStatsTable
        18 27              # "lowpanIfReasmTimeout"
        14                 # 20
        18 28              # "lowpanIfInReceives"
        18 2A              # 42
        18 29              # "lowpanIfInHdrErrors"
        00                 # 0
        18 2A              # "lowpanIfInMeshReceives"
        08                 # 8
        18 2B              # "lowpanIfInMeshForwds"
        00                 # 0
        18 2C              # "lowpanIfInMeshDelivers"
        00                 # 0
        18 2D              # "lowpanIfInReasmReqds"
        16                 # 22
        18 2E              # "lowpanIfInReasmFails"
        02                 # 02
        18 2F              # "lowpanIfInReasmOKs"
        14                 # 20
        18 30              # "lowpanIfInCompReqds"
        10                 # 16
        18 31              # "lowpanIfInCompFails"
        02                 # 2
        18 32              # "lowpanIfInCompOKs"
        0E                 # 14
        18 33              # "lowpanIfInDiscards"
        01                 # 01
        18 34              # "lowpanIfInDelivers"
        0C                 # 12
        18 35              # "lowpanIfOutRequests"
        0C                 # 12
        18 36              # "lowpanIfOutCompReqds"
        00                 # 0
        18 37              # "lowpanIfOutCompFails"
        00                 # 0
        18 38              # "lowpanIfOutCompOKs"
        00                 # 0
        18 39              # "lowpanIfOutFragReqds"
        05                 # 5
        18 3A              # "lowpanIfOutFragFails"
        00                 # 0
        18 3B              # "lowpanIfOutFragOKs"
        05                 # 5
        18 3C              # "lowpanIfOutFragCreates"
        08                 # 8
        18 3D              # "lowpanIfOutMeshHopLimitExceeds"
        00                 # 0
        18 3E              # "lowpanIfOutMeshNoRoutes"
        00                 # 0
        18 3F              # "lowpanIfOutMeshRequests"
        00                 # 0
        18 40              # "lowpanIfOutMeshForwds"
        00                 # 0
        18 41              # "lowpanIfOutMeshTransmits"
        00                 # 0
        18 42              # "lowpanIfOutDiscards"
        00                 # 0
        18 43              # "lowpanIfOutTransmits"
        0F                 # 15
     FF
   FF
]]></artwork></figure>
  </section>
</section>
 -->

  </back>

</rfc>
