Decode v0.3 Interest format and interpret as v0.2
NDN Packet Format v0.3 is introducing a new Interest packet format.
Compared to v0.2.1 packet format, the differences are:
- Optional CanBePrefix and MustBeFresh elements are added after Name.
- Nonce becomes optional.
- ForwardingHint is moved before Nonce and InterestLifetime.
- Optional HopLimit and Parameters elements are added after InterestLifetime.
This issue changes
ndn::Interest class to recognize v0.3 format, and interpret it as v0.2 semantics.
Encoder continues to emit v0.2 format, and remains unchanged under this issue.
As part of Packet03Transition, this is an interim step for a forwarder or application to receive Interest v0.3 without any changes.
#1 Updated by Junxiao Shi over 1 year ago
- Description updated (diff)
- Estimated time set to 4.50 h
The superset of Interest v0.2 and v0.3 is:
Interest ::= INTEREST-TYPE TLV-LENGTH Name CanBePrefix-3? MustBeFresh-3? Selectors-2? Nonce-2? InterestLifetime-2? ForwardingHint? Nonce-3? InterestLifetime-3? HopLimit-3? Parameters-3?
The decoder should parse packet using this structure, but reject the packet if both 2 and 3 elements are present. Note that Nonce and InterestLifetime could be 2 or 3 when other fields are omitted, in this case: "Name Nonce InterestLifetime?" is interpreted as Nonce-2 InterestLifetime-2; "Name InterestLifetime?" is interpreted as InterestLifetime-3.
Interest v0.3 elements are mapped into v0.2 semantics as follows:
- CanBePrefix: if present, do nothing; if absent and the packet is conclusively identified as v0.3 (contains v0.3 elements/ordering, or Nonce is absent), set Selectors.MaxSuffixComponents to 1.
- MustBeFresh: set Selectors.MustBeFresh.
- Nonce: if absent, set to random value.
- HopLimit: ignore, will not appear when encoded as v0.2.
- Parameters: ignore, will not appear when encoded as v0.2.
#5 Updated by Junxiao Shi over 1 year ago
- Status changed from New to In Progress
- Assignee set to Junxiao Shi
- % Done changed from 0 to 20
https://gerrit.named-data.net/4647 adds getter/setter for CanBePrefix and MustBeFresh. Accessors are sorted in the order the elements appear in v0.3 Interest. Selector accessors are deprecated.
Decoder changes come next.
#6 Updated by Junxiao Shi over 1 year ago
- % Done changed from 20 to 50
https://gerrit.named-data.net/4670 declares TLV-TYPE numbers in
encoding/tlv.hpp. Constants are sorted in the order they appear in the spec.
https://gerrit.named-data.net/4671 implements the decoding procedures. I decide not to take note-1 approach because it is error-prone. Instead, I have separate
decode03 functions handling each format.
decode02 is made more strict than the old
wireDecode so that it would reject v0.3 format and leave it to