38#include "ns3/constant-position-mobility-model.h"
39#include "ns3/core-module.h"
41#include "ns3/lr-wpan-module.h"
42#include "ns3/packet.h"
43#include "ns3/propagation-delay-model.h"
44#include "ns3/propagation-loss-model.h"
45#include "ns3/simulator.h"
46#include "ns3/single-model-spectrum-channel.h"
47#include "ns3/zigbee-module.h"
63 <<
"Traceroute to destination [" << dst <<
"]:\n";
79 bool neighbor =
false;
83 std::cout << count <<
". Node " <<
zstack->GetNode()->GetId() <<
" ["
84 <<
zstack->GetNwk()->GetNetworkAddress() <<
" | "
85 <<
zstack->GetNwk()->GetIeeeAddress() <<
"]: "
86 <<
" Destination Unreachable\n";
90 std::cout << count <<
". Node " <<
zstack->GetNode()->GetId() <<
" ["
91 <<
zstack->GetNwk()->GetNetworkAddress() <<
" | "
92 <<
zstack->GetNwk()->GetIeeeAddress() <<
"]: "
93 <<
"NextHop [" <<
target <<
"] ";
96 std::cout <<
"(*Neighbor)\n";
112 <<
"NsdeDataIndication: Received packet of size " << p->GetSize() <<
"\n";
118 std::cout <<
"NlmeNetworkFormationConfirmStatus = " << params.m_status <<
"\n";
129 if (params.m_status == NwkStatus::SUCCESS)
131 std::cout <<
" Network discovery confirm Received. Networks found ("
132 << params.m_netDescList.size() <<
"):\n";
136 std::cout <<
" ExtPanID: 0x" << std::hex <<
netDescriptor.m_extPanId <<
"\n"
139 << std::hex <<
" Pan ID: 0x" <<
netDescriptor.m_panId <<
"\n"
140 <<
" Stack profile: " << std::dec
142 <<
"--------------------\n";
151 joinParams.m_rejoinNetwork = zigbee::JoiningMethod::ASSOCIATION;
153 joinParams.m_extendedPanId = params.m_netDescList[0].m_extPanId;
159 NS_ABORT_MSG(
"Unable to discover networks | status: " << params.m_status);
166 if (params.m_status == NwkStatus::SUCCESS)
169 <<
" The device joined the network SUCCESSFULLY with short address " << std::hex
170 << params.m_networkAddress <<
" on the Extended PAN Id: " << std::hex
171 << params.m_extendedPanId <<
"\n"
183 std::cout <<
" The device FAILED to join the network with status " << params.m_status
191 std::cout <<
"NlmeRouteDiscoveryConfirmStatus = " << params.m_status <<
"\n";
217 stackSrc->GetNwk()->GetNetworkAddress(),
218 stackDst->GetNwk()->GetNetworkAddress());
256 dev0->
GetMac()->SetExtendedAddress(
"00:00:00:00:00:00:CA:FE");
257 dev1->GetMac()->SetExtendedAddress(
"00:00:00:00:00:00:00:01");
258 dev2->GetMac()->SetExtendedAddress(
"00:00:00:00:00:00:00:02");
259 dev3->GetMac()->SetExtendedAddress(
"00:00:00:00:00:00:00:03");
260 dev4->GetMac()->SetExtendedAddress(
"00:00:00:00:00:00:00:04");
272 dev0->SetChannel(channel);
273 dev1->SetChannel(channel);
274 dev2->SetChannel(channel);
275 dev3->SetChannel(channel);
276 dev4->SetChannel(channel);
298 zstack0->GetNwk()->AssignStreams(0);
299 zstack1->GetNwk()->AssignStreams(10);
300 zstack2->GetNwk()->AssignStreams(20);
301 zstack3->GetNwk()->AssignStreams(30);
302 zstack4->GetNwk()->AssignStreams(40);
331 zstack0->GetNwk()->SetNlmeNetworkFormationConfirmCallback(
333 zstack0->GetNwk()->SetNlmeRouteDiscoveryConfirmCallback(
336 zstack0->GetNwk()->SetNldeDataIndicationCallback(
338 zstack1->GetNwk()->SetNldeDataIndicationCallback(
340 zstack2->GetNwk()->SetNldeDataIndicationCallback(
342 zstack3->GetNwk()->SetNldeDataIndicationCallback(
344 zstack4->GetNwk()->SetNldeDataIndicationCallback(
347 zstack1->GetNwk()->SetNlmeNetworkDiscoveryConfirmCallback(
349 zstack2->GetNwk()->SetNlmeNetworkDiscoveryConfirmCallback(
351 zstack3->GetNwk()->SetNlmeNetworkDiscoveryConfirmCallback(
353 zstack4->GetNwk()->SetNlmeNetworkDiscoveryConfirmCallback(
381 netDiscParams.m_scanChannelList.channelsField[0] = 0x00007800;
helps to manage and create IEEE 802.15.4 NetDevice objects
This class can contain 16 bit addresses.
holds a vector of ns3::NetDevice pointers
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 SetRun(uint64_t run)
Set the run number of simulation.
static void SetSeed(uint32_t seed)
Set the seed.
static EventId Schedule(const Time &delay, FUNC f, Ts &&... args)
Schedule an event to expire after delay.
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.
static void Stop()
Tell the Simulator the calling event should be the last one executed.
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.
zigbee::ZigbeeStackContainer Install(NetDeviceContainer c)
Install the Zigbee stack on top of an existing LrWpanNetDevice.
Network layer to device interface.
Ptr< LrWpanMac > GetMac() const
Get the MAC used by this NetDevice.
void PrintRoutingTable(Ptr< OutputStreamWrapper > stream) const
Print the entries in the routing table.
void NlmeStartRouterRequest(NlmeStartRouterRequestParams params)
Zigbee Specification r22.1.0, section 3.2.2.9 NLME-START-ROUTER.request This primitive allows the nex...
void NldeDataRequest(NldeDataRequestParams params, Ptr< Packet > packet)
Zigbee Specification r22.1.0, Section 3.2.1.1 NLDE-DATA.request Request to transfer a NSDU.
void PrintNeighborTable(Ptr< OutputStreamWrapper > stream) const
Print the entries in the neighbor table.
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 PrintRouteDiscoveryTable(Ptr< OutputStreamWrapper > stream)
Print the entries in the route discovery table.
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.
Iterator End() const
Get an iterator which indicates past the last ZigbeeStack in the container.
Iterator Begin() const
Get and iterator which refers to the first ZigbeeStack in the container.
void Add(ZigbeeStackContainer other)
Append the contents of another ZigbeeStackContainer to the end of this 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.
auto MakeBoundCallback(R(*fnPtr)(Args...), BArgs &&... bargs)
Make Callbacks with varying number of bound arguments.
Ptr< T > Create(Ts &&... args)
Create class instances by constructors with varying numbers of arguments and return them by Ptr.
Time Seconds(double value)
Construct a Time in the indicated unit.
@ UCST_BCST
Unicast or Broadcast address mode.
@ ENABLE_ROUTE_DISCOVERY
Enable route discovery.
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.
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_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.
NLDE-DATA.indication params.
NLDE-DATA.request params.
AddressMode m_dstAddrMode
Destination address mode.
NLME-JOIN.confirm params.
NLME-JOIN.request params.
NLME-NETWORK-DISCOVERY.confirm params.
NLME-NETWORK-DISCOVERY.request params.
ChannelList m_scanChannelList
The list of all channel pages and the associated channels that shall be scanned.
NLME-ROUTE-DISCOVERY.confirm params.
NLME-START-ROUTER.request params.
static void NwkNetworkDiscoveryConfirm(Ptr< ZigbeeStack > stack, NlmeNetworkDiscoveryConfirmParams params)
static void SendData(Ptr< ZigbeeStack > stackSrc, Ptr< ZigbeeStack > stackDst)
static void TraceRoute(Mac16Address src, Mac16Address dst)
static void NwkDataIndication(Ptr< ZigbeeStack > stack, NldeDataIndicationParams params, Ptr< Packet > p)
static void NwkJoinConfirm(Ptr< ZigbeeStack > stack, NlmeJoinConfirmParams params)
ZigbeeStackContainer zigbeeStacks
static void NwkRouteDiscoveryConfirm(Ptr< ZigbeeStack > stack, NlmeRouteDiscoveryConfirmParams params)
static void NwkNetworkFormationConfirm(Ptr< ZigbeeStack > stack, NlmeNetworkFormationConfirmParams params)