23 #include "ns3/wifi-net-device.h"
24 #include "ns3/ap-wifi-mac.h"
25 #include "ns3/ampdu-subframe-header.h"
26 #include "ns3/mobility-model.h"
28 #include "ns3/pointer.h"
29 #include "ns3/radiotap-header.h"
30 #include "ns3/config.h"
31 #include "ns3/names.h"
32 #include "ns3/net-device-queue-interface.h"
33 #include "ns3/wifi-mac-queue.h"
34 #include "ns3/qos-utils.h"
35 #include "ns3/qos-txop.h"
36 #include "ns3/ht-configuration.h"
37 #include "ns3/vht-configuration.h"
38 #include "ns3/he-configuration.h"
39 #include "ns3/obss-pd-algorithm.h"
40 #include "ns3/wifi-mac-trailer.h"
65 NS_LOG_FUNCTION (stream << context << p << mode << preamble << txLevel);
66 auto pCopy = p->
Copy ();
68 pCopy->RemoveTrailer (fcs);
89 auto pCopy = p->
Copy ();
91 pCopy->RemoveTrailer (fcs);
114 auto pCopy = p->
Copy ();
116 pCopy->RemoveTrailer (fcs);
137 auto pCopy = p->
Copy ();
139 pCopy->RemoveTrailer (fcs);
169 uint16_t channelFreqMhz,
174 uint32_t dlt =
file->GetDataLinkType ();
182 NS_FATAL_ERROR (
"PcapSniffTxEvent(): DLT_PRISM_HEADER not implemented");
195 NS_ABORT_MSG (
"PcapSniffTxEvent(): Unexpected data link type " << dlt);
203 uint16_t channelFreqMhz,
209 uint32_t dlt =
file->GetDataLinkType ();
217 NS_FATAL_ERROR (
"PcapSniffRxEvent(): DLT_PRISM_HEADER not implemented");
224 GetRadiotapHeader (header, p, channelFreqMhz, txVector, aMpdu, staId, signalNoise);
230 NS_ABORT_MSG (
"PcapSniffRxEvent(): Unexpected data link type " << dlt);
238 uint16_t channelFreqMhz,
253 uint16_t channelFreqMhz,
284 header.
SetRate (
static_cast<uint8_t
> (rate));
287 uint16_t channelFlags = 0;
301 if (channelFreqMhz < 2500)
334 if (txVector.
GetNess () & 0x01)
338 if (txVector.
GetNess () & 0x02)
360 uint32_t extractedLength;
363 packet = packet->
CreateFragment (0,
static_cast<uint32_t
> (extractedLength));
375 uint8_t vhtBandwidth = 0;
376 uint8_t vhtMcsNss[4] = {0,0,0,0};
377 uint8_t vhtCoding = 0;
378 uint8_t vhtGroupId = 0;
379 uint16_t vhtPartialAid = 0;
411 vhtMcsNss[0] |= (txVector.
GetNss (staId) & 0x0f);
414 header.
SetVhtFields (vhtKnown, vhtFlags, vhtBandwidth, vhtMcsNss, vhtCoding, vhtGroupId, vhtPartialAid);
450 data4 |= ((staId << 4) & 0x7ff0);
505 header.
SetHeFields (data1, data2, data3, data4, data5, 0);
511 std::array<uint8_t, 4> ruChannel1, ruChannel2;
532 NS_ABORT_MSG (
"WifiPhyHelper::SetPcapFormat(): Unexpected format");
545 NS_LOG_FUNCTION (
this << prefix << nd << promiscuous << explicitFilename);
553 NS_LOG_INFO (
"WifiHelper::EnablePcapInternal(): Device " << &device <<
" not of type ns3::WifiNetDevice");
558 NS_ABORT_MSG_IF (
phy == 0,
"WifiPhyHelper::EnablePcapInternal(): Phy layer in WifiNetDevice must be set");
562 std::string filename;
563 if (explicitFilename)
583 bool explicitFilename)
591 NS_LOG_INFO (
"WifiHelper::EnableAsciiInternal(): Device " << device <<
" not of type ns3::WifiNetDevice");
601 std::ostringstream oss;
614 std::string filename;
615 if (explicitFilename)
630 oss <<
"/NodeList/" << nodeid <<
"/DeviceList/" << deviceid <<
"/$ns3::WifiNetDevice/Phy/State/RxOk";
634 oss <<
"/NodeList/" << nodeid <<
"/DeviceList/" << deviceid <<
"/$ns3::WifiNetDevice/Phy/State/Tx";
646 oss <<
"/NodeList/" << nodeid <<
"/DeviceList/" << deviceid <<
"/$ns3::WifiNetDevice/Phy/State/RxOk";
650 oss <<
"/NodeList/" << nodeid <<
"/DeviceList/" << deviceid <<
"/$ns3::WifiNetDevice/Phy/State/Tx";
661 m_enableFlowControl (true)
733 obssPdAlgorithm->ConnectWifiNetDevice (device);
743 mac->GetAttributeFailSafe (
"QosSupported", qosSupported);
744 if (qosSupported.
Get ())
746 ndqi = CreateObjectWithAttributes<NetDeviceQueueInterface> (
"NTxQueues",
752 ndqi->GetTxQueue (
static_cast<std::size_t
> (ac))->ConnectQueueTraces (wmq);
758 ndqi = CreateObject<NetDeviceQueueInterface> ();
760 wmq =
mac->GetTxop ()->GetWifiMacQueue ();
761 ndqi->GetTxQueue (0)->ConnectQueueTraces (wmq);
787 Ptr<Node> node = Names::Find<Node> (nodeName);
891 int64_t currentStream = stream;
900 currentStream +=
wifi->GetPhy ()->AssignStreams (currentStream);
903 currentStream +=
wifi->GetRemoteStationManager ()->AssignStreams (currentStream);
908 if (!
mac->GetQosSupported ())
910 mac->GetAttribute (
"Txop", ptr);
916 mac->GetAttribute (
"VO_Txop", ptr);
920 mac->GetAttribute (
"VI_Txop", ptr);
924 mac->GetAttribute (
"BE_Txop", ptr);
928 mac->GetAttribute (
"BK_Txop", ptr);
937 currentStream += apmac->AssignStreams (currentStream);
941 return (currentStream - stream);
double f(double x, void *params)
Manage ASCII trace files for device models.
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< 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.
Hold a value for an Attribute.
AttributeValue implementation for Boolean.
RuType GetRuType(void) const
Get the RU type.
bool GetPrimary80MHz(void) const
Get the primary 80 MHz flag.
std::size_t GetIndex(void) const
Get the RU index.
RuType
The different HE Resource Unit (RU) types.
Keep track of the current position and velocity of an object.
holds a vector of ns3::NetDevice pointers
Iterator End(void) const
Get an iterator which indicates past-the-last NetDevice in the container.
std::vector< Ptr< NetDevice > >::const_iterator Iterator
NetDevice container iterator.
Iterator Begin(void) const
Get an iterator which refers to the first NetDevice in the container.
virtual Ptr< Node > GetNode(void) const =0
virtual uint32_t GetIfIndex(void) const =0
keep track of a set of node pointers.
Iterator Begin(void) const
Get an iterator which refers to the first Node in the container.
Iterator End(void) const
Get an iterator which indicates past-the-last Node in the container.
std::vector< Ptr< Node > >::const_iterator Iterator
Node container iterator.
uint32_t GetId(void) const
uint32_t AddDevice(Ptr< NetDevice > device)
Associate a NetDevice to this node.
void Set(const std::string &name, const AttributeValue &value, Args &&... args)
Set an attribute to be set during construction.
Ptr< Object > Create(void) const
Create an Object instance of the configured TypeId.
bool IsTypeIdSet(void) const
Check if the ObjectFactory has been configured with a TypeId.
void SetTypeId(TypeId tid)
Set the TypeId of the Objects to be created by this factory.
Ptr< T > GetObject(void) const
Get a pointer to the requested aggregated Object.
void AggregateObject(Ptr< Object > other)
Aggregate two Objects together.
OBSS PD algorithm interface.
std::ostream * GetStream(void)
Return a pointer to an ostream previously set in the wrapper.
uint32_t RemoveHeader(Header &header)
Deserialize and remove the header from the internal buffer.
void AddHeader(const Header &header)
Add header to this packet.
Ptr< Packet > CreateFragment(uint32_t start, uint32_t length) const
Create a new packet which contains a fragment of the original packet.
static void EnablePrinting(void)
Enable printing packets metadata.
Ptr< Packet > Copy(void) const
performs a COW copy of the packet.
Manage pcap files for device models.
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.
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.
DataLinkType
This enumeration holds the data link types that will be written to the pcap file.
Hold objects of type Ptr<T>.
Handle packet fragmentation and retransmissions for QoS data frames as well as MSDU aggregation (A-MS...
static Time Now(void)
Return the current simulation virtual time.
double GetSeconds(void) const
Get an approximation of the time stored in this instance in the indicated unit.
Handle packet fragmentation and retransmissions for data and management frames.
int64_t AssignStreams(int64_t stream)
Assign a fixed random variable stream number to the random variables used by this model.
Ptr< WifiMacQueue > GetWifiMacQueue() const
Return the packet queue associated with this Txop.
a unique identifier for an interface.
Hold an unsigned integer type.
void SetRemoteStationManager(std::string type, Args &&... args)
Helper function used to set the station manager.
ObjectFactory m_obssPdAlgorithm
OBSS_PD algorithm.
ObjectFactory m_stationManager
station manager
void SetSelectQueueCallback(SelectQueueCallback f)
static void EnableLogComponents(void)
Helper to enable all WifiNetDevice log components with one statement.
WifiStandard m_standard
wifi standard
void DisableFlowControl(void)
Disable flow control only if you know what you are doing.
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 ...
virtual void SetStandard(WifiStandard standard)
virtual NetDeviceContainer Install(const WifiPhyHelper &phy, const WifiMacHelper &mac, NodeContainer::Iterator first, NodeContainer::Iterator last) const
SelectQueueCallback m_selectQueueCallback
select queue callback
std::function< std::size_t(Ptr< QueueItem >)> SelectQueueCallback
Callback invoked to determine the MAC queue selected for a given packet.
bool m_enableFlowControl
whether to enable flow control
WifiHelper()
Create a Wifi helper in an empty state: all its parameters must be set before calling ns3::WifiHelper...
create MAC layers for a ns3::WifiNetDevice.
virtual Ptr< WifiMac > Create(Ptr< WifiNetDevice > device, WifiStandard standard) const
Implements the IEEE 802.11 MAC trailer.
represent a single transmission mode
uint8_t GetMcsValue(void) const
WifiModulationClass GetModulationClass() const
uint64_t GetDataRate(uint16_t channelWidth, uint16_t guardInterval, uint8_t nss) const
Hold together all Wifi-related objects.
void SetMac(const Ptr< WifiMac > mac)
void SetHeConfiguration(Ptr< HeConfiguration > heConfiguration)
void SetHtConfiguration(Ptr< HtConfiguration > htConfiguration)
void SetVhtConfiguration(Ptr< VhtConfiguration > vhtConfiguration)
Ptr< WifiPhy > GetPhy(void) const
void SetRemoteStationManager(const Ptr< WifiRemoteStationManager > manager)
void SetStandard(WifiStandard standard)
Set the Wifi standard.
void SetPhy(const Ptr< WifiPhy > phy)
void SetPcapDataLinkType(SupportedPcapDataLinkTypes dlt)
Set the data link type of PCAP traces to be used.
virtual void EnableAsciiInternal(Ptr< OutputStreamWrapper > stream, std::string prefix, Ptr< NetDevice > nd, bool explicitFilename) override
Enable ASCII trace output on the indicated net device.
void Set(std::string name, const AttributeValue &v)
void DisablePreambleDetectionModel()
Disable the preamble detection model.
virtual void EnablePcapInternal(std::string prefix, Ptr< NetDevice > nd, bool promiscuous, bool explicitFilename) override
Enable pcap output the indicated net device.
PcapHelper::DataLinkType m_pcapDlt
PCAP data link type.
static void PcapSniffRxEvent(Ptr< PcapFileWrapper > file, Ptr< const Packet > packet, uint16_t channelFreqMhz, WifiTxVector txVector, MpduInfo aMpdu, SignalNoiseDbm signalNoise, uint16_t staId=SU_STA_ID)
ObjectFactory m_preambleDetectionModel
preamble detection model
void SetPreambleDetectionModel(std::string type, Args &&... args)
Helper function used to set the preamble detection model.
static void PcapSniffTxEvent(Ptr< PcapFileWrapper > file, Ptr< const Packet > packet, uint16_t channelFreqMhz, WifiTxVector txVector, MpduInfo aMpdu, uint16_t staId=SU_STA_ID)
virtual Ptr< WifiPhy > Create(Ptr< Node > node, Ptr< WifiNetDevice > device) const =0
SupportedPcapDataLinkTypes
An enumeration of the pcap data link types (DLTs) which this helper supports.
@ DLT_IEEE802_11
IEEE 802.11 Wireless LAN headers on packets.
@ DLT_IEEE802_11_RADIO
Include Radiotap link layer information.
@ DLT_PRISM_HEADER
Include Prism monitor mode information.
static void GetRadiotapHeader(RadiotapHeader &header, Ptr< Packet > packet, uint16_t channelFreqMhz, WifiTxVector txVector, MpduInfo aMpdu, uint16_t staId)
Get the Radiotap header for a transmitted packet.
ObjectFactory m_phy
PHY object.
PcapHelper::DataLinkType GetPcapDataLinkType(void) const
Get the data link type of PCAP traces to be used.
hold a list of per-remote-station state.
This class mimics the TXVECTOR which is to be passed to the PHY in order to define the parameters whi...
uint8_t GetBssColor(void) const
Get the BSS color.
WifiMode GetMode(uint16_t staId=SU_STA_ID) const
If this TX vector is associated with an SU PPDU, return the selected payload transmission mode.
uint8_t GetNess(void) const
HeMuUserInfo GetHeMuUserInfo(uint16_t staId) const
Get the HE MU user-specific transmission information for the given STA-ID.
WifiPreamble GetPreambleType(void) const
uint8_t GetNss(uint16_t staId=SU_STA_ID) const
If this TX vector is associated with an SU PPDU, return the number of spatial streams.
bool IsAggregation(void) const
Checks whether the PSDU contains A-MPDU.
uint16_t GetChannelWidth(void) const
bool IsStbc(void) const
Check if STBC is used or not.
uint16_t GetGuardInterval(void) const
void Connect(std::string path, const CallbackBase &cb)
void ConnectWithoutContext(std::string path, const CallbackBase &cb)
#define NS_FATAL_ERROR(msg)
Report a fatal error with a message and terminate.
#define NS_ABORT_MSG(msg)
Unconditional abnormal program termination with a message.
#define NS_ABORT_MSG_IF(cond, msg)
Abnormal program termination if a condition is true, with a message.
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by ",...
#define NS_LOG_INFO(msg)
Use NS_LOG to output a message of level LOG_INFO.
Callback< R > MakeBoundCallback(R(*fnPtr)(TX), ARG a1)
Make Callbacks with one bound argument.
WifiStandard
Identifies the IEEE 802.11 specifications that a Wifi device can be configured to use.
WifiPreamble
The type of preamble to be used by an IEEE 802.11 transmission.
uint8_t SelectQueueByDSField(Ptr< QueueItem > item)
Determine the TX queue for a given packet.
@ WIFI_STANDARD_UNSPECIFIED
@ WIFI_MOD_CLASS_HT
HT (Clause 19)
@ WIFI_MOD_CLASS_VHT
VHT (Clause 22)
@ WIFI_MOD_CLASS_HE
HE (Clause 27)
@ LAST_MPDU_IN_AGGREGATE
The MPDU is the last aggregate in an A-MPDU with multiple MPDUs.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
static void AsciiPhyReceiveSinkWithContext(Ptr< OutputStreamWrapper > stream, std::string context, Ptr< const Packet > p, double snr, WifiMode mode, enum WifiPreamble preamble)
ASCII Phy receive sink with context.
static void AsciiPhyReceiveSinkWithoutContext(Ptr< OutputStreamWrapper > stream, Ptr< const Packet > p, double snr, WifiMode mode, enum WifiPreamble preamble)
ASCII Phy receive sink without context.
@ LOG_LEVEL_ALL
Print everything.
@ LOG_PREFIX_TIME
Prefix all trace prints with simulation time.
@ LOG_PREFIX_NODE
Prefix all trace prints with simulation node.
void LogComponentEnable(char const *name, enum LogLevel level)
Enable the logging output associated with that log component.
static void AsciiPhyTransmitSinkWithContext(Ptr< OutputStreamWrapper > stream, std::string context, Ptr< const Packet > p, WifiMode mode, WifiPreamble preamble, uint8_t txLevel)
ASCII Phy transmit sink with context.
void LogComponentEnableAll(enum LogLevel level)
Enable the logging output for all registered log components.
static void AsciiPhyTransmitSinkWithoutContext(Ptr< OutputStreamWrapper > stream, Ptr< const Packet > p, WifiMode mode, WifiPreamble preamble, uint8_t txLevel)
ASCII Phy transmit sink without context.
HeRu::RuSpec ru
RU specification.
MpduType type
type of MPDU
uint32_t mpduRefNumber
MPDU ref number.
SignalNoiseDbm structure.
double noise
noise power in dBm
double signal
signal strength in dBm