sixlowpan: Implement RFC 7400 Generic Header Compression (GHC)
Summary
This MR adds RFC 7400 Generic Header Compression (GHC) support to the ns-3 6LoWPAN module, filling the gap left by RFC 6282 (which defines no ICMPv6 NHC and no way to compress extension-header payloads).
Provenance
Original implementation written from scratch against RFC 7400 (Bormann, November 2014) as the sole normative reference. No code was borrowed or ported from any prior third-party implementation; the existing RFC 6282 IPHC/NHC paths in SixLowPanNetDevice were used as a stylistic reference only. License: GPL-2.0-only, matching the rest of the module.
What it adds
- GHC engine (
SixLowPanGhcEngine): LZ77-style greedy compressor / decompressor with the 48-byte predefined dictionary from RFC 7400 Section 2 (16 B src addr + 16 B dst addr + 16 B static dictionary). Supports all five bytecode types (Literal, ZeroInsert, StopCode, ExtendedArgs, Backref). - Three NHC header classes wired into the existing NHC dispatch:
SixLowPanGhcExtension-10111EIDNH(0xB0-0xBF) — IPv6 extension headersSixLowPanGhcUdp-11010CPP(0xD0-0xD7) — UDP w/ compressed payloadSixLowPanGhcIcmpv6-11011111(0xDF) — ICMPv6 w/ compressed body
- 6CIO option (
SixLowPan6Cio): ND option Type 36 with the G-bit for GHC capability signaling (RFC 7400 Section 6). UseGhcattribute onSixLowPanNetDevice(bool, defaultfalsefor interop). When enabled, compression tries GHC first and falls back to RFC 6282 NHC if the compressed form is not smaller; the decompressor transparently handles both dispatch spaces.
Tests (suite: sixlowpan-ghc)
SixlowpanGhcEngineTest- engine compress/decompress round-trip.SixlowpanGhcHeaderTest- NHC header serialization for Extension/UDP/ICMPv6.SixlowpanGhcUdpImplTest- end-to-end UDP over simple channel.SixlowpanGhcAppendixATest- RFC 7400 Appendix A patterns (zero-run, dictionary back-reference, literal passthrough).
All pre-existing sixlowpan tests continue to pass unchanged.
Files
src/sixlowpan/model/sixlowpan-ghc.{h,cc}(new)src/sixlowpan/test/sixlowpan-ghc-test.cc(new)src/sixlowpan/model/sixlowpan-net-device.{h,cc}(GHC hooks +UseGhcattr)src/sixlowpan/doc/sixlowpan.rst(new GHC section + reference)src/sixlowpan/CMakeLists.txt(register new files)
Compression observed on the included tests
- Extension headers: ~70-80 %
- UDP payloads: ~40-50 %
- ICMPv6 bodies: ~50-65 %
References
- RFC 7400 - 6LoWPAN-GHC, C. Bormann, November 2014.
- RFC 6282 - Compression Format for IPv6 Datagrams over IEEE 802.15.4 (baseline).
AI tool disclosure
Per the ns-3 AI policy, this MR was developed with Claude Code (Anthropic, Opus 4.7) assistance. The GHC engine, NHC header classes, integration into SixLowPanNetDevice, and the test suite were generated with AI support and reviewed against ns-3 conventions, the relevant RFC text (RFC 7400, 6282, 4944), and existing test patterns before each commit. Every commit on this MR carries an Assisted-by: trailer.