41#include <ns3/core-module.h> 
   42#include <ns3/lr-wpan-module.h> 
   43#include <ns3/mobility-module.h> 
   44#include <ns3/netanim-module.h> 
   45#include <ns3/network-module.h> 
   46#include <ns3/propagation-module.h> 
   47#include <ns3/spectrum-module.h> 
   67        int panId = lrwpanDevice->GetMac()->GetPanId();
 
   96        if (!params.m_panDescList.empty())
 
   98            for (
uint32_t i = 0; i < params.m_panDescList.size(); i++)
 
  100                if (params.m_panDescList[i].m_linkQuality > maxLqi)
 
  102                    maxLqi = params.m_panDescList[i].m_linkQuality;
 
  108            if (params.m_panDescList[panDescIndex].m_superframeSpec.IsAssocPermit())
 
  110                std::string addressing;
 
  111                if (params.m_panDescList[panDescIndex].m_coorAddrMode == 
SHORT_ADDR)
 
  113                    addressing = 
"Short";
 
  115                else if (params.m_panDescList[panDescIndex].m_coorAddrMode == 
EXT_ADDR)
 
  121                          << 
" [" << device->GetMac()->GetShortAddress() << 
" | " 
  122                          << device->GetMac()->GetExtendedAddress() << 
"]" 
  123                          << 
" MLME-scan.confirm:  Selected PAN ID " 
  124                          << params.m_panDescList[panDescIndex].m_coorPanId
 
  125                          << 
"| Coord addressing mode: " << addressing << 
" | LQI " 
  126                          << 
static_cast<int>(params.m_panDescList[panDescIndex].m_linkQuality)
 
  129                if (params.m_panDescList[panDescIndex].m_linkQuality >= 127)
 
  132                    assocParams.
m_chNum = params.m_panDescList[panDescIndex].m_logCh;
 
  133                    assocParams.
m_chPage = params.m_panDescList[panDescIndex].m_logChPage;
 
  134                    assocParams.
m_coordPanId = params.m_panDescList[panDescIndex].m_coorPanId;
 
  135                    assocParams.
m_coordAddrMode = params.m_panDescList[panDescIndex].m_coorAddrMode;
 
  137                    if (params.m_panDescList[panDescIndex].m_coorAddrMode ==
 
  138                        LrWpanAddressMode::SHORT_ADDR)
 
  142                            params.m_panDescList[panDescIndex].m_coorShortAddr;
 
  149                            params.m_panDescList[panDescIndex].m_coorExtAddr;
 
  161                              << device->GetNode()->GetId() << 
" [" 
  162                              << device->GetMac()->GetShortAddress() << 
" | " 
  163                              << device->GetMac()->GetExtendedAddress() << 
"]" 
  164                              << 
" MLME-scan.confirm: Beacon found but link quality too low for " 
  172                      << 
" [" << device->GetMac()->GetShortAddress() << 
" | " 
  173                      << device->GetMac()->GetExtendedAddress()
 
  174                      << 
"] MLME-scan.confirm: Beacon not found.\n";
 
  180                  << 
" | " << device->GetMac()->GetExtendedAddress()
 
  181                  << 
"]  error occurred, scan failed.\n";
 
  209    assocRespParams.
m_status = LrWpanAssociationStatus::ASSOCIATED;
 
  210    if (params.capabilityInfo.IsShortAddrAllocOn())
 
  215        uint8_t buffer64MacAddr[8];
 
  216        uint8_t buffer16MacAddr[2];
 
  218        params.m_extDevAddr.CopyTo(buffer64MacAddr);
 
  219        buffer16MacAddr[1] = buffer64MacAddr[7];
 
  220        buffer16MacAddr[0] = buffer64MacAddr[6];
 
  223        shortAddr.
CopyFrom(buffer16MacAddr);
 
  243    switch (params.m_status)
 
  245    case LrWpanMlmeCommStatus::MLMECOMMSTATUS_TRANSACTION_EXPIRED:
 
  247                  << 
" [" << device->GetMac()->GetShortAddress() << 
" | " 
  248                  << device->GetMac()->GetExtendedAddress() << 
"]" 
  249                  << 
" MLME-comm-status.indication: Transaction for device " << params.m_dstExtAddr
 
  250                  << 
" EXPIRED in pending transaction list\n";
 
  252    case LrWpanMlmeCommStatus::MLMECOMMSTATUS_NO_ACK:
 
  254                  << 
" [" << device->GetMac()->GetShortAddress() << 
" | " 
  255                  << device->GetMac()->GetExtendedAddress() << 
"]" 
  256                  << 
" MLME-comm-status.indication: NO ACK from " << params.m_dstExtAddr
 
  257                  << 
" device registered in the pending transaction list\n";
 
  260    case LrWpanMlmeCommStatus::MLMECOMMSTATUS_CHANNEL_ACCESS_FAILURE:
 
  262                  << 
" [" << device->GetMac()->GetShortAddress() << 
" | " 
  263                  << device->GetMac()->GetExtendedAddress() << 
"]" 
  264                  << 
" MLME-comm-status.indication: CHANNEL ACCESS problem in transaction for " 
  265                  << params.m_dstExtAddr << 
" registered in the pending transaction list\n";
 
  279    if (params.m_status == LrWpanMlmeAssociateConfirmStatus::MLMEASSOC_SUCCESS)
 
  282                  << device->GetMac()->GetShortAddress() << 
" | " 
  283                  << device->GetMac()->GetExtendedAddress() << 
"]" 
  284                  << 
" MLME-associate.confirm: Association with coordinator successful." 
  285                  << 
" (PAN: " << device->GetMac()->GetPanId()
 
  286                  << 
" | CoordShort: " << device->GetMac()->GetCoordShortAddress()
 
  287                  << 
" | CoordExt: " << device->GetMac()->GetCoordExtAddress() << 
")\n";
 
  289    else if (params.m_status == LrWpanMlmeAssociateConfirmStatus::MLMEASSOC_NO_ACK)
 
  292                  << device->GetMac()->GetShortAddress() << 
" | " 
  293                  << device->GetMac()->GetExtendedAddress() << 
"]" 
  294                  << 
" MLME-associate.confirm: Association with coordinator FAILED (NO ACK).\n";
 
  299                  << device->GetMac()->GetShortAddress() << 
" | " 
  300                  << device->GetMac()->GetExtendedAddress() << 
"]" 
  301                  << 
" MLME-associate.confirm: Association with coordinator FAILED.\n";
 
  308    if (params.m_status == LrWpanMlmePollConfirmStatus::MLMEPOLL_CHANNEL_ACCESS_FAILURE)
 
  312            << device->GetMac()->GetShortAddress() << 
" | " 
  313            << device->GetMac()->GetExtendedAddress() << 
"]" 
  314            << 
" MLME-poll.confirm:  CHANNEL ACCESS problem when sending a data request command.\n";
 
  316    else if (params.m_status == LrWpanMlmePollConfirmStatus::MLMEPOLL_NO_ACK)
 
  319                  << device->GetMac()->GetShortAddress() << 
" | " 
  320                  << device->GetMac()->GetExtendedAddress() << 
"]" 
  321                  << 
" MLME-poll.confirm: Data Request Command FAILED (NO ACK).\n";
 
  323    else if (params.m_status != LrWpanMlmePollConfirmStatus::MLMEPOLL_SUCCESS)
 
  326                  << device->GetMac()->GetShortAddress() << 
" | " 
  327                  << device->GetMac()->GetExtendedAddress() << 
"]" 
  328                  << 
" MLME-poll.confirm: Data Request command FAILED.\n";
 
  333main(
int argc, 
char* argv[])
 
  341    mobility.SetMobilityModel(
"ns3::ConstantPositionMobilityModel");
 
  342    mobility.SetPositionAllocator(
"ns3::GridPositionAllocator",
 
  359    listPositionAlloc->Add(Vector(210, 50, 0)); 
 
  360    listPositionAlloc->Add(Vector(360, 50, 0)); 
 
  362    mobility.SetPositionAllocator(listPositionAlloc);
 
  367        CreateObject<LogDistancePropagationLossModel>();
 
  369        CreateObject<ConstantSpeedPropagationDelayModel>();
 
  371    channel->AddPropagationLossModel(propModel);
 
  372    channel->SetPropagationDelayModel(delayModel);
 
  389        lrwpanDevice->GetMac()->SetMlmeScanConfirmCallback(
 
  391        lrwpanDevice->GetMac()->SetMlmeAssociateConfirmCallback(
 
  393        lrwpanDevice->GetMac()->SetMlmePollConfirmCallback(
 
  414                                       lrwpanDevice->GetMac(),
 
  424        lrwpanDevice->GetMac()->SetMlmeAssociateIndicationCallback(
 
  426        lrwpanDevice->GetMac()->SetMlmeCommStatusIndicationCallback(
 
  445    coor1Device->GetMac()->SetShortAddress(
Mac16Address(
"FF:FE"));
 
  446    coor2Device->GetMac()->SetShortAddress(
Mac16Address(
"CA:FE"));
 
  459                                   coor1Device->GetMac(),
 
  473                                   coor2Device->GetMac(),
 
Interface to network animator.
 
void SkipPacketTracing()
Do not trace packets.
 
void UpdateNodeSize(Ptr< Node > n, double width, double height)
Helper function to update the size of a node.
 
void UpdateNodeDescription(Ptr< Node > n, std::string descr)
Helper function to update the description for a given node.
 
void UpdateNodeColor(Ptr< Node > n, uint8_t r, uint8_t g, uint8_t b)
Helper function to update the node color.
 
void SetShortAddrAllocOn(bool addrAlloc)
Set the Short Address Flag in the Capability Information Field.
 
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.
 
void MlmeStartRequest(MlmeStartRequestParams params)
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)
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)
IEEE 802.15.4-2011, section 6.2.10.1 MLME-SCAN.request Request primitive used to initiate a channel s...
 
void MlmeAssociateResponse(MlmeAssociateResponseParams params)
IEEE 802.15.4-2011, section 6.2.2.3 MLME-ASSOCIATE.response Primitive used to initiate a response to ...
 
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.
 
std::vector< Ptr< Node > >::const_iterator Iterator
Node container iterator.
 
Iterator End() const
Get an iterator which indicates past-the-last Node in the container.
 
uint32_t GetN() const
Get the number of Ptr<Node> stored in this container.
 
void Create(uint32_t n)
Create n nodes and append pointers to them to the end of this NodeContainer.
 
Iterator Begin() const
Get an iterator which refers to the first Node in the container.
 
Ptr< Node > Get(uint32_t i) const
Get the Ptr<Node> stored in this container at a given index.
 
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.
 
auto MakeBoundCallback(R(*fnPtr)(Args...), BArgs &&... bargs)
Make Callbacks with varying number of bound arguments.
 
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 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.
 
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.
 
FtrParams 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.
 
uint8_t m_chNum
The channel number on which to attempt association.
 
CapabilityField m_capabilityInfo
Specifies the operational capabilities of the associating device.
 
uint8_t m_coordAddrMode
The coordinator addressing mode for this primitive and subsequent MPDU.
 
uint32_t m_chPage
The channel page on which to attempt association.
 
Mac64Address m_coordExtAddr
The extended address of the coordinator with which to associate.
 
Mac16Address m_coordShortAddr
The short address of the coordinator with which to associate.
 
uint16_t m_coordPanId
The identifier of the PAN with which to associate.
 
MLME-ASSOCIATE.response params.
 
LrWpanAssociationStatus m_status
The status of the association attempt (As defined on Table 83 IEEE 802.15.4-2006)
 
Mac16Address m_assocShortAddr
The short address allocated by the coordinator on successful assoc.
 
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.
 
uint32_t m_scanChannels
The channel numbers to be scanned.
 
uint32_t m_chPage
The channel page on which to perform scan.
 
uint8_t m_scanDuration
The factor (0-14) used to calculate the length of time to spend scanning.
 
LrWpanMlmeScanType m_scanType
Indicates the type of scan performed as described in IEEE 802.15.4-2011 (5.1.2.1).
 
MLME-START.request params.
 
uint8_t m_logCh
Logical channel on which to start using the new superframe configuration.
 
bool m_panCoor
On true this device will become coordinator.
 
uint8_t m_bcnOrd
Beacon Order, Used to calculate the beacon interval, a value of 15 indicates no periodic beacons will...
 
uint16_t m_PanId
Pan Identifier used by the device.
 
uint8_t m_sfrmOrd
Superframe Order, indicates the length of the CAP in time slots.