15#include "ns3/interference-helper.h"
17#include "ns3/simulator.h"
18#include "ns3/wifi-phy.h"
19#include "ns3/wifi-psdu.h"
20#include "ns3/wifi-utils.h"
24#undef NS_LOG_APPEND_CONTEXT
25#define NS_LOG_APPEND_CONTEXT WIFI_PHY_NS_LOG_APPEND_CONTEXT(m_wifiPhy)
65const std::array<uint64_t, 4>&
217 <<
", PER=" << snrPer.
per);
229 NS_LOG_DEBUG(
"Abort reception because long/short PHY header reception failed");
261 const auto& centerFrequencies = ppdu->GetTxCenterFreqs();
262 NS_ASSERT(centerFrequencies.size() == 1);
263 const auto& txVector = ppdu->GetTxVector();
264 const auto channelWidth = txVector.GetChannelWidth();
265 NS_LOG_FUNCTION(
this << centerFrequencies.front() << channelWidth << txPower);
297 NS_ABORT_MSG(
"Inexistent rate (" << rate <<
" bps) requested for HR/DSSS");
302#define GET_DSSS_MODE(x, m) \
303 WifiMode DsssPhy::Get##x() \
305 static WifiMode mode = CreateDsssMode(#x, WIFI_MOD_CLASS_##m); \
323 "DSSS or HR/DSSS mode cannot be created because it is not in the lookup table!");
326 "DSSS or HR/DSSS mode must be either WIFI_MOD_CLASS_DSSS or WIFI_MOD_CLASS_HR_DSSS!");
362 uint16_t divisor = 0;
373 NS_FATAL_ERROR(
"Incorrect modulation class, must specify either WIFI_MOD_CLASS_DSSS or "
374 "WIFI_MOD_CLASS_HR_DSSS!");
376 auto numberOfBitsPerSubcarrier =
static_cast<uint16_t
>(log2(constellationSize));
377 uint64_t dataRate = ((11000000 / divisor) * numberOfBitsPerSubcarrier);
Constructor class for DSSS modes.
PhyFieldRxStatus DoEndReceiveField(WifiPpduField field, Ptr< Event > event) override
End receiving a given field, perform amendment-specific actions, and provide the status of the recept...
static uint16_t GetConstellationSize(const std::string &name)
Return the constellation size from the DSSS or HR/DSSS mode's unique name using ModulationLookupTable...
static const PpduFormats m_dsssPpduFormats
DSSS and HR/DSSS PPDU formats.
PhyFieldRxStatus EndReceiveHeader(Ptr< Event > event)
End receiving the header, perform DSSS-specific actions, and provide the status of the reception.
static WifiMode CreateDsssMode(std::string uniqueName, WifiModulationClass modClass)
Create a DSSS or HR/DSSS mode from a unique name, the unique name must already be contained inside Mo...
static WifiCodeRate GetCodeRate(const std::string &name)
Return the WifiCodeRate from the DSSS or HR/DSSS mode's unique name using ModulationLookupTable.
static const ModulationLookupTable m_dsssModulationLookupTable
lookup table to retrieve code rate and constellation size corresponding to a unique name of modulatio...
static uint64_t GetDataRateFromTxVector(const WifiTxVector &txVector, uint16_t staId)
Return the data rate corresponding to the supplied TXVECTOR.
~DsssPhy() override
Destructor for HR/DSSS PHY.
static WifiMode GetDsssRate5_5Mbps()
Return a WifiMode for HR/DSSS at 5.5 Mbps.
WifiMode GetSigMode(WifiPpduField field, const WifiTxVector &txVector) const override
Get the WifiMode for the SIG field specified by the PPDU field.
static uint64_t GetDataRate(const std::string &name, WifiModulationClass modClass)
Return the data rate from the DSSS or HR/DSSS mode's unique name and the supplied parameters.
static bool IsAllowed(const WifiTxVector &txVector)
Check whether the combination in TXVECTOR is allowed.
Time GetHeaderDuration(const WifiTxVector &txVector) const
Time GetPayloadDuration(uint32_t size, const WifiTxVector &txVector, WifiPhyBand band, MpduType mpdutype, bool incFlag, uint32_t &totalAmpduSize, double &totalAmpduNumSymbols, uint16_t staId) const override
DsssPhy()
Constructor for HR/DSSS PHY.
static WifiMode GetDsssRate(uint64_t rate)
Return a WifiMode for HR/DSSS corresponding to the provided rate.
const PpduFormats & GetPpduFormats() const override
Return the PPDU formats of the PHY.
MHz_u GetMeasurementChannelWidth(const Ptr< const WifiPpdu > ppdu) const override
Return the channel width used to measure the RSSI.
uint32_t GetMaxPsduSize() const override
Get the maximum PSDU size in bytes.
Time GetPreambleDuration(const WifiTxVector &txVector) const
static WifiMode GetDsssRate1Mbps()
Return a WifiMode for DSSS at 1 Mbps.
WifiMode GetHeaderMode(const WifiTxVector &txVector) const
MHz_u GetRxChannelWidth(const WifiTxVector &txVector) const override
Return the channel width used in the reception spectrum model.
static void InitializeModes()
Initialize all HR/DSSS modes.
Ptr< WifiPpdu > BuildPpdu(const WifiConstPsduMap &psdus, const WifiTxVector &txVector, Time ppduDuration) override
Build amendment-specific PPDU.
Ptr< SpectrumValue > GetTxPowerSpectralDensity(Watt_u txPower, Ptr< const WifiPpdu > ppdu) const override
static WifiMode GetDsssRate11Mbps()
Return a WifiMode for HR/DSSS at 11 Mbps.
static WifiMode GetDsssRate2Mbps()
Return a WifiMode for DSSS at 2 Mbps.
Time GetDuration(WifiPpduField field, const WifiTxVector &txVector) const override
Get the duration of the PPDU field (or group of fields) used by this entity for the given transmissio...
MHz_u GetGuardBandwidth(MHz_u currentChannelWidth) const
virtual Time GetDuration(WifiPpduField field, const WifiTxVector &txVector) const
Get the duration of the PPDU field (or group of fields) used by this entity for the given transmissio...
virtual uint64_t ObtainNextUid(const WifiTxVector &txVector)
Obtain the next UID for the PPDU to transmit.
Ptr< WifiPhy > m_wifiPhy
Pointer to the owning WifiPhy.
std::map< std::string, CodeRateConstellationSizePair > ModulationLookupTable
A modulation lookup table using unique name of modulation as key.
virtual MHz_u GetRxChannelWidth(const WifiTxVector &txVector) const
Return the channel width used in the reception spectrum model.
std::map< WifiPreamble, std::vector< WifiPpduField > > PpduFormats
A map of PPDU field elements per preamble type.
virtual WifiMode GetSigMode(WifiPpduField field, const WifiTxVector &txVector) const
Get the WifiMode for the SIG field specified by the PPDU field.
std::list< WifiMode > m_modeList
the list of supported modes
double GetRandomValue() const
Obtain a random value from the WifiPhy's generator.
SnrPer GetPhyHeaderSnrPer(WifiPpduField field, Ptr< Event > event) const
Obtain the SNR and PER of the PPDU field from the WifiPhy's InterferenceHelper class.
virtual bool IsConfigSupported(Ptr< const WifiPpdu > ppdu) const
Checks if the signaled configuration (excluding bandwidth) is supported by the PHY.
@ DROP
drop PPDU and set CCA_BUSY
@ ABORT
abort reception of PPDU
virtual PhyFieldRxStatus DoEndReceiveField(WifiPpduField field, Ptr< Event > event)
End receiving a given field, perform amendment-specific actions, and provide the status of the recept...
Smart pointer class similar to boost::intrusive_ptr.
Simulation virtual time values and global simulation resolution.
static WifiMode CreateWifiMode(std::string uniqueName, WifiModulationClass modClass, bool isMandatory, CodeRateCallback codeRateCallback, ConstellationSizeCallback constellationSizeCallback, PhyRateCallback phyRateCallback, DataRateCallback dataRateCallback, AllowedCallback isAllowedCallback)
represent a single transmission mode
const std::string & GetUniqueName() const
WifiModulationClass GetModulationClass() const
uint64_t GetDataRate(MHz_u channelWidth, Time guardInterval, uint8_t nss) const
static void AddStaticPhyEntity(WifiModulationClass modulation, Ptr< PhyEntity > phyEntity)
Add the PHY entity to the map of implemented PHY entities for the given modulation class.
MHz_u GetChannelWidth() const
const WifiPhyOperatingChannel & GetOperatingChannel() const
Get a const reference to the operating channel.
static Ptr< SpectrumValue > CreateDsssTxPowerSpectralDensity(MHz_u centerFrequency, Watt_u txPower, MHz_u guardBandwidth)
Create a transmit power spectral density corresponding to DSSS.
This class mimics the TXVECTOR which is to be passed to the PHY in order to define the parameters whi...
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.
WifiPreamble GetPreambleType() const
#define GET_DSSS_MODE(x, m)
Declaration of ns3::DsssPhy class.
Declaration of ns3::DsssPpdu class.
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file,...
#define NS_ASSERT_MSG(condition, message)
At runtime, in debugging builds, if this condition is not true, the program prints the message to out...
#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_LOGIC(msg)
Use NS_LOG to output a message of level LOG_LOGIC.
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by ",...
auto MakeBoundCallback(R(*fnPtr)(Args...), BArgs &&... bargs)
Make Callbacks with varying number of bound arguments.
Ptr< T > Create(Ts &&... args)
Create class instances by constructors with varying numbers of arguments and return them by Ptr.
Time MicroSeconds(uint64_t value)
Construct a Time in the indicated unit.
WifiPhyBand
Identifies the PHY band.
WifiModulationClass
This enumeration defines the modulation classes per (Table 10-6 "Modulation classes"; IEEE 802....
WifiPpduField
The type of PPDU field (grouped for convenience)
MpduType
The type of an MPDU.
@ WIFI_MOD_CLASS_HR_DSSS
HR/DSSS (Clause 16)
@ WIFI_MOD_CLASS_DSSS
DSSS (Clause 15)
@ WIFI_PPDU_FIELD_NON_HT_HEADER
PHY header field for DSSS or ERP, short PHY header field for HR/DSSS or ERP, field not present for HT...
@ WIFI_PPDU_FIELD_PREAMBLE
SYNC + SFD fields for DSSS or ERP, shortSYNC + shortSFD fields for HR/DSSS or ERP,...
@ WIFI_PPDU_FIELD_DATA
data field
class anonymous_namespace{dsss-phy.cc}::ConstructorDsss g_constructor_dsss
the constructor for DSSS modes
Every class exported by the ns3 library is enclosed in the ns3 namespace.
std::unordered_map< uint16_t, Ptr< const WifiPsdu > > WifiConstPsduMap
Map of const PSDUs indexed by STA-ID.
Callback< R, Args... > MakeCallback(R(T::*memPtr)(Args...), OBJ objPtr)
Build Callbacks for class method members which take varying numbers of arguments and potentially retu...
dB_u RatioToDb(double ratio)
Convert from ratio to dB.
static const std::array< uint64_t, 4 > s_dsssRatesBpsList
DSSS rates in bits per second.
double MHz_u
MHz weak type.
WifiCodeRate
These constants define the various convolutional coding rates used for the OFDM transmission modes in...
@ WIFI_CODE_RATE_UNDEFINED
undefined coding rate
const std::array< uint64_t, 4 > & GetDsssRatesBpsList()
Get the array of possible DSSS rates.
Status of the reception of the PPDU field.
WifiPhyRxfailureReason reason
failure reason
PhyRxFailureAction actionIfFailure
action to perform in case of failure
bool isSuccess
outcome (true if success) of the reception
A struct for both SNR and PER.
double snr
SNR in linear scale.