10#include "ns3/constant-position-mobility-model.h"
12#include "ns3/lr-wpan-helper.h"
13#include "ns3/net-device-container.h"
14#include "ns3/node-container.h"
16#include "ns3/packet.h"
17#include "ns3/propagation-delay-model.h"
18#include "ns3/propagation-loss-model.h"
19#include "ns3/rng-seed-manager.h"
20#include "ns3/simulator.h"
21#include "ns3/single-model-spectrum-channel.h"
23#include "ns3/zigbee-helper.h"
24#include "ns3/zigbee-stack-container.h"
25#include "ns3/zigbee-stack.h"
73 void DoRun()
override;
79 :
TestCase(
"Zigbee: ZDO commands test")
96 std::cout <<
"NWK_addr_rsp received | status: SUCCESS "
97 <<
" | IEEE address: " << params.m_ieeeAddrRemoteDev
98 <<
" | NWK address: " << params.m_nwkAddrRemoteDev << std::endl;
102 std::cout <<
"NWK_addr_rsp not received or received with error status\n";
127 NS_ABORT_MSG(
"Unable to discover networks | status: " << params.m_status);
160 dev0->GetMac()->SetExtendedAddress(
"00:00:00:00:00:00:CA:FE");
161 dev1->GetMac()->SetExtendedAddress(
"00:00:00:00:00:00:00:01");
162 dev2->GetMac()->SetExtendedAddress(
"00:00:00:00:00:00:00:02");
171 channel->AddPropagationLossModel(propModel);
172 channel->SetPropagationDelayModel(delayModel);
174 dev0->SetChannel(channel);
175 dev1->SetChannel(channel);
176 dev2->SetChannel(channel);
187 zstack0->GetNwk()->AssignStreams(1);
188 zstack1->GetNwk()->AssignStreams(20);
189 zstack2->GetNwk()->AssignStreams(25);
194 dev0Mobility->SetPosition(Vector(0, 0, 0));
195 dev0->GetPhy()->SetMobility(dev0Mobility);
198 dev1Mobility->SetPosition(Vector(50, 0, 0));
199 dev1->GetPhy()->SetMobility(dev1Mobility);
202 dev2Mobility->SetPosition(Vector(0, 50, 0));
203 dev2->GetPhy()->SetMobility(dev2Mobility);
206 zstack0->GetZdo()->SetZdoNwkAddrRspIndCallback(
213 zstack1->GetNwk()->SetNlmeNetworkDiscoveryConfirmCallback(
215 zstack2->GetNwk()->SetNlmeNetworkDiscoveryConfirmCallback(
275 zdoNwkAddrReqParams);
282 "Dev2 (stack2) is not using the correct 64-bit IEEE address");
287 "Error: The obtained address via NWK_Addr_req do not correspond to the "
288 "address used by the device");
293 zstack0->GetNwk()->GetNwkAddrByIeeeAddr(
Mac64Address(
"00:00:00:00:00:00:00:02"),
297 zstack2->GetNwk()->GetNetworkAddress().ConvertToInt(),
299 "Error: The nwkAddressMap do not have a matching entry even after a NWK_Addr_req CMD");
Zigbee ZDO Commands test.
void DoRun() override
Implementation to actually run this TestCase.
ZigbeeZdoCommandsTestCase()
Mac16Address m_requestedNwkAddr
The 16-bit address requested by the ZDO command.
static void ZdoNwkAddrRspInd(ZigbeeZdoCommandsTestCase *testcase, Ptr< ZigbeeStack > stack, NwkAddrRespIndParams params)
Callback for ZDO NWK_addr_rsp indication This callback is called when a NWK_addr_rsp is received.
~ZigbeeZdoCommandsTestCase() override
static void NwkNetworkDiscoveryConfirm(ZigbeeZdoCommandsTestCase *testcase, Ptr< ZigbeeStack > stack, NlmeNetworkDiscoveryConfirmParams params)
Callback for NLME-NETWORK-DISCOVERY.confirm This callback is called when a network discovery has been...
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.
uint16_t ConvertToInt() const
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 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
Caller graph was not generated because of its size.
TestSuite(std::string name, Type type=Type::UNIT)
Construct a new test suite.
Setup a Zigbee stack to be used with LrWpanNetDevice.
zigbee::ZigbeeStackContainer Install(NetDeviceContainer c)
Install the Zigbee stack on top of an existing LrWpanNetDevice.
Network layer to device interface.
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 ...
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.
void NwkAddrRequest(NwkAddrRequestParams params)
This function is used to send a Network Address (16-bit address)Request to a remote device when the I...
#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.
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.
@ SINGLE_DEVICE_RESPONSE
Request type for a single device response.
@ ENDDEVICE
End device or router treated as an end device.
@ ASSOCIATION
The device is requesting to join a network through association.
@ SUCCESS
The request was successful.
@ SUCCESS
The operation was completed successfully.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
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.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.
ZDO Network Address Request Parameters.
NwkAddrRequestType m_requestType
Request type of this command.
Mac16Address m_dstAddr
The destination of the request, unicast or broadcast (0xFFFF).
Mac64Address m_ieeeAddr
The known IEEE Address(64-bit address) of the device that we are request its network address (16-bit ...
ZDO Network Address Response Indication Parameters.
static ZigbeeZdoTestSuite zigbeeZdoTestSuite
Static variable for test initialization.