10#include "ns3/constant-position-mobility-model.h" 
   11#include "ns3/core-module.h" 
   13#include "ns3/lr-wpan-module.h" 
   14#include "ns3/packet.h" 
   15#include "ns3/propagation-delay-model.h" 
   16#include "ns3/propagation-loss-model.h" 
   17#include "ns3/rng-seed-manager.h" 
   18#include "ns3/simulator.h" 
   19#include "ns3/single-model-spectrum-channel.h" 
   20#include "ns3/zigbee-module.h" 
   79                                     uint8_t rreqRetriesNum);
 
   80    void DoRun() 
override;
 
   82    std::vector<std::pair<uint32_t, uint32_t>>
 
 
   89    : 
TestCase(
"Zigbee: RREQ retries test")
 
 
  109        std::cout << 
" Network discovery confirm Received. Networks found (" 
  110                  << params.m_netDescList.size() << 
"):\n";
 
  112        for (
const auto& netDescriptor : params.m_netDescList)
 
  114            std::cout << 
" ExtPanID: 0x" << std::hex << netDescriptor.m_extPanId << 
"\n" 
  115                      << std::dec << 
" CH:  " << 
static_cast<uint32_t>(netDescriptor.m_logCh)
 
  117                      << std::hex << 
" Pan ID: 0x" << netDescriptor.m_panId << 
"\n" 
  118                      << 
" Stack profile: " << std::dec
 
  119                      << 
static_cast<uint32_t>(netDescriptor.m_stackProfile) << 
"\n" 
  120                      << 
"--------------------\n";
 
  137        NS_ABORT_MSG(
"Unable to discover networks | status: " << params.m_status);
 
 
  149                  << 
" The device joined the network SUCCESSFULLY with short address " << std::hex
 
  150                  << params.m_networkAddress << 
" on the Extended PAN Id: " << std::hex
 
  151                  << params.m_extendedPanId << 
"\n" 
  163        std::cout << 
" The device FAILED to join the network with status " << params.m_status
 
 
  173                                              uint8_t rreqRetriesNum)
 
  176                                  << 
") exhausted for destination [" << dst << 
"] and RREQ ID " 
  180        std::pair(stack->GetNode()->GetId(), rreqRetriesNum));
 
 
  220    dev0->GetMac()->SetExtendedAddress(
"00:00:00:00:00:00:CA:FE");
 
  221    dev1->GetMac()->SetExtendedAddress(
"00:00:00:00:00:00:00:01");
 
  222    dev2->GetMac()->SetExtendedAddress(
"00:00:00:00:00:00:00:02");
 
  231    channel->AddPropagationLossModel(propModel);
 
  232    channel->SetPropagationDelayModel(delayModel);
 
  234    dev0->SetChannel(channel);
 
  235    dev1->SetChannel(channel);
 
  236    dev2->SetChannel(channel);
 
  251    dev0Mobility->SetPosition(Vector(0, 0, 0));
 
  252    dev0->GetPhy()->SetMobility(dev0Mobility);
 
  255    dev1Mobility->SetPosition(Vector(90, 0, 0)); 
 
  256    dev1->GetPhy()->SetMobility(dev1Mobility);
 
  259    dev2Mobility->SetPosition(Vector(170, 0, 0)); 
 
  260    dev2->GetPhy()->SetMobility(dev2Mobility);
 
  265    zstack1->GetNwk()->SetNlmeNetworkDiscoveryConfirmCallback(
 
  267    zstack2->GetNwk()->SetNlmeNetworkDiscoveryConfirmCallback(
 
  270    zstack1->GetNwk()->SetNlmeJoinConfirmCallback(
 
  272    zstack2->GetNwk()->SetNlmeJoinConfirmCallback(
 
  276    zstack0->GetNwk()->TraceConnectWithoutContext(
 
  277        "rreqRetriesExhausted",
 
  280    zstack1->GetNwk()->TraceConnectWithoutContext(
 
  281        "rreqRetriesExhausted",
 
  284    zstack2->GetNwk()->TraceConnectWithoutContext(
 
  285        "rreqRetriesExhausted",
 
  338        if (rreqRetriesExhaustedElement.first == 0)
 
  344                                  "The number of RREQ retries from an originator should be 3");
 
  352                                  "The number of RREQ retries from a relaying node should be 2");
 
 
Zigbee RREQ transmission retries test case.
static void NwkNetworkDiscoveryConfirm(ZigbeeRreqRetryTestCase *testcase, Ptr< ZigbeeStack > stack, NlmeNetworkDiscoveryConfirmParams params)
Called in response to a NLME-NETWORK-DISCOVERY.request.
ZigbeeRreqRetryTestCase()
void DoRun() override
Implementation to actually run this TestCase.
static void RreqRetriesExhausted(ZigbeeRreqRetryTestCase *testcase, Ptr< ZigbeeStack > stack, uint8_t rreqid, Mac16Address dst, uint8_t rreqRetriesNum)
Called when a maximum RREQ retries are reached.
std::vector< std::pair< uint32_t, uint32_t > > m_rreqRetriesExhaustedList
A list containing the RREQ ID and the allowed max retries every time the maximum RREQ retries are rea...
static void NwkJoinConfirm(ZigbeeRreqRetryTestCase *testcase, Ptr< ZigbeeStack > stack, NlmeJoinConfirmParams params)
Called in response to a NLME-JOIN.request.
~ZigbeeRreqRetryTestCase() override
helps to manage and create IEEE 802.15.4 NetDevice objects
NetDeviceContainer Install(NodeContainer c)
Install a LrWpanNetDevice and the associated structures (e.g., channel) in the nodes.
This class can contain 16 bit addresses.
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.
static void SetRun(uint64_t run)
Set the run number of simulation.
static void SetSeed(uint32_t seed)
Set the seed.
static void Destroy()
Execute the events scheduled with ScheduleDestroy().
static void ScheduleWithContext(uint32_t context, const Time &delay, FUNC f, Ts &&... args)
Schedule an event with the given context.
static Time Now()
Return the current simulation virtual time.
static void Run()
Run the simulation.
static EventId ScheduleNow(FUNC f, Ts &&... args)
Schedule an event to expire Now.
void AddTestCase(TestCase *testCase, Duration duration=Duration::QUICK)
Add an individual child TestCase to this test suite.
TestCase(const TestCase &)=delete
@ UNIT
This test suite implements a Unit Test.
TestSuite(std::string name, Type type=Type::UNIT)
Construct a new test suite.
TimeWithUnit As(const Unit unit=Time::AUTO) const
Attach a unit to a Time, to facilitate output in a specific unit.
Setup a Zigbee stack to be used with LrWpanNetDevice.
Network layer to device interface.
void NlmeStartRouterRequest(NlmeStartRouterRequestParams params)
Zigbee Specification r22.1.0, section 3.2.2.9 NLME-START-ROUTER.request This primitive allows the nex...
void NlmeNetworkDiscoveryRequest(NlmeNetworkDiscoveryRequestParams params)
Zigbee Specification r22.1.0, section 3.2.2.3 NLME-NETWORK-DISCOVERY.request Allows the next higher l...
void NlmeJoinRequest(NlmeJoinRequestParams params)
Zigbee Specification r22.1.0, section 3.2.2.13 NLME-JOIN.request This primitive allows the next highe...
void NlmeNetworkFormationRequest(NlmeNetworkFormationRequestParams params)
Zigbee Specification r22.1.0, Section 3.2.2.5 and 3.6.1.1 NLME-NETWORK-FORMATION.request Request the ...
void NlmeRouteDiscoveryRequest(NlmeRouteDiscoveryRequestParams params)
Zigbee Specification r22.1.0, section 3.2.2.33.3 and 3.6.3.5 NLME-ROUTE-DISCOVERY....
Holds a vector of ns3::ZigbeeStack pointers.
Ptr< ZigbeeStack > Get(uint32_t i) const
Get a stack element from the container.
Zigbee protocol stack to device interface.
#define NS_ABORT_MSG(msg)
Unconditional abnormal program termination with a message.
#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.
auto MakeBoundCallback(R(*fnPtr)(Args...), BArgs &&... bargs)
Make Callbacks with varying number of bound arguments.
Ptr< T > CreateObject(Args &&... args)
Create an object by type, with varying number of constructor parameters.
#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.
@ ASSOCIATION
The device is requesting to join a network through association.
static constexpr uint32_t ALL_CHANNELS
Bitmap representing all channels (11~26) LSB b0-b26, b27-b31 MSB Page 0 in Zigbee (250kbps O-QPSK)
@ SUCCESS
The operation was completed successfully.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
void LogComponentEnable(const std::string &name, LogLevel level)
Enable the logging output associated with that log component.
LogLevel
Logging severity classes and levels.
@ LOG_PREFIX_FUNC
Prefix all trace prints with function.
@ LOG_PREFIX_TIME
Prefix all trace prints with simulation time.
@ LOG_LEVEL_DEBUG
LOG_DEBUG and above.
@ LOG_PREFIX_NODE
Prefix all trace prints with simulation node.
void LogComponentEnableAll(LogLevel level)
Enable the logging output for all registered log components.
uint8_t channelPageCount
The number of the channel page structures contained in the channel list structure.
std::vector< uint32_t > channelsField
The set of channels for a given page.
NLME-JOIN.confirm params.
NLME-JOIN.request params.
JoiningMethod m_rejoinNetwork
This parameter controls the method of joining the network.
uint8_t m_capabilityInfo
The operating capabilities of the device being directly joined (Bit map).
uint64_t m_extendedPanId
The 64 bit PAN identifier of the the network to join.
NLME-NETWORK-DISCOVERY.confirm params.
NLME-NETWORK-DISCOVERY.request params.
uint8_t m_scanDuration
A value used to calculate the length of time to spend.
ChannelList m_scanChannelList
The list of all channel pages and the associated channels that shall be scanned.
NLME-ROUTE-DISCOVERY.request params.
Mac16Address m_dstAddr
The 16-bit destination address or Group ID (MCST destination) of the route discovery.
NLME-START-ROUTER.request params.
static ZigbeeRreqTestSuite zigbeeRreqTestSuite
Static variable for test initialization.