Re: [Cbor] Using packed CBOR in BIRD's custom protocol

Carsten Bormann <cabo@tzi.org> Wed, 07 June 2023 11:02 UTC

Return-Path: <cabo@tzi.org>
X-Original-To: cbor@ietfa.amsl.com
Delivered-To: cbor@ietfa.amsl.com
Received: from localhost (localhost [127.0.0.1]) by ietfa.amsl.com (Postfix) with ESMTP id 081C4C15108A for <cbor@ietfa.amsl.com>; Wed, 7 Jun 2023 04:02:33 -0700 (PDT)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -6.897
X-Spam-Level:
X-Spam-Status: No, score=-6.897 tagged_above=-999 required=5 tests=[BAYES_00=-1.9, RCVD_IN_DNSWL_HI=-5, RCVD_IN_ZEN_BLOCKED_OPENDNS=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, URIBL_DBL_BLOCKED_OPENDNS=0.001, URIBL_ZEN_BLOCKED_OPENDNS=0.001] autolearn=ham autolearn_force=no
Received: from mail.ietf.org ([50.223.129.194]) by localhost (ietfa.amsl.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 5LKDIfewLbnx for <cbor@ietfa.amsl.com>; Wed, 7 Jun 2023 04:02:29 -0700 (PDT)
Received: from smtp.zfn.uni-bremen.de (smtp.zfn.uni-bremen.de [IPv6:2001:638:708:32::21]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by ietfa.amsl.com (Postfix) with ESMTPS id DF686C14CE36 for <cbor@ietf.org>; Wed, 7 Jun 2023 04:02:27 -0700 (PDT)
Received: from [192.168.217.124] (p548dc15c.dip0.t-ipconnect.de [84.141.193.92]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.zfn.uni-bremen.de (Postfix) with ESMTPSA id 4QbkvP3nLxzDCfg; Wed, 7 Jun 2023 13:02:25 +0200 (CEST)
Content-Type: text/plain; charset="utf-8"
Mime-Version: 1.0 (Mac OS X Mail 13.4 \(3608.120.23.2.7\))
From: Carsten Bormann <cabo@tzi.org>
In-Reply-To: <25a4a6ed-5b00-c900-c9c6-b83dd45b4003@nic.cz>
Date: Wed, 07 Jun 2023 13:02:25 +0200
Cc: cbor@ietf.org
X-Mao-Original-Outgoing-Id: 707828544.991901-c250a43a300356cf778fe8f5560963ef
Content-Transfer-Encoding: quoted-printable
Message-Id: <59A63030-506D-4F20-94E0-73EFE49B5AF9@tzi.org>
References: <25a4a6ed-5b00-c900-c9c6-b83dd45b4003@nic.cz>
To: Maria Matejka <maria.matejka=40nic.cz@dmarc.ietf.org>
X-Mailer: Apple Mail (2.3608.120.23.2.7)
Archived-At: <https://mailarchive.ietf.org/arch/msg/cbor/XlGKB1YIvGYlf-ZkF5kCSNhj-Js>
Subject: Re: [Cbor] Using packed CBOR in BIRD's custom protocol
X-BeenThere: cbor@ietf.org
X-Mailman-Version: 2.1.39
Precedence: list
List-Id: "Concise Binary Object Representation \(CBOR\)" <cbor.ietf.org>
List-Unsubscribe: <https://www.ietf.org/mailman/options/cbor>, <mailto:cbor-request@ietf.org?subject=unsubscribe>
List-Archive: <https://mailarchive.ietf.org/arch/browse/cbor/>
List-Post: <mailto:cbor@ietf.org>
List-Help: <mailto:cbor-request@ietf.org?subject=help>
List-Subscribe: <https://www.ietf.org/mailman/listinfo/cbor>, <mailto:cbor-request@ietf.org?subject=subscribe>
X-List-Received-Date: Wed, 07 Jun 2023 11:02:33 -0000

Hi Maria,

This is a very interesting use case, thank you for bringing it to the WG.

The idea behind CBOR-packed is that we have a common unpacking mechanism, but leave room for multiple table (dictionary) building mechanisms; the CBOR-packed spec only provides a basic one (as a “batteries included” starter kit).
So you definitely are not bound to tag 113 if you have a different way to build the table.

The nesting behavior of tag 113 is really of interest if you have a common dictionary to which further instance-specific updates need to be made.  You wouldn’t necessarily use tag 113 for the outer dictionary — that might come from an application-defined tag or even from the knowledge of the media type (or other context).

I don’t think 28/29 are a good way forward, as they rely on order-preserving processing, which may not be supported by a CBOR library.

You do know about tag 52/54?  (RFC 9164.)
Do you have an example where length indication (beyond what a byte string already does) would lead to easier data management?

Defining a representation of BGP attributes in CBOR is a valid subject of an RFC.
That could define tags, but your actual use of this might elide them (which would be seen as an “unwrap”, ~tag, in CDDL).
Note that the BGP YANG project already provides such a representation (via YANG-CBOR); that may or may not be expeditious for your use.

This message is just a quick response; we could pick up this subject in one of the next interims of the CBOR WG (next: 2023-06-14).
Let’s prepare that with a few messages on the mailing list.

Grüße, Carsten


> On 2023-06-07, at 12:35, Maria Matejka <maria.matejka=40nic.cz@dmarc.ietf.org> wrote:
> 
> Hello!
> 
> We're planning to implement a machine-friendly protocol for common and generic communication between BIRD and the surroundings, like GUIs and CLIs or automation machinery. (Currently, everybody is parsing our CLI, which is an awful mess.) We decided to go with CBOR and I'd like to consult with you whether our way is reasonable, and also ask some questions, as we're newbies in this area, if you don't mind.
> 
> We're definitely going for the packed CBOR as our data can easily get annoyingly big if not packed. Yet we typically don't know the actual contents of the dictionary when starting to pack – and we don't like caching the data either before sending it to generate the dictionary to the beginning. Is there any possibility to send dictionary updates? I'm quite confused by the wording of section 3 of draft-ietf-cbor-packed-08 – at least my concerns are partially relieved by the Appendix A. I'm reading it this way – when we have anything to pack, we open a new 113-tag enclosing the rest of the message … and as soon as we find something more to add to the dictionary, we nest the 113-tags and we put the new values to the end of the dictionary by explicitly marking them by their tags. Is this a valid understanding of that section?
> 
> Or should we better go for value-sharing by Marc A. Lehmann with tags 28 and 29 in this kind of setup?
> 
> For the in-socket format, I'm also missing a possibility to explicitly say "the following object (data item) is exactly N bytes long" to allow for easier data management – shall we define this functionality and register it as a tag?
> 
> And also we're going to encode routing information (like BGP attributes) which may need a standardized representation, yet it's just a map (in case of one route) or a map of maps (full RIB). I think that in this case, it doesn't deserve a tag, yet it may be handy to write an informational RFC about that. Is this the right way to go?
> 
> Thank you for helping us.
> 
> -- 
> Maria Matejka | BIRD Team Leader | CZ.NIC, z.s.p.o.
> 
> _______________________________________________
> CBOR mailing list
> CBOR@ietf.org
> https://www.ietf.org/mailman/listinfo/cbor