30#include "ns3/core-module.h"
31#include "ns3/lr-wpan-module.h"
32#include "ns3/mobility-module.h"
33#include "ns3/netanim-module.h"
34#include "ns3/network-module.h"
35#include "ns3/propagation-module.h"
36#include "ns3/spectrum-module.h"
53 anim->UpdateNodeSize(i, 5, 5);
57 int panId = lrwpanDevice->GetMac()->GetPanId();
62 anim->UpdateNodeColor(node, 0, 0, 255);
65 anim->UpdateNodeColor(node, 0, 51, 102);
86 if (!params.m_panDescList.empty())
88 for (
uint32_t i = 0; i < params.m_panDescList.size(); i++)
90 if (params.m_panDescList[i].m_linkQuality > maxLqi)
92 maxLqi = params.m_panDescList[i].m_linkQuality;
98 SuperframeField superframe(params.m_panDescList[panDescIndex].m_superframeSpec);
101 std::string addressing;
102 if (params.m_panDescList[panDescIndex].m_coorAddrMode ==
SHORT_ADDR)
104 addressing =
"Short";
106 else if (params.m_panDescList[panDescIndex].m_coorAddrMode ==
EXT_ADDR)
112 <<
" [" << device->GetMac()->GetShortAddress() <<
" | "
113 << device->GetMac()->GetExtendedAddress() <<
"]"
114 <<
" MLME-scan.confirm: Selected PAN ID "
115 << params.m_panDescList[panDescIndex].m_coorPanId
116 <<
"| Coord addressing mode: " << addressing <<
" | LQI "
117 <<
static_cast<int>(params.m_panDescList[panDescIndex].m_linkQuality)
120 if (params.m_panDescList[panDescIndex].m_linkQuality >= 127)
123 assocParams.
m_chNum = params.m_panDescList[panDescIndex].m_logCh;
124 assocParams.
m_chPage = params.m_panDescList[panDescIndex].m_logChPage;
125 assocParams.
m_coordPanId = params.m_panDescList[panDescIndex].m_coorPanId;
126 assocParams.
m_coordAddrMode = params.m_panDescList[panDescIndex].m_coorAddrMode;
129 if (params.m_panDescList[panDescIndex].m_coorAddrMode ==
134 params.m_panDescList[panDescIndex].m_coorShortAddr;
141 params.m_panDescList[panDescIndex].m_coorExtAddr;
154 << device->GetNode()->GetId() <<
" ["
155 << device->GetMac()->GetShortAddress() <<
" | "
156 << device->GetMac()->GetExtendedAddress() <<
"]"
157 <<
" MLME-scan.confirm: Beacon found but link quality too low for "
165 <<
" [" << device->GetMac()->GetShortAddress() <<
" | "
166 << device->GetMac()->GetExtendedAddress()
167 <<
"] MLME-scan.confirm: Beacon not found.\n";
173 <<
" | " << device->GetMac()->GetExtendedAddress()
174 <<
"] error occurred, scan failed.\n";
211 uint8_t buffer64MacAddr[8];
212 uint8_t buffer16MacAddr[2];
214 params.m_extDevAddr.CopyTo(buffer64MacAddr);
215 buffer16MacAddr[1] = buffer64MacAddr[7];
216 buffer16MacAddr[0] = buffer64MacAddr[6];
219 shortAddr.
CopyFrom(buffer16MacAddr);
239 switch (params.m_status)
243 <<
" [" << device->GetMac()->GetShortAddress() <<
" | "
244 << device->GetMac()->GetExtendedAddress() <<
"]"
245 <<
" MLME-comm-status.indication: Transaction for device " << params.m_dstExtAddr
246 <<
" EXPIRED in pending transaction list\n";
250 <<
" [" << device->GetMac()->GetShortAddress() <<
" | "
251 << device->GetMac()->GetExtendedAddress() <<
"]"
252 <<
" MLME-comm-status.indication: NO ACK from " << params.m_dstExtAddr
253 <<
" device registered in the pending transaction list\n";
258 <<
" [" << device->GetMac()->GetShortAddress() <<
" | "
259 << device->GetMac()->GetExtendedAddress() <<
"]"
260 <<
" MLME-comm-status.indication: CHANNEL ACCESS problem in transaction for "
261 << params.m_dstExtAddr <<
" registered in the pending transaction list\n";
278 << device->GetMac()->GetShortAddress() <<
" | "
279 << device->GetMac()->GetExtendedAddress() <<
"]"
280 <<
" MLME-associate.confirm: Association with coordinator successful."
281 <<
" (PAN: " << device->GetMac()->GetPanId()
282 <<
" | CoordShort: " << device->GetMac()->GetCoordShortAddress()
283 <<
" | CoordExt: " << device->GetMac()->GetCoordExtAddress() <<
")\n";
288 << device->GetMac()->GetShortAddress() <<
" | "
289 << device->GetMac()->GetExtendedAddress() <<
"]"
290 <<
" MLME-associate.confirm: Association with coordinator FAILED (NO ACK).\n";
295 << device->GetMac()->GetShortAddress() <<
" | "
296 << device->GetMac()->GetExtendedAddress() <<
"]"
297 <<
" MLME-associate.confirm: Association with coordinator FAILED.\n";
308 << device->GetMac()->GetShortAddress() <<
" | "
309 << device->GetMac()->GetExtendedAddress() <<
"]"
310 <<
" MLME-poll.confirm: CHANNEL ACCESS problem when sending a data request command.\n";
315 << device->GetMac()->GetShortAddress() <<
" | "
316 << device->GetMac()->GetExtendedAddress() <<
"]"
317 <<
" MLME-poll.confirm: Data Request Command FAILED (NO ACK).\n";
322 << device->GetMac()->GetShortAddress() <<
" | "
323 << device->GetMac()->GetExtendedAddress() <<
"]"
324 <<
" MLME-poll.confirm: Data Request command FAILED.\n";
329main(
int argc,
char* argv[])
337 mobility.SetMobilityModel(
"ns3::ConstantPositionMobilityModel");
338 mobility.SetPositionAllocator(
"ns3::GridPositionAllocator",
355 listPositionAlloc->Add(Vector(210, 50, 0));
356 listPositionAlloc->Add(Vector(360, 50, 0));
358 mobility.SetPositionAllocator(listPositionAlloc);
372 for (
auto i =
nodes.Begin(); i !=
nodes.End(); i++)
377 lrwpanDevice->GetMac()->SetMlmeScanConfirmCallback(
379 lrwpanDevice->GetMac()->SetMlmeAssociateConfirmCallback(
381 lrwpanDevice->GetMac()->SetMlmePollConfirmCallback(
402 lrwpanDevice->GetMac(),
412 lrwpanDevice->GetMac()->SetMlmeAssociateIndicationCallback(
414 lrwpanDevice->GetMac()->SetMlmeCommStatusIndicationCallback(
433 coor1Device->GetMac()->SetShortAddress(
Mac16Address(
"FF:FE"));
434 coor2Device->GetMac()->SetShortAddress(
Mac16Address(
"CA:FE"));
447 coor1Device->GetMac(),
461 coor2Device->GetMac(),
465 anim->SkipPacketTracing();
470 anim->UpdateNodeSize(
nodes.GetN(), 9, 9);
471 anim->UpdateNodeSize(
nodes.GetN() + 1, 9, 9);
Interface to network animator.
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 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.
void SetPropagationDelayModel(std::string name, Ts &&... args)
void AddPropagationLossModel(std::string name, Ts &&... args)
This class can contain 16 bit addresses.
void CopyFrom(const uint8_t buffer[2])
Helper class used to assign positions and mobility models to nodes.
holds a vector of ns3::NetDevice pointers
void Add(NetDeviceContainer other)
Append the contents of another NetDeviceContainer to the end of this container.
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.
Simulation virtual time values and global simulation resolution.
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.
Represent the Capability Information Field.
bool IsShortAddrAllocOn() const
True if the device wishes the coordinator to allocate a short address as result of the association pr...
uint8_t GetCapability() const
Get the bitmap representing the device capability.
void SetCapability(uint8_t bitmap)
Set the bitmap representing the device capability.
void SetShortAddrAllocOn(bool addrAlloc)
Set the Short Address Flag in the Capability Information Field.
void MlmeAssociateResponse(MlmeAssociateResponseParams params) override
IEEE 802.15.4-2011, section 6.2.2.3 MLME-ASSOCIATE.response Primitive used to initiate a response to ...
void MlmeStartRequest(MlmeStartRequestParams params) override
IEEE 802.15.4-2006, section 7.1.14.1 MLME-START.request Request to allow a PAN coordinator to initiat...
void MlmeAssociateRequest(MlmeAssociateRequestParams params) override
IEEE 802.15.4-2011, section 6.2.2.1 MLME-ASSOCIATE.request Request primitive used by a device to requ...
void MlmeScanRequest(MlmeScanRequestParams params) override
IEEE 802.15.4-2011, section 6.2.10.1 MLME-SCAN.request Request primitive used to initiate a channel s...
Represent the Superframe Specification information field.
bool IsAssocPermit() const
Check if the Association Permit bit is enabled.
@ CHANNEL_ACCESS_FAILURE
A Tx could not take place due to activity in the CH.
@ TRANSACTION_EXPIRED
The transaction expired and its information discarded.
@ SUCCESS
The operation was completed successfully.
@ NO_ACK
No acknowledgment was received after macMaxFrameRetries.
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 void ScanConfirm(Ptr< LrWpanNetDevice > device, MlmeScanConfirmParams params)
static void UpdateAnimation()
static void AssociateIndication(Ptr< LrWpanNetDevice > device, MlmeAssociateIndicationParams params)
NodeContainer coordinators
static void PollConfirm(Ptr< LrWpanNetDevice > device, MlmePollConfirmParams params)
static void AssociateConfirm(Ptr< LrWpanNetDevice > device, MlmeAssociateConfirmParams params)
AnimationInterface * anim
static void ScanConfirm(Ptr< LrWpanNetDevice > device, MlmeScanConfirmParams params)
static void CommStatusIndication(Ptr< LrWpanNetDevice > device, MlmeCommStatusIndicationParams params)
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Ptr< T1 > DynamicCast(const Ptr< T2 > &p)
Cast a Ptr.
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.
params
Fit Fluctuating Two Ray model to the 3GPP TR 38.901 using the Anderson-Darling goodness-of-fit ##.
MLME-ASSOCIATE.confirm params.
MLME-ASSOCIATE.indication params.
MLME-ASSOCIATE.request params.
Mac64Address m_coordExtAddr
The extended address of the coordinator with which to associate.
uint8_t m_coordAddrMode
The coordinator addressing mode for this primitive and subsequent MPDU.
uint8_t m_capabilityInfo
Specifies the operational capabilities of the associating device (bitmap).
Mac16Address m_coordShortAddr
The short address of the coordinator with which to associate.
uint8_t m_chNum
The channel number on which to attempt association.
uint32_t m_chPage
The channel page on which to attempt association.
uint16_t m_coordPanId
The identifier of the PAN with which to associate.
MLME-ASSOCIATE.response params.
Mac16Address m_assocShortAddr
The short address allocated by the coordinator on successful assoc.
MacStatus m_status
The status of the association attempt (As defined on Table 83 IEEE 802.15.4-2006)
Mac64Address m_extDevAddr
The extended address of the device requesting association.
MLME-COMM-STATUS.indication params.
MLME-START.confirm params.
MLME-SCAN.confirm params.
MLME-SCAN.request params.
MlmeScanType m_scanType
Indicates the type of scan performed as described in IEEE 802.15.4-2011 (5.1.2.1).
uint32_t m_scanChannels
The channel numbers to be scanned.
uint8_t m_scanDuration
The factor (0-14) used to calculate the length of time to spend scanning.
uint32_t m_chPage
The channel page on which to perform scan.
MLME-START.request params.
uint8_t m_logCh
Logical channel on which to start using the new superframe configuration.
uint8_t m_bcnOrd
Beacon Order, Used to calculate the beacon interval, a value of 15 indicates no periodic beacons will...
bool m_panCoor
On true this device will become coordinator.
uint8_t m_sfrmOrd
Superframe Order, indicates the length of the CAP in time slots.
uint16_t m_PanId
Pan Identifier used by the device.