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/propagation-loss-model.h>
65 m_channel = CreateObject<SingleModelSpectrumChannel> ();
67 m_channel->AddPropagationLossModel (model);
97 return std::string (
"BUSY");
99 return std::string (
"BUSY_RX");
101 return std::string (
"BUSY_TX");
103 return std::string (
"FORCE_TRX_OFF");
105 return std::string (
"IDLE");
107 return std::string (
"INVALID_PARAMETER");
109 return std::string (
"RX_ON");
111 return std::string (
"SUCCESS");
113 return std::string (
"TRX_OFF");
115 return std::string (
"TX_ON");
117 return std::string (
"UNSUPPORTED_ATTRIBUTE");
119 return std::string (
"READ_ONLY");
121 return std::string (
"UNSPECIFIED");
123 return std::string (
"INVALID");
133 return std::string (
"MAC_IDLE");
135 return std::string (
"CHANNEL_ACCESS_FAILURE");
137 return std::string (
"CHANNEL_IDLE");
139 return std::string (
"SET_PHY_TX_ON");
141 return std::string (
"INVALID");
148 phy->SetMobility (m);
162 netDevice->SetNode (node);
165 devices.
Add (netDevice);
173 int64_t currentStream = stream;
181 currentStream += lrwpan->AssignStreams (currentStream);
184 return (currentStream - stream);
199 idBuf[0] = (
id >> 8) & 0xff;
200 idBuf[1] = (
id >> 0) & 0xff;
204 device->GetMac ()->SetPanId (panId);
205 device->GetMac ()->SetShortAddress (address);
226 NS_LOG_FUNCTION (
this << prefix << nd << promiscuous << explicitFilename);
240 NS_LOG_INFO (
"LrWpanHelper::EnablePcapInternal(): Device " << device <<
" not of type ns3::LrWpanNetDevice");
246 std::string filename;
247 if (explicitFilename)
259 if (promiscuous ==
true)
275 bool explicitFilename)
277 uint32_t nodeid = nd->GetNode ()->GetId ();
278 uint32_t deviceid = nd->GetIfIndex ();
279 std::ostringstream oss;
284 NS_LOG_INFO (
"LrWpanHelper::EnableAsciiInternal(): Device " << device <<
" not of type ns3::LrWpanNetDevice");
309 std::string filename;
310 if (explicitFilename)
351 oss <<
"/NodeList/" << nodeid <<
"/DeviceList/" << deviceid <<
"/$ns3::LrWpanNetDevice/Mac/MacRx";
355 oss <<
"/NodeList/" << nodeid <<
"/DeviceList/" << deviceid <<
"/$ns3::LrWpanNetDevice/Mac/MacTx";
359 oss <<
"/NodeList/" << nodeid <<
"/DeviceList/" << deviceid <<
"/$ns3::LrWpanNetDevice/Mac/MacTxEnqueue";
363 oss <<
"/NodeList/" << nodeid <<
"/DeviceList/" << deviceid <<
"/$ns3::LrWpanNetDevice/Mac/MacTxDequeue";
367 oss <<
"/NodeList/" << nodeid <<
"/DeviceList/" << deviceid <<
"/$ns3::LrWpanNetDevice/Mac/MacTxDrop";
void LogComponentEnableAll(enum LogLevel level)
Enable the logging output for all registered log components.
NetDeviceContainer Install(NodeContainer c)
Install a LrWpanNetDevice and the associated structures (e.g., channel) in the nodes.
Iterator Begin(void) const
Get an iterator which refers to the first NetDevice in the container.
LrWpanMacState
MAC states.
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.
Ptr< PcapFileWrapper > CreateFile(std::string filename, std::ios::openmode filemode, uint32_t dataLinkType, uint32_t snapLen=65535, int32_t tzCorrection=0)
Create and initialize a pcap file.
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.
Manage pcap files for device models.
void Write(Time t, Ptr< const Packet > p)
Write the next packet to file.
Callback< R > MakeBoundCallback(R(*fnPtr)(TX), ARG a1)
Make Callbacks with one bound argument.
void CopyFrom(const uint8_t buffer[2])
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.
Iterator End(void) const
Get an iterator which indicates past-the-last Node in the container.
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.
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 ...
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...
Network layer to device interface.
double GetSeconds(void) const
Get an approximation of the time stored in this instance in the indicated unit.
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...
static void EnablePrinting(void)
Enable printing packets metadata.
void Add(NetDeviceContainer other)
Append the contents of another NetDeviceContainer to the end of this 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)
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.
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 DefaultDequeueSinkWithContext(Ptr< OutputStreamWrapper > file, std::string context, Ptr< const Packet > p)
Basic Dequeue default trace sink.
keep track of a set of node pointers.
prefix all trace prints with simulation time
LrWpanHelper(void)
Create a LrWpan helper in an empty state.
Iterator Begin(void) const
Get an iterator which refers to the first Node in the container.
prefix all trace prints with function
This class can contain 16 bit addresses.
static Time Now(void)
Return the "current simulation 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 ...
uint32_t AddDevice(Ptr< NetDevice > device)
Associate a NetDevice to this node.
std::vector< Ptr< NetDevice > >::const_iterator Iterator
NetDevice container iterator.
Ptr< SingleModelSpectrumChannel > m_channel
channel to be used for the devices
void AddMobility(Ptr< LrWpanPhy > phy, Ptr< MobilityModel > m)
Add mobility model to a physical device.
virtual ~LrWpanHelper(void)
Iterator End(void) const
Get an iterator which indicates past-the-last NetDevice in the container.
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.
LrWpanPhyEnumeration
IEEE802.15.4-2006 PHY Emumerations Table 18 in section 6.2.3.
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 ...
void LogComponentEnable(char const *name, enum LogLevel level)
Enable the logging output associated with that log component.
Ptr< LrWpanMac > GetMac(void) const
Get the MAC used by this NetDevice.