24 #include "ns3/wifi-net-device.h"
25 #include "ns3/wifi-mac.h"
26 #include "ns3/regular-wifi-mac.h"
27 #include "ns3/dca-txop.h"
28 #include "ns3/edca-txop-n.h"
29 #include "ns3/minstrel-wifi-manager.h"
30 #include "ns3/ap-wifi-mac.h"
31 #include "ns3/wifi-phy.h"
32 #include "ns3/ampdu-subframe-header.h"
33 #include "ns3/wifi-remote-station-manager.h"
34 #include "ns3/wifi-channel.h"
35 #include "ns3/yans-wifi-channel.h"
36 #include "ns3/propagation-delay-model.h"
37 #include "ns3/propagation-loss-model.h"
38 #include "ns3/mobility-model.h"
40 #include "ns3/pointer.h"
41 #include "ns3/radiotap-header.h"
42 #include "ns3/pcap-file-wrapper.h"
43 #include "ns3/abort.h"
44 #include "ns3/config.h"
45 #include "ns3/simulator.h"
46 #include "ns3/names.h"
61 NS_LOG_FUNCTION (stream << context << p << mode << preamble << txLevel);
144 uint16_t channelFreqMhz,
145 uint16_t channelNumber,
151 uint32_t dlt = file->GetDataLinkType ();
160 NS_FATAL_ERROR (
"PcapSniffTxEvent(): DLT_PRISM_HEADER not implemented");
186 uint16_t channelFlags = 0;
201 if (channelFreqMhz < 2500)
219 mcsRate = rate - 128;
240 if (txVector.
GetNess () & 0x01)
244 if (txVector.
GetNess () & 0x02)
266 uint32_t extractedLength;
269 p = p->
CreateFragment (0, static_cast<uint32_t> (extractedLength));
281 uint8_t vhtBandwidth = 0;
282 uint8_t vhtMcsNss[4] = {0,0,0,0};
283 uint8_t vhtCoding = 0;
284 uint8_t vhtGroupId = 0;
285 uint16_t vhtPartialAid = 0;
317 vhtMcsNss[0] |= (txVector.
GetNss () & 0x0f);
318 vhtMcsNss[0] |= (((rate - 128) << 4) & 0xf0);
320 header.
SetVhtFields (vhtKnown, vhtFlags, vhtBandwidth, vhtMcsNss, vhtCoding, vhtGroupId, vhtPartialAid);
328 NS_ABORT_MSG (
"PcapSniffTxEvent(): Unexpected data link type " << dlt);
336 uint16_t channelFreqMhz,
337 uint16_t channelNumber,
344 uint32_t dlt = file->GetDataLinkType ();
353 NS_FATAL_ERROR (
"PcapSniffRxEvent(): DLT_PRISM_HEADER not implemented");
379 uint16_t channelFlags = 0;
394 if (channelFreqMhz < 2500)
415 mcsRate = rate - 128;
436 if (txVector.
GetNess () & 0x01)
440 if (txVector.
GetNess () & 0x02)
463 uint32_t extractedLength;
466 p = p->
CreateFragment (0, static_cast<uint32_t> (extractedLength));
478 uint8_t vhtBandwidth = 0;
479 uint8_t vhtMcsNss[4] = {0,0,0,0};
480 uint8_t vhtCoding = 0;
481 uint8_t vhtGroupId = 0;
482 uint16_t vhtPartialAid = 0;
514 vhtMcsNss[0] |= (txVector.
GetNss () & 0x0f);
515 vhtMcsNss[0] |= (((rate - 128) << 4) & 0xf0);
517 header.
SetVhtFields (vhtKnown, vhtFlags, vhtBandwidth, vhtMcsNss, vhtCoding, vhtGroupId, vhtPartialAid);
525 NS_ABORT_MSG (
"PcapSniffRxEvent(): Unexpected data link type " << dlt);
544 NS_ABORT_MSG (
"WifiPhyHelper::SetPcapFormat(): Unexpected format");
563 NS_LOG_INFO (
"WifiHelper::EnablePcapInternal(): Device " << &device <<
" not of type ns3::WifiNetDevice");
568 NS_ABORT_MSG_IF (phy == 0,
"WifiPhyHelper::EnablePcapInternal(): Phy layer in WifiNetDevice must be set");
572 std::string filename;
573 if (explicitFilename)
593 bool explicitFilename)
601 NS_LOG_INFO (
"WifiHelper::EnableAsciiInternal(): Device " << device <<
" not of type ns3::WifiNetDevice");
609 uint32_t nodeid = nd->GetNode ()->GetId ();
610 uint32_t deviceid = nd->GetIfIndex ();
611 std::ostringstream oss;
624 std::string filename;
625 if (explicitFilename)
640 oss <<
"/NodeList/" << nodeid <<
"/DeviceList/" << deviceid <<
"/$ns3::WifiNetDevice/Phy/State/RxOk";
644 oss <<
"/NodeList/" << nodeid <<
"/DeviceList/" << deviceid <<
"/$ns3::WifiNetDevice/Phy/State/Tx";
656 oss <<
"/NodeList/" << nodeid <<
"/DeviceList/" << deviceid <<
"/$ns3::WifiNetDevice/Phy/State/RxOk";
660 oss <<
"/NodeList/" << nodeid <<
"/DeviceList/" << deviceid <<
"/$ns3::WifiNetDevice/Phy/State/Tx";
726 device->SetMac (mac);
727 device->SetPhy (phy);
728 device->SetRemoteStationManager (manager);
730 devices.
Add (device);
747 Ptr<Node> node = Names::Find<Node> (nodeName);
789 int64_t currentStream = stream;
798 currentStream += wifi->GetPhy ()->AssignStreams (currentStream);
805 currentStream += minstrel->AssignStreams (currentStream);
814 rmac->GetAttribute (
"DcaTxop", ptr);
816 currentStream += dcaTxop->AssignStreams (currentStream);
818 rmac->GetAttribute (
"VO_EdcaTxopN", ptr);
820 currentStream += vo_edcaTxopN->
AssignStreams (currentStream);
822 rmac->GetAttribute (
"VI_EdcaTxopN", ptr);
824 currentStream += vi_edcaTxopN->
AssignStreams (currentStream);
826 rmac->GetAttribute (
"BE_EdcaTxopN", ptr);
828 currentStream += be_edcaTxopN->
AssignStreams (currentStream);
830 rmac->GetAttribute (
"BK_EdcaTxopN", ptr);
832 currentStream += bk_edcaTxopN->
AssignStreams (currentStream);
838 currentStream += apmac->AssignStreams (currentStream);
843 return (currentStream - stream);
uint32_t RemoveHeader(Header &header)
Deserialize and remove the header from the internal buffer.
void Set(std::string name, const AttributeValue &v)
Iterator Begin(void) const
Get an iterator which refers to the first NetDevice in the container.
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 "...
#define NS_ABORT_MSG(msg)
Unconditional abnormal program termination with a message.
This class mimics the TXVECTOR which is to be passed to the PHY in order to define the parameters whi...
bool IsAggregation(void) const
Checks whether the PSDU contains A-MPDU.
static void AsciiPhyReceiveSinkWithoutContext(Ptr< OutputStreamWrapper > stream, Ptr< const Packet > p, double snr, WifiMode mode, enum WifiPreamble preamble)
std::vector< Ptr< Node > >::const_iterator Iterator
Node container iterator.
void SetRemoteStationManager(std::string type, 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< T > GetObject(void) const
Get a pointer to the requested aggregated Object.
Hold a value for an Attribute.
Manage pcap files for device models.
Callback< R > MakeBoundCallback(R(*fnPtr)(TX), ARG a1)
Make Callbacks with one bound argument.
PcapHelper::DataLinkType m_pcapDlt
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
void SetTypeId(TypeId tid)
Set the TypeId of the Objects to be created by this factory.
bool IsShortGuardInterval(void) const
Iterator End(void) const
Get an iterator which indicates past-the-last Node in the container.
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)
Report a fatal error with a message and terminate.
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. ...
ObjectFactory m_errorRateModel
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.
helps to create WifiNetDevice objects
represent a single transmission modeA WifiMode is implemented by a single integer which is used to lo...
WifiHelper()
Create a Wifi helper in an empty state: all its parameters must be set before calling ns3::WifiHelper...
void SetPcapDataLinkType(enum SupportedPcapDataLinkTypes dlt)
Set the data link type of PCAP traces to be used.
virtual NetDeviceContainer Install(const WifiPhyHelper &phy, const WifiMacHelper &mac, NodeContainer c) const
virtual void EnableAsciiInternal(Ptr< OutputStreamWrapper > stream, std::string prefix, Ptr< NetDevice > nd, bool explicitFilename)
Enable ascii trace output on the indicated net device.
DataLinkType
This enumeration holds the data link types that will be written to the pcap file. ...
WifiPreamble
The type of preamble to be used by an IEEE 802.11 transmission.
Ptr< Packet > CreateFragment(uint32_t start, uint32_t length) const
Create a new packet which contains a fragment of the original packet.
Keep track of the current position and velocity of an object.
double GetSeconds(void) const
Get an approximation of the time stored in this instance in the indicated unit.
WifiPhyStandard
Identifies the PHY specification that a Wifi device is configured to use.
This queue contains packets for a particular access class.
static void PcapSniffTxEvent(Ptr< PcapFileWrapper > file, Ptr< const Packet > packet, uint16_t channelFreqMhz, uint16_t channelNumber, uint32_t rate, WifiPreamble preamble, WifiTxVector txVector, struct mpduInfo aMpdu)
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.
static Mac48Address Allocate(void)
Allocate a new Mac48Address.
static void EnablePrinting(void)
Enable printing packets metadata.
Ptr< Object > Create(void) const
Create an Object instance of the configured TypeId.
void Add(NetDeviceContainer other)
Append the contents of another NetDeviceContainer to the end of this container.
holds a vector of ns3::NetDevice pointers
virtual void SetStandard(enum WifiPhyStandard standard)
uint8_t GetNess(void) const
uint32_t GetChannelWidth(void) const
int64_t AssignStreams(NetDeviceContainer c, int64_t stream)
Assign a fixed random variable stream number to the random variables used by the Phy and Mac aspects ...
Hold together all Wifi-related objects.
void ConnectWithoutContext(std::string path, const CallbackBase &cb)
int64_t AssignStreams(int64_t stream)
Assign a fixed random variable stream number to the random variables used by this model...
bool IsStbc(void) const
Check if STBC is used or not.
hold a list of per-remote-station state.
void Connect(std::string path, const CallbackBase &cb)
Include Prism monitor mode information.
Ptr< Packet > Copy(void) const
performs a COW copy of the packet.
bool TraceConnectWithoutContext(std::string name, const CallbackBase &cb)
Connect a TraceSource to a Callback without a context.
OFDM PHY for the 5 GHz band (Clause 17)
Every class exported by the ns3 library is enclosed in the ns3 namespace.
keep track of a set of node pointers.
Hold objects of type Ptr.
Iterator Begin(void) const
Get an iterator which refers to the first Node in the container.
void Set(std::string name, const AttributeValue &value)
Set an attribute to be set during construction.
ObjectFactory m_stationManager
create MAC layers for a ns3::WifiNetDevice.
static Time Now(void)
Return the current simulation virtual time.
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())
virtual Ptr< WifiMac > Create(void) const
virtual void EnablePcapInternal(std::string prefix, Ptr< NetDevice > nd, bool promiscuous, bool explicitFilename)
Enable pcap output the indicated net device.
virtual void ConfigureStandard(enum WifiPhyStandard standard)
Configure the PHY-level parameters for different Wi-Fi standard.
Instantiate subclasses of ns3::Object.
static void EnableLogComponents(void)
Helper to enable all WifiNetDevice log components with one statement.
uint8_t GetNss(void) const
virtual Ptr< WifiPhy > Create(Ptr< Node > node, Ptr< NetDevice > device) const =0
uint32_t AddDevice(Ptr< NetDevice > device)
Associate a NetDevice to this node.
#define NS_ABORT_MSG_IF(cond, msg)
Abnormal program termination if a condition is true, with a message.
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.
IEEE 802.11 Wireless LAN headers on packets.
enum WifiPhyStandard m_standard
SupportedPcapDataLinkTypes
An enumeration of the pcap data link types (DLTs) which this helper supports.
Iterator End(void) const
Get an iterator which indicates past-the-last NetDevice in the container.
handle packet fragmentation and retransmissions.
static void PcapSniffRxEvent(Ptr< PcapFileWrapper > file, Ptr< const Packet > packet, uint16_t channelFreqMhz, uint16_t channelNumber, uint32_t rate, WifiPreamble preamble, WifiTxVector txVector, struct mpduInfo aMpdu, struct signalNoiseDbm signalNoise)
Include Radiotap link layer information.
PcapHelper::DataLinkType GetPcapDataLinkType(void) const
Get the data link type of PCAP traces to be used.
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.
void AddHeader(const Header &header)
Add header to this packet.
The MPDU is the last aggregate in an A-MPDU.
static NS_DEPRECATED WifiHelper Default(void)
static void AsciiPhyTransmitSinkWithoutContext(Ptr< OutputStreamWrapper > stream, Ptr< const Packet > p, WifiMode mode, WifiPreamble preamble, uint8_t txLevel)