42#include <ns3/constant-position-mobility-model.h>
43#include <ns3/core-module.h>
45#include <ns3/lr-wpan-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>
61 std::cout <<
Simulator::Now().
As(Time::S) <<
"| Active scan status SUCCESSFUL (Completed)"
65 std::cout <<
"Device [" << device->
GetMac()->GetShortAddress()
66 <<
"] found the following PANs:\n";
67 for (
long unsigned int i = 0; i < params.
m_panDescList.size(); i++)
69 std::cout <<
"PAN DESCRIPTOR " << i <<
":\n"
74 <<
"\nCoordinator Short Address: "
80 std::cout <<
"No PANs found (Could not find any beacons)\n";
85 std::cout <<
"Something went wrong, scan could not be completed\n";
90main(
int argc,
char* argv[])
110 CreateObject<LogDistancePropagationLossModel>();
112 CreateObject<ConstantSpeedPropagationDelayModel>();
113 channel->AddPropagationLossModel(propModel);
114 channel->SetPropagationDelayModel(delayModel);
126 CreateObject<ConstantPositionMobilityModel>();
127 coord1Mobility->SetPosition(
Vector(0, 0, 0));
128 coord1NetDevice->
GetPhy()->SetMobility(coord1Mobility);
131 CreateObject<ConstantPositionMobilityModel>();
132 endNodeMobility->SetPosition(
Vector(100, 0, 0));
133 endNodeNetDevice->
GetPhy()->SetMobility(endNodeMobility);
136 CreateObject<ConstantPositionMobilityModel>();
137 coord2Mobility->SetPosition(
Vector(206, 0, 0));
138 coord2NetDevice->
GetPhy()->SetMobility(coord2Mobility);
141 endNodeNetDevice->
GetMac()->SetMlmeScanConfirmCallback(
156 Simulator::ScheduleWithContext(1,
158 &LrWpanMac::MlmeStartRequest,
159 coord1NetDevice->
GetMac(),
170 Simulator::ScheduleWithContext(2,
172 &LrWpanMac::MlmeStartRequest,
173 coord2NetDevice->
GetMac(),
187 Simulator::ScheduleWithContext(1,
189 &LrWpanMac::MlmeScanRequest,
190 endNodeNetDevice->
GetMac(),
193 Simulator::Stop(
Seconds(2000));
196 Simulator::Destroy();
void SetChannel(Ptr< SpectrumChannel > channel)
Set the channel to which the NetDevice, and therefore the PHY, should be attached to.
Ptr< LrWpanMac > GetMac() const
Get the MAC used by this NetDevice.
Ptr< LrWpanPhy > GetPhy() const
Get the PHY used by this NetDevice.
void SetAddress(Address address) override
This method indirects to LrWpanMac::SetShortAddress ()
This class can contain 16 bit addresses.
uint32_t AddDevice(Ptr< NetDevice > device)
Associate a NetDevice to this node.
TimeWithUnit As(const enum Unit unit=Time::AUTO) const
Attach a unit to a Time, to facilitate output in a specific unit.
Vector3D Vector
Vector alias typedef for compatibility with mobility models.
auto MakeBoundCallback(R(*fnPtr)(Args...), BArgs... bargs)
Make Callbacks with varying number of bound arguments.
Time Now()
create an ns3::Time instance which contains the current simulation time.
Time Seconds(double value)
Construct a Time in the indicated unit.
static void ScanConfirm(Ptr< LrWpanNetDevice > device, MlmeScanConfirmParams 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.
void LogComponentEnableAll(enum LogLevel level)
Enable the logging output for all registered log components.
MLME-SCAN.confirm params.
std::vector< PanDescriptor > m_panDescList
A list of PAN descriptor, one for each beacon found (Not valid for ED and Orphan scans).
LrWpanMlmeScanConfirmStatus m_status
The status of the scan request.
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
A value used to calculate the length of time to spend scanning [aBaseSuperframeDuration * (2^m_scanDu...
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.