[Ndn-interest] [EXT] Custom TLV vs library

Junxiao Shi shijunxiao at email.arizona.edu
Wed Jan 20 15:48:50 PST 2021


Hi Varun


> You can choose either one, but you should write down the schema first. In
>> other words, CBOR is not an excuse for not writing the schema.
>>
> At least for my use case, there isn't a schema - I just need to encode an
> unordered_map<string, int>. Which is why CBOR seemed ideal.
>

Even if it's an unordered_map<string, int>, you still need to write a
schema.
The schema would answer questions like:

   - Is the string a byte string (major type 2) or a text string (major
   type 3)?
   - Is it allowable to encode the integer as bignum format?

If you are referring to the version vector
<https://github.com/JonnyKong/Sync-MANET/blob/388d41f5e5b2626f9d82a06ad7d41c97e490ba5a/svs_helper.hpp#L12-L29>
:

   - It's more than an unordered_map<string, int>. There are three items in
   each tuple.
   - It should not be "unordered" because allowing arbitrary order would
   cause different network nodes to encode this component differently,
   reducing the effectiveness of Interest aggregation.
   - If the string is actually a name, you should use its NDN-TLV encoding,
   not the URI format. Canonical URI is standardized but less compact.
   Alternate URI is implementation dependent - PSync made the mistake of using
   alternate URI, so it's not portable.


Version vector encoded in NDN-TLV would be something like:
VERSION-VECTOR = *VECTOR-VECTOR-ITEM
; items should be sorted by Name in NDN canonical order

VERSION-VECTOR-ITEM = VERSION-VECTOR-ITEM-TYPE TLV-LENGTH
                      Name
                      SeqNum
                      [IsImportant]

SeqNum = SequenceNumNameComponent

IsImportant = IS-IMPORTANT-TYPE
              TLV-LENGTH ; zero

VERSION-VECTOR-ITEM-TYPE = 0xFD.2F.C1

IS-IMPORTANT-TYPE = 0xFD.2F.C3

; Name defined in NDN Packet Format v0.3
; SequenceNumNameComponent is defined in NDN Naming Conventions rev02

Version vector encoded in CBOR would be something like:
version-vector = {
  *name => version-vector-value
}

name = bstr ; Name TLV-VALUE, as defined in NDN Packet Format

version-vector-value = [
  uint, ; sequence number
  bool, ; is important
]
Map item ordering should follow RFC8949 section 4.2, which differs from NDN
canonical order.
Also note that the name is encoded as TLV-VALUE only, because the
"NAME-TYPE TLV-LENGTH" portion is redundant. As mentioned above, you should
not use the URI format.

Yours, Junxiao
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.lists.cs.ucla.edu/pipermail/ndn-interest/attachments/20210120/639b70ea/attachment.html>


More information about the Ndn-interest mailing list