A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
sixlowpan-ghc-test.cc
Go to the documentation of this file.
1/*
2 * Copyright (c) 2026 SRM Institute of Science and Technology
3 *
4 * SPDX-License-Identifier: GPL-2.0-only
5 *
6 * Author: Usham Roy <ushamroy80@gmail.com>
7 *
8 * Tests for 6LoWPAN-GHC (RFC 7400) implementation.
9 */
10
11#include "ns3/boolean.h"
12#include "ns3/enum.h"
13#include "ns3/inet6-socket-address.h"
14#include "ns3/internet-stack-helper.h"
15#include "ns3/log.h"
16#include "ns3/node.h"
17#include "ns3/simple-channel.h"
18#include "ns3/simple-net-device.h"
19#include "ns3/simulator.h"
20#include "ns3/sixlowpan-ghc.h"
21#include "ns3/sixlowpan-header.h"
22#include "ns3/sixlowpan-net-device.h"
23#include "ns3/socket-factory.h"
24#include "ns3/socket.h"
25#include "ns3/test.h"
26#include "ns3/udp-socket-factory.h"
27
28#include <array>
29#include <cstring>
30#include <limits>
31#include <string>
32#include <vector>
33
34using namespace ns3;
35
36// ============================================================================
37// Test 1: GHC engine (compress/decompress)
38// ============================================================================
39
40/**
41 * @ingroup sixlowpan-tests
42 * @brief GHC engine in-memory compress/decompress test.
43 *
44 * Tests that the GHC engine can compress data and decompress it
45 * back to the original, verifying the LZ77 bytecode pipeline.
46 */
48{
49 public:
51 void DoRun() override;
52};
53
55 : TestCase("GHC engine compress then decompress (in-memory)")
56{
57}
58
59void
61{
62 Ipv6Address srcAddr("2001:1::1");
63 Ipv6Address dstAddr("2001:1::2");
64
65 // Subtest 1: Data with lots of zeros (should compress well via zero-insert)
66 {
67 auto input = std::to_array<uint8_t>({0x3a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
68 0x80, 0x00, 0x12, 0x34, 0x00, 0x01, 0x00, 0x01,
69 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00});
70 const auto inputLen = static_cast<uint32_t>(input.size());
71
72 std::array<uint8_t, 256> compressed{};
73 const auto compBufLen = static_cast<uint32_t>(compressed.size());
74 uint32_t compLen = SixLowPanGhcEngine::Compress(srcAddr,
75 dstAddr,
76 input.data(),
77 inputLen,
78 compressed.data(),
79 compBufLen,
80 false);
81
82 NS_TEST_ASSERT_MSG_GT(compLen, 0u, "Subtest 1: compressor produced no output");
83 NS_TEST_ASSERT_MSG_EQ(compLen, 12u, "Subtest 1: exact compressed size");
84 {
85 NS_TEST_ASSERT_MSG_LT(compLen, inputLen, "Compressed size should be less than input");
86
87 std::array<uint8_t, 1280> decompressed{};
88 const auto decompBufLen = static_cast<uint32_t>(decompressed.size());
89 uint32_t decompLen = SixLowPanGhcEngine::Decompress(srcAddr,
90 dstAddr,
91 compressed.data(),
92 compLen,
93 decompressed.data(),
94 decompBufLen,
95 false);
96
97 NS_TEST_ASSERT_MSG_EQ(decompLen, inputLen, "Decompressed length must match original");
98 NS_TEST_ASSERT_MSG_EQ(std::memcmp(input.data(), decompressed.data(), inputLen),
99 0,
100 "Decompressed data must match original");
101 }
102 }
103
104 // Subtest 2: Data that matches the static dictionary
105 {
106 // Include bytes from static dictionary: 0x16, 0xfe, 0xfd, 0x17...
107 auto input = std::to_array<uint8_t>({0x16,
108 0xfe,
109 0xfd,
110 0x17,
111 0xfe,
112 0xfd,
113 0x00,
114 0x01,
115 0x00,
116 0x00,
117 0x00,
118 0x00,
119 0x00,
120 0x01,
121 0x00,
122 0x00});
123 const auto inputLen = static_cast<uint32_t>(input.size());
124
125 std::array<uint8_t, 256> compressed{};
126 const auto compBufLen = static_cast<uint32_t>(compressed.size());
127 uint32_t compLen = SixLowPanGhcEngine::Compress(srcAddr,
128 dstAddr,
129 input.data(),
130 inputLen,
131 compressed.data(),
132 compBufLen,
133 false);
134
135 NS_TEST_ASSERT_MSG_GT(compLen, 0u, "Subtest 2: compressor produced no output");
136 NS_TEST_ASSERT_MSG_EQ(compLen, 2u, "Subtest 2: exact compressed size");
137 {
138 std::array<uint8_t, 1280> decompressed{};
139 const auto decompBufLen = static_cast<uint32_t>(decompressed.size());
140 uint32_t decompLen = SixLowPanGhcEngine::Decompress(srcAddr,
141 dstAddr,
142 compressed.data(),
143 compLen,
144 decompressed.data(),
145 decompBufLen,
146 false);
147
148 NS_TEST_ASSERT_MSG_EQ(decompLen,
149 inputLen,
150 "Dictionary match: decompressed length must match");
151 NS_TEST_ASSERT_MSG_EQ(std::memcmp(input.data(), decompressed.data(), inputLen),
152 0,
153 "Dictionary match: decompressed data must match");
154 }
155 }
156
157 // Subtest 3: Data with address-derived dictionary match
158 {
159 // Use bytes that match the source IPv6 address (first 16 bytes of dictionary)
160 std::array<uint8_t, 16> srcBuf{};
161 srcAddr.GetBytes(srcBuf.data());
162 const auto srcBufLen = static_cast<uint32_t>(srcBuf.size());
163
164 std::array<uint8_t, 256> compressed{};
165 const auto compBufLen = static_cast<uint32_t>(compressed.size());
166 uint32_t compLen = SixLowPanGhcEngine::Compress(srcAddr,
167 dstAddr,
168 srcBuf.data(),
169 srcBufLen,
170 compressed.data(),
171 compBufLen,
172 false);
173
174 NS_TEST_ASSERT_MSG_GT(compLen, 0u, "Subtest 3: compressor produced no output");
175 NS_TEST_ASSERT_MSG_EQ(compLen, 2u, "Subtest 3: exact compressed size");
176 {
177 NS_TEST_ASSERT_MSG_LT(compLen, srcBufLen, "Address data should compress significantly");
178
179 std::array<uint8_t, 1280> decompressed{};
180 const auto decompBufLen = static_cast<uint32_t>(decompressed.size());
181 uint32_t decompLen = SixLowPanGhcEngine::Decompress(srcAddr,
182 dstAddr,
183 compressed.data(),
184 compLen,
185 decompressed.data(),
186 decompBufLen,
187 false);
188
189 NS_TEST_ASSERT_MSG_EQ(decompLen,
190 srcBufLen,
191 "Address match: decompressed length must match");
192 NS_TEST_ASSERT_MSG_EQ(std::memcmp(srcBuf.data(), decompressed.data(), srcBufLen),
193 0,
194 "Address match: decompressed data must match");
195 }
196 }
197
198 // Subtest 4: Stop code handling for extension headers (compressible input)
199 {
200 auto input = std::to_array<uint8_t>({0x80,
201 0x00,
202 0x00,
203 0x00,
204 0x00,
205 0x00,
206 0x00,
207 0x00,
208 0x00,
209 0x00,
210 0x00,
211 0x00,
212 0x00,
213 0x00,
214 0x00,
215 0x00});
216 const auto inputLen = static_cast<uint32_t>(input.size());
217
218 std::array<uint8_t, 256> compressed{};
219 const auto compBufLen = static_cast<uint32_t>(compressed.size());
220 uint32_t compLen = SixLowPanGhcEngine::Compress(srcAddr,
221 dstAddr,
222 input.data(),
223 inputLen,
224 compressed.data(),
225 compBufLen,
226 true);
227
228 NS_TEST_ASSERT_MSG_GT(compLen, 0u, "Subtest 4: compressor produced no output");
229 NS_TEST_ASSERT_MSG_EQ(compLen, 4u, "Subtest 4: exact compressed size");
230 {
231 std::array<uint8_t, 1280> decompressed{};
232 const auto decompBufLen = static_cast<uint32_t>(decompressed.size());
233 uint32_t decompLen = SixLowPanGhcEngine::Decompress(srcAddr,
234 dstAddr,
235 compressed.data(),
236 compLen,
237 decompressed.data(),
238 decompBufLen,
239 true);
240
241 NS_TEST_ASSERT_MSG_EQ(decompLen, inputLen, "Stop code: decompressed length must match");
242 NS_TEST_ASSERT_MSG_EQ(std::memcmp(input.data(), decompressed.data(), inputLen),
243 0,
244 "Stop code: decompressed data must match");
245 }
246 }
247
248 // Subtest 5: Payload larger than the IPv6 minimum MTU (1280). The engine
249 // sizes its working buffers from the caller's lengths, so payloads from
250 // larger-MTU links (e.g. Ethernet) must round-trip too.
251 {
252 constexpr uint32_t largeLen = 2000;
253 std::vector<uint8_t> input(largeLen);
254 for (uint32_t i = 0; i < largeLen; i++)
255 {
256 // Repetitive pattern with zero runs: compressible via backrefs
257 input[i] = (i % 8 < 4) ? static_cast<uint8_t>(i % 4) : 0;
258 }
259
260 std::vector<uint8_t> compressed(largeLen);
261 uint32_t compLen = SixLowPanGhcEngine::Compress(srcAddr,
262 dstAddr,
263 input.data(),
264 largeLen,
265 compressed.data(),
266 largeLen,
267 false);
268
269 NS_TEST_ASSERT_MSG_GT(compLen, 0u, "Subtest 5: compressor produced no output");
270 NS_TEST_ASSERT_MSG_LT(compLen, largeLen, "Subtest 5: no compression benefit");
271
272 std::vector<uint8_t> decompressed(largeLen);
273 uint32_t decompLen = SixLowPanGhcEngine::Decompress(srcAddr,
274 dstAddr,
275 compressed.data(),
276 compLen,
277 decompressed.data(),
278 largeLen,
279 false);
280
281 NS_TEST_ASSERT_MSG_EQ(decompLen, largeLen, "Subtest 5: decompressed length mismatch");
282 NS_TEST_ASSERT_MSG_EQ(std::memcmp(input.data(), decompressed.data(), largeLen),
283 0,
284 "Subtest 5: decompressed data must match original");
285 }
286
287 // Subtest 6: Bytecode classification
288 {
290 static_cast<int>(GhcBytecodeType::LITERAL),
291 "0x00 should be LITERAL");
293 static_cast<int>(GhcBytecodeType::LITERAL),
294 "0x7F should be LITERAL");
296 static_cast<int>(GhcBytecodeType::ZERO_INSERT),
297 "0x80 should be ZERO_INSERT");
299 static_cast<int>(GhcBytecodeType::ZERO_INSERT),
300 "0x8F should be ZERO_INSERT");
302 static_cast<int>(GhcBytecodeType::STOP_CODE),
303 "0x90 should be STOP_CODE");
305 static_cast<int>(GhcBytecodeType::EXTENDED_ARGS),
306 "0xA0 should be EXTENDED_ARGS");
308 static_cast<int>(GhcBytecodeType::EXTENDED_ARGS),
309 "0xBF should be EXTENDED_ARGS");
311 static_cast<int>(GhcBytecodeType::BACKREF),
312 "0xC0 should be BACKREF");
314 static_cast<int>(GhcBytecodeType::BACKREF),
315 "0xFF should be BACKREF");
316 }
317}
318
319// ============================================================================
320// Test 2: GHC NHC header (serialize/deserialize)
321// ============================================================================
322
323/**
324 * @ingroup sixlowpan-tests
325 * @brief GHC NHC header serialize/deserialize test.
326 */
328{
329 public:
331 void DoRun() override;
332};
333
335 : TestCase("GHC NHC header serialize then deserialize (in-memory)")
336{
337}
338
339void
341{
342 // Test GHC Extension Header
343 {
344 SixLowPanGhcExtension original;
346 original.SetNh(true);
347 // 3 literal bytes + stop code
348 auto blob = std::to_array<uint8_t>({0x01, 0x02, 0x03, 0x90});
349 original.SetBlob(blob.data(), static_cast<uint32_t>(blob.size()));
350
351 // Serialize
352 Buffer buf;
353 buf.AddAtStart(original.GetSerializedSize());
354 original.Serialize(buf.Begin());
355
356 // Deserialize
357 SixLowPanGhcExtension decoded;
358 decoded.Deserialize(buf.Begin());
359
362 "EID must match");
363 NS_TEST_ASSERT_MSG_EQ(decoded.GetNh(), true, "NH flag must match");
364 NS_TEST_ASSERT_MSG_EQ(decoded.GetBlobLength(), 4u, "Blob length must match");
365
366 std::array<uint8_t, 256> decodedBlob{};
367 decoded.CopyBlob(decodedBlob.data(), static_cast<uint32_t>(decodedBlob.size()));
368 NS_TEST_ASSERT_MSG_EQ(std::memcmp(blob.data(), decodedBlob.data(), blob.size()),
369 0,
370 "Blob data must match");
371
372 // Check dispatch type
375 "Dispatch type must be LOWPAN_GHC_EXT");
376 }
377
378 // Test GHC UDP Header
379 {
380 SixLowPanGhcUdp original;
382 original.SetSrcPort(1234);
383 original.SetDstPort(5678);
384 original.SetC(false);
385 original.SetChecksum(0xABCD);
386
387 Buffer buf;
388 buf.AddAtStart(original.GetSerializedSize());
389 original.Serialize(buf.Begin());
390
391 SixLowPanGhcUdp decoded;
392 decoded.Deserialize(buf.Begin());
393
394 NS_TEST_ASSERT_MSG_EQ(decoded.GetSrcPort(), 1234u, "Src port must match");
395 NS_TEST_ASSERT_MSG_EQ(decoded.GetDstPort(), 5678u, "Dst port must match");
396 NS_TEST_ASSERT_MSG_EQ(decoded.GetC(), false, "C flag must match");
397 NS_TEST_ASSERT_MSG_EQ(decoded.GetChecksum(), 0xABCDu, "Checksum must match");
400 "Dispatch type must be LOWPAN_GHC_UDP");
401 }
402
403 // Test GHC ICMPv6 Header
404 {
405 SixLowPanGhcIcmpv6 original;
406 auto blob = std::to_array<uint8_t>({0x05, 0x80, 0x00, 0x12, 0x34, 0x84});
407 original.SetBlob(blob.data(), static_cast<uint32_t>(blob.size()));
408
409 Buffer buf;
410 buf.AddAtStart(original.GetSerializedSize());
411 original.Serialize(buf.Begin());
412
413 SixLowPanGhcIcmpv6 decoded;
414 decoded.Deserialize(buf.Begin(), buf.End());
415
416 NS_TEST_ASSERT_MSG_EQ(decoded.GetBlobLength(), 6u, "Blob length must match");
419 "Dispatch type must be LOWPAN_GHC_ICMPV6");
420
421 std::array<uint8_t, 256> decodedBlob{};
422 decoded.CopyBlob(decodedBlob.data(), static_cast<uint32_t>(decodedBlob.size()));
423 NS_TEST_ASSERT_MSG_EQ(std::memcmp(blob.data(), decodedBlob.data(), blob.size()),
424 0,
425 "Blob data must match");
426 }
427
428 // Test 6CIO Option Header
429 {
430 SixLowPan6Cio original;
431 original.SetGhcCapable(true);
432
433 Buffer buf;
434 buf.AddAtStart(original.GetSerializedSize());
435 original.Serialize(buf.Begin());
436
437 SixLowPan6Cio decoded;
438 decoded.Deserialize(buf.Begin());
439
440 NS_TEST_ASSERT_MSG_EQ(decoded.GetGhcCapable(), true, "GHC capable flag must match");
441 }
442
443 // Test dispatch type recognition
444 {
447 "0xB0 must be GHC_EXT");
450 "0xBF must be GHC_EXT");
453 "0xD0 must be GHC_UDP");
456 "0xD7 must be GHC_UDP");
459 "0xDF must be GHC_ICMPV6");
460 // Ensure standard NHC is still recognized
463 "0xE0 must still be NHC");
466 "0xF0 must still be UDPNHC");
467 }
468}
469
470// ============================================================================
471// Test 3: End-to-End GHC UDP Compression Test
472// ============================================================================
473
474/**
475 * @ingroup sixlowpan-tests
476 * @brief 6LoWPAN GHC end-to-end UDP test.
477 *
478 * Sends a UDP packet between two nodes with GHC enabled and verifies
479 * the packet arrives intact after compression + decompression.
480 */
482{
483 Ptr<Packet> m_receivedPacket; ///< The received packet.
484
485 /**
486 * @brief Schedule-friendly wrapper that performs the actual send.
487 * @param [in] socket The sending socket.
488 * @param [in] to Destination address in text form.
489 */
490 void DoSendData(Ptr<Socket> socket, std::string to);
491
492 /**
493 * @brief Schedule data to be sent through the socket.
494 * @param [in] socket The sending socket.
495 * @param [in] to Destination address in text form.
496 */
497 void SendData(Ptr<Socket> socket, std::string to);
498
499 public:
500 void DoRun() override;
502
503 /**
504 * @brief Receive data callback.
505 * @param [in] socket The receiving socket.
506 * @param [in] packet The received packet.
507 * @param [in] from The sender address.
508 */
509 void ReceivePacket(Ptr<Socket> socket, Ptr<Packet> packet, const Address& from);
510
511 /**
512 * @brief Receive data from the socket's RX buffer.
513 * @param [in] socket The receiving socket.
514 */
515 void ReceivePkt(Ptr<Socket> socket);
516};
517
519 : TestCase("Sixlowpan GHC UDP end-to-end")
520{
521}
522
523void
525{
526 m_receivedPacket = packet;
527}
528
529void
531{
532 uint32_t availableData [[maybe_unused]] = socket->GetRxAvailable();
533 m_receivedPacket = socket->Recv(std::numeric_limits<uint32_t>::max(), 0);
534 NS_ASSERT(availableData == m_receivedPacket->GetSize());
535}
536
537void
539{
540 Address realTo = Inet6SocketAddress(Ipv6Address(to.c_str()), 1234);
541 const char* msg = "GHC RFC 7400 compression test - Generic Header Compression for "
542 "6LoWPAN IPv6 over Low-Power Wireless Personal Area Networks.";
543 std::array<uint8_t, 128> buffer{};
544 std::memcpy(buffer.data(), msg, std::strlen(msg));
545
546 Ptr<Packet> packet = Create<Packet>(buffer.data(), static_cast<uint32_t>(buffer.size()));
547 NS_TEST_EXPECT_MSG_EQ(socket->SendTo(packet, 0, realTo),
548 static_cast<int>(buffer.size()),
549 "Send should succeed");
550}
551
552void
554{
556 Simulator::ScheduleWithContext(socket->GetNode()->GetId(),
557 Seconds(0),
559 this,
560 socket,
561 to);
563}
564
565void
567{
568 InternetStackHelper internet;
569 internet.SetIpv4StackInstall(false);
570
571 // Receiver Node
572 Ptr<Node> rxNode = CreateObject<Node>();
573 internet.Install(rxNode);
575 {
578 rxNode->AddDevice(rxDev);
579
581 rxSix->SetAttribute("CompressionType", EnumValue(SixLowPanNetDevice::GHC));
582 rxNode->AddDevice(rxSix);
583 rxSix->SetNetDevice(rxDev);
584
585 Ptr<Ipv6> ipv6 = rxNode->GetObject<Ipv6>();
586 ipv6->AddInterface(rxDev);
587 uint32_t netdev_idx = ipv6->AddInterface(rxSix);
588 Ipv6InterfaceAddress ipv6Addr =
589 Ipv6InterfaceAddress(Ipv6Address("2001:0100::1"), Ipv6Prefix(64));
590 ipv6->AddAddress(netdev_idx, ipv6Addr);
591 ipv6->SetUp(netdev_idx);
592 }
593
594 // Sender Node
595 Ptr<Node> txNode = CreateObject<Node>();
596 internet.Install(txNode);
598 {
601 txNode->AddDevice(txDev);
602
604 txSix->SetAttribute("CompressionType", EnumValue(SixLowPanNetDevice::GHC));
605 txNode->AddDevice(txSix);
606 txSix->SetNetDevice(txDev);
607
608 Ptr<Ipv6> ipv6 = txNode->GetObject<Ipv6>();
609 ipv6->AddInterface(txDev);
610 uint32_t netdev_idx = ipv6->AddInterface(txSix);
611 Ipv6InterfaceAddress ipv6Addr =
612 Ipv6InterfaceAddress(Ipv6Address("2001:0100::2"), Ipv6Prefix(64));
613 ipv6->AddAddress(netdev_idx, ipv6Addr);
614 ipv6->SetUp(netdev_idx);
615 }
616
617 // Link the two nodes
619 rxDev->SetChannel(channel1);
620 txDev->SetChannel(channel1);
621
622 // Create the UDP sockets
623 Ptr<SocketFactory> rxSocketFactory = rxNode->GetObject<UdpSocketFactory>();
624 Ptr<Socket> rxSocket = rxSocketFactory->CreateSocket();
625 NS_TEST_EXPECT_MSG_EQ(rxSocket->Bind(Inet6SocketAddress(Ipv6Address("2001:0100::1"), 1234)),
626 0,
627 "trivial");
628 rxSocket->SetRecvCallback(MakeCallback(&SixlowpanGhcUdpImplTest::ReceivePkt, this));
629
630 Ptr<SocketFactory> txSocketFactory = txNode->GetObject<UdpSocketFactory>();
631 Ptr<Socket> txSocket = txSocketFactory->CreateSocket();
632 txSocket->SetAllowBroadcast(true);
633
634 // Unicast test
635 SendData(txSocket, "2001:0100::1");
636 NS_TEST_EXPECT_MSG_EQ(m_receivedPacket->GetSize(), 128, "Received packet size must match");
637
638 std::array<uint8_t, 128> rxBuffer{};
639 std::array<uint8_t, 128> txBuffer{};
640 const char* msg = "GHC RFC 7400 compression test - Generic Header Compression for "
641 "6LoWPAN IPv6 over Low-Power Wireless Personal Area Networks.";
642 std::memcpy(txBuffer.data(), msg, std::strlen(msg));
643 m_receivedPacket->CopyData(rxBuffer.data(), static_cast<uint32_t>(rxBuffer.size()));
644 NS_TEST_EXPECT_MSG_EQ((rxBuffer == txBuffer), true, "Received data must match sent data");
645
646 m_receivedPacket->RemoveAllByteTags();
648}
649
650// ============================================================================
651// Test 4: RFC 7400 Appendix A Test Vectors
652// ============================================================================
653
654/**
655 * @ingroup sixlowpan-tests
656 * @brief RFC 7400 Appendix A test vectors (Figures 8 - 17).
657 *
658 * For every one of the ten worked examples in RFC 7400 Appendix A the test
659 * carries three reference byte arrays: the source/destination IPv6 addresses
660 * (extracted from the example's IP header, seeding the GHC dictionary), the
661 * original uncompressed payload (RefUncomp), and the RFC-provided compressed
662 * form (RefComp).
663 *
664 * For each vector, the test runs two steps in the order suggested by the
665 * RFC 7400 authors:
666 *
667 * 1. Compress(RefUncomp) -> MyComp. Because RFC 7400 LZ77 does not mandate
668 * a unique encoding (different compressors may select different but
669 * equally valid matches), MyComp is not required to match RefComp
670 * byte-for-byte. The test only asserts that MyComp is non-empty and
671 * fits in the output buffer.
672 *
673 * 2. Decompress(MyComp) -> MyUncomp. Decompression must recover
674 * RefUncomp byte-for-byte: this is the primary correctness check for
675 * codec consistency and is strict.
676 *
677 * A third independent check decompresses RefComp (the RFC-provided stream)
678 * and verifies that it recovers RefUncomp; this validates interoperability
679 * of the decompressor with third-party (and typically optimal) encodings.
680 */
682{
683 public:
685 void DoRun() override;
686
687 private:
688 /**
689 * @brief One RFC 7400 Appendix A reference vector.
690 *
691 * Uses std::vector<uint8_t> for the byte arrays so that the compressed
692 * and uncompressed sizes travel with the data (per RFC 7400 guidance:
693 * lexicographic std::vector comparison makes size + content checks
694 * implicit).
695 */
696 struct Vector
697 {
698 /// Figure number / short description.
699 std::string label;
700 /// Source IPv6 address (text form).
701 std::string src;
702 /// Destination IPv6 address (text form).
703 std::string dst;
704 /// Original (uncompressed) payload.
705 std::vector<uint8_t> payload;
706 /// RFC-provided compressed bytes.
707 std::vector<uint8_t> compressed;
708 };
709
710 /**
711 * @brief Run one reference vector through Compress and Decompress.
712 * @param [in] v The reference vector.
713 */
714 void RunVector(const Vector& v);
715};
716
718 : TestCase("GHC RFC 7400 Appendix A test vectors (Figures 8-17)")
719{
720}
721
722void
724{
725 Ipv6Address srcAddr(v.src.c_str());
726 Ipv6Address dstAddr(v.dst.c_str());
727 const std::string& tag = v.label;
728
729 // --- Step 1: Compress RefUncomp into MyComp ------------------------------
730 // Per RFC 7400, LZ77 is not a unique encoding: different compressors can
731 // produce different but equally valid compressed streams. MyComp is
732 // therefore not required to match RefComp byte-for-byte; we only assert
733 // that it is non-empty and fits in the output buffer.
734 std::array<uint8_t, 512> myCompBuf{};
735 const auto myPayloadLen = static_cast<uint32_t>(v.payload.size());
736 const auto myCompBufLen = static_cast<uint32_t>(myCompBuf.size());
737 uint32_t myCompLen = SixLowPanGhcEngine::Compress(srcAddr,
738 dstAddr,
739 v.payload.data(),
740 myPayloadLen,
741 myCompBuf.data(),
742 myCompBufLen);
743 NS_TEST_EXPECT_MSG_GT(myCompLen, 0u, tag + ": compressor produced empty output");
744 NS_TEST_EXPECT_MSG_LT(myCompLen, myCompBufLen, tag + ": compressed fits in buffer");
745
746 std::vector<uint8_t> myComp(myCompBuf.begin(), myCompBuf.begin() + myCompLen);
747
748 // --- Step 2: Decompress MyComp into MyUncomp; must equal RefUncomp ------
749 // This compress/decompress recovery is the primary correctness check. The
750 // codec must recover the original payload byte-for-byte regardless of
751 // whether MyComp matches RefComp exactly.
752 std::array<uint8_t, 512> myUncompBuf{};
753 const auto myUncompBufLen = static_cast<uint32_t>(myUncompBuf.size());
754 uint32_t myUncompLen = SixLowPanGhcEngine::Decompress(srcAddr,
755 dstAddr,
756 myComp.data(),
757 myCompLen,
758 myUncompBuf.data(),
759 myUncompBufLen);
760 std::vector<uint8_t> myUncomp(myUncompBuf.begin(), myUncompBuf.begin() + myUncompLen);
761 NS_TEST_EXPECT_MSG_EQ((myUncomp == v.payload),
762 true,
763 tag + ": decompression must recover original payload");
764
765 // --- Step 3: Decompress RefComp; must equal RefUncomp --------------------
766 // Independent interop check: our decompressor must handle the RFC-
767 // provided (optimal) encoding produced by a third-party compressor.
768 std::array<uint8_t, 512> refUncompBuf{};
769 const auto refCompLen = static_cast<uint32_t>(v.compressed.size());
770 const auto refUncompBufLen = static_cast<uint32_t>(refUncompBuf.size());
771 uint32_t refUncompLen = SixLowPanGhcEngine::Decompress(srcAddr,
772 dstAddr,
773 v.compressed.data(),
774 refCompLen,
775 refUncompBuf.data(),
776 refUncompBufLen);
777 std::vector<uint8_t> refUncomp(refUncompBuf.begin(), refUncompBuf.begin() + refUncompLen);
778 NS_TEST_EXPECT_MSG_EQ((refUncomp == v.payload),
779 true,
780 tag + ": decompressed RFC reference must equal payload");
781}
782
783void
785{
786 // clang-format off
787 const std::vector<Vector> vectors = {
788 // ---- Figure 8: A Simple RPL Example ----------------------------------
789 {"Fig 8 (RPL simple)",
790 "fe80::21c:daff:fe00:2024",
791 "ff02::1a",
792 {0x9b, 0x00, 0x6b, 0xde, 0x00, 0x00, 0x00, 0x00},
793 {0x04, 0x9b, 0x00, 0x6b, 0xde, 0x82}},
794
795 // ---- Figure 9: A Longer RPL Example ----------------------------------
796 {"Fig 9 (RPL longer)",
797 "fe80::21c:daff:fe00:3023",
798 "ff02::1a",
799 {0x9b, 0x01, 0x7a, 0x5f, 0x00, 0xf0, 0x01, 0x00, 0x88, 0x00, 0x00, 0x00,
800 0x20, 0x02, 0x0d, 0xb8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff,
801 0xfe, 0x00, 0xfa, 0xce, 0x04, 0x0e, 0x00, 0x14, 0x09, 0xff, 0x00, 0x00,
802 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x1e, 0x80, 0x20,
803 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00,
804 0x20, 0x02, 0x0d, 0xb8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff,
805 0xfe, 0x00, 0xfa, 0xce, 0x03, 0x0e, 0x40, 0x00, 0xff, 0xff, 0xff, 0xff,
806 0x20, 0x02, 0x0d, 0xb8, 0x00, 0x00, 0x00, 0x00},
807 {0x06, 0x9b, 0x01, 0x7a, 0x5f, 0x00, 0xf0, 0xc7, 0x01, 0x88, 0x81, 0x04,
808 0x20, 0x02, 0x0d, 0xb8, 0x85, 0xa7, 0xc9, 0x08, 0xfa, 0xce, 0x04, 0x0e,
809 0x00, 0x14, 0x09, 0xff, 0xa4, 0xda, 0x83, 0x06, 0x08, 0x1e, 0x80, 0x20,
810 0xff, 0xff, 0xc0, 0xd0, 0x82, 0xb4, 0xf0, 0x03, 0x03, 0x0e, 0x40, 0xc7,
811 0xa3, 0xc9, 0xa2, 0xf0}},
812
813 // ---- Figure 10: A RPL DAO Message ------------------------------------
814 {"Fig 10 (RPL DAO)",
815 "2002:db8::ff:fe00:3344",
816 "2002:db8::ff:fe00:1122",
817 {0x9b, 0x02, 0x58, 0x7d, 0x01, 0x80, 0x00, 0xf1, 0x05, 0x12, 0x00, 0x80,
818 0x20, 0x02, 0x0d, 0xb8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff,
819 0xfe, 0x00, 0x33, 0x44, 0x06, 0x14, 0x00, 0x80, 0xf1, 0x00, 0xfe, 0x80,
820 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xfe, 0x00,
821 0x11, 0x22},
822 {0x0c, 0x9b, 0x02, 0x58, 0x7d, 0x01, 0x80, 0x00, 0xf1, 0x05, 0x12, 0x00,
823 0x80, 0xb5, 0xf4, 0x08, 0x06, 0x14, 0x00, 0x80, 0xf1, 0x00, 0xfe, 0x80,
824 0x87, 0xa7, 0xdd}},
825
826 // ---- Figure 11: An ND Neighbor Solicitation --------------------------
827 {"Fig 11 (ND NS)",
828 "2002:db8::ff:fe00:3bd3",
829 "fe80::21c:daff:fe00:3023",
830 {0x87, 0x00, 0xa7, 0x68, 0x00, 0x00, 0x00, 0x00, 0xfe, 0x80, 0x00, 0x00,
831 0x00, 0x00, 0x00, 0x00, 0x02, 0x1c, 0xda, 0xff, 0xfe, 0x00, 0x30, 0x23,
832 0x01, 0x01, 0x3b, 0xd3, 0x00, 0x00, 0x00, 0x00, 0x1f, 0x02, 0x00, 0x00,
833 0x00, 0x00, 0x00, 0x06, 0x00, 0x1c, 0xda, 0xff, 0xfe, 0x00, 0x20, 0x24},
834 {0x04, 0x87, 0x00, 0xa7, 0x68, 0x82, 0xb3, 0xf0, 0x04, 0x01, 0x01, 0x3b,
835 0xd3, 0x82, 0x02, 0x1f, 0x02, 0x83, 0x02, 0x06, 0x00, 0xa2, 0xdb, 0x02,
836 0x20, 0x24}},
837
838 // ---- Figure 12: An ND Neighbor Advertisement -------------------------
839 {"Fig 12 (ND NA)",
840 "fe80::21c:daff:fe00:3023",
841 "2002:db8::ff:fe00:3bd3",
842 {0x88, 0x00, 0x26, 0x6c, 0xc0, 0x00, 0x00, 0x00, 0xfe, 0x80, 0x00, 0x00,
843 0x00, 0x00, 0x00, 0x00, 0x02, 0x1c, 0xda, 0xff, 0xfe, 0x00, 0x30, 0x23,
844 0x02, 0x01, 0xfa, 0xce, 0x00, 0x00, 0x00, 0x00, 0x1f, 0x02, 0x00, 0x00,
845 0x00, 0x00, 0x00, 0x06, 0x00, 0x1c, 0xda, 0xff, 0xfe, 0x00, 0x20, 0x24},
846 {0x05, 0x88, 0x00, 0x26, 0x6c, 0xc0, 0x81, 0xb5, 0xf0, 0x04, 0x02, 0x01,
847 0xfa, 0xce, 0x82, 0x02, 0x1f, 0x02, 0x83, 0x02, 0x06, 0x00, 0xa2, 0xdb,
848 0x02, 0x20, 0x24}},
849
850 // ---- Figure 13: An ND Router Solicitation ----------------------------
851 {"Fig 13 (ND RS)",
852 "fe80::aede:4800:0:1",
853 "ff02::2",
854 {0x85, 0x00, 0x90, 0x65, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0xac, 0xde,
855 0x48, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
856 {0x04, 0x85, 0x00, 0x90, 0x65, 0xde, 0x02, 0x02, 0xac, 0xa5, 0xeb, 0x84}},
857
858 // ---- Figure 14: An ND Router Advertisement ---------------------------
859 {"Fig 14 (ND RA)",
860 "fe80::1034:ff:fe00:1122",
861 "fe80::aede:4800:0:1",
862 {0x86, 0x00, 0x55, 0xc9, 0x40, 0x00, 0x0f, 0xa0, 0x1c, 0x5a, 0x38, 0x17,
863 0x00, 0x00, 0x07, 0xd0, 0x01, 0x01, 0x11, 0x22, 0x00, 0x00, 0x00, 0x00,
864 0x03, 0x04, 0x40, 0x40, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
865 0x00, 0x00, 0x00, 0x00, 0x20, 0x02, 0x0d, 0xb8, 0x00, 0x00, 0x00, 0x00,
866 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x02, 0x40, 0x10,
867 0x00, 0x00, 0x03, 0xe8, 0x20, 0x02, 0x0d, 0xb8, 0x00, 0x00, 0x00, 0x00,
868 0x21, 0x03, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x20, 0x02, 0x0d, 0xb8,
869 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xfe, 0x00, 0x11, 0x22},
870 {0x0c, 0x86, 0x00, 0x55, 0xc9, 0x40, 0x00, 0x0f, 0xa0, 0x1c, 0x5a, 0x38,
871 0x17, 0x80, 0x06, 0x07, 0xd0, 0x01, 0x01, 0x11, 0x22, 0x82, 0x06, 0x03,
872 0x04, 0x40, 0x40, 0xff, 0xff, 0xc0, 0xd0, 0x82, 0x04, 0x20, 0x02, 0x0d,
873 0xb8, 0x8a, 0x04, 0x20, 0x02, 0x40, 0x10, 0xa4, 0xcb, 0x01, 0xe8, 0xa2,
874 0xf0, 0x02, 0x21, 0x03, 0xa9, 0xe6, 0xb3, 0xcd, 0xaf, 0xdb}},
875
876 // ---- Figure 15: A DTLS Application Data Packet -----------------------
877 {"Fig 15 (DTLS AppData)",
878 "::",
879 "::",
880 {0x17, 0xfe, 0xfd, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00,
881 0x1d, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x09, 0xb2, 0x0e,
882 0x82, 0xc1, 0x6e, 0xb6, 0x96, 0xc5, 0x1f, 0x36, 0x8d, 0x17, 0x61, 0xe2,
883 0xb5, 0xd4, 0x22, 0xd4, 0xed, 0x2b},
884 {0xb0, 0xd1, 0x01, 0x1d, 0xf2, 0x15, 0x09, 0xb2, 0x0e, 0x82, 0xc1, 0x6e,
885 0xb6, 0x96, 0xc5, 0x1f, 0x36, 0x8d, 0x17, 0x61, 0xe2, 0xb5, 0xd4, 0x22,
886 0xd4, 0xed, 0x2b}},
887
888 // ---- Figure 16: Another DTLS Application Data Packet -----------------
889 {"Fig 16 (DTLS AppData 2)",
890 "::",
891 "::",
892 {0x17, 0xfe, 0xfd, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00,
893 0x16, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0xae, 0xa0, 0x15,
894 0x56, 0x67, 0x92, 0x4d, 0xff, 0x8a, 0x24, 0xe4, 0xcb, 0x35, 0xb9},
895 {0xb0, 0xc3, 0x03, 0x05, 0x00, 0x16, 0xf2, 0x0e, 0xae, 0xa0, 0x15, 0x56,
896 0x67, 0x92, 0x4d, 0xff, 0x8a, 0x24, 0xe4, 0xcb, 0x35, 0xb9}},
897
898 // ---- Figure 17: A DTLS Handshake Packet (Client Hello) ---------------
899 {"Fig 17 (DTLS ClientHello)",
900 "::",
901 "::",
902 {0x16, 0xfe, 0xfd, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
903 0x36, 0x01, 0x00, 0x00, 0x2a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
904 0x2a, 0xfe, 0xfd, 0x51, 0x52, 0xed, 0x79, 0xa4, 0x20, 0xc9, 0x62, 0x56,
905 0x11, 0x47, 0xc9, 0x39, 0xee, 0x6c, 0xc0, 0xa4, 0xfe, 0xc6, 0x89, 0x2f,
906 0x32, 0x26, 0x9a, 0x16, 0x4e, 0x31, 0x7e, 0x9f, 0x20, 0x92, 0x92, 0x00,
907 0x00, 0x00, 0x02, 0xc0, 0xa8, 0x01, 0x00},
908 {0xa1, 0xcd, 0x87, 0x01, 0x36, 0xa1, 0xcd, 0x01, 0x2a, 0x85, 0x23, 0x2a,
909 0xfe, 0xfd, 0x51, 0x52, 0xed, 0x79, 0xa4, 0x20, 0xc9, 0x62, 0x56, 0x11,
910 0x47, 0xc9, 0x39, 0xee, 0x6c, 0xc0, 0xa4, 0xfe, 0xc6, 0x89, 0x2f, 0x32,
911 0x26, 0x9a, 0x16, 0x4e, 0x31, 0x7e, 0x9f, 0x20, 0x92, 0x92, 0x81, 0x05,
912 0x02, 0xc0, 0xa8, 0x01, 0x00}},
913 };
914 // clang-format on
915
916 for (const auto& v : vectors)
917 {
918 RunVector(v);
919 }
920}
921
922// ============================================================================
923// Test Suite
924// ============================================================================
925
926/**
927 * @ingroup sixlowpan-tests
928 * @brief 6LoWPAN GHC (RFC 7400) Test Suite.
929 */
931{
932 public:
934};
935
944
uint32_t v
uint32_t u
RFC 7400 Appendix A test vectors (Figures 8 - 17).
void DoRun() override
Implementation to actually run this TestCase.
void RunVector(const Vector &v)
Run one reference vector through Compress and Decompress.
GHC engine in-memory compress/decompress test.
void DoRun() override
Implementation to actually run this TestCase.
GHC NHC header serialize/deserialize test.
void DoRun() override
Implementation to actually run this TestCase.
6LoWPAN GHC (RFC 7400) Test Suite.
6LoWPAN GHC end-to-end UDP test.
Ptr< Packet > m_receivedPacket
The received packet.
void DoRun() override
Implementation to actually run this TestCase.
void ReceivePkt(Ptr< Socket > socket)
Receive data from the socket's RX buffer.
void ReceivePacket(Ptr< Socket > socket, Ptr< Packet > packet, const Address &from)
Receive data callback.
void SendData(Ptr< Socket > socket, std::string to)
Schedule data to be sent through the socket.
void DoSendData(Ptr< Socket > socket, std::string to)
Schedule-friendly wrapper that performs the actual send.
a polymophic address class
Definition address.h:114
automatically resized byte buffer
Definition buffer.h:103
void AddAtStart(uint32_t start)
Definition buffer.cc:303
Buffer::Iterator Begin() const
Definition buffer.h:1137
Buffer::Iterator End() const
Definition buffer.h:1144
Hold variables of type enum.
Definition enum.h:52
An Inet6 address class.
aggregate IP/TCP/UDP functionality to existing Nodes.
Describes an IPv6 address.
void GetBytes(uint8_t buf[ADDRESS_LENGTH]) const
Get the bytes corresponding to the address.
Access to the IPv6 forwarding table, interfaces, and configuration.
Definition ipv6.h:71
IPv6 address associated with an interface.
Describes an IPv6 prefix.
static Mac48Address ConvertFrom(const Address &address)
static Mac48Address Allocate()
Allocate a new Mac48Address.
Smart pointer class similar to boost::intrusive_ptr.
Definition ptr.h:70
static void Destroy()
Execute the events scheduled with ScheduleDestroy().
Definition simulator.cc:125
static void ScheduleWithContext(uint32_t context, const Time &delay, FUNC f, Ts &&... args)
Schedule an event with the given context.
Definition simulator.h:597
static void Run()
Run the simulation.
Definition simulator.cc:161
6LoWPAN Capability Indication Option (6CIO) - RFC 7400 Section 6.
uint32_t GetSerializedSize() const override
void Serialize(Buffer::Iterator start) const override
void SetGhcCapable(bool ghcCapable)
Set the GHC capability flag.
bool GetGhcCapable() const
Get the GHC capability flag.
uint32_t Deserialize(Buffer::Iterator start) override
static NhcDispatch_e GetNhcDispatchType(uint8_t dispatch)
Get the NhcDispatch type.
static uint32_t Decompress(const Ipv6Address &srcAddr, const Ipv6Address &dstAddr, const uint8_t *compressed, uint32_t compressedLen, uint8_t *output, uint32_t outputMaxLen, bool useStopCode=false)
Decompress a GHC-compressed byte stream.
static GhcBytecodeType ClassifyBytecode(uint8_t byte)
Classify a GHC bytecode instruction.
static uint32_t Compress(const Ipv6Address &srcAddr, const Ipv6Address &dstAddr, const uint8_t *input, uint32_t inputLen, uint8_t *output, uint32_t outputMaxLen, bool emitStopCode=false)
Compress a byte stream using the GHC LZ77 algorithm.
GHC NHC Extension Header - see RFC 7400 Section 5.
void Serialize(Buffer::Iterator start) const override
Eid_e GetEid() const
Get the Extension Header Type.
bool GetNh() const
Get the NH field.
uint32_t GetSerializedSize() const override
void SetNh(bool nhField)
Set the NH field (next header compressed flag).
uint32_t CopyBlob(uint8_t *blob, uint32_t size) const
Copy the GHC-compressed bytecode blob.
SixLowPanDispatch::NhcDispatch_e GetNhcDispatchType() const
Get the NhcDispatch type.
void SetBlob(const uint8_t *blob, uint32_t size)
Set the GHC-compressed bytecode blob.
uint32_t Deserialize(Buffer::Iterator start) override
void SetEid(Eid_e eid)
Set the Extension Header Type.
uint32_t GetBlobLength() const
Get the blob length.
GHC ICMPv6 NHC Header - see RFC 7400 Section 5.
uint32_t GetBlobLength() const
Get the blob length.
SixLowPanDispatch::NhcDispatch_e GetNhcDispatchType() const
Get the NhcDispatch type.
uint32_t CopyBlob(uint8_t *blob, uint32_t size) const
Copy the GHC-compressed bytecode blob.
uint32_t Deserialize(Buffer::Iterator start) override
void SetBlob(const uint8_t *blob, uint32_t size)
Set the GHC-compressed bytecode blob for the ICMPv6 body.
void Serialize(Buffer::Iterator start) const override
uint32_t GetSerializedSize() const override
GHC UDP NHC Header - see RFC 7400 Section 5.
void SetSrcPort(uint16_t port)
Set the source port.
uint32_t Deserialize(Buffer::Iterator start) override
void SetPorts(Ports_e port)
Set the port compression mode.
uint16_t GetDstPort() const
Get the destination port.
void SetChecksum(uint16_t checksum)
Set the UDP checksum.
void SetDstPort(uint16_t port)
Set the destination port.
uint16_t GetChecksum() const
Get the UDP checksum.
void SetC(bool cField)
Set the checksum elision flag (C bit).
void Serialize(Buffer::Iterator start) const override
SixLowPanDispatch::NhcDispatch_e GetNhcDispatchType() const
Get the NhcDispatch type.
uint32_t GetSerializedSize() const override
bool GetC() const
Get the checksum elision flag (C bit).
uint16_t GetSrcPort() const
Get the source port.
void AddTestCase(TestCase *testCase, Duration duration=Duration::QUICK)
Add an individual child TestCase to this test suite.
Definition test.cc:296
@ QUICK
Fast test.
Definition test.h:1057
TestCase(const TestCase &)=delete
Caller graph was not generated because of its size.
Type
Type of test.
Definition test.h:1271
TestSuite(std::string name, Type type=Type::UNIT)
Construct a new test suite.
Definition test.cc:494
API to create UDP socket instances.
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file,...
Definition assert.h:55
Callback< R, Args... > MakeCallback(R(T::*memPtr)(Args...), OBJ objPtr)
Build Callbacks for class method members which take varying numbers of arguments and potentially retu...
Definition callback.h:690
Ptr< T > CreateObject(Args &&... args)
Create an object by type, with varying number of constructor parameters.
Definition object.h:627
Ptr< T > Create(Ts &&... args)
Create class instances by constructors with varying numbers of arguments and return them by Ptr.
Definition ptr.h:492
@ STOP_CODE
10010000: terminate decompression
@ BACKREF
11nnnkkk: backreference copy
@ LITERAL
0kkkkkkk: copy k literal bytes
@ ZERO_INSERT
1000nnnn: insert (n+2) zero bytes
@ EXTENDED_ARGS
101nssss: extend backreference
#define NS_TEST_ASSERT_MSG_LT(actual, limit, msg)
Test that an actual value is less than a limit and report and abort if not.
Definition test.h:698
#define NS_TEST_ASSERT_MSG_EQ(actual, limit, msg)
Test that an actual and expected (limit) value are equal and report and abort if not.
Definition test.h:133
#define NS_TEST_EXPECT_MSG_LT(actual, limit, msg)
Test that an actual value is less than a limit and report if not.
Definition test.h:779
#define NS_TEST_EXPECT_MSG_GT(actual, limit, msg)
Test that an actual value is greater than a limit and report if not.
Definition test.h:945
#define NS_TEST_EXPECT_MSG_EQ(actual, limit, msg)
Test that an actual and expected (limit) value are equal and report if not.
Definition test.h:240
#define NS_TEST_ASSERT_MSG_GT(actual, limit, msg)
Test that an actual value is greater than a limit and report and abort if not.
Definition test.h:863
Time Seconds(double value)
Construct a Time in the indicated unit.
Definition nstime.h:1313
Every class exported by the ns3 library is enclosed in the ns3 namespace.
static SixlowpanGhcTestSuite g_sixlowpanGhcTestSuite
One RFC 7400 Appendix A reference vector.
std::string src
Source IPv6 address (text form).
std::string dst
Destination IPv6 address (text form).
std::string label
Figure number / short description.
std::vector< uint8_t > payload
Original (uncompressed) payload.
std::vector< uint8_t > compressed
RFC-provided compressed bytes.