25#include <ns3/lr-wpan-csmaca.h> 
   26#include <ns3/lr-wpan-error-model.h> 
   27#include <ns3/lr-wpan-net-device.h> 
   28#include <ns3/mobility-model.h> 
   29#include <ns3/multi-model-spectrum-channel.h> 
   30#include <ns3/propagation-delay-model.h> 
   31#include <ns3/propagation-loss-model.h> 
   32#include <ns3/single-model-spectrum-channel.h> 
   67    m_channel = CreateObject<SingleModelSpectrumChannel>();
 
   70        CreateObject<LogDistancePropagationLossModel>();
 
   71    m_channel->AddPropagationLossModel(lossModel);
 
   74        CreateObject<ConstantSpeedPropagationDelayModel>();
 
   75    m_channel->SetPropagationDelayModel(delayModel);
 
   80    if (useMultiModelSpectrumChannel)
 
   82        m_channel = CreateObject<MultiModelSpectrumChannel>();
 
   86        m_channel = CreateObject<SingleModelSpectrumChannel>();
 
   89        CreateObject<LogDistancePropagationLossModel>();
 
   90    m_channel->AddPropagationLossModel(lossModel);
 
   93        CreateObject<ConstantSpeedPropagationDelayModel>();
 
   94    m_channel->SetPropagationDelayModel(delayModel);
 
  124        return std::string(
"BUSY");
 
  126        return std::string(
"BUSY_RX");
 
  128        return std::string(
"BUSY_TX");
 
  130        return std::string(
"FORCE_TRX_OFF");
 
  132        return std::string(
"IDLE");
 
  134        return std::string(
"INVALID_PARAMETER");
 
  136        return std::string(
"RX_ON");
 
  138        return std::string(
"SUCCESS");
 
  140        return std::string(
"TRX_OFF");
 
  142        return std::string(
"TX_ON");
 
  144        return std::string(
"UNSUPPORTED_ATTRIBUTE");
 
  146        return std::string(
"READ_ONLY");
 
  148        return std::string(
"UNSPECIFIED");
 
  150        return std::string(
"INVALID");
 
  160        return std::string(
"MAC_IDLE");
 
  162        return std::string(
"CHANNEL_ACCESS_FAILURE");
 
  164        return std::string(
"CHANNEL_IDLE");
 
  166        return std::string(
"SET_PHY_TX_ON");
 
  168        return std::string(
"INVALID");
 
  219    int64_t currentStream = stream;
 
  230    return (currentStream - stream);
 
  238    uint8_t idBuf[2] = {0, 0};
 
  239    uint8_t idBuf2[8] = {0, 0, 0, 0, 0, 0, 0, 0};
 
  247        if (id < 0x0001 || id > 0xFFFD)
 
  249            NS_ABORT_MSG(
"Only 65533 addresses supported. Range [00:01]-[FF:FD]");
 
  255            idBuf[0] = (
id >> 8) & 0xff;
 
  256            idBuf[1] = (
id >> 0) & 0xff;
 
  259            idBuf2[6] = (
id >> 8) & 0xff;
 
  260            idBuf2[7] = (
id >> 0) & 0xff;
 
  263            if (address64 == 
Mac64Address(
"00:00:00:00:00:00:00:01"))
 
  266                coordShortAddr = address16;
 
  267                coordExtAddr = address64;
 
  272            device->
GetMac()->SetExtendedAddress(address64);
 
  285    uint8_t idBuf[8] = {0, 0, 0, 0, 0, 0, 0, 0};
 
  293            idBuf[0] = (
id >> 56) & 0xff;
 
  294            idBuf[1] = (
id >> 48) & 0xff;
 
  295            idBuf[2] = (
id >> 40) & 0xff;
 
  296            idBuf[3] = (
id >> 32) & 0xff;
 
  297            idBuf[4] = (
id >> 24) & 0xff;
 
  298            idBuf[5] = (
id >> 16) & 0xff;
 
  299            idBuf[6] = (
id >> 8) & 0xff;
 
  300            idBuf[7] = (
id >> 0) & 0xff;
 
  306            device->
GetMac()->SetExtendedAddress(address64);
 
  328                                 bool explicitFilename)
 
  330    NS_LOG_FUNCTION(
this << prefix << nd << promiscuous << explicitFilename);
 
  344        NS_LOG_INFO(
"LrWpanHelper::EnablePcapInternal(): Device " 
  345                    << device << 
" not of type ns3::LrWpanNetDevice");
 
  351    std::string filename;
 
  352    if (explicitFilename)
 
  364    if (promiscuous == 
true)
 
  366        device->
GetMac()->TraceConnectWithoutContext(
"PromiscSniffer",
 
  371        device->
GetMac()->TraceConnectWithoutContext(
"Sniffer",
 
  380                                  bool explicitFilename)
 
  382    uint32_t nodeid = nd->GetNode()->GetId();
 
  383    uint32_t deviceid = nd->GetIfIndex();
 
  384    std::ostringstream oss;
 
  389        NS_LOG_INFO(
"LrWpanHelper::EnableAsciiInternal(): Device " 
  390                    << device << 
" not of type ns3::LrWpanNetDevice");
 
  415        std::string filename;
 
  416        if (explicitFilename)
 
  435        device->
GetMac()->TraceConnectWithoutContext(
 
  466    oss << 
"/NodeList/" << nodeid << 
"/DeviceList/" << deviceid
 
  467        << 
"/$ns3::LrWpanNetDevice/Mac/MacRx";
 
  468    device->
GetMac()->TraceConnect(
 
  474    oss << 
"/NodeList/" << nodeid << 
"/DeviceList/" << deviceid
 
  475        << 
"/$ns3::LrWpanNetDevice/Mac/MacTx";
 
  476    device->
GetMac()->TraceConnect(
 
  482    oss << 
"/NodeList/" << nodeid << 
"/DeviceList/" << deviceid
 
  483        << 
"/$ns3::LrWpanNetDevice/Mac/MacTxEnqueue";
 
  484    device->
GetMac()->TraceConnect(
 
  490    oss << 
"/NodeList/" << nodeid << 
"/DeviceList/" << deviceid
 
  491        << 
"/$ns3::LrWpanNetDevice/Mac/MacTxDequeue";
 
  492    device->
GetMac()->TraceConnect(
 
  498    oss << 
"/NodeList/" << nodeid << 
"/DeviceList/" << deviceid
 
  499        << 
"/$ns3::LrWpanNetDevice/Mac/MacTxDrop";
 
  500    device->
GetMac()->TraceConnect(
 
Manage ASCII trace files for device models.
void HookDefaultDropSinkWithoutContext(Ptr< T > object, std::string traceName, Ptr< OutputStreamWrapper > stream)
Hook a trace source to the default drop operation trace sink that does not accept nor log a trace con...
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.
Ptr< OutputStreamWrapper > CreateFileStream(std::string filename, std::ios::openmode filemode=std::ios::out)
Create and initialize an output stream object we'll use to write the traced bits.
void HookDefaultEnqueueSinkWithoutContext(Ptr< T > object, std::string traceName, Ptr< OutputStreamWrapper > stream)
Hook a trace source to the default enqueue operation trace sink that does not accept nor log a trace ...
void HookDefaultReceiveSinkWithoutContext(Ptr< T > object, std::string traceName, Ptr< OutputStreamWrapper > stream)
Hook a trace source to the default receive operation trace sink that does not accept nor log a trace ...
static void DefaultEnqueueSinkWithContext(Ptr< OutputStreamWrapper > file, std::string context, Ptr< const Packet > p)
Basic Enqueue default trace sink.
void HookDefaultDequeueSinkWithoutContext(Ptr< T > object, std::string traceName, Ptr< OutputStreamWrapper > stream)
Hook a trace source to the default dequeue operation trace sink that does not accept nor log a trace ...
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.
static std::string LrWpanPhyEnumerationPrinter(LrWpanPhyEnumeration e)
Transform the LrWpanPhyEnumeration enumeration into a printable string.
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...
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.
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.
LrWpanHelper()
Create a LrWpan helper in an empty state.
void AddMobility(Ptr< LrWpanPhy > phy, Ptr< MobilityModel > m)
Add mobility model to a physical device.
static std::string LrWpanMacStatePrinter(LrWpanMacState e)
Transform the LrWpanMacState enumeration into a printable string.
int64_t AssignStreams(NetDeviceContainer c, int64_t stream)
Assign a fixed random variable stream number to the random variables used by this model.
Class that implements the LR-WPAN MAC state machine.
Network layer to device interface.
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.
void SetNode(Ptr< Node > node) override
int64_t AssignStreams(int64_t stream)
Assign a fixed random variable stream number to the random variables used by this model.
void SetPanAssociation(uint16_t panId, Mac64Address coordExtAddr, Mac16Address coordShortAddr, Mac16Address assignedShortAddr)
This method is use to manually configure the coordinator through which the device or coordinator is a...
This class can contain 16 bit addresses.
void CopyFrom(const uint8_t buffer[2])
void CopyFrom(const uint8_t buffer[8])
holds a vector of ns3::NetDevice pointers
std::vector< Ptr< NetDevice > >::const_iterator Iterator
NetDevice container iterator.
Iterator Begin() const
Get an iterator which refers to the first NetDevice in the container.
Iterator End() const
Get an iterator which indicates past-the-last NetDevice in the 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.
Iterator Begin() const
Get an iterator which refers to the first Node in the container.
uint32_t AddDevice(Ptr< NetDevice > device)
Associate a NetDevice to this node.
std::ostream * GetStream()
Return a pointer to an ostream previously set in the wrapper.
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.
Ptr< PcapFileWrapper > CreateFile(std::string filename, std::ios::openmode filemode, DataLinkType dataLinkType, uint32_t snapLen=std::numeric_limits< uint32_t >::max(), int32_t tzCorrection=0)
Create and initialize a pcap file.
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.
#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.
LrWpanMacState
MAC states.
LrWpanPhyEnumeration
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_BUSY_RX
@ IEEE_802_15_4_PHY_UNSUPPORTED_ATTRIBUTE
@ IEEE_802_15_4_PHY_SUCCESS
@ IEEE_802_15_4_PHY_UNSPECIFIED
@ IEEE_802_15_4_PHY_TRX_OFF
@ IEEE_802_15_4_PHY_FORCE_TRX_OFF
@ IEEE_802_15_4_PHY_BUSY_TX
@ IEEE_802_15_4_PHY_RX_ON
@ IEEE_802_15_4_PHY_TX_ON
@ IEEE_802_15_4_PHY_INVALID_PARAMETER
@ IEEE_802_15_4_PHY_READ_ONLY
auto MakeBoundCallback(R(*fnPtr)(Args...), BArgs &&... bargs)
Make Callbacks with varying number of bound arguments.
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.