13#include "ns3/lr-wpan-csmaca.h"
14#include "ns3/lr-wpan-error-model.h"
15#include "ns3/lr-wpan-net-device.h"
16#include "ns3/mobility-model.h"
17#include "ns3/multi-model-spectrum-channel.h"
19#include "ns3/single-model-spectrum-channel.h"
89 return std::string(
"BUSY");
91 return std::string(
"BUSY_RX");
93 return std::string(
"BUSY_TX");
95 return std::string(
"FORCE_TRX_OFF");
97 return std::string(
"IDLE");
99 return std::string(
"INVALID_PARAMETER");
101 return std::string(
"RX_ON");
103 return std::string(
"SUCCESS");
105 return std::string(
"TRX_OFF");
107 return std::string(
"TX_ON");
109 return std::string(
"UNSUPPORTED_ATTRIBUTE");
111 return std::string(
"READ_ONLY");
113 return std::string(
"UNSPECIFIED");
115 return std::string(
"INVALID");
125 return std::string(
"MAC_IDLE");
127 return std::string(
"CHANNEL_ACCESS_FAILURE");
129 return std::string(
"CHANNEL_IDLE");
131 return std::string(
"SET_PHY_TX_ON");
133 return std::string(
"INVALID");
171 m_channel->SetPropagationDelayModel(delay);
175 if (!
m_channel->GetPropagationDelayModel())
177 NS_FATAL_ERROR(
"No propagation delay model added to the channel");
179 if (!
m_channel->GetPropagationLossModel())
186 for (
auto i =
c.Begin();
i !=
c.End();
i++)
225 for (
auto i =
c.Begin();
i !=
c.End(); ++
i)
242 uint8_t
idBuf[2] = {0, 0};
243 uint8_t
idBuf2[8] = {0, 0, 0, 0, 0, 0, 0, 0};
249 for (
auto i =
c.Begin();
i !=
c.End();
i++)
253 NS_ABORT_MSG(
"Only 65533 addresses supported. Range [00:01]-[FF:FD]");
259 idBuf[0] = (
id >> 8) & 0xff;
260 idBuf[1] = (
id >> 0) & 0xff;
263 idBuf2[6] = (
id >> 8) & 0xff;
264 idBuf2[7] = (
id >> 0) & 0xff;
276 device->GetMac()->SetExtendedAddress(
address64);
289 uint8_t
idBuf[8] = {0, 0, 0, 0, 0, 0, 0, 0};
292 for (
auto i =
c.Begin();
i !=
c.End();
i++)
297 idBuf[0] = (
id >> 56) & 0xff;
298 idBuf[1] = (
id >> 48) & 0xff;
299 idBuf[2] = (
id >> 40) & 0xff;
300 idBuf[3] = (
id >> 32) & 0xff;
301 idBuf[4] = (
id >> 24) & 0xff;
302 idBuf[5] = (
id >> 16) & 0xff;
303 idBuf[6] = (
id >> 8) & 0xff;
304 idBuf[7] = (
id >> 0) & 0xff;
310 device->GetMac()->SetExtendedAddress(
address64);
348 NS_LOG_INFO(
"LrWpanHelper::EnablePcapInternal(): Device "
349 << device <<
" not of type ns3::lrwpan::LrWpanNetDevice");
370 device->GetMac()->TraceConnectWithoutContext(
"PromiscSniffer",
375 device->GetMac()->TraceConnectWithoutContext(
"Sniffer",
388 std::ostringstream
oss;
393 NS_LOG_INFO(
"LrWpanHelper::EnableAsciiInternal(): Device "
394 << device <<
" not of type ns3::LrWpanNetDevice");
439 device->GetMac()->TraceConnectWithoutContext(
471 <<
"/$ns3::lrwpan::LrWpanNetDevice/Mac/MacRx";
472 device->GetMac()->TraceConnect(
479 <<
"/$ns3::lrwpan::LrWpanNetDevice/Mac/MacTx";
480 device->GetMac()->TraceConnect(
487 <<
"/$ns3::lrwpan::LrWpanNetDevice/Mac/MacTxEnqueue";
488 device->GetMac()->TraceConnect(
495 <<
"/$ns3::lrwpan::LrWpanNetDevice/Mac/MacTxDequeue";
496 device->GetMac()->TraceConnect(
503 <<
"/$ns3::lrwpan::LrWpanNetDevice/Mac/MacTxDrop";
504 device->GetMac()->TraceConnect(
Manage ASCII trace files for device models.
std::string GetFilenameFromDevice(std::string prefix, Ptr< NetDevice > device, bool useObjectNames=true)
Let the ascii trace helper figure out a reasonable filename to use for an ascii trace file associated...
static void DefaultDropSinkWithContext(Ptr< OutputStreamWrapper > file, std::string context, Ptr< const Packet > p)
Basic Drop default trace sink.
static void DefaultReceiveSinkWithContext(Ptr< OutputStreamWrapper > file, std::string context, Ptr< const Packet > p)
Basic Receive default trace sink.
static void DefaultEnqueueSinkWithContext(Ptr< OutputStreamWrapper > file, std::string context, Ptr< const Packet > p)
Basic Enqueue default trace sink.
static void DefaultDequeueSinkWithContext(Ptr< OutputStreamWrapper > file, std::string context, Ptr< const Packet > p)
Basic Dequeue default trace sink.
Ptr< SpectrumChannel > GetChannel()
Get the channel associated to this helper.
Ptr< SpectrumChannel > m_channel
channel to be used for the devices
void SetChannel(Ptr< SpectrumChannel > channel)
Set the channel associated to this helper.
void AddMobility(Ptr< lrwpan::LrWpanPhy > phy, Ptr< MobilityModel > m)
Add mobility model to a physical device.
void EnablePcapInternal(std::string prefix, Ptr< NetDevice > nd, bool promiscuous, bool explicitFilename) override
Enable pcap output on the indicated net device.
void CreateAssociatedPan(NetDeviceContainer c, uint16_t panId)
Creates an PAN with associated nodes and assigned addresses(16 and 64) from the nodes in the node con...
std::vector< ObjectFactory > m_propagationLoss
vector of propagation loss models
bool m_useMultiModelSpectrumChannel
indicates whether a MultiModelSpectrumChannel is used
void SetExtendedAddresses(NetDeviceContainer c)
Set the extended 64 bit addresses (EUI-64) for a group of LrWpanNetDevices.
void EnableLogComponents()
Helper to enable all LrWpan log components with one statement.
static std::string LrWpanMacStatePrinter(lrwpan::MacState e)
Transform the LrWpanMacState enumeration into a printable string.
NetDeviceContainer Install(NodeContainer c)
Install a LrWpanNetDevice and the associated structures (e.g., channel) in the nodes.
void EnableAsciiInternal(Ptr< OutputStreamWrapper > stream, std::string prefix, Ptr< NetDevice > nd, bool explicitFilename) override
Enable ascii trace output on the indicated net device.
static std::string LrWpanPhyEnumerationPrinter(lrwpan::PhyEnumeration e)
Transform the LrWpanPhyEnumeration enumeration into a printable string.
LrWpanHelper()
Create a LrWpan helper in an empty state.
ObjectFactory m_propagationDelay
propagation delay model
void SetPropagationDelayModel(std::string name, Ts &&... args)
int64_t AssignStreams(NetDeviceContainer c, int64_t stream)
Assign a fixed random variable stream number to the random variables used by this model.
void AddPropagationLossModel(std::string name, Ts &&... args)
This class can contain 16 bit addresses.
holds a vector of ns3::NetDevice pointers
keep track of a set of node pointers.
Ptr< Object > Create() const
Create an Object instance of the configured TypeId.
bool IsTypeIdSet() const
Check if the ObjectFactory has been configured with a TypeId.
static void EnablePrinting()
Enable printing packets metadata.
Manage pcap files for device models.
std::string GetFilenameFromDevice(std::string prefix, Ptr< NetDevice > device, bool useObjectNames=true)
Let the pcap helper figure out a reasonable filename to use for a pcap file associated with a device.
calculate a propagation delay.
Models the propagation loss through a transmission medium.
Smart pointer class similar to boost::intrusive_ptr.
static Time Now()
Return the current simulation virtual time.
TimeWithUnit As(const Unit unit=Time::AUTO) const
Attach a unit to a Time, to facilitate output in a specific unit.
Class that implements the LR-WPAN MAC state machine.
Network layer to device interface.
#define NS_FATAL_ERROR(msg)
Report a fatal error with a message and terminate.
#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.
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by ",...
#define NS_LOG_INFO(msg)
Use NS_LOG to output a message of level LOG_INFO.
PhyEnumeration
IEEE802.15.4-2006 PHY Emumerations Table 18 in section 6.2.3.
@ CHANNEL_ACCESS_FAILURE
CHANNEL_ACCESS_FAILURE.
@ CHANNEL_IDLE
CHANNEL_IDLE.
@ SET_PHY_TX_ON
SET_PHY_TX_ON.
@ IEEE_802_15_4_PHY_READ_ONLY
@ IEEE_802_15_4_PHY_BUSY_TX
@ IEEE_802_15_4_PHY_RX_ON
@ IEEE_802_15_4_PHY_TRX_OFF
@ IEEE_802_15_4_PHY_TX_ON
@ IEEE_802_15_4_PHY_INVALID_PARAMETER
@ IEEE_802_15_4_PHY_UNSUPPORTED_ATTRIBUTE
@ IEEE_802_15_4_PHY_SUCCESS
@ IEEE_802_15_4_PHY_FORCE_TRX_OFF
@ IEEE_802_15_4_PHY_BUSY_RX
@ IEEE_802_15_4_PHY_UNSPECIFIED
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.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
void LogComponentEnable(const std::string &name, LogLevel level)
Enable the logging output associated with that log component.
static void AsciiLrWpanMacTransmitSinkWithContext(Ptr< OutputStreamWrapper > stream, std::string context, Ptr< const Packet > p)
Output an ascii line representing the Transmit event (with context)
static void AsciiLrWpanMacTransmitSinkWithoutContext(Ptr< OutputStreamWrapper > stream, Ptr< const Packet > p)
Output an ascii line representing the Transmit event (without context)
static void PcapSniffLrWpan(Ptr< PcapFileWrapper > file, Ptr< const Packet > packet)
Write a packet in a PCAP file.
@ LOG_LEVEL_ALL
Print everything.
@ LOG_PREFIX_FUNC
Prefix all trace prints with function.
@ LOG_PREFIX_TIME
Prefix all trace prints with simulation time.
void LogComponentEnableAll(LogLevel level)
Enable the logging output for all registered log components.