25 #include "ns3/simulator.h"
26 #include "ns3/packet.h"
27 #include "ns3/assert.h"
29 #include "ns3/double.h"
30 #include "ns3/uinteger.h"
32 #include "ns3/trace-source-accessor.h"
59 .AddTraceSource (
"PhyTxBegin",
60 "Trace source indicating a packet has begun transmitting over the channel medium",
62 .AddTraceSource (
"PhyTxEnd",
63 "Trace source indicating a packet has been completely transmitted over the channel. NOTE: the only official WifiPhy implementation available to this date (YansWifiPhy) never fires this trace source.",
65 .AddTraceSource (
"PhyTxDrop",
66 "Trace source indicating a packet has been dropped by the device during transmission",
68 .AddTraceSource (
"PhyRxBegin",
69 "Trace source indicating a packet has begun being received from the channel medium by the device",
71 .AddTraceSource (
"PhyRxEnd",
72 "Trace source indicating a packet has been completely received from the channel medium by the device",
74 .AddTraceSource (
"PhyRxDrop",
75 "Trace source indicating a packet has been dropped by the device during reception",
77 .AddTraceSource (
"MonitorSnifferRx",
78 "Trace source simulating a wifi device in monitor mode sniffing all received frames",
80 .AddTraceSource (
"MonitorSnifferTx",
81 "Trace source simulating the capability of a wifi device in monitor mode to sniff all frames being transmitted",
119 return 4+ (4* txvector.
GetNss());
346 uint32_t symbolDurationUs;
352 symbolDurationUs = 4;
355 symbolDurationUs = 8;
358 symbolDurationUs = 16;
364 double numDataBitsPerSymbol = payloadMode.
GetDataRate () * symbolDurationUs / 1e6;
367 uint32_t numSymbols = lrint (ceil ((16 + size * 8.0 + 6.0) / numDataBitsPerSymbol));
372 return numSymbols * symbolDurationUs + 6;
376 return numSymbols * symbolDurationUs;
381 double symbolDurationUs;
385 if (payloadMode.
GetUniqueName() ==
"OfdmRate135MbpsBW40MHzShGi" || payloadMode.
GetUniqueName() ==
"OfdmRate65MbpsBW20MHzShGi" )
387 symbolDurationUs=3.6;
407 symbolDurationUs=3.6;
417 double numDataBitsPerSymbol = payloadMode.
GetDataRate () *txvector.
GetNss() * symbolDurationUs / 1e6;
421 uint32_t numSymbols = lrint (m_Stbc*ceil ((16 + size * 8.0 + 6.0*Nes) / (m_Stbc* numDataBitsPerSymbol)));
423 return numSymbols * symbolDurationUs;
429 <<
" mode=" << payloadMode
431 return lrint (ceil ((size * 8.0) / (payloadMode.
GetDataRate () / 1.0e6)));
448 return MicroSeconds (duration);
1329 40000000, 108000000,
1341 40000000, 120000000,
1353 40000000, 121500000,
1365 40000000, 135000000,
1377 40000000, 135000000,
1390 40000000, 150000000,
1403 return (os <<
"IDLE");
1405 return (os <<
"CCA_BUSY");
1407 return (os <<
"TX");
1409 return (os <<
"RX");
1411 return (os <<
"SWITCHING");
1414 return (os <<
"INVALID");
static class anonymous_namespace{wifi-phy.cc}::Constructor g_constructor
static WifiMode GetOfdmRate9MbpsBW5MHz()
Return a WifiMode for ODFM 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-ODFM at 24Mbps.
static WifiMode GetDsssRate11Mbps()
Return a WifiMode for DSSS at 11Mbps.
static uint32_t GetPlcpHeaderDurationMicroSeconds(WifiMode payloadMode, WifiPreamble preamble)
keep track of time values and allow control of global simulation resolution
static WifiMode GetErpOfdmRate36Mbps()
Return a WifiMode for ERP-ODFM at 36Mbps.
#define NS_LOG_FUNCTION(parameters)
static WifiMode GetOfdmRate26MbpsBW20MHz()
Return a WifiMode for ODFM at 26Mbps with 20MHz channel spacing.
static WifiMode GetOfdmRate9Mbps()
Return a WifiMode for ODFM at 9Mbps.
static WifiMode GetOfdmRate7_2MbpsBW20MHz()
Return a WifiMode for ODFM at 7.2Mbps with 20MHz channel spacing.
static WifiMode GetOfdmRate18MbpsBW10MHz()
Return a WifiMode for ODFM 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 ODFM at 27Mbps with 10MHz channel spacing.
static WifiMode GetOfdmRate3MbpsBW5MHz()
Return a WifiMode for ODFM at 3Mbps with 5MHz channel spacing.
static WifiMode GetDsssRate1Mbps()
Return a WifiMode for DSSS at 1Mbps.
void NotifyMonitorSniffTx(Ptr< const Packet > packet, uint16_t channelFreqMhz, uint16_t channelNumber, uint32_t rate, bool isShortPreamble, uint8_t txPower)
Public method used to fire a MonitorSniffer trace for a wifi packet being transmitted.
static WifiMode GetOfdmRate81MbpsBW40MHz()
Return a WifiMode for ODFM at 81Mbps with 40MHz channel spacing.
static WifiMode GetErpOfdmRate18Mbps()
Return a WifiMode for ERP-ODFM at 18Mbps.
State
The state of the PHY layer.
NS_LOG_COMPONENT_DEFINE("WifiPhy")
static WifiMode GetOfdmRate12Mbps()
Return a WifiMode for ODFM 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 GetOfdmRate43_3MbpsBW20MHz()
Return a WifiMode for ODFM at 43.3Mbps with 20MHz channel spacing.
NS_OBJECT_ENSURE_REGISTERED(NullMessageSimulatorImpl)
static WifiMode GetOfdmRate60MbpsBW40MHz()
Return a WifiMode for ODFM at 60Mbps with 40MHz channel spacing.
static WifiMode GetOfdmRate1_5MbpsBW5MHz()
Return a WifiMode for ODFM at 1.5Mbps with 5MHz channel spacing.
static WifiMode GetOfdmRate4_5MbpsBW10MHz()
Return a WifiMode for ODFM at 4.5Mbps with 10MHz channel spacing.
static WifiMode GetMFPlcpHeaderMode(WifiMode payloadMode, WifiPreamble preamble)
static WifiMode GetOfdmRate54Mbps()
Return a WifiMode for ODFM at 54Mbps.
void NotifyTxDrop(Ptr< const Packet > packet)
Public method used to fire a PhyTxDrop trace.
static WifiMode GetOfdmRate108MbpsBW40MHz()
Return a WifiMode for ODFM at 108Mbps with 40MHz channel spacing.
static WifiMode GetOfdmRate21_7MbpsBW20MHz()
Return a WifiMode for ODFM at 21.7Mbps with 20MHz channel spacing.
void NotifyTxBegin(Ptr< const Packet > packet)
Public method used to fire a PhyTxBegin trace.
represent a single transmission modeA WifiMode is implemented by a single integer which is used to lo...
static WifiMode GetOfdmRate135MbpsBW40MHz()
Return a WifiMode for ODFM at 135Mbps with 40MHz channel spacing.
static WifiMode GetOfdmRate36Mbps()
Return a WifiMode for ODFM at 36Mbps.
static WifiMode GetOfdmRate6MbpsBW5MHz()
Return a WifiMode for ODFM at 6Mbps with 5MHz channel spacing.
#define NS_FATAL_ERROR(msg)
fatal error handling
The PHY layer is switching to other channel.
static WifiMode GetErpOfdmRate54Mbps()
Return a WifiMode for ERP-ODFM at 54Mbps.
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.
static WifiMode GetOfdmRate6_5MbpsBW20MHz()
Return a WifiMode for ODFM at 6.5Mbps with 20MHz channel spacing.
static double GetPayloadDurationMicroSeconds(uint32_t size, WifiTxVector txvector)
static WifiMode GetOfdmRate135MbpsBW40MHzShGi()
Return a WifiMode for ODFM at 135Mbps with 40MHz channel spacing.
TracedCallback< Ptr< const Packet >, uint16_t, uint16_t, uint32_t, bool, uint8_t > m_phyMonitorSniffTxTrace
A trace source that emulates a wifi device in monitor mode sniffing a packet being transmitted...
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 GetErpOfdmRate48Mbps()
Return a WifiMode for ERP-ODFM at 48Mbps.
static WifiMode GetPlcpHeaderMode(WifiMode payloadMode, WifiPreamble preamble)
uint8_t GetNess(void) const
static WifiMode GetOfdmRate12MbpsBW10MHz()
Return a WifiMode for ODFM at 12Mbps with 10MHz channel spacing.
std::string GetUniqueName(void) const
TracedCallback< Ptr< const Packet > > m_phyRxDropTrace
The trace source fired when the phy layer drops a packet it has received.
virtual ~WifiPhyListener()
static WifiMode CreateWifiMode(std::string uniqueName, enum WifiModulationClass modClass, bool isMandatory, uint32_t bandwidth, uint32_t dataRate, enum WifiCodeRate codingRate, uint8_t constellationSize)
void NotifyRxBegin(Ptr< const Packet > packet)
Public method used to fire a PhyRxBegin trace.
static WifiMode GetOfdmRate19_5MbpsBW20MHz()
Return a WifiMode for ODFM at 19.5Mbps with 20MHz channel spacing.
static WifiMode GetOfdmRate18Mbps()
Return a WifiMode for ODFM at 18Mbps.
static WifiMode GetOfdmRate9MbpsBW10MHz()
Return a WifiMode for ODFM at 9Mbps with 10MHz channel spacing.
TracedCallback< Ptr< const Packet >, uint16_t, uint16_t, uint32_t, bool, double, double > m_phyMonitorSniffRxTrace
A trace source that emulates a wifi device in monitor mode sniffing a packet being received...
bool IsStbc(void) const
Check if STBC is used or not.
static WifiMode GetOfdmRate12MbpsBW5MHz()
Return a WifiMode for ODFM at 12Mbps with 5MHz channel spacing.
static WifiMode GetOfdmRate52MbpsBW20MHz()
Return a WifiMode for ODFM at 52Mbps with 20MHz channel spacing.
#define NS_LOG_LOGIC(msg)
static WifiMode GetOfdmRate40_5MbpsBW40MHz()
Return a WifiMode for ODFM at 40.5Mbps with 40MHz channel spacing.
uint32_t GetBandwidth(void) const
TracedCallback< Ptr< const Packet > > m_phyTxBeginTrace
The trace source fired when a packet begins the transmission process on the medium.
static WifiMode GetOfdmRate72_2MbpsBW20MHz()
Return a WifiMode for ODFM at 72.2Mbps with 20MHz channel spacing.
static WifiMode GetOfdmRate65MbpsBW20MHzShGi()
Return a WifiMode for ODFM at 65Mbps with 20MHz channel spacing.
static WifiMode GetOfdmRate48Mbps()
Return a WifiMode for ODFM at 48Mbps.
std::ostream & operator<<(std::ostream &os, const Angles &a)
print a struct Angles to output
void NotifyMonitorSniffRx(Ptr< const Packet > packet, uint16_t channelFreqMhz, uint16_t channelNumber, uint32_t rate, bool isShortPreamble, double signalDbm, double noiseDbm)
Public method used to fire a MonitorSniffer trace for a wifi packet being received.
static TypeId GetTypeId(void)
static WifiMode GetOfdmRate57_8MbpsBW20MHz()
Return a WifiMode for ODFM at 57.8Mbps with 20MHz channel spacing.
static WifiMode GetOfdmRate24Mbps()
Return a WifiMode for ODFM at 24Mbps.
Ptr< const TraceSourceAccessor > MakeTraceSourceAccessor(T a)
static WifiMode GetOfdmRate13MbpsBW20MHz()
Return a WifiMode for ODFM at 13Mbps with 20MHz channel spacing.
static WifiMode GetOfdmRate65MbpsBW20MHz()
Return a WifiMode for ODFM at 65Mbps with 20MHz channel spacing.
static uint32_t GetPlcpHtTrainingSymbolDurationMicroSeconds(WifiMode payloadMode, WifiPreamble preamble, WifiTxVector txvector)
static WifiMode GetOfdmRate58_5MbpsBW20MHz()
Return a WifiMode for ODFM at 58.5Mbps with 20MHz channel spacing.
static WifiMode GetDsssRate5_5Mbps()
Return a WifiMode for DSSS at 5.5Mbps.
static WifiMode GetOfdmRate2_25MbpsBW5MHz()
Return a WifiMode for ODFM at 2.25Mbps with 5MHz channel spacing.
static WifiMode GetErpOfdmRate9Mbps()
Return a WifiMode for ERP-ODFM at 9Mbps.
void NotifyTxEnd(Ptr< const Packet > packet)
Public method used to fire a PhyTxEnd trace.
static WifiMode GetOfdmRate15MbpsBW40MHz()
Return a WifiMode for ODFM at 15Mbps with 40MHz channel spacing.
static WifiMode GetOfdmRate121_5MbpsBW40MHz()
Return a WifiMode for ODFM at 121.5Mbps with 40MHz channel spacing.
static WifiMode GetOfdmRate28_9MbpsBW20MHz()
Return a WifiMode for ODFM at 28.9Mbps with 20MHz channel spacing.
No explicit coding (e.g., DSSS rates)
static WifiMode GetErpOfdmRate6Mbps()
Return a WifiMode for ERP-ODFM at 6Mbps.
static Time CalculateTxDuration(uint32_t size, WifiTxVector txvector, enum WifiPreamble preamble)
uint8_t GetNss(void) const
static WifiMode GetErpOfdmRate12Mbps()
Return a WifiMode for ERP-ODFM at 12Mbps.
void NotifyRxEnd(Ptr< const Packet > packet)
Public method used to fire a PhyRxEnd trace.
static WifiMode GetOfdmRate13_5MbpsBW40MHz()
Return a WifiMode for ODFM at 13.5Mbps with 40MHz channel spacing.
static WifiMode GetOfdmRate30MbpsBW40MHz()
Return a WifiMode for ODFM at 30Mbps with 40MHz channel spacing.
static WifiMode GetOfdmRate54MbpsBW40MHz()
Return a WifiMode for ODFM at 54Mbps with 40MHz channel spacing.
static WifiMode GetOfdmRate90MbpsBW40MHz()
Return a WifiMode for ODFM at 90Mbps with 40MHz channel spacing.
static WifiMode GetOfdmRate45MbpsBW40MHz()
Return a WifiMode for ODFM at 45Mbps with 40MHz channel spacing.
static WifiMode GetOfdmRate120MbpsBW40MHz()
Return a WifiMode for ODFM at 120Mbps with 40MHz channel spacing.
static WifiMode GetOfdmRate39MbpsBW20MHz()
Return a WifiMode for ODFM at 39Mbps with 20MHz channel spacing.
a base class which provides memory management and object aggregation
static WifiMode GetDsssRate2Mbps()
Return a WifiMode for DSSS at 2Mbps.
static WifiMode GetOfdmRate6MbpsBW10MHz()
Return a WifiMode for ODFM at 6Mbps with 10MHz channel spacing.
WifiMode GetMode(void) const
The PHY layer is receiving a packet.
static WifiMode GetOfdmRate24MbpsBW10MHz()
Return a WifiMode for ODFM at 24Mbps with 10MHz channel spacing.
The PHY layer has sense the medium busy through the CCA mechanism.
static WifiMode GetOfdmRate13_5MbpsBW5MHz()
Return a WifiMode for ODFM at 13.5Mbps with 5MHz channel spacing.
a unique identifier for an interface.
static uint32_t GetPlcpPreambleDurationMicroSeconds(WifiMode payloadMode, WifiPreamble preamble)
The PHY layer is sending a packet.
uint64_t GetDataRate(void) const
TypeId SetParent(TypeId tid)
static WifiMode GetOfdmRate6Mbps()
Return a WifiMode for ODFM at 6Mbps.
static WifiMode GetOfdmRate27MbpsBW40MHz()
Return a WifiMode for ODFM at 27Mbps with 40MHz channel spacing.
DSSS PHY (Clause 15) and HR/DSSS PHY (Clause 18)
static WifiMode GetOfdmRate4_5MbpsBW5MHz()
Return a WifiMode for ODFM at 4.5Mbps with 5MHz channel spacing.
static WifiMode GetOfdmRate14_4MbpsBW20MHz()
Return a WifiMode for ODFM at 14.4Mbps with 20MHz channel spacing.
static uint32_t GetPlcpHtSigHeaderDurationMicroSeconds(WifiMode payloadMode, WifiPreamble preamble)
static WifiMode GetOfdmRate3MbpsBW10MHz()
Return a WifiMode for ODFM 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. ...
static WifiMode GetOfdmRate150MbpsBW40MHz()
Return a WifiMode for ODFM at 150Mbps with 40MHz channel spacing.