9#include "ns3/ipv6-address.h"
11#include "ns3/simple-net-device.h"
12#include "ns3/simulator.h"
13#include "ns3/sixlowpan-nd-binding-table.h"
29 :
TestCase(
"SixLowPanNdBindingTable Basic Operations Test")
44 auto entry1 = bindingTable->Add(addr1);
45 auto entry2 = bindingTable->Add(addr2);
51 std::vector<uint8_t> rovr(16);
52 for (uint8_t i = 0; i < 16; ++i)
56 entry1->SetRovr(rovr);
57 auto gotRovr = entry1->GetRovr();
61 "ROVR content mismatch");
64 auto foundEntry1 = bindingTable->Lookup(addr1);
65 auto foundEntry2 = bindingTable->Lookup(addr2);
66 auto notFoundEntry = bindingTable->Lookup(addr3);
72 "Lookup for non-existent entry should return nullptr");
75 auto duplicateEntry = bindingTable->Add(addr1);
78 "Adding duplicate should return existing entry");
81 entry1->MarkReachable(10);
104 :
TestCase(
"SixLowPanNdBindingTable REACHABLE to STALE Transition Test"),
116 auto entry = bindingTable->Add(testAddr);
119 entry->MarkReachable(1);
146 auto entry = bindingTable->Lookup(addr);
148 if (entry !=
nullptr)
154 "Entry should be STALE after timer expiry");
157 "Entry should not be REACHABLE after timer expiry");
160 NS_LOG_DEBUG(
"Entry found and is STALE: " << entry->IsStale());
180 :
TestCase(
"SixLowPanNdBindingTable STALE Entry Removal Test")
193 auto entry = bindingTable->Add(testAddr);
200 auto foundEntry = bindingTable->Lookup(testAddr);
233 auto entry = bindingTable->Lookup(addr);
245 auto entry = bindingTable->Lookup(addr);
263 :
TestCase(
"SixLowPanNdBindingTable State Transition Test")
271 auto entry = bindingTable->Add(testAddr);
274 entry->MarkReachable(5);
284 entry->MarkReachable(10);
6LoWPAN-ND binding table test case for basic entry creation and manipulation
SixLowPanNdBindingTableBasicTest()
void DoRun() override
Implementation to actually run this TestCase.
Test REACHABLE to STALE state transition after timer expiry.
bool m_entryBecameStale
True if the entry transitioned to STALE during the test.
SixLowPanNdBindingTableReachableToStaleTest()
void DoRun() override
Implementation to actually run this TestCase.
void CheckStaleState(Ptr< SixLowPanNdBindingTable > bindingTable, Ipv6Address addr)
Verify that the binding table entry for addr is in STALE state.
Test STALE entry removal after stale duration.
bool m_entryStillExisted
True if the entry was present before the stale timer expired.
void CheckEntryRemoved(Ptr< SixLowPanNdBindingTable > bindingTable, Ipv6Address addr)
Verify that the binding table entry for addr has been removed.
void CheckEntryExists(Ptr< SixLowPanNdBindingTable > bindingTable, Ipv6Address addr)
Verify that the binding table entry for addr still exists.
SixLowPanNdBindingTableStaleRemovalTest()
bool m_entryWasRemoved
True if the entry was removed after the stale timer expired.
void DoRun() override
Implementation to actually run this TestCase.
Test state transitions and timer cancellations.
void DoRun() override
Implementation to actually run this TestCase.
SixLowPanNdBindingTableStateTransitionTest()
6LoWPAN-ND binding table test suite
SixLowPanNdBindingTableTestSuite()
Describes an IPv6 address.
Smart pointer class similar to boost::intrusive_ptr.
static EventId Schedule(const Time &delay, FUNC f, Ts &&... args)
Schedule an event to expire after delay.
static void Destroy()
Execute the events scheduled with ScheduleDestroy().
static void Run()
Run the simulation.
static void Stop()
Tell the Simulator the calling event should be the last one executed.
void AddTestCase(TestCase *testCase, Duration duration=Duration::QUICK)
Add an individual child TestCase to this test suite.
TestCase(const TestCase &)=delete
Caller graph was not generated because of its size.
@ UNIT
This test suite implements a Unit Test.
TestSuite(std::string name, Type type=Type::UNIT)
Construct a new test suite.
AttributeValue implementation for Time.
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
Ptr< T > CreateObject(Args &&... args)
Create an object by type, with varying number of constructor parameters.
#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.
#define NS_TEST_ASSERT_MSG_NE(actual, limit, msg)
Test that an actual and expected (limit) value are not equal and report and abort if not.
Time Seconds(double value)
Construct a Time in the indicated unit.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
static SixLowPanNdBindingTableTestSuite g_sixlowpanNdBindingTableTestSuite
Static variable for registering the 6LoWPAN-ND binding table test suite.