Re: [core] YANG to CBOR mapping

Michel Veillette <Michel.Veillette@trilliantinc.com> Mon, 14 March 2016 15:48 UTC

Return-Path: <Michel.Veillette@trilliantinc.com>
X-Original-To: core@ietfa.amsl.com
Delivered-To: core@ietfa.amsl.com
Received: from localhost (localhost [127.0.0.1]) by ietfa.amsl.com (Postfix) with ESMTP id 26CF912DB2C for <core@ietfa.amsl.com>; Mon, 14 Mar 2016 08:48:28 -0700 (PDT)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -1.903
X-Spam-Level:
X-Spam-Status: No, score=-1.903 tagged_above=-999 required=5 tests=[BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001] autolearn=ham autolearn_force=no
Authentication-Results: ietfa.amsl.com (amavisd-new); dkim=pass (1024-bit key) header.d=trilliant.onmicrosoft.com
Received: from mail.ietf.org ([4.31.198.44]) by localhost (ietfa.amsl.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id Y26jlBRJqJfA for <core@ietfa.amsl.com>; Mon, 14 Mar 2016 08:48:25 -0700 (PDT)
Received: from na01-by2-obe.outbound.protection.outlook.com (mail-by2on0145.outbound.protection.outlook.com [207.46.100.145]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by ietfa.amsl.com (Postfix) with ESMTPS id 0B11E12DCE1 for <core@ietf.org>; Mon, 14 Mar 2016 08:42:53 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Trilliant.onmicrosoft.com; s=selector1-trilliantinc-com; h=From:To:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=Y6vQCrBtfFN1YCgTq42pLUfZhyhfXnuimbJupNojRII=; b=xBJMvo0dypAHeEW2n+Y0S4V3kQB6pb8OQPMw1CqPdZjYritAHIn5z7Dy4QZZ9uHy0KjNe3XFcTKz7uCGepaGlAYSiGh9kQDIfIuanquCi9BwUBZe0xfnDi6gva3cIhO1E6fVmUjyFXOuO9tDWZB+k/gcYDNkJ8vAgsLltQXksS4=
Received: from BLUPR06MB1763.namprd06.prod.outlook.com (10.162.224.149) by BLUPR06MB1764.namprd06.prod.outlook.com (10.162.224.150) with Microsoft SMTP Server (TLS) id 15.1.434.16; Mon, 14 Mar 2016 15:42:51 +0000
Received: from BLUPR06MB1763.namprd06.prod.outlook.com ([10.162.224.149]) by BLUPR06MB1763.namprd06.prod.outlook.com ([10.162.224.149]) with mapi id 15.01.0434.016; Mon, 14 Mar 2016 15:42:51 +0000
From: Michel Veillette <Michel.Veillette@trilliantinc.com>
To: "consultancy@vanderstok.org" <consultancy@vanderstok.org>
Thread-Topic: YANG to CBOR mapping
Thread-Index: AQHReqwpv4GV3DdT0UCv7zUIvxJWyp9SwChAgAXlGwCAAGiLsA==
Date: Mon, 14 Mar 2016 15:42:51 +0000
Message-ID: <BLUPR06MB1763A818557AB9E0D4D7EC9AFE880@BLUPR06MB1763.namprd06.prod.outlook.com>
References: <125ea14670116bd8cbc275a2b1b011f9@xs4all.nl> <BLUPR06MB1763AC14774F3C21EC21CE79FEB40@BLUPR06MB1763.namprd06.prod.outlook.com> <d1bd7cebdd16c434dc007c73319a920b@xs4all.nl>
In-Reply-To: <d1bd7cebdd16c434dc007c73319a920b@xs4all.nl>
Accept-Language: fr-CA, en-US
Content-Language: en-US
X-MS-Has-Attach:
X-MS-TNEF-Correlator:
authentication-results: vanderstok.org; dkim=none (message not signed) header.d=none;vanderstok.org; dmarc=none action=none header.from=trilliantinc.com;
x-originating-ip: [207.96.192.122]
x-ms-office365-filtering-correlation-id: 571b7d23-926d-4032-3186-08d34c1f4d6e
x-microsoft-exchange-diagnostics: 1; BLUPR06MB1764; 5:3JXICsfasispYmWu42DIkWsc1pdst+656EDpF1GiJZU5X0+j3nKUoohcLsUNtgwjTAUW0tMAhKK733eJKT6WqMnqXwAHbog1ly0HX9TNuWnLjbqSDYuAyhWVhXEz3hw1dCVP2zpUrfWftw5iZ4lEDA==; 24:vvJMHKkkgPNJKHOJThJYuYRqGByWgeZEBOy/gUE9Hswc3ZJ35tUYal7yMzyVsWJeYkaHH4lNI0EpjmIWozOVuYJiLpmOUzh3Q+32LubNxe0=
x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:BLUPR06MB1764;
x-microsoft-antispam-prvs: <BLUPR06MB1764A9D589171A85E2239897FE880@BLUPR06MB1764.namprd06.prod.outlook.com>
x-exchange-antispam-report-test: UriScan:;
x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(601004)(2401047)(5005006)(8121501046)(3002001)(10201501046); SRVR:BLUPR06MB1764; BCL:0; PCL:0; RULEID:; SRVR:BLUPR06MB1764;
x-forefront-prvs: 0881A7A935
x-forefront-antispam-report: SFV:NSPM; SFS:(10019020)(6009001)(13464003)(377454003)(2501003)(81166005)(586003)(5003600100002)(76576001)(6116002)(3846002)(102836003)(74316001)(5002640100001)(86362001)(15975445007)(2950100001)(2900100001)(77096005)(110136002)(5640700001)(10400500002)(54356999)(50986999)(76176999)(99286002)(2351001)(2906002)(3480700003)(3280700002)(106116001)(3660700001)(5004730100002)(87936001)(1730700002)(1096002)(1220700001)(33656002)(4326007)(66066001)(189998001)(19580395003)(19580405001)(122556002)(5008740100001)(92566002)(11100500001); DIR:OUT; SFP:1102; SCL:1; SRVR:BLUPR06MB1764; H:BLUPR06MB1763.namprd06.prod.outlook.com; FPR:; SPF:None; MLV:sfv; LANG:en;
spamdiagnosticoutput: 1:23
spamdiagnosticmetadata: NSPM
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: quoted-printable
MIME-Version: 1.0
X-OriginatorOrg: trilliantinc.com
X-MS-Exchange-CrossTenant-originalarrivaltime: 14 Mar 2016 15:42:51.3948 (UTC)
X-MS-Exchange-CrossTenant-fromentityheader: Hosted
X-MS-Exchange-CrossTenant-id: 4f6fbd13-0dfb-4150-85c3-d43260c04309
X-MS-Exchange-Transport-CrossTenantHeadersStamped: BLUPR06MB1764
Archived-At: <http://mailarchive.ietf.org/arch/msg/core/Lc7Oirjce88Mw0sXSjakakAfqRE>
Cc: Core <core@ietf.org>
Subject: Re: [core] YANG to CBOR mapping
X-BeenThere: core@ietf.org
X-Mailman-Version: 2.1.17
Precedence: list
List-Id: "Constrained RESTful Environments \(CoRE\) Working Group list" <core.ietf.org>
List-Unsubscribe: <https://www.ietf.org/mailman/options/core>, <mailto:core-request@ietf.org?subject=unsubscribe>
List-Archive: <https://mailarchive.ietf.org/arch/browse/core/>
List-Post: <mailto:core@ietf.org>
List-Help: <mailto:core-request@ietf.org?subject=help>
List-Subscribe: <https://www.ietf.org/mailman/listinfo/core>, <mailto:core-request@ietf.org?subject=subscribe>
X-List-Received-Date: Mon, 14 Mar 2016 15:48:28 -0000

Hi Peter

List instances are defined in section 7.8 of RFC 6020, I-D.ietf-netmod-rfc6020bis-09.
(https://tools.ietf.org/html/rfc6020#section-7.8.3.1) 

For example, the following definition:

list server {
  key "name";
  unique "ip port";
  leaf name {
    type string;
  }
  leaf ip {
    type inet:ip-address;
  }
  leaf port {
    type inet:port-number;
    }
}

Is encoded in xml as:

<server>
  <name>smtp</name>
  <ip>192.0.2.1</ip>
  <port>25</port>
</server>

In draft-ietf-netmod-yang-json, the encoding of a list instance in JSON is defined in section 5.4.
(https://tools.ietf.org/html/draft-ietf-netmod-yang-json-09#section-5.4) 
"A list instance is encoded as a name/array pair, and the array elements are JSON objects."

For the above example, the JSON encoding is:

{
  "name" : "smtp",
  "ip" : "192.0.2.1",
  "port" : 25
}

I-D.veillette-core-yang-cbor-mapping use the same approach in section 4.4 and propose a CBOR map.
(https://tools.ietf.org/html/draft-veillette-core-yang-cbor-mapping-00#section-4.4)

 For the above example, the CBOR encoding is:

* For name*

Diagnostic notation:
{
  "name" : "smtp",
  "ip" : "192.0.2.1",
  "port" : 25
}

CBOR encoding (31 bytes):
a3
   64
      6e616d65
   64  
      736d7470
   62
      6970 
   69
      3139322e302e322e31
   64
      706f7274
   18 19

* For YANG hashes*
Assuming:
- YANG hash of "/unknown-module:server/name" = h'0e99676c'
- YANG hash of "/unknown-module:server/ip" = h'2aa29479'
- YANG hash of "/unknown-module:server/port" = h'30f67b93'

Diagnostic notation:
{
  h'0e99676c' : "smtp",
  h'2aa29479' : "192.0.2.1",
  h'30f67b93' : 25
}

CBOR encoding (33 byte):
a3
   44 
      0e99676c
   64
      736d7470
   44
      2aa29479
   69
      3139322e302e322e31
   44
      30f67b93
   18 19

* For SID *
Assuming:
- SID of "/unknown-module:server/name" = 1576
- SID of "/unknown-module:server/ip" = 1577
- SID of "/unknown-module:server/port" = 1578

Diagnostic notation:
{
  1576 : "smtp",
  1577 : "192.0.2.1",
  1578 : 25
}

CBOR encoding (27 byte):
a3
   19 0628
   64
      736d7470
   19 0629
   69
      3139322e302e322e31
   19 062a
   18 19

* For SID delta *

Diagnostic notation:
{
  1 : "smtp",
  2 : "192.0.2.1",
  3 : 25
}

CBOR encoding (21 byte):
a3
   01
   64
      736d7470
   02
   69
      3139322e302e322e31
   03
   18 19

I understand that CoMI introduces a new approach to encode List instances
which add metadata to identify which data nodes are keys and which ones are
associated data. For the XML and JSON encoding, it seems too late to change
the way list instances are encoded. For the CBOR encoding, adding metadata
will be in contradiction with the "Properties of the CBOR Encoding" as defined
in section 3
(https://tools.ietf.org/html/draft-veillette-core-yang-cbor-mapping-00#section-3)

 "In order to minimize the size of the encoded data, the proposed
   mapping does not make use of any meta-information beyond those
   natively supported by CBOR."

If this assumption in not what you had in mind, please clarify.

Regards,
Michel

-----Original Message-----
From: peter van der Stok [mailto:stokcons@xs4all.nl] 
Sent: March-14-16 4:42 AM
To: Michel Veillette <Michel.Veillette@trilliantinc.com>
Cc: consultancy@vanderstok.org; Core <core@ietf.org>
Subject: RE: YANG to CBOR mapping

Hi Michel

I'm confused about the answers below.

> === About list instance
> 
> On the identification side of list instance, I thinks this is fully 
> documented in section
> (https://core-wg.github.io/yang-cbor/draft-veillette-core-yang-cbor-ma
> pping-latest.html#rfc.section.5.13)
> and the third example in this section address specifically this topic.

This section is about the "instance-identifier" not about the instance.

> 
> On the encoding side, we mention list instances in section
> (https://core-wg.github.io/yang-cbor/draft-veillette-core-yang-cbor-ma
> pping-latest.html#rfc.section.4.2)
> "Collections such as containers, list instances, notifications, RPC 
> inputs, RPC outputs, action inputs and action outputs MUST be encoded 
> using a CBOR map data item (major type 5)."

This section is about lists without keys.

My suggestion is to create a section that describes the encoding of list instances (multiple instances) identified with key values.
I prefer to have that subject handled here, so it is not exclusively comi speak, but for example can be used also for restconf.

Greetings,

Peter