Draft: Proposed new RFC5444 (PacketBB) API

This is proposed to supersede !2426, to overhaul PacketBB.

This is just an API proposal (no implementation yet). I propose to make a new rfc5444.h/cc and deprecate the PacketBB in src/network/utils. This plan would reuse some of the packetbb.cc implementation and all of the tests that are currently written. This would cut down about 2/3 of the header file length from existing packetbb.h.

Main changes (as summarized by Claude who wrote the header; some of these refer to implementation plans):

  • RFC 5444 by name, not draft-era "PacketBB" — classes are prefixed Rfc5444, matching the published RFC, the OONF reference implementation (rfc5444_reader/rfc5444_writer), and every consuming RFC (6130, 7181, 5497, 7182).
  • Value semantics, standard containers — TLVs, address blocks, and messages are plain value types held in std::vector; no Ptr<>/SimpleRefCount, no hand-written container facades. Aggregates expose their contents directly (Tlvs(), Messages(), Addresses()), replacing ~150 forwarding methods with iterators, ranges, and algorithms for free.
  • A conventional ns-3 Header — Rfc5444Packet derives from Header alone and is used by value with Packet::AddHeader/RemoveHeader, like every other ns-3 header.
  • Optional fields are std::optional — no Has*()/Get*() pairs whose misuse is undefined behavior in optimized builds; the presence check is the access. Setters accept std::nullopt to clear a field.
  • Address family enforced at compile time — Rfc5444Message and Rfc5444AddressBlock are templates over Ipv4Address/Ipv6Address; mixing families is a compile error, not a runtime footgun. A packet carries mixed-family messages via std::variant, as the RFC permits.
  • Wire encoding stays on the wire — the length - 1 address-size octet, head/tail/zero-tail compression, and prefix-length encoding are serializer internals, not public API (the old {IPV4 = 3, IPV6 = 15} enum is gone).
  • Typed TLV values, first-class multivalue support — values are std::vector<uint8_t> with 1- and 2-octet convenience accessors; SetValues()/GetValueForIndex() implement the RFC 5444 Section 5.4.2 per-address value semantics that NHDP/OLSRv2 need most, previously left entirely to the caller.
  • Robust against malformed input — every length field is bounds-checked during deserialization; anything RFC 5444 Section 5.5 deems malformed (including an unknown version) rejects the packet with the standard Header error convention, instead of relying on debug-only asserts.
  • Equality by default — operator== is = default wherever possible, supporting round-trip testing without hand-maintained comparisons.

Merge request reports

Loading
Loading