23 #include <ns3/lr-wpan-csmaca.h> 24 #include <ns3/lr-wpan-error-model.h> 25 #include <ns3/lr-wpan-net-device.h> 26 #include <ns3/mobility-model.h> 27 #include <ns3/single-model-spectrum-channel.h> 28 #include <ns3/multi-model-spectrum-channel.h> 29 #include <ns3/propagation-loss-model.h> 30 #include <ns3/propagation-delay-model.h> 32 #include "ns3/names.h" 68 m_channel = CreateObject<SingleModelSpectrumChannel> ();
71 m_channel->AddPropagationLossModel (lossModel);
74 m_channel->SetPropagationDelayModel (delayModel);
79 if (useMultiModelSpectrumChannel)
81 m_channel = CreateObject<MultiModelSpectrumChannel> ();
85 m_channel = CreateObject<SingleModelSpectrumChannel> ();
88 m_channel->AddPropagationLossModel (lossModel);
91 m_channel->SetPropagationDelayModel (delayModel);
121 return std::string (
"BUSY");
123 return std::string (
"BUSY_RX");
125 return std::string (
"BUSY_TX");
127 return std::string (
"FORCE_TRX_OFF");
129 return std::string (
"IDLE");
131 return std::string (
"INVALID_PARAMETER");
133 return std::string (
"RX_ON");
135 return std::string (
"SUCCESS");
137 return std::string (
"TRX_OFF");
139 return std::string (
"TX_ON");
141 return std::string (
"UNSUPPORTED_ATTRIBUTE");
143 return std::string (
"READ_ONLY");
145 return std::string (
"UNSPECIFIED");
147 return std::string (
"INVALID");
157 return std::string (
"MAC_IDLE");
159 return std::string (
"CHANNEL_ACCESS_FAILURE");
161 return std::string (
"CHANNEL_IDLE");
163 return std::string (
"SET_PHY_TX_ON");
165 return std::string (
"INVALID");
172 phy->SetMobility (m);
186 netDevice->SetNode (node);
218 int64_t currentStream = stream;
226 currentStream += lrwpan->AssignStreams (currentStream);
229 return (currentStream - stream);
244 idBuf[0] = (
id >> 8) & 0xff;
245 idBuf[1] = (
id >> 0) & 0xff;
249 device->GetMac ()->SetPanId (panId);
250 device->GetMac ()->SetShortAddress (
address);
267 NS_LOG_DEBUG(
"The Beacon Order must be an int between 0 and 14");
272 if ((sfrmOrd > 14) || (sfrmOrd > bcnOrd))
274 NS_LOG_DEBUG(
"The Superframe Order must be an int between 0 and 14, and less or equal to Beacon Order");
283 idBuf[0] = (
id >> 8) & 0xff;
284 idBuf[1] = (
id >> 0) & 0xff;
287 device->GetMac ()->SetShortAddress (
address);
301 device->GetMac (), params);
305 device->GetMac ()->SetPanId (panId);
306 device->GetMac ()->SetAssociatedCoor(coor);
328 NS_LOG_FUNCTION (
this << prefix << nd << promiscuous << explicitFilename);
342 NS_LOG_INFO (
"LrWpanHelper::EnablePcapInternal(): Device " << device <<
" not of type ns3::LrWpanNetDevice");
348 std::string filename;
349 if (explicitFilename)
361 if (promiscuous ==
true)
377 bool explicitFilename)
379 uint32_t nodeid = nd->GetNode ()->GetId ();
380 uint32_t deviceid = nd->GetIfIndex ();
381 std::ostringstream oss;
386 NS_LOG_INFO (
"LrWpanHelper::EnableAsciiInternal(): Device " << device <<
" not of type ns3::LrWpanNetDevice");
411 std::string filename;
412 if (explicitFilename)
453 oss <<
"/NodeList/" << nodeid <<
"/DeviceList/" << deviceid <<
"/$ns3::LrWpanNetDevice/Mac/MacRx";
457 oss <<
"/NodeList/" << nodeid <<
"/DeviceList/" << deviceid <<
"/$ns3::LrWpanNetDevice/Mac/MacTx";
461 oss <<
"/NodeList/" << nodeid <<
"/DeviceList/" << deviceid <<
"/$ns3::LrWpanNetDevice/Mac/MacTxEnqueue";
465 oss <<
"/NodeList/" << nodeid <<
"/DeviceList/" << deviceid <<
"/$ns3::LrWpanNetDevice/Mac/MacTxDequeue";
469 oss <<
"/NodeList/" << nodeid <<
"/DeviceList/" << deviceid <<
"/$ns3::LrWpanNetDevice/Mac/MacTxDrop";
static EventId Schedule(Time const &delay, FUNC f, Ts &&... args)
Schedule an event to expire after delay.
NetDeviceContainer Install(NodeContainer c)
Install a LrWpanNetDevice and the associated structures (e.g., channel) in the nodes.
Simulation virtual time values and global simulation resolution.
Manage ASCII trace files for device models.
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by "...
static void DefaultEnqueueSinkWithContext(Ptr< OutputStreamWrapper > file, std::string context, Ptr< const Packet > p)
Basic Enqueue default trace sink.
Class that implements the LR-WPAN MAC state machine.
static std::string LrWpanPhyEnumerationPrinter(LrWpanPhyEnumeration e)
Transform the LrWpanPhyEnumeration enumeration into a printable string.
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::vector< Ptr< Node > >::const_iterator Iterator
Node container iterator.
Iterator End(void) const
Get an iterator which indicates past-the-last NetDevice in the container.
Manage pcap files for device models.
Callback< R > MakeBoundCallback(R(*fnPtr)(TX), ARG a1)
Make Callbacks with one bound argument.
static void DefaultDropSinkWithContext(Ptr< OutputStreamWrapper > file, std::string context, Ptr< const Packet > p)
Basic Drop default trace sink.
static std::string LrWpanMacStatePrinter(LrWpanMacState e)
Transform the LrWpanMacState enumeration into a printable string.
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Time MilliSeconds(uint64_t value)
Construct a Time in the indicated unit.
void AssociateToPan(NetDeviceContainer c, uint16_t panId)
Associate the nodes to the same PAN.
#define NS_LOG_INFO(msg)
Use NS_LOG to output a message of level LOG_INFO.
void(* Time)(Time oldValue, Time newValue)
TracedValue callback signature for Time.
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. ...
TimeWithUnit As(const enum Unit unit) const
Attach a unit to a Time, to facilitate output in a specific unit.
Iterator End(void) const
Get an iterator which indicates past-the-last Node in the container.
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 ...
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...
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.
Network layer to device interface.
MLME-START.request params.
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...
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...
void LogComponentEnable(char const *name, enum LogLevel level)
Enable the logging output associated with that log component.
uint8_t m_sfrmOrd
Superframe Order, indicates the length of the CAP in time slots.
static void EnablePrinting(void)
Enable printing packets metadata.
Iterator Begin(void) const
Get an iterator which refers to the first NetDevice in the container.
holds a vector of ns3::NetDevice pointers
static void AsciiLrWpanMacTransmitSinkWithoutContext(Ptr< OutputStreamWrapper > stream, Ptr< const Packet > p)
Output an ascii line representing the Transmit event (without context)
uint8_t m_bcnOrd
Beacon Order, Used to calculate the beacon interval, a value of 15 indicates no periodic beacons will...
int64_t AssignStreams(NetDeviceContainer c, int64_t stream)
Assign a fixed random variable stream number to the random variables used by this model...
virtual void EnablePcapInternal(std::string prefix, Ptr< NetDevice > nd, bool promiscuous, bool explicitFilename)
Enable pcap output on the indicated net device.
static void DefaultReceiveSinkWithContext(Ptr< OutputStreamWrapper > file, std::string context, Ptr< const Packet > p)
Basic Receive default trace sink.
uint16_t m_PanId
Pan Identifier used by the device.
Ptr< SpectrumChannel > m_channel
channel to be used for the devices
static void AsciiLrWpanMacTransmitSinkWithContext(Ptr< OutputStreamWrapper > stream, std::string context, Ptr< const Packet > p)
Output an ascii line representing the Transmit event (with context)
void LogComponentEnableAll(enum LogLevel level)
Enable the logging output for all registered log components.
Prefix all trace prints with simulation time.
static void DefaultDequeueSinkWithContext(Ptr< OutputStreamWrapper > file, std::string context, Ptr< const Packet > p)
Basic Dequeue default trace sink.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
keep track of a set of node pointers.
LrWpanHelper(void)
Create a LrWpan helper in an empty state.
This class can contain 16 bit addresses.
static Time Now(void)
Return the current simulation virtual time.
virtual void EnableAsciiInternal(Ptr< OutputStreamWrapper > stream, std::string prefix, Ptr< NetDevice > nd, bool explicitFilename)
Enable ascii trace output on the indicated net device.
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 ...
void SetChannel(Ptr< SpectrumChannel > channel)
Set the channel associated to this helper.
void AssociateToBeaconPan(NetDeviceContainer c, uint16_t panId, Mac16Address coor, uint8_t bcnOrd, uint8_t sfrmOrd)
Associate the nodes to the same PAN and initiate beacon enabled mode.
uint32_t AddDevice(Ptr< NetDevice > device)
Associate a NetDevice to this node.
Prefix all trace prints with function.
std::vector< Ptr< NetDevice > >::const_iterator Iterator
NetDevice container iterator.
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
LrWpanMacState
MAC states.
Ptr< SpectrumChannel > GetChannel(void)
Get the channel associated to this helper.
bool m_panCoor
On true this device will become coordinator.
void AddMobility(Ptr< LrWpanPhy > phy, Ptr< MobilityModel > m)
Add mobility model to a physical device.
LrWpanPhyEnumeration
IEEE802.15.4-2006 PHY Emumerations Table 18 in section 6.2.3.
virtual ~LrWpanHelper(void)
void EnableLogComponents(void)
Helper to enable all LrWpan log components with one statement.
std::ostream * GetStream(void)
Return a pointer to an ostream previously set in the wrapper.
static void PcapSniffLrWpan(Ptr< PcapFileWrapper > file, Ptr< const Packet > packet)
Write a packet in a PCAP file.
Iterator Begin(void) const
Get an iterator which refers to the first Node in the container.
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 ...