26 #include "ns3/simulator.h"
27 #include "ns3/packet.h"
28 #include "ns3/assert.h"
30 #include "ns3/double.h"
31 #include "ns3/uinteger.h"
33 #include "ns3/trace-source-accessor.h"
59 .SetGroupName (
"Wifi")
60 .AddTraceSource (
"PhyTxBegin",
61 "Trace source indicating a packet "
62 "has begun transmitting over the channel medium",
64 "ns3::Packet::TracedCallback")
65 .AddTraceSource (
"PhyTxEnd",
66 "Trace source indicating a packet "
67 "has been completely transmitted over the channel. "
68 "NOTE: the only official WifiPhy implementation "
69 "available to this date (YansWifiPhy) never fires "
72 "ns3::Packet::TracedCallback")
73 .AddTraceSource (
"PhyTxDrop",
74 "Trace source indicating a packet "
75 "has been dropped by the device during transmission",
77 "ns3::Packet::TracedCallback")
78 .AddTraceSource (
"PhyRxBegin",
79 "Trace source indicating a packet "
80 "has begun being received from the channel medium "
83 "ns3::Packet::TracedCallback")
84 .AddTraceSource (
"PhyRxEnd",
85 "Trace source indicating a packet "
86 "has been completely received from the channel medium "
89 "ns3::Packet::TracedCallback")
90 .AddTraceSource (
"PhyRxDrop",
91 "Trace source indicating a packet "
92 "has been dropped by the device during reception",
94 "ns3::Packet::TracedCallback")
95 .AddTraceSource (
"MonitorSnifferRx",
96 "Trace source simulating a wifi device in monitor mode "
97 "sniffing all received frames",
99 "ns3::WifiPhy::MonitorSnifferRxTracedCallback")
100 .AddTraceSource (
"MonitorSnifferTx",
101 "Trace source simulating the capability of a wifi device "
102 "in monitor mode to sniff all frames being transmitted",
104 "ns3::WifiPhy::MonitorSnifferTxTracedCallback")
136 uint8_t Ndltf, Neltf;
139 if (txVector.
GetNss () < 3)
141 Ndltf = txVector.
GetNss ();
143 else if (txVector.
GetNss () < 5)
147 else if (txVector.
GetNss () < 7)
435 numSymbols = ceil ((16 + size * 8.0 + 6) / numDataBitsPerSymbol);
445 numSymbols = ((size * 8.0) / numDataBitsPerSymbol);
456 numSymbols = lrint (ceil ((16 + totalAmpduSize * 8.0 + 6) / numDataBitsPerSymbol));
467 numSymbols = lrint (ceil ((16 + size * 8.0 + 6.0) / numDataBitsPerSymbol));
481 return Time (numSymbols * symbolDuration);
529 numSymbols = ceil (m_Stbc * (16 + size * 8.0 + 6 * Nes) / (m_Stbc * numDataBitsPerSymbol));
539 numSymbols = m_Stbc * ((size * 8.0 ) / (m_Stbc * numDataBitsPerSymbol));
550 numSymbols = lrint (m_Stbc * ceil ((16 + totalAmpduSize * 8.0 + 6 * Nes) / (m_Stbc * numDataBitsPerSymbol)));
562 numSymbols = lrint (m_Stbc * ceil ((16 + size * 8.0 + 6.0 * Nes) / (m_Stbc * numDataBitsPerSymbol)));
575 return Time (numSymbols * symbolDuration);
582 <<
" mode=" << payloadMode
583 <<
" rate=" << payloadMode.
GetDataRate (22, 0, 1));
1457 return (os <<
"IDLE");
1459 return (os <<
"CCA_BUSY");
1461 return (os <<
"TX");
1463 return (os <<
"RX");
1465 return (os <<
"SWITCHING");
1467 return (os <<
"SLEEP");
1470 return (os <<
"INVALID");
static class anonymous_namespace{wifi-phy.cc}::Constructor g_constructor
static WifiMode GetVhtMcs6()
Return MCS 6 from VHT MCS values.
static WifiMode GetOfdmRate9MbpsBW5MHz()
Return a WifiMode for OFDM at 9Mbps with 5MHz channel spacing.
TracedCallback< Ptr< const Packet > > m_phyRxBeginTrace
The trace source fired when a packet begins the reception process from the medium.
static WifiMode GetErpOfdmRate24Mbps()
Return a WifiMode for ERP-OFDM at 24Mbps.
static WifiMode GetDsssRate11Mbps()
Return a WifiMode for DSSS at 11Mbps.
Simulation virtual time values and global simulation resolution.
static WifiMode GetErpOfdmRate36Mbps()
Return a WifiMode for ERP-OFDM at 36Mbps.
void NotifyMonitorSniffTx(Ptr< const Packet > packet, uint16_t channelFreqMhz, uint16_t channelNumber, uint32_t rate, WifiPreamble preamble, WifiTxVector txVector, struct mpduInfo aMpdu)
Public method used to fire a MonitorSniffer trace for a wifi packet being transmitted.
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by "...
static WifiMode GetVhtMcs8()
Return MCS 8 from VHT MCS values.
static WifiMode GetOfdmRate9Mbps()
Return a WifiMode for OFDM at 9Mbps.
static WifiMode GetOfdmRate18MbpsBW10MHz()
Return a WifiMode for OFDM at 18Mbps with 10MHz channel spacing.
This class mimics the TXVECTOR which is to be passed to the PHY in order to define the parameters whi...
static WifiMode GetOfdmRate27MbpsBW10MHz()
Return a WifiMode for OFDM at 27Mbps with 10MHz channel spacing.
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
static WifiMode GetOfdmRate3MbpsBW5MHz()
Return a WifiMode for OFDM at 3Mbps with 5MHz channel spacing.
static WifiMode GetVhtMcs0()
Return MCS 0 from VHT MCS values.
static WifiMode GetDsssRate1Mbps()
Return a WifiMode for DSSS at 1Mbps.
static WifiMode GetErpOfdmRate18Mbps()
Return a WifiMode for ERP-OFDM at 18Mbps.
The PHY layer has sense the medium busy through the CCA mechanism.
static WifiMode GetHtMcs7()
Return MCS 7 from HT MCS values.
static WifiMode GetHtPlcpHeaderMode(WifiMode payloadMode)
static Time GetPlcpHtSigHeaderDuration(WifiPreamble preamble)
static WifiMode GetVhtMcs5()
Return MCS 5 from VHT MCS values.
static WifiMode GetHtMcs22()
Return MCS 22 from HT MCS values.
static WifiMode GetHtMcs14()
Return MCS 14 from HT MCS values.
uint32_t m_totalAmpduNumSymbols
Number of symbols previously transmitted for the MPDUs in an A-MPDU, used for the computation of the ...
static WifiMode GetOfdmRate12Mbps()
Return a WifiMode for OFDM at 12Mbps.
TracedCallback< Ptr< const Packet > > m_phyRxEndTrace
The trace source fired when a packet ends the reception process from the medium.
enum WifiModulationClass GetModulationClass() const
static WifiMode GetHtMcs31()
Return MCS 31 from HT MCS values.
static WifiMode GetHtMcs21()
Return MCS 21 from HT MCS values.
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file...
static WifiMode GetHtMcs30()
Return MCS 30 from HT MCS values.
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
static WifiMode GetHtMcs10()
Return MCS 10 from HT MCS values.
static WifiMode GetHtMcs26()
Return MCS 26 from HT MCS values.
bool IsShortGuardInterval(void) const
static WifiMode GetOfdmRate1_5MbpsBW5MHz()
Return a WifiMode for OFDM at 1.5Mbps with 5MHz channel spacing.
The PHY layer is sleeping.
static WifiMode GetHtMcs17()
Return MCS 17 from HT MCS values.
static WifiMode GetHtMcs24()
Return MCS 24 from HT MCS values.
static WifiMode GetOfdmRate4_5MbpsBW10MHz()
Return a WifiMode for OFDM at 4.5Mbps with 10MHz channel spacing.
static WifiMode GetOfdmRate54Mbps()
Return a WifiMode for OFDM at 54Mbps.
#define NS_FATAL_ERROR(msg)
Report a fatal error with a message and terminate.
void(* Time)(Time oldValue, Time newValue)
TracedValue callback signature for Time.
void NotifyTxDrop(Ptr< const Packet > packet)
Public method used to fire a PhyTxDrop trace.
static WifiMode GetHtMcs8()
Return MCS 8 from HT MCS values.
static WifiMode GetHtMcs18()
Return MCS 18 from HT MCS values.
void NotifyTxBegin(Ptr< const Packet > packet)
Public method used to fire a PhyTxBegin trace.
Time CalculateTxDuration(uint32_t size, WifiTxVector txVector, enum WifiPreamble preamble, double frequency, enum mpduType mpdutype, uint8_t incFlag)
static WifiMode GetVhtMcs4()
Return MCS 4 from VHT MCS values.
static WifiMode GetHtMcs27()
Return MCS 27 from HT MCS values.
represent a single transmission modeA WifiMode is implemented by a single integer which is used to lo...
static WifiMode GetOfdmRate36Mbps()
Return a WifiMode for OFDM at 36Mbps.
static WifiMode CreateWifiMcs(std::string uniqueName, uint8_t mcsValue, enum WifiModulationClass modClass)
static WifiMode GetVhtMcs7()
Return MCS 7 from VHT MCS values.
static WifiMode GetOfdmRate6MbpsBW5MHz()
Return a WifiMode for OFDM at 6Mbps with 5MHz channel spacing.
static WifiMode GetVhtMcs3()
Return MCS 3 from VHT MCS values.
void NotifyMonitorSniffRx(Ptr< const Packet > packet, uint16_t channelFreqMhz, uint16_t channelNumber, uint32_t rate, WifiPreamble preamble, WifiTxVector txVector, struct mpduInfo aMpdu, struct signalNoiseDbm signalNoise)
Public method used to fire a MonitorSniffer trace for a wifi packet being received.
Ptr< const TraceSourceAccessor > MakeTraceSourceAccessor(T a)
Create a TraceSourceAccessor which will control access to the underlying trace source.
static WifiMode GetVhtPlcpHeaderMode(WifiMode payloadMode)
static WifiMode GetHtMcs16()
Return MCS 16 from HT MCS values.
static WifiMode GetErpOfdmRate54Mbps()
Return a WifiMode for ERP-OFDM at 54Mbps.
static WifiMode GetHtMcs29()
Return MCS 29 from HT MCS values.
static WifiMode GetHtMcs11()
Return MCS 11 from HT MCS values.
void NotifyRxDrop(Ptr< const Packet > packet)
Public method used to fire a PhyRxDrop trace.
WifiPreamble
The type of preamble to be used by an IEEE 802.11 transmission.
TracedCallback< Ptr< const Packet >, uint16_t, uint16_t, uint32_t, WifiPreamble, WifiTxVector, struct mpduInfo, struct signalNoiseDbm > m_phyMonitorSniffRxTrace
A trace source that emulates a wifi device in monitor mode sniffing a packet being received...
The MPDU is not part of an A-MPDU.
static WifiMode GetHtMcs2()
Return MCS 2 from HT MCS values.
Time CalculatePlcpPreambleAndHeaderDuration(WifiTxVector txVector, enum WifiPreamble preamble)
Time NanoSeconds(uint64_t value)
Construct a Time in the indicated unit.
TracedCallback< Ptr< const Packet > > m_phyTxDropTrace
The trace source fired when the phy layer drops a packet as it tries to transmit it.
static WifiMode GetPlcpHeaderMode(WifiMode payloadMode, WifiPreamble preamble, WifiTxVector txVector)
static WifiMode GetHtMcs12()
Return MCS 12 from HT MCS values.
static WifiMode GetErpOfdmRate48Mbps()
Return a WifiMode for ERP-OFDM at 48Mbps.
uint8_t GetNess(void) const
static WifiMode GetOfdmRate12MbpsBW10MHz()
Return a WifiMode for OFDM at 12Mbps with 10MHz channel spacing.
uint32_t GetChannelWidth(void) const
std::string GetUniqueName(void) const
The PHY layer is receiving a packet.
TracedCallback< Ptr< const Packet > > m_phyRxDropTrace
The trace source fired when the phy layer drops a packet it has received.
virtual ~WifiPhyListener()
void NotifyRxBegin(Ptr< const Packet > packet)
Public method used to fire a PhyRxBegin trace.
The PHY layer is sending a packet.
static WifiMode GetOfdmRate18Mbps()
Return a WifiMode for OFDM at 18Mbps.
static WifiMode GetOfdmRate9MbpsBW10MHz()
Return a WifiMode for OFDM at 9Mbps with 10MHz channel spacing.
bool IsStbc(void) const
Check if STBC is used or not.
static WifiMode GetOfdmRate12MbpsBW5MHz()
Return a WifiMode for OFDM at 12Mbps with 5MHz channel spacing.
#define NS_LOG_LOGIC(msg)
Use NS_LOG to output a message of level LOG_LOGIC.
The PHY layer is switching to other channel.
TracedCallback< Ptr< const Packet > > m_phyTxBeginTrace
The trace source fired when a packet begins the transmission process on the medium.
The MPDU is part of an A-MPDU, but is not the last aggregate.
static WifiMode GetVhtMcs1()
Return MCS 1 from VHT MCS values.
static WifiMode GetOfdmRate48Mbps()
Return a WifiMode for OFDM at 48Mbps.
std::ostream & operator<<(std::ostream &os, const Angles &a)
print a struct Angles to output
static WifiMode GetHtMcs0()
Return MCS 0 from HT MCS values.
static TypeId GetTypeId(void)
Every class exported by the ns3 library is enclosed in the ns3 namespace.
TracedCallback< Ptr< const Packet >, uint16_t, uint16_t, uint32_t, WifiPreamble, WifiTxVector, struct mpduInfo > m_phyMonitorSniffTxTrace
A trace source that emulates a wifi device in monitor mode sniffing a packet being transmitted...
static WifiMode GetOfdmRate24Mbps()
Return a WifiMode for OFDM at 24Mbps.
static WifiMode GetHtMcs13()
Return MCS 13 from HT MCS values.
static WifiMode GetHtMcs20()
Return MCS 20 from HT MCS values.
static WifiMode GetHtMcs5()
Return MCS 5 from HT MCS values.
uint64_t GetDataRate(uint32_t channelWidth, bool isShortGuardInterval, uint8_t nss) const
static WifiMode GetVhtMcs2()
Return MCS 2 from VHT MCS values.
static WifiMode GetDsssRate5_5Mbps()
Return a WifiMode for DSSS at 5.5Mbps.
static WifiMode GetOfdmRate2_25MbpsBW5MHz()
Return a WifiMode for OFDM at 2.25Mbps with 5MHz channel spacing.
static Time GetPlcpVhtSigA1Duration(WifiPreamble preamble)
static WifiMode GetErpOfdmRate9Mbps()
Return a WifiMode for ERP-OFDM at 9Mbps.
void NotifyTxEnd(Ptr< const Packet > packet)
Public method used to fire a PhyTxEnd trace.
Time GetPayloadDuration(uint32_t size, WifiTxVector txVector, WifiPreamble preamble, double frequency, enum mpduType mpdutype, uint8_t incFlag)
static WifiMode CreateWifiMode(std::string uniqueName, enum WifiModulationClass modClass, bool isMandatory, enum WifiCodeRate codingRate, uint16_t constellationSize)
int64_t GetNanoSeconds(void) const
Get an approximation of the time stored in this instance in the indicated unit.
No explicit coding (e.g., DSSS rates)
static WifiMode GetErpOfdmRate6Mbps()
Return a WifiMode for ERP-OFDM at 6Mbps.
uint8_t GetNss(void) const
static WifiMode GetErpOfdmRate12Mbps()
Return a WifiMode for ERP-OFDM at 12Mbps.
void NotifyRxEnd(Ptr< const Packet > packet)
Public method used to fire a PhyRxEnd trace.
static WifiMode GetHtMcs19()
Return MCS 19 from HT MCS values.
static WifiMode GetHtMcs6()
Return MCS 6 from HT MCS values.
static WifiMode GetHtMcs28()
Return MCS 28 from HT MCS values.
static WifiMode GetHtMcs9()
Return MCS 9 from HT MCS values.
static Time GetPlcpHeaderDuration(WifiTxVector txVector, WifiPreamble preamble)
static WifiMode GetHtMcs4()
Return MCS 4 from HT MCS values.
static WifiMode GetHtMcs25()
Return MCS 25 from HT MCS values.
uint32_t m_totalAmpduSize
Total size of the previously transmitted MPDUs in an A-MPDU, used for the computation of the number o...
Time MicroSeconds(uint64_t value)
Construct a Time in the indicated unit.
static WifiMode GetHtMcs1()
Return MCS 1 from HT MCS values.
static WifiMode GetHtMcs23()
Return MCS 23 from HT MCS values.
A base class which provides memory management and object aggregation.
static WifiMode GetDsssRate2Mbps()
Return a WifiMode for DSSS at 2Mbps.
static WifiMode GetVhtMcs9()
Return MCS 9 from VHT MCS values.
static WifiMode GetOfdmRate6MbpsBW10MHz()
Return a WifiMode for OFDM at 6Mbps with 10MHz channel spacing.
WifiMode GetMode(void) const
State
The state of the PHY layer.
static Time GetPlcpHtTrainingSymbolDuration(WifiPreamble preamble, WifiTxVector txVector)
static WifiMode GetOfdmRate24MbpsBW10MHz()
Return a WifiMode for OFDM at 24Mbps with 10MHz channel spacing.
static Time GetPlcpVhtSigBDuration(WifiPreamble preamble)
static WifiMode GetOfdmRate13_5MbpsBW5MHz()
Return a WifiMode for OFDM at 13.5Mbps with 5MHz channel spacing.
a unique identifier for an interface.
static WifiMode GetHtMcs15()
Return MCS 15 from HT MCS values.
static Time GetPlcpPreambleDuration(WifiTxVector txVector, WifiPreamble preamble)
TypeId SetParent(TypeId tid)
Set the parent TypeId.
static WifiMode GetHtMcs3()
Return MCS 3 from HT MCS values.
static WifiMode GetOfdmRate6Mbps()
Return a WifiMode for OFDM at 6Mbps.
static Time GetPlcpVhtSigA2Duration(WifiPreamble preamble)
static WifiMode GetOfdmRate4_5MbpsBW5MHz()
Return a WifiMode for OFDM at 4.5Mbps with 5MHz channel spacing.
mpduType
This enumeration defines the type of an MPDU.
static WifiMode GetOfdmRate3MbpsBW10MHz()
Return a WifiMode for OFDM at 3Mbps with 10MHz channel spacing.
TracedCallback< Ptr< const Packet > > m_phyTxEndTrace
The trace source fired when a packet ends the transmission process on the medium. ...
The MPDU is the last aggregate in an A-MPDU.