34#include "ns3/constant-position-mobility-model.h"
35#include "ns3/core-module.h"
37#include "ns3/lr-wpan-module.h"
38#include "ns3/packet.h"
39#include "ns3/propagation-delay-model.h"
40#include "ns3/propagation-loss-model.h"
41#include "ns3/simulator.h"
42#include "ns3/single-model-spectrum-channel.h"
43#include "ns3/zigbee-module.h"
56 std::cout <<
"Received packet of size " << p->GetSize() <<
"\n";
62 std::cout <<
"NlmeNetworkFormationConfirmStatus = " << params.m_status <<
"\n";
68 std::cout <<
"NlmeDirectJoinConfirmStatus = " << params.m_status <<
"\n";
74 if (params.m_status == NwkStatus::SUCCESS)
76 std::cout <<
" The device join the network SUCCESSFULLY with short address "
77 << params.m_networkAddress <<
"\n";
81 std::cout <<
" The device FAILED to join the network with status " << params.m_status
87main(
int argc,
char* argv[])
103 dev0->GetMac()->SetExtendedAddress(
"00:00:00:00:00:00:CA:FE");
106 dev1->GetMac()->SetExtendedAddress(
"00:00:00:00:00:00:00:01");
107 dev2->GetMac()->SetExtendedAddress(
"00:00:00:00:00:00:00:02");
116 channel->AddPropagationLossModel(propModel);
117 channel->SetPropagationDelayModel(delayModel);
119 dev0->SetChannel(channel);
120 dev1->SetChannel(channel);
121 dev2->SetChannel(channel);
137 sender0Mobility->SetPosition(Vector(0, 0, 0));
138 dev0->GetPhy()->SetMobility(sender0Mobility);
142 sender1Mobility->SetPosition(Vector(0, 10, 0));
143 dev1->GetPhy()->SetMobility(sender1Mobility);
147 sender2Mobility->SetPosition(Vector(0, 20, 0));
148 dev2->GetPhy()->SetMobility(sender2Mobility);
152 zstack0->GetNwk()->SetNlmeNetworkFormationConfirmCallback(
155 zstack0->GetNwk()->SetNlmeDirectJoinConfirmCallback(
158 zstack0->GetNwk()->SetNldeDataIndicationCallback(
161 zstack1->GetNwk()->SetNldeDataIndicationCallback(
164 zstack2->GetNwk()->SetNldeDataIndicationCallback(
187 capaInfo.SetDeviceType(zigbee::MacDeviceType::ROUTER);
188 capaInfo.SetAllocateAddrOn(
true);
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.
uint64_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.
void Create(uint32_t n)
Create n nodes and append pointers to them to the end of this NodeContainer.
Smart pointer class similar to boost::intrusive_ptr.
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 void Stop()
Tell the Simulator the calling event should be the last one executed.
Setup a Zigbee stack to be used with LrWpanNetDevice.
zigbee::ZigbeeStackContainer Install(NetDeviceContainer c)
Install the Zigbee stack on top of an existing LrWpanNetDevice.
void SetNwkLayerOnly()
If this is set, the helper will only create Zigbee stacks that contain only the NWK layer.
Network layer to device interface.
void NlmeDirectJoinRequest(NlmeDirectJoinRequestParams params)
Zigbee Specification r22.1.0, section 3.2.2.16 and 3.6.1.4.3 NLME-DIRECT-JOIN.request Allows the next...
void NlmeStartRouterRequest(NlmeStartRouterRequestParams params)
Zigbee Specification r22.1.0, section 3.2.2.9 NLME-START-ROUTER.request This primitive allows the nex...
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.
#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.
Time Seconds(double value)
Construct a Time in the indicated unit.
Time MilliSeconds(uint64_t value)
Construct a Time in the indicated unit.
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)
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.
NLDE-DATA.indication params.
NLME-DIRECT-JOIN.confirm params.
NLME-DIRECT-JOIN.request params.
Mac64Address m_deviceAddr
The EUI-64 bit address of the device directly joined.
uint8_t m_capabilityInfo
The operating capabilities of the device being directly joined.
NLME-JOIN.confirm params.
NLME-JOIN.request params.
JoiningMethod m_rejoinNetwork
This parameter controls the method of joining the network.
ChannelList m_scanChannelList
The list of all channel pages and the associated channels that shall be scanned.
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-START-ROUTER.request params.
static void NwkDataIndication(Ptr< ZigbeeStack > stack, NldeDataIndicationParams params, Ptr< Packet > p)
static void NwkJoinConfirm(Ptr< ZigbeeStack > stack, NlmeJoinConfirmParams params)
static void NwkDirectJoinConfirm(Ptr< ZigbeeStack > stack, NlmeDirectJoinConfirmParams params)
static void NwkNetworkFormationConfirm(Ptr< ZigbeeStack > stack, NlmeNetworkFormationConfirmParams params)