21 #include "ns3/trace-helper.h"
23 #include "ns3/error-rate-model.h"
24 #include "ns3/propagation-loss-model.h"
25 #include "ns3/propagation-delay-model.h"
26 #include "ns3/yans-wifi-channel.h"
27 #include "ns3/yans-wifi-phy.h"
28 #include "ns3/wifi-net-device.h"
29 #include "ns3/radiotap-header.h"
30 #include "ns3/pcap-file-wrapper.h"
31 #include "ns3/simulator.h"
32 #include "ns3/config.h"
33 #include "ns3/names.h"
34 #include "ns3/abort.h"
50 NS_LOG_FUNCTION (stream << context << p << mode << preamble << txLevel);
117 factory.
Set (n0, v0);
118 factory.
Set (n1, v1);
119 factory.
Set (n2, v2);
120 factory.
Set (n3, v3);
121 factory.
Set (n4, v4);
122 factory.
Set (n5, v5);
123 factory.
Set (n6, v6);
124 factory.
Set (n7, v7);
141 factory.
Set (n0, v0);
142 factory.
Set (n1, v1);
143 factory.
Set (n2, v2);
144 factory.
Set (n3, v3);
145 factory.
Set (n4, v4);
146 factory.
Set (n5, v5);
147 factory.
Set (n6, v6);
148 factory.
Set (n7, v7);
166 channel->SetPropagationLossModel (cur);
171 channel->SetPropagationDelayModel (delay);
178 return c->AssignStreams (stream);
252 uint16_t channelFreqMhz,
253 uint16_t channelNumber,
255 bool isShortPreamble,
267 NS_FATAL_ERROR (
"PcapSniffTxEvent(): DLT_PRISM_HEADER not implemented");
288 uint16_t channelFlags = 0;
303 if (channelFreqMhz < 2500)
320 NS_ABORT_MSG (
"PcapSniffTxEvent(): Unexpected data link type " << dlt);
328 uint16_t channelFreqMhz,
329 uint16_t channelNumber,
331 bool isShortPreamble,
344 NS_FATAL_ERROR (
"PcapSniffRxEvent(): DLT_PRISM_HEADER not implemented");
365 uint16_t channelFlags = 0;
380 if (channelFreqMhz < 2500)
399 NS_ABORT_MSG (
"PcapSniffRxEvent(): Unexpected data link type " << dlt);
418 NS_ABORT_MSG (
"YansWifiPhyHelper::SetPcapFormat(): Unexpected format");
439 NS_LOG_INFO (
"YansWifiHelper::EnablePcapInternal(): Device " << &device <<
" not of type ns3::WifiNetDevice");
444 NS_ABORT_MSG_IF (phy == 0,
"YansWifiPhyHelper::EnablePcapInternal(): Phy layer in WifiNetDevice must be set");
448 std::string filename;
449 if (explicitFilename)
469 bool explicitFilename)
479 NS_LOG_INFO (
"YansWifiHelper::EnableAsciiInternal(): Device " << device <<
" not of type ns3::WifiNetDevice");
489 uint32_t nodeid = nd->GetNode ()->GetId ();
490 uint32_t deviceid = nd->GetIfIndex ();
491 std::ostringstream oss;
508 std::string filename;
509 if (explicitFilename)
526 oss <<
"/NodeList/" << nodeid <<
"/DeviceList/" << deviceid <<
"/$ns3::WifiNetDevice/Phy/State/RxOk";
530 oss <<
"/NodeList/" << nodeid <<
"/DeviceList/" << deviceid <<
"/$ns3::WifiNetDevice/Phy/State/Tx";
544 oss <<
"/NodeList/" << nodeid <<
"/DeviceList/" << deviceid <<
"/$ns3::WifiNetDevice/Phy/State/RxOk";
548 oss <<
"/NodeList/" << nodeid <<
"/DeviceList/" << deviceid <<
"/$ns3::WifiNetDevice/Phy/State/Tx";
void AddPropagationLoss(std::string name, std::string n0="", const AttributeValue &v0=EmptyAttributeValue(), std::string n1="", const AttributeValue &v1=EmptyAttributeValue(), std::string n2="", const AttributeValue &v2=EmptyAttributeValue(), std::string n3="", const AttributeValue &v3=EmptyAttributeValue(), std::string n4="", const AttributeValue &v4=EmptyAttributeValue(), std::string n5="", const AttributeValue &v5=EmptyAttributeValue(), std::string n6="", const AttributeValue &v6=EmptyAttributeValue(), std::string n7="", const AttributeValue &v7=EmptyAttributeValue())
uint32_t GetPcapDataLinkType(void) const
Get the data link type of PCAP traces to be used.
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 "...
void SetErrorRateModel(std::string name, std::string n0="", const AttributeValue &v0=EmptyAttributeValue(), std::string n1="", const AttributeValue &v1=EmptyAttributeValue(), std::string n2="", const AttributeValue &v2=EmptyAttributeValue(), std::string n3="", const AttributeValue &v3=EmptyAttributeValue(), std::string n4="", const AttributeValue &v4=EmptyAttributeValue(), std::string n5="", const AttributeValue &v5=EmptyAttributeValue(), std::string n6="", const AttributeValue &v6=EmptyAttributeValue(), std::string n7="", const AttributeValue &v7=EmptyAttributeValue())
#define NS_ABORT_MSG(msg)
Unconditional abnormal program termination with a message.
void SetErrorRateModel(Ptr< ErrorRateModel > rate)
Sets the error rate model.
static void AsciiPhyReceiveSinkWithoutContext(Ptr< OutputStreamWrapper > stream, Ptr< const Packet > p, double snr, WifiMode mode, enum WifiPreamble preamble)
void SetNext(Ptr< PropagationLossModel > next)
Enables a chain of loss models to act on the signal.
Ptr< YansWifiChannel > Create(void) const
Make it easy to create and manage PHY objects for the yans model.
static YansWifiChannelHelper Default(void)
Create a channel helper in a default working state.
Hold a value for an Attribute.
Manage pcap files for device models.
void Write(Time t, Ptr< const Packet > p)
Write the next packet to file.
Include Prism monitor mode information.
Callback< R > MakeBoundCallback(R(*fnPtr)(TX), ARG a1)
Make Callbacks with one bound argument.
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
void SetPcapDataLinkType(enum SupportedPcapDataLinkTypes dlt)
Set the data link type of PCAP traces to be used.
void SetTypeId(TypeId tid)
Set the TypeId of the Objects to be created by this factory.
virtual void EnableAsciiInternal(Ptr< OutputStreamWrapper > stream, std::string prefix, Ptr< NetDevice > nd, bool explicitFilename)
Enable ascii trace output on the indicated net device.
static void AsciiPhyReceiveSinkWithContext(Ptr< OutputStreamWrapper > stream, std::string context, Ptr< const Packet > p, double snr, WifiMode mode, enum WifiPreamble preamble)
#define NS_LOG_INFO(msg)
Use NS_LOG to output a message of level LOG_INFO.
#define NS_FATAL_ERROR(msg)
Fatal error handling.
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 Set(std::string name, const AttributeValue &v)
static YansWifiPhyHelper Default(void)
Create a phy helper in a default working state.
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...
YansWifiChannelHelper()
Create a channel helper without any parameter set.
represent a single transmission modeA WifiMode is implemented by a single integer which is used to lo...
Include Radiotap link layer information.
the interface for Wifi's error models
IEEE 802.11 Wireless LAN headers on packets.
WifiPreamble
The type of preamble to be used by an IEEE 802.11 transmission.
void SetChannel(Ptr< YansWifiChannel > channel)
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...
uint32_t GetDataLinkType(void)
Returns the data link type field of the pcap file as defined by the network field in the pcap global ...
static void EnablePrinting(void)
Enable printing packets metadata.
Ptr< Object > Create(void) const
Create an Object instance of the configured TypeId.
calculate a propagation delay.
Hold together all Wifi-related objects.
void ConnectWithoutContext(std::string path, const CallbackBase &cb)
YansWifiPhyHelper()
Create a phy helper without any parameter set.
void Connect(std::string path, const CallbackBase &cb)
static void PcapSniffRxEvent(Ptr< PcapFileWrapper > file, Ptr< const Packet > packet, uint16_t channelFreqMhz, uint16_t channelNumber, uint32_t rate, bool isShortPreamble, double signalDbm, double noiseDbm)
void SetChannel(Ptr< YansWifiChannel > channel)
Set the YansWifiChannel this YansWifiPhy is to be connected to.
void SetDevice(Ptr< Object > device)
Sets the device this PHY is associated with.
Ptr< Packet > Copy(void) const
performs a COW copy of the packet.
ObjectFactory m_errorRateModel
bool TraceConnectWithoutContext(std::string name, const CallbackBase &cb)
Connect a TraceSource to a Callback without a context.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
802.11 PHY layer modelThis PHY implements a model of 802.11a.
virtual void EnablePcapInternal(std::string prefix, Ptr< NetDevice > nd, bool promiscuous, bool explicitFilename)
Enable pcap output the indicated net device.
Ptr< YansWifiChannel > m_channel
void Set(std::string name, const AttributeValue &value)
Set an attribute to be set during construction.
manage and create wifi channel objects for the yans model.
static Time Now(void)
Return the current simulation virtual time.
ObjectFactory m_propagationDelay
Instantiate subclasses of ns3::Object.
static void PcapSniffTxEvent(Ptr< PcapFileWrapper > file, Ptr< const Packet > packet, uint16_t channelFreqMhz, uint16_t channelNumber, uint32_t rate, bool isShortPreamble, uint8_t txPower)
Models the propagation loss through a transmission medium.
#define NS_ABORT_MSG_IF(cond, msg)
Abnormal program termination if a condition is true, with a message.
void SetMobility(Ptr< Object > mobility)
Sets the mobility model.
virtual Ptr< WifiPhy > Create(Ptr< Node > node, Ptr< NetDevice > device) const
Ptr< PcapFileWrapper > CreateFile(std::string filename, std::ios::openmode filemode, uint32_t dataLinkType, uint32_t snapLen=std::numeric_limits< uint32_t >::max(), int32_t tzCorrection=0)
Create and initialize a pcap file.
void SetPropagationDelay(std::string name, std::string n0="", const AttributeValue &v0=EmptyAttributeValue(), std::string n1="", const AttributeValue &v1=EmptyAttributeValue(), std::string n2="", const AttributeValue &v2=EmptyAttributeValue(), std::string n3="", const AttributeValue &v3=EmptyAttributeValue(), std::string n4="", const AttributeValue &v4=EmptyAttributeValue(), std::string n5="", const AttributeValue &v5=EmptyAttributeValue(), std::string n6="", const AttributeValue &v6=EmptyAttributeValue(), std::string n7="", const AttributeValue &v7=EmptyAttributeValue())
std::vector< ObjectFactory > m_propagationLoss
static void AsciiPhyTransmitSinkWithContext(Ptr< OutputStreamWrapper > stream, std::string context, Ptr< const Packet > p, WifiMode mode, WifiPreamble preamble, uint8_t txLevel)
std::ostream * GetStream(void)
Return a pointer to an ostream previously set in the wrapper.
SupportedPcapDataLinkTypes
An enumeration of the pcap data link types (DLTs) which this helper supports.
void AddHeader(const Header &header)
Add header to this packet.
int64_t AssignStreams(Ptr< YansWifiChannel > c, int64_t stream)
Assign a fixed random variable stream number to the random variables used by the channel.
static void AsciiPhyTransmitSinkWithoutContext(Ptr< OutputStreamWrapper > stream, Ptr< const Packet > p, WifiMode mode, WifiPreamble preamble, uint8_t txLevel)