[Cbor] GRASP packet header extensions (CBOR question)

Toerless Eckert <tte@cs.fau.de> Fri, 19 August 2022 15:04 UTC

Return-Path: <eckert@i4.informatik.uni-erlangen.de>
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 46AD3C15270E; Fri, 19 Aug 2022 08:04:48 -0700 (PDT)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -1.66
X-Spam-Level:
X-Spam-Status: No, score=-1.66 tagged_above=-999 required=5 tests=[BAYES_00=-1.9, HEADER_FROM_DIFFERENT_DOMAINS=0.249, RCVD_IN_DNSWL_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01] autolearn=no 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 fKU6I0N4hlcL; Fri, 19 Aug 2022 08:04:46 -0700 (PDT)
Received: from faui40.informatik.uni-erlangen.de (faui40.informatik.uni-erlangen.de [131.188.34.40]) (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 A1B9DC1522BA; Fri, 19 Aug 2022 08:04:44 -0700 (PDT)
Received: from faui48e.informatik.uni-erlangen.de (faui48e.informatik.uni-erlangen.de [IPv6:2001:638:a000:4134::ffff:51]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by faui40.informatik.uni-erlangen.de (Postfix) with ESMTPS id CD65C58C4AF; Fri, 19 Aug 2022 17:04:40 +0200 (CEST)
Received: by faui48e.informatik.uni-erlangen.de (Postfix, from userid 10463) id B51534EB7CE; Fri, 19 Aug 2022 17:04:40 +0200 (CEST)
Date: Fri, 19 Aug 2022 17:04:40 +0200
From: Toerless Eckert <tte@cs.fau.de>
To: anima@ietf.org, cbor@ietf.org
Message-ID: <Yv+miC76QMc887cJ@faui48e.informatik.uni-erlangen.de>
MIME-Version: 1.0
Content-Type: text/plain; charset="us-ascii"
Content-Disposition: inline
Archived-At: <https://mailarchive.ietf.org/arch/msg/cbor/cP0LSJj_9menSqFgbAo7Jvgfp7A>
Subject: [Cbor] GRASP packet header extensions (CBOR question)
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: Fri, 19 Aug 2022 15:04:48 -0000

[ Sorry for cross-post but given how this is about ANIMA GRASP, a CBOR
  protocol, i think its the best/fastest way to converge. ]

In GRASP (RFC8990] we define the GRASP message structure as follows:

message-structure = [MESSAGE_TYPE, session-id, ?initiator, *grasp-option]

MESSAGE_TYPE = 0..255
session-id = 0..4294967295 ; up to 32 bits
grasp-option = any

Then we've defined a few MESSAGE_TYPEs of which the one we are primarily
interested in now is:

flood-message = [M_FLOOD, session-id, initiator, ttl,
                +[objective, (locator-option / [])]]

(its also the most difficult one).

objective = [ objective-name, objective-flags, loop-count, ?objective-value ]
objective-name = text
objective-value = any

[ Not official GRASP language, but i always think of the objective to be the
 payload and the rest of the message to be the GRASP header. ]

The M_FLOOD message is already something special because all other GRASP
message types we have only have at most one objective, but because M_FLOOD
multicasts the message, we wanted the optimization to send fewer multicast
packets by coalescing them (good for low-power IoT devices).

So now the question is how we want to generically as possible extend the header.
Our specific first goal is a signature extension, but hopefully we don't
need to discuss this here (in this thread), as its not a CBOR/CDDL encoding question.

Brians suggestion, if i understand him right would be something like this:

EXTENSION_TYPE = 0..255
grasp-extension = [ EXTENSION_TYPE, *any ]
grasp-option /= grasp-extension

flood-message = [M_FLOOD, session-id, initiator, ttl,
                +[objective, (locator-option / [])], *grasp-option ]

Lets look at three different messages:

  A) [M_FLOOD, session-id, initiator, ttl,
       [    [ "objective1", ...] , locator-option ], [     [ "objective2", ...], locator-option ] ]
      (A1) (A2)                                      (A3) (A4)

  B) [M_FLOOD, session-id, initiator, ttl,
       [     ["objective1", ...], locator-option ], [    115, whatever ]]
       (B1) (B2)                                   (B3)  (B4)

  C) [M_FLOOD, session-id, initiator, ttl,
       [     ["objective1", ...], locator-option ], somethingelse, [   115, whatever ]]
       (C1) (C2)                                   (C3)           (C4) (C5)
       

When receiving message A, and looking after ttl, the next element in the array, (A1)
is itself an array, AND the first element of that array is also an array, so
this can only be an objective. Likewise logic for (A3), (A4).

When receiving B), same logic for (B1), (B2), then after (B3) the check is that the first
element of the array is of type numeric (B4) instead of array, so this must be a
grasp-extension.

When receiving C), same logic for (C1), (C2), but then at (C3) the array element is
not of type array itself, so it can't contain an objective nor can it be a grasp-extension.
But it is still matching the any of grasp-option, so its still a valid M_FLOOD grasp
messages and simply needs to be ignored (maybe we later on come up with additional stuff
that wouldn't be an array... And then at (C4), (C5) the logic to recognize a grasp-extension.

Questions:

- Is it ok. to expect the analysis to have to do two steps (e.g.: A1, A2 or B3, B4)
  to decide whats' next (i called that lookahead in another mail thread).

- does "grasp-option /= grasp-extension" work. I ask because previously grasp-option
  was "any", so logically i am not sure if CDDL expect to pick the alternative that
  is more specific, so that we can ensure that grasp-extension is always the option
  that MUST be used if it matches - instead of any.

- So everything ok ? or any other concerns ?

Cheers
    toerless