Re: [netconf] YANG encoding in CBOR

"Rob Wilton (rwilton)" <> Fri, 22 March 2019 17:32 UTC

Return-Path: <>
Received: from localhost (localhost []) by (Postfix) with ESMTP id 002E113124D; Fri, 22 Mar 2019 10:32:45 -0700 (PDT)
X-Virus-Scanned: amavisd-new at
X-Spam-Flag: NO
X-Spam-Score: -14.5
X-Spam-Status: No, score=-14.5 tagged_above=-999 required=5 tests=[BAYES_00=-1.9, DKIMWL_WL_MED=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, HTML_MESSAGE=0.001, RCVD_IN_DNSWL_HI=-5, SPF_PASS=-0.001, URIBL_BLOCKED=0.001, USER_IN_DEF_DKIM_WL=-7.5] autolearn=ham autolearn_force=no
Authentication-Results: (amavisd-new); dkim=pass (1024-bit key)
Received: from ([]) by localhost ( []) (amavisd-new, port 10024) with ESMTP id kESfwdQ52kJy; Fri, 22 Mar 2019 10:32:42 -0700 (PDT)
Received: from ( []) (using TLSv1.2 with cipher DHE-RSA-SEED-SHA (128/128 bits)) (No client certificate requested) by (Postfix) with ESMTPS id F1AC3131362; Fri, 22 Mar 2019 10:32:41 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple;;; l=16959; q=dns/txt; s=iport; t=1553275962; x=1554485562; h=from:to:subject:date:message-id:references:in-reply-to: mime-version; bh=cAZv961zRktHDt5LV5+eOjxytb5d77os58Lam1lZSr8=; b=RjbQzFNepV1HAo4KrNprMgo9z6YF/jfwH4jHMZvXHoJfd36ifZdZZ0iT 2lr1bPlEZ6Iv6Lz87U7o2zhxKvktij+EWXDXc/qsODXG6exO0kdERp5wN 0yl97/x2ba+pNlJFaZW5HBfefbQ1TvEs8gKBhNlMWlPGuYQNp8KkXYrlI U=;
X-IronPort-Anti-Spam-Filtered: true
X-IronPort-AV: E=Sophos;i="5.60,256,1549929600"; d="scan'208,217";a="251126838"
Received: from ([]) by with ESMTP/TLS/DHE-RSA-SEED-SHA; 22 Mar 2019 17:32:37 +0000
Received: from ( []) by (8.15.2/8.15.2) with ESMTPS id x2MHWbbi001478 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=FAIL); Fri, 22 Mar 2019 17:32:37 GMT
Received: from ( by ( with Microsoft SMTP Server (TLS) id 15.0.1473.3; Fri, 22 Mar 2019 12:32:36 -0500
Received: from ([]) by ([]) with mapi id 15.00.1473.003; Fri, 22 Mar 2019 12:32:36 -0500
From: "Rob Wilton (rwilton)" <>
To: Michel Veillette <>, "" <>, "" <>
Thread-Topic: YANG encoding in CBOR
Thread-Index: AdTf3q8hCOPNH5o0Q0SJZRQQHN87VgA3tcGQAAXew9A=
Date: Fri, 22 Mar 2019 17:32:36 +0000
Message-ID: <>
References: <> <>
In-Reply-To: <>
Accept-Language: en-GB, en-US
Content-Language: en-US
x-ms-exchange-transport-fromentityheader: Hosted
x-originating-ip: []
Content-Type: multipart/alternative; boundary="_000_edbd00c68ad2440684d61160be263e9cXCHRCD007ciscocom_"
MIME-Version: 1.0
Archived-At: <>
Subject: Re: [netconf] YANG encoding in CBOR
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: NETCONF WG list <>
List-Unsubscribe: <>, <>
List-Archive: <>
List-Post: <>
List-Help: <>
List-Subscribe: <>, <>
X-List-Received-Date: Fri, 22 Mar 2019 17:32:45 -0000

Hi Michael,

Indeed, it was the encoding of unions containing more than one enum that was the concern raised in the meeting.


From: Michel Veillette <>
Sent: 22 March 2019 15:45
To: Rob Wilton (rwilton) <>om>;;
Subject: RE: YANG encoding in CBOR

Hi Rob

About "I was wondering whether it would be better to encode enum values ..."

YANG assigns either explicitly or implicitly to each enumeration, a unique integer value, see
In CBOR, these values are used, see
When used outside of a union, I don't see any issues with those values.
Andy, do you have a specific example for which, the current encoding is ambiguous?

The encoding of union is defined in:

Currently, each YANG datatype in a union is encoded differently to avoid any ambiguities between  them.
For example, integer 4 is encoded as:

04 # unsigned(4)

enumerator value 4 is encoded as (assuming the allocated tag is 99):

D8 63 # tag(99)
   04 # unsigned(4)

The list of these encoding is shown below:
- unsigned integer --> CBOR unsigned integer
- integer --> CBOR unsigned integer, CBOR negative integer
- enumeration --> CBOR tag <TBD>
- identityref as SID --> CBOR tag <TBD>
- string --> CBOR text string
- identityref as name --> CBOR tag <TBD>
- bits --> CBOR tag <TBD>
- binary --> CBOR byte string
- decimal64 --> CBOR tag 4
- boolean --> CBOR simple value

The only potential problem I aware is when multiple enumerations are part of the same union.
Value 4 from enumeration A will be encoded the same way as Value 4 from enumeration B.

Is it a real problem is proactive?
If so, how this can be resolved?

I won't be present at the Prague meeting, but I'm certainly available to discuss this topic by email.
I will be present at the Montreal meeting for any remaining discussions on this draft.

Note: I'm currently updating the draft to remove any dependencies with RFC 7951, to resolve a comment sent by Andy.


From: core <<>> On Behalf Of Rob Wilton (rwilton)
Sent: Friday, March 22, 2019 8:43 AM
Subject: [core] YANG encoding in CBOR


As part of YANG evolution discussion, that was some talk about using a binary encoding of YANG in NETCONF or RESTCONF.

CBOR looks like a good fit for this, and obviously CORE WG are working on draft-ietf-core-yang-cbor-07, but one comment came up from Andy that the CBOR encoding of YANG cannot handle all YANG data models.  In particular, because of the way that the encoding works there are limitations on how unions of enums work.  Is that still the case?

Hence I was wondering whether it would be better to encode enum values in CBOR using module-qualified names, or also assign them SIDs and use the SIDs.  Has this approach been considered at all?

Or, is there an alternative approach to how we could/should consider using CBOR as a binary encoding for YANG data in NETCONF or RESTCONF?

Do you think it would be possible to get interested parties together to discuss this at some point in Prague?