9#include "ns3/boolean.h"
10#include "ns3/inet6-socket-address.h"
11#include "ns3/internet-stack-helper.h"
14#include "ns3/simple-channel.h"
15#include "ns3/simple-net-device.h"
16#include "ns3/simulator.h"
17#include "ns3/sixlowpan-header.h"
18#include "ns3/sixlowpan-nd-prefix.h"
19#include "ns3/sixlowpan-nd-protocol.h"
20#include "ns3/sixlowpan-net-device.h"
21#include "ns3/socket-factory.h"
22#include "ns3/socket.h"
24#include "ns3/udp-socket-factory.h"
40 :
TestCase(
"Make and Parse NS(EARO) Packet")
53 std::vector<uint8_t> rovr(16, 0xAB);
78 "SLLAO type should be source");
81 "SLLAO MAC should match TLLAO MAC");
86 "TLLAO type should be target");
124 :
TestCase(
"Make and Parse NA(EARO) Packet")
138 std::vector<uint8_t> rovr(16, 0xCD);
146 bool hasEaro =
false;
158 "Target address in NA should match");
181 :
TestCase(
"Make and Parse RA Packet")
192 raEntry->SetManagedFlag(
false);
193 raEntry->SetHomeAgentFlag(
false);
194 raEntry->SetOtherConfigFlag(
false);
195 raEntry->SetOtherConfigFlag(
false);
196 raEntry->SetCurHopLimit(0);
197 raEntry->SetRetransTimer(0);
198 raEntry->SetReachableTime(0);
199 raEntry->SetRouterLifeTime(60);
200 raEntry->SetAbroBorderRouterAddress(
"2001::ff:fe00:1");
201 raEntry->SetAbroVersion(0x66);
202 raEntry->SetAbroValidLifeTime(600);
208 raEntry->AddPrefix(newPrefix);
222 std::list<Icmpv6OptionPrefixInformation> pios;
223 std::list<Icmpv6OptionSixLowPanContext> contexts;
237 "E bit should be set");
240 "B bit should be set");
243 "L bit should not be set");
256 :
TestCase(
"Make and Parse RS Packet")
286 "SLLAO type should be source");
291 "E bit should be set");
294 "B bit should be set");
297 "L bit should not be set");
ICMPv6 Neighbor Advertisement header.
bool GetFlagS() const
Get the S flag.
void SetFlagS(bool s)
Set the S flag.
void SetIpv6Target(Ipv6Address target)
Set the IPv6 target field.
void SetFlagR(bool r)
Set the R flag.
Ipv6Address GetIpv6Target() const
Get the IPv6 target field.
bool GetFlagR() const
Get the R flag.
bool GetFlagO() const
Get the O flag.
void SetFlagO(bool o)
Set the O flag.
ICMPv6 Neighbor Solicitation header.
Ipv6Address GetIpv6Target() const
Get the IPv6 target field.
ICMPv6 link-layer address option.
Address GetAddress() const
Get the hardware address.
ICMPv6 Authoritative Border Router Option header (see RFC 8505).
uint32_t GetVersion() const
Get the version field.
6LoWPAN Capability Indication Option - see RFC 7400.
void SetOption(SixLowPanCapability_e option)
Set an option.
bool CheckOption(SixLowPanCapability_e option) const
Checks an option.
@ B
The node is a 6LBR (see RFC 8505).
@ E
The node is an IPv6 ND Registrar (see RFC 8505).
@ L
The node is a 6LR (see RFC 8505).
ICMPv6 Extended Address Registration Option header RFC 8505.
uint8_t GetStatus() const
Get the status field.
uint8_t GetTransactionId() const
Get the transaction ID field.
uint16_t GetRegTime() const
Get the registration lifetime field.
ICMPv6 Router Advertisement header.
ICMPv6 Router Solicitation header.
Describes an IPv6 address.
Describes an IPv6 prefix.
uint8_t GetPrefixLength() const
Get prefix length.
Ipv6Address ConvertToIpv6Address() const
Convert the Prefix into an IPv6 Address.
Smart pointer class similar to boost::intrusive_ptr.
6LoWPAN-ND test case for NA(EARO) packet creation and parsing
SixLowPanNdNaEaroPacketTest()
void DoRun() override
Implementation to actually run this TestCase.
6LoWPAN-ND test case for NS(EARO) packet creation and parsing
SixLowPanNdNsEaroPacketTest()
void DoRun() override
Implementation to actually run this TestCase.
static Ptr< Packet > MakeRaPacket(Ipv6Address src, Ipv6Address dst, Icmpv6OptionLinkLayerAddress &slla, Icmpv6OptionSixLowPanCapabilityIndication &cio, Ptr< SixLowPanRaEntry > raEntry)
Constructs a RA packet (raEntry contains info for raHdr, pios, abro and contexts).
static bool ParseAndValidateRaPacket(Ptr< Packet > p, Icmpv6RA &raHdr, std::list< Icmpv6OptionPrefixInformation > &pios, Icmpv6OptionSixLowPanAuthoritativeBorderRouter &abro, Icmpv6OptionLinkLayerAddress &slla, Icmpv6OptionSixLowPanCapabilityIndication &cio, std::list< Icmpv6OptionSixLowPanContext > &contexts)
Parses RA packet and populates params, returning true if packet is valid.
static Ptr< Packet > MakeNaEaroPacket(Ipv6Address src, Ipv6Address dst, Icmpv6NA &naHdr, Icmpv6OptionSixLowPanExtendedAddressRegistration &earo)
Construct NA (EARO) packet.
static bool ParseAndValidateNsEaroPacket(Ptr< Packet > p, Icmpv6NS &nsHdr, Icmpv6OptionLinkLayerAddress &slla, Icmpv6OptionLinkLayerAddress &tlla, Icmpv6OptionSixLowPanExtendedAddressRegistration &earo, bool &hasEaro)
Parses NS packet and populates params, returning true if packet is a valid NS/NS(EARO) packet.
static bool ParseAndValidateNaEaroPacket(Ptr< Packet > p, Icmpv6NA &naHdr, Icmpv6OptionLinkLayerAddress &tlla, Icmpv6OptionSixLowPanExtendedAddressRegistration &earo, bool &hasEaro)
Parses NA packet and populates params, returning true if packet is valid.
static bool ParseAndValidateRsPacket(Ptr< Packet > p, Icmpv6RS &rsHdr, Icmpv6OptionLinkLayerAddress &slla, Icmpv6OptionSixLowPanCapabilityIndication &cio)
Parses RS packet and populates params, returning true if packet is valid.
static Ptr< Packet > MakeNsEaroPacket(Ipv6Address src, Ipv6Address dst, Icmpv6NS &nsHdr, Icmpv6OptionLinkLayerAddress &slla, Icmpv6OptionLinkLayerAddress &tlla, Icmpv6OptionSixLowPanExtendedAddressRegistration &earo)
Construct NS (EARO) packet.
6LoWPAN-ND test case for RA packet creation and parsing
void DoRun() override
Implementation to actually run this TestCase.
SixLowPanNdRaPacketTest()
6LoWPAN-ND test case for RS packet creation and parsing
void DoRun() override
Implementation to actually run this TestCase.
SixLowPanNdRsPacketTest()
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.
Ptr< T > Create(Ts &&... args)
Create class instances by constructors with varying numbers of arguments and return them by Ptr.
#define NS_TEST_EXPECT_MSG_EQ(actual, limit, msg)
Test that an actual and expected (limit) value are equal and report if not.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
static SixlowpanNdTestSuite g_sixlowpanNdTestSuite
Static variable for test initialization.