11#include "ns3/core-module.h"
12#include "ns3/internet-module.h"
13#include "ns3/internet-stack-helper.h"
14#include "ns3/simple-net-device-helper.h"
15#include "ns3/simple-net-device.h"
16#include "ns3/sixlowpan-module.h"
17#include "ns3/sixlowpan-nd-protocol.h"
37 :
TestCase(
"Registration of 1 6LN with 1 6LBR")
79 std::ostringstream ndiscStream;
81 std::ostringstream routingTableStream;
84 std::ostringstream bindingTableStream;
93 nd->TraceConnectWithoutContext(
94 "AddressRegistrationResult",
101 constexpr auto expectedNdiscStream =
102 "NDISC Cache of node 0 at time +5s\n"
103 "2001::200:ff:fe00:2 dev 2 lladdr 03-06-00:00:00:00:00:02 REACHABLE\n"
104 "fe80::200:ff:fe00:2 dev 2 lladdr 03-06-00:00:00:00:00:02 REACHABLE\n"
105 "NDISC Cache of node 1 at time +5s\n"
106 "fe80::200:ff:fe00:1 dev 2 lladdr 03-06-00:00:00:00:00:01 REACHABLE\n";
109 constexpr auto expectedRoutingTableStream =
110 "Node: 0, Time: +5s, Local time: +5s, Ipv6ListRouting table\n"
111 " Priority: 0 Protocol: ns3::Ipv6StaticRouting\n"
112 "Node: 0, Time: +5s, Local time: +5s, Ipv6StaticRouting table\n"
113 "Destination Next Hop Flag Met Ref Use If\n"
114 "::1/128 :: UH 0 - - 0\n"
115 "fe80::/64 :: U 0 - - 1\n"
116 "2001::200:ff:fe00:2/128 fe80::200:ff:fe00:2 UH 0 - - 1\n\n"
117 " Priority: -10 Protocol: ns3::Ipv6GlobalRouting\n"
118 "Node: 0, Time: +5s, Local time: +5s, Ipv6GlobalRouting table\n"
119 "Destination Next Hop Flag Met Ref Use Iface\n\n"
120 "Node: 1, Time: +5s, Local time: +5s, Ipv6ListRouting table\n"
121 " Priority: 0 Protocol: ns3::Ipv6StaticRouting\n"
122 "Node: 1, Time: +5s, Local time: +5s, Ipv6StaticRouting table\n"
123 "Destination Next Hop Flag Met Ref Use If\n"
124 "::1/128 :: UH 0 - - 0\n"
125 "fe80::/64 :: U 0 - - 1\n"
126 "::/0 fe80::200:ff:fe00:1 UG 0 - - 1\n\n"
127 " Priority: -10 Protocol: ns3::Ipv6GlobalRouting\n"
128 "Node: 1, Time: +5s, Local time: +5s, Ipv6GlobalRouting table\n"
129 "Destination Next Hop Flag Met Ref Use Iface\n\n";
131 expectedRoutingTableStream,
132 "Routing table does not match expected.");
136 "Registered address does not match expected value.");
141 "BindingTable does not match expected output.");
171 :
TestCase(
"Registration of 5 6LNs with 1 6LBR")
182 nodes.Create(1 + numLns);
188 simpleNetDevices = simpleNetDeviceHelper.
Install(
nodes);
199 for (
uint32_t i = 1; i <= numLns; ++i)
204 std::ostringstream ndiscStream;
206 std::ostringstream routingTableStream;
209 std::ostringstream bindingTableStream;
223 "NdiscCache does not match expected output.");
227 "RoutingTable does not match expected output.");
231 "BindingTable does not match expected output.");
244 :
TestCase(
"Registration of 15 6LNs with 1 6LBR")
254 nodes.Create(1 + numLns);
271 for (
uint32_t i = 1; i <= numLns; ++i)
276 std::ostringstream ndiscStream;
278 std::ostringstream routingTableStream;
281 std::ostringstream bindingTableStream;
295 "NdiscCache does not match expected output.");
299 "RoutingTable does not match expected output.");
303 "BindingTable does not match expected output.");
316 :
TestCase(
"Registration of 20 6LNs with 1 6LBR")
326 nodes.Create(1 + numLns);
343 for (
uint32_t i = 1; i <= numLns; ++i)
348 std::ostringstream ndiscStream;
350 std::ostringstream routingTableStream;
353 std::ostringstream bindingTableStream;
367 "NdiscCache does not match expected output.");
371 "RoutingTable does not match expected output.");
375 "BindingTable does not match expected output.");
388 :
TestCase(
"6LN sends multicast RS but receives no RA, test timeout behavior")
416 nd->TraceConnectWithoutContext(
429 "Expected 7 multicast RS events, but got " +
434 std::vector<Ipv6Address>
466static SixLowPanNdRegTestSuite
aggregate IP/TCP/UDP functionality to existing Nodes.
void Install(std::string nodeName) const
Aggregate implementations of the ns3::Ipv4, ns3::Ipv6, ns3::Udp, and ns3::Tcp classes onto the provid...
Describes an IPv6 address.
Describes an IPv6 prefix.
static void PrintRoutingTableAllAt(Time printTime, Ptr< OutputStreamWrapper > stream, Time::Unit unit=Time::S)
prints the routing tables of all nodes at a particular time.
static void PrintNeighborCacheAllAt(Time printTime, Ptr< OutputStreamWrapper > stream, Time::Unit unit=Time::S)
prints the neighbor cache of all nodes at a particular time.
holds a vector of ns3::NetDevice pointers
Ptr< NetDevice > Get(uint32_t i) const
Get the Ptr<NetDevice> stored in this container at a given index.
keep track of a set of node pointers.
Smart pointer class similar to boost::intrusive_ptr.
build a set of SimpleNetDevice objects
NetDeviceContainer Install(Ptr< Node > node) const
This method creates an ns3::SimpleChannel with the attributes configured by SimpleNetDeviceHelper::Se...
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.
Setup a sixlowpan stack to be used as a shim between IPv6 and a generic NetDevice.
Ipv6InterfaceContainer InstallSixLowPanNdNode(NetDeviceContainer c)
Install the SixLoWPAN-ND stack, associate it with a NetDevice, and set it as a 6LN.
NetDeviceContainer Install(NetDeviceContainer c)
Install the SixLoWPAN stack on top of an existing NetDevice.
static void PrintBindingTableAllAt(Time printTime, Ptr< OutputStreamWrapper > stream, Time::Unit unit=Time::S)
Print the binding table of all nodes at a specific time.
void SetAdvertisedPrefix(const Ptr< NetDevice > nd, Ipv6Prefix prefix)
Add a new prefix to be advertised by 6LoWPAN-ND.
Ipv6InterfaceContainer InstallSixLowPanNdBorderRouter(NetDeviceContainer c, Ipv6Address baseAddr)
Install the SixLoWPAN-ND stack, associate it with a NetDevice, and set it as a 6LBR.
Test successful registration of 15 6LNs with 1 6LBR.
SixLowPanNdFifteenLNRegTest()
void DoRun() override
Implementation to actually run this TestCase.
Test successful registration of 5 6LNs with 1 6LBR.
void DoRun() override
Implementation to actually run this TestCase.
SixLowPanNdFiveLNRegTest()
Test 6LN multicast RS timeout behavior when no RA is received.
std::vector< Ipv6Address > m_multicastRsEvents
Container for multicast RS events captured during test.
void MulticastRsSink(Ipv6Address src)
Callback sink for multicast RS trace events.
SixLowPanNdMulticastRsTimeoutTest()
void DoRun() override
Implementation to actually run this TestCase.
Test successful registration of varying numbers of 6LNs with 1 6LBR.
void RegistrationResultSink(Ipv6Address address, bool success, uint8_t status)
Callback sink for address registration result trace events.
SixLowPanNdOneLNRegTest()
void DoRun() override
Implementation to actually run this TestCase.
Ipv6Address registeredAddress
Address that was successfully registered during the test.
An optimization of the ND protocol for 6LoWPANs.
SixLowPanNdRegTestSuite()
Test successful registration of 20 6LNs with 1 6LBR.
void DoRun() override
Implementation to actually run this TestCase.
SixLowPanNdTwentyLNRegTest()
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.
Simulation virtual time values and global simulation resolution.
#define NS_ASSERT_MSG(condition, message)
At runtime, in debugging builds, if this condition is not true, the program prints the message to out...
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...
Ptr< T > Create(Ts &&... args)
Create class instances by constructors with varying numbers of arguments and return them by Ptr.
#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_EXPECT_MSG_EQ(actual, limit, msg)
Test that an actual and expected (limit) value are equal and report 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.
std::string SortRoutingTableString(std::string routingTable)
Sort the host-route entries in node 0's routing table block numerically.
std::string GenerateNdiscCacheOutput(uint32_t numNodes, Time time)
Generate expected NDisc cache output for a star topology.
std::string GenerateBindingTableOutput(uint32_t numNodes, Time time)
Generate expected binding table output for a star topology.
std::string NormalizeNdiscCacheStates(const std::string &ndiscOutput)
Replace STALE with REACHABLE in an NDisc cache output string.
std::string GenerateRoutingTableOutput(uint32_t numNodes, Time time)
Generate expected routing table output for a star topology.
static SixLowPanNdRegTestSuite g_sixlowpanndregTestSuite
Static variable for test initialization.