42#include "ns3/core-module.h"
44#include "ns3/lr-wpan-module.h"
45#include "ns3/mobility-module.h"
46#include "ns3/packet.h"
47#include "ns3/propagation-delay-model.h"
48#include "ns3/propagation-loss-model.h"
49#include "ns3/simulator.h"
50#include "ns3/single-model-spectrum-channel.h"
51#include "ns3/zigbee-module.h"
76 if (zstack->GetNwk()->GetNetworkAddress() == target)
82 bool neighbor =
false;
83 target = zstack->GetNwk()->FindRoute(dst, neighbor);
86 std::cout << count <<
". Node " << zstack->GetNode()->GetId() <<
" ["
87 << zstack->GetNwk()->GetNetworkAddress() <<
" | "
88 << zstack->GetNwk()->GetIeeeAddress() <<
"]: "
89 <<
" Destination Unreachable\n";
93 std::cout << count <<
". Node " << zstack->GetNode()->GetId() <<
" ["
94 << zstack->GetNwk()->GetNetworkAddress() <<
" | "
95 << zstack->GetNwk()->GetIeeeAddress() <<
"]: "
96 <<
"NextHop [" << target <<
"] ";
99 std::cout <<
"(*Neighbor)\n";
118 zigbeeStackConcentrator->GetNwk(),
125 zigbeeStackSrc->GetNwk()->GetNetworkAddress(),
126 zigbeeStackConcentrator->GetNwk()->GetNetworkAddress());
132 zigbeeStackSrc->GetNwk(),
137 zigbeeStackSrc->GetNwk(),
142 zigbeeStackSrc->GetNwk(),
149 std::cout <<
"Received packet of size " << p->GetSize() <<
"\n";
155 std::cout <<
"NlmeNetworkFormationConfirmStatus = " << params.m_status <<
"\n";
168 std::cout <<
" Network discovery confirm Received. Networks found "
169 <<
"(" << params.m_netDescList.size() <<
")\n";
171 for (
const auto& netDescriptor : params.m_netDescList)
173 std::cout <<
" ExtPanID: 0x" << std::hex << netDescriptor.m_extPanId << std::dec
175 <<
" CH: " <<
static_cast<uint32_t>(netDescriptor.m_logCh) << std::hex
177 <<
" Pan Id: 0x" << netDescriptor.m_panId << std::hex <<
"\n"
178 <<
" stackprofile: " << std::dec
179 <<
static_cast<uint32_t>(netDescriptor.m_stackProfile) <<
"\n"
180 <<
" ----------------\n ";
197 std::cout <<
" WARNING: Unable to discover networks | status: " << params.m_status <<
"\n";
207 <<
" The device joined the network SUCCESSFULLY with short address [" << std::hex
208 << params.m_networkAddress <<
"] on the Extended PAN Id: " << std::hex
209 << params.m_extendedPanId <<
"\n"
222 <<
" The device FAILED to join the network with status " << params.m_status
230 std::cout <<
"NlmeRouteDiscoveryConfirmStatus = " << params.m_status <<
"\n";
234main(
int argc,
char* argv[])
244 mobility.SetPositionAllocator(
"ns3::GridPositionAllocator",
266 channel->AddPropagationLossModel(propModel);
267 channel->SetPropagationDelayModel(delayModel);
292 zstack->GetNwk()->SetNlmeNetworkFormationConfirmCallback(
295 zstack->GetNwk()->SetNldeDataIndicationCallback(
298 zstack->GetNwk()->SetNlmeNetworkDiscoveryConfirmCallback(
303 zstack->GetNwk()->SetNlmeRouteDiscoveryConfirmCallback(
315 zstack->GetNwk()->AssignStreams(index);
This class can be used to hold variables of floating point type such as 'double' or 'float'.
helps to manage and create IEEE 802.15.4 NetDevice objects
void SetChannel(Ptr< SpectrumChannel > channel)
Set the channel associated to this helper.
void SetExtendedAddresses(NetDeviceContainer c)
Set the extended 64 bit addresses (EUI-64) for a group of LrWpanNetDevices.
NetDeviceContainer Install(NodeContainer c)
Install a LrWpanNetDevice and the associated structures (e.g., channel) in the nodes.
This class can contain 16 bit addresses.
Helper class used to assign positions and mobility models to nodes.
holds a vector of ns3::NetDevice pointers
keep track of a set of node pointers.
Smart pointer class similar to boost::intrusive_ptr.
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.
Hold variables of type string.
TimeWithUnit As(const Unit unit=Time::AUTO) const
Attach a unit to a Time, to facilitate output in a specific unit.
Hold an unsigned integer type.
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 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 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 ...
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.
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.
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.
Time MilliSeconds(uint64_t value)
Construct a Time in the indicated unit.
@ NO_ADDRESS
No destination address.
@ SUCCESS
The operation was completed successfully.
@ 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)
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.
std::vector< uint32_t > channelsField
The set of channels for a given page.
NLDE-DATA.indication params.
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.confirm params.
NLME-ROUTE-DISCOVERY.request params.
AddressMode m_dstAddrMode
Specifies the kind of destination address.
NLME-START-ROUTER.request params.
static void NwkNetworkDiscoveryConfirm(Ptr< ZigbeeStack > stack, NlmeNetworkDiscoveryConfirmParams params)
static void NwkDataIndication(Ptr< ZigbeeStack > stack, NldeDataIndicationParams params, Ptr< Packet > p)
static void NwkJoinConfirm(Ptr< ZigbeeStack > stack, NlmeJoinConfirmParams params)
static void NwkNetworkFormationConfirm(Ptr< ZigbeeStack > stack, NlmeNetworkFormationConfirmParams params)
static void CreateManyToOneRoutes(Ptr< ZigbeeStack > zigbeeStackConcentrator, Ptr< ZigbeeStack > zigbeeStackSrc)
static void NwkNetworkDiscoveryConfirm(Ptr< ZigbeeStack > stack, NlmeNetworkDiscoveryConfirmParams params)
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)