Re: [core] YANG to CBOR mapping

peter van der Stok <stokcons@xs4all.nl> Thu, 10 March 2016 09:52 UTC

Return-Path: <stokcons@xs4all.nl>
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 483D512D63C for <core@ietfa.amsl.com>; Thu, 10 Mar 2016 01:52:47 -0800 (PST)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -2.621
X-Spam-Level:
X-Spam-Status: No, score=-2.621 tagged_above=-999 required=5 tests=[BAYES_00=-1.9, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_PASS=-0.001] autolearn=ham autolearn_force=no
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 CdOp4mF0710K for <core@ietfa.amsl.com>; Thu, 10 Mar 2016 01:52:45 -0800 (PST)
Received: from lb2-smtp-cloud6.xs4all.net (lb2-smtp-cloud6.xs4all.net [194.109.24.28]) (using TLSv1 with cipher DHE-RSA-AES128-SHA (128/128 bits)) (No client certificate requested) by ietfa.amsl.com (Postfix) with ESMTPS id A912712D643 for <core@ietf.org>; Thu, 10 Mar 2016 01:52:42 -0800 (PST)
Received: from webmail.xs4all.nl ([194.109.20.214]) by smtp-cloud6.xs4all.net with ESMTP id U9sg1s0164d84Ai019sgwW; Thu, 10 Mar 2016 10:52:40 +0100
Received: from AMontpellier-654-1-113-50.w90-0.abo.wanadoo.fr ([90.0.128.50]) by webmail.xs4all.nl with HTTP (HTTP/1.1 POST); Thu, 10 Mar 2016 10:52:40 +0100
MIME-Version: 1.0
Content-Type: text/plain; charset="UTF-8"; format="flowed"
Content-Transfer-Encoding: 8bit
Date: Thu, 10 Mar 2016 10:52:40 +0100
From: peter van der Stok <stokcons@xs4all.nl>
To: Carsten Bormann <cabo@tzi.org>
Organization: vanderstok consultancy
Mail-Reply-To: consultancy@vanderstok.org
In-Reply-To: <56E13F0C.7020504@tzi.org>
References: <125ea14670116bd8cbc275a2b1b011f9@xs4all.nl> <56E13F0C.7020504@tzi.org>
Message-ID: <595bb409b727e8fb26bdc5d0bae86d47@xs4all.nl>
X-Sender: stokcons@xs4all.nl (9hlKXRAfPXdINAbY/lkJJCbE0hLIMHNf)
User-Agent: XS4ALL Webmail
Archived-At: <http://mailarchive.ietf.org/arch/msg/core/ZesHTsTaidS4bfdDM6tdtjxeQ-M>
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
Reply-To: consultancy@vanderstok.org
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: Thu, 10 Mar 2016 09:52:47 -0000

Hi Carsten,

thanks, see below.

Carsten Bormann schreef op 2016-03-10 10:31:
> Hi Peter,
> 
>> The SID and and hash are both numbers, why not map them both to 
>> unsigned
>> integer (major type 0)?
> 
> SIDs benefit from compression by delta encoding (turning them into
> signed integers in the actual delta).
> Delta encoding does not make sense for hashes (just spreads the numbers
> further out).
> So it is useful to be able to *distinguish* the two, specifically 
> before
> the delta encoding kicks in.
> 
> One way that came up for this in discussions about how to best use CBOR
> for YANG data representation is to represent the hashes as binary
> strings.  E.g., if the hash value is 1234567890, what might have been
> 
> 1a 499602d2 # unsigned(1234567890)
> 
> becomes h'499602d2' or
> 
> 44          # bytes(4)
>    499602d2 # "I\x96\x02\xD2"
<pvds>
Is misinterpreted this in the draft as a rather long "character" string
thanks for the explanation
</pvds>
> 
> Since hashes are evenly distributed in the 30-bit space, there is no
> change in the number of bytes needed (except maybe for the p = 1/16384
> case that the hash happens to be < 65536).
> 
> With this way of distinguishing identifiers, in the end, we can have a
> mapping of CBOR data types to identifiers:
> 
> CBOR type     meaning
> integer       delta encoded SID
> byte string   hash
> text string   native YANG identifier
<pvds>
like the table
</pvds>
> 
> (It is then a matter of design and/or deployment which of these kinds 
> of
> identifiers are actually used in a specific instance.)
> 
>> The server does not care how these numbers are produced, it only needs
>> to map the number to the memory locations in the server.
> 
> Exactly.
> 
> Grüße, Carsten