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");
433 NS_LOG_INFO (
"YansWifiHelper::EnablePcapInternal(): Device " << &device <<
" not of type ns3::WifiNetDevice");
438 NS_ABORT_MSG_IF (phy == 0,
"YansWifiPhyHelper::EnablePcapInternal(): Phy layer in WifiNetDevice must be set");
442 std::string filename;
443 if (explicitFilename)
463 bool explicitFilename)
473 NS_LOG_INFO (
"YansWifiHelper::EnableAsciiInternal(): Device " << device <<
" not of type ns3::WifiNetDevice");
483 uint32_t nodeid = nd->GetNode ()->GetId ();
484 uint32_t deviceid = nd->GetIfIndex ();
485 std::ostringstream oss;
502 std::string filename;
503 if (explicitFilename)
520 oss <<
"/NodeList/" << nodeid <<
"/DeviceList/" << deviceid <<
"/$ns3::WifiNetDevice/Phy/State/RxOk";
524 oss <<
"/NodeList/" << nodeid <<
"/DeviceList/" << deviceid <<
"/$ns3::WifiNetDevice/Phy/State/Tx";
538 oss <<
"/NodeList/" << nodeid <<
"/DeviceList/" << deviceid <<
"/$ns3::WifiNetDevice/Phy/State/RxOk";
542 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())
Manage ASCII trace files for device models.
#define NS_LOG_FUNCTION(parameters)
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())
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.
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)
Build bound Callbacks which take varying numbers of arguments, and potentially returning a value...
void SetPcapDataLinkType(enum SupportedPcapDataLinkTypes dlt)
Set the data link type of PCAP traces to be used.
void SetTypeId(TypeId tid)
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)
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.
void Connect(std::string path, const CallbackBase &cb)
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.
#define NS_FATAL_ERROR(msg)
fatal error handling
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
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)
static void EnablePrinting(void)
By default, packets do not keep around enough metadata to perform the operations requested by the Pri...
Ptr< Object > Create(void) const
calculate a propagation delay.
Hold together all Wifi-related objects.
YansWifiPhyHelper()
Create a phy helper without any parameter set.
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
ObjectFactory m_errorRateModel
bool TraceConnectWithoutContext(std::string name, const CallbackBase &cb)
802.11 PHY layer modelThis PHY implements a model of 802.11a.
virtual Ptr< WifiPhy > Create(Ptr< Node > node, Ptr< WifiNetDevice > device) const
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)
manage and create wifi channel objects for the yans model.
static Time Now(void)
Return the "current simulation time".
ObjectFactory m_propagationDelay
#define NS_ABORT_MSG(msg)
Abnormal program termination.
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)
Modelize the propagation loss through a transmission medium.
void SetMobility(Ptr< Object > mobility)
Sets the mobility model.
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
#define NS_ABORT_MSG_IF(cond, msg)
Abnormal program termination if cond is true.
NS_LOG_COMPONENT_DEFINE("YansWifiHelper")
static void AsciiPhyTransmitSinkWithContext(Ptr< OutputStreamWrapper > stream, std::string context, Ptr< const Packet > p, WifiMode mode, WifiPreamble preamble, uint8_t txLevel)
void ConnectWithoutContext(std::string path, const CallbackBase &cb)
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)