From 32c9ec57c77644ba9cfad0e9518138bd886d3051 Mon Sep 17 00:00:00 2001 From: Jared Ivey Date: Tue, 20 May 2025 23:00:17 +0200 Subject: [PATCH] wifi: ClangCL/MSVC compatibility patches --- examples/wireless/wifi-spatial-reuse.cc | 6 ++- src/wifi/CMakeLists.txt | 1 + src/wifi/helper/wifi-helper.cc | 4 ++ .../helper/wifi-radio-energy-model-helper.h | 3 +- .../model/eht/eht-frame-exchange-manager.cc | 4 +- src/wifi/model/eht/eht-phy.cc | 2 +- .../model/he/constant-obss-pd-algorithm.cc | 5 ++- .../model/he/he-frame-exchange-manager.cc | 10 +++-- src/wifi/model/he/he-phy.cc | 2 +- src/wifi/model/he/obss-pd-algorithm.cc | 6 ++- src/wifi/model/ht/ht-phy.cc | 2 +- src/wifi/model/interference-helper.cc | 22 +++++----- src/wifi/model/interference-helper.h | 33 ++++++++------ src/wifi/model/non-ht/dsss-phy.cc | 2 +- src/wifi/model/non-ht/erp-ofdm-phy.cc | 2 +- src/wifi/model/non-ht/ofdm-phy.cc | 5 ++- src/wifi/model/phy-entity.cc | 7 ++- src/wifi/model/phy-entity.h | 43 ++----------------- src/wifi/model/qos-utils.h | 3 +- src/wifi/model/vht/vht-phy.cc | 2 +- src/wifi/model/wifi-constants.h | 7 +-- src/wifi/model/wifi-phy-common.h | 39 +++++++++++++++++ src/wifi/model/wifi-phy-operating-channel.cc | 6 +++ src/wifi/model/wifi-phy-operating-channel.h | 15 +++++-- src/wifi/model/wifi-phy-state-helper.h | 4 +- src/wifi/model/wifi-phy.cc | 41 +++++++++--------- src/wifi/model/wifi-phy.h | 31 ++++++++----- src/wifi/model/wifi-standards.h | 3 +- src/wifi/test/tx-duration-test.cc | 25 ++++++----- src/wifi/test/wifi-eht-info-elems-test.cc | 27 ++++++------ src/wifi/test/wifi-non-ht-dup-test.cc | 5 ++- src/wifi/test/wifi-phy-cca-test.cc | 4 +- src/wifi/test/wifi-phy-mu-mimo-test.cc | 7 +-- src/wifi/test/wifi-phy-ofdma-test.cc | 17 ++++---- src/wifi/test/wifi-primary-channels-test.cc | 2 +- src/wifi/test/wifi-tx-stats-helper-test.cc | 11 ++++- 36 files changed, 238 insertions(+), 170 deletions(-) diff --git a/examples/wireless/wifi-spatial-reuse.cc b/examples/wireless/wifi-spatial-reuse.cc index a780d785d..a9115a578 100644 --- a/examples/wireless/wifi-spatial-reuse.cc +++ b/examples/wireless/wifi-spatial-reuse.cc @@ -351,11 +351,13 @@ main(int argc, char* argv[]) // to the Reset trace source on each STA. Note that this trace connection // cannot be done through the Config path system, so pointers are used. auto deviceA = staDeviceA.Get(0)->GetObject(); - auto hePhyA = DynamicCast(deviceA->GetPhy()->GetPhyEntity(WIFI_MOD_CLASS_HE)); + auto hePhyA = + std::dynamic_pointer_cast(deviceA->GetPhy()->GetPhyEntity(WIFI_MOD_CLASS_HE)); // Pass in the context string "1" to allow the trace to distinguish objects hePhyA->GetObssPdAlgorithm()->TraceConnect("Reset", "1", MakeCallback(&ResetTrace)); auto deviceB = staDeviceB.Get(0)->GetObject(); - auto hePhyB = DynamicCast(deviceB->GetPhy()->GetPhyEntity(WIFI_MOD_CLASS_HE)); + auto hePhyB = + std::dynamic_pointer_cast(deviceB->GetPhy()->GetPhyEntity(WIFI_MOD_CLASS_HE)); // Pass in the context string "2" to allow the trace to distinguish objects hePhyB->GetObssPdAlgorithm()->TraceConnect("Reset", "2", MakeCallback(&ResetTrace)); } diff --git a/src/wifi/CMakeLists.txt b/src/wifi/CMakeLists.txt index f3b42fc37..b7702f1b1 100644 --- a/src/wifi/CMakeLists.txt +++ b/src/wifi/CMakeLists.txt @@ -411,4 +411,5 @@ build_lib( test/wifi-phy-mu-mimo-test.cc test/wifi-operating-channel-test.cc test/wifi-tx-stats-helper-test.cc + GENERATE_EXPORT_HEADER ) diff --git a/src/wifi/helper/wifi-helper.cc b/src/wifi/helper/wifi-helper.cc index df1401ac5..deda2067a 100644 --- a/src/wifi/helper/wifi-helper.cc +++ b/src/wifi/helper/wifi-helper.cc @@ -15,14 +15,17 @@ #include "ns3/config.h" #include "ns3/eht-configuration.h" #include "ns3/eht-ppdu.h" +#include "ns3/frame-capture-model.h" #include "ns3/he-configuration.h" #include "ns3/ht-configuration.h" +#include "ns3/interference-helper.h" #include "ns3/log.h" #include "ns3/mobility-model.h" #include "ns3/names.h" #include "ns3/net-device-queue-interface.h" #include "ns3/obss-pd-algorithm.h" #include "ns3/pointer.h" +#include "ns3/preamble-detection-model.h" #include "ns3/qos-txop.h" #include "ns3/qos-utils.h" #include "ns3/radiotap-header.h" @@ -30,6 +33,7 @@ #include "ns3/vht-configuration.h" #include "ns3/wifi-mac-queue.h" #include "ns3/wifi-mac-trailer.h" +#include "ns3/wifi-radio-energy-model.h" #include #include diff --git a/src/wifi/helper/wifi-radio-energy-model-helper.h b/src/wifi/helper/wifi-radio-energy-model-helper.h index c91978b4c..b9c6965ec 100644 --- a/src/wifi/helper/wifi-radio-energy-model-helper.h +++ b/src/wifi/helper/wifi-radio-energy-model-helper.h @@ -10,6 +10,7 @@ #define WIFI_RADIO_ENERGY_MODEL_HELPER_H #include "ns3/energy-model-helper.h" +#include "ns3/wifi-export.h" #include "ns3/wifi-radio-energy-model.h" namespace ns3 @@ -22,7 +23,7 @@ namespace ns3 * This installer installs WifiRadioEnergyModel for only WifiNetDevice objects. * */ -class WifiRadioEnergyModelHelper : public DeviceEnergyModelHelper +class WIFI_EXPORT WifiRadioEnergyModelHelper : public DeviceEnergyModelHelper { public: /** diff --git a/src/wifi/model/eht/eht-frame-exchange-manager.cc b/src/wifi/model/eht/eht-frame-exchange-manager.cc index d0e7d4259..217567924 100644 --- a/src/wifi/model/eht/eht-frame-exchange-manager.cc +++ b/src/wifi/model/eht/eht-frame-exchange-manager.cc @@ -343,7 +343,7 @@ EhtFrameExchangeManager::ForwardPsduDown(Ptr psdu, WifiTxVector& // EHT-SIG, the equivalent of HE-SIG-B, is present in EHT SU transmissions, too if (txVector.GetPreambleType() == WIFI_PREAMBLE_EHT_MU) { - auto phy = StaticCast(m_phy->GetPhyEntity(WIFI_MOD_CLASS_EHT)); + auto phy = std::static_pointer_cast(m_phy->GetPhyEntity(WIFI_MOD_CLASS_EHT)); auto sigBMode = phy->GetSigBMode(txVector); txVector.SetSigBMode(sigBMode); } @@ -472,7 +472,7 @@ EhtFrameExchangeManager::ForwardPsduMapDown(WifiConstPsduMap psduMap, WifiTxVect const auto psduMapIt = psduMap.find(aid); const auto aidNotFoundAndNotTf = (psduMapIt == psduMap.cend()) && !IsTrigger(psduMap); // the PSDU to process: the one addressed to the given AID (if any) or the unique one - const auto psdu = (psduMapIt != psduMap.cend() ? psduMapIt : psduMap.cbegin())->second; + const auto psdu = (psduMapIt != psduMap.cend() ? psduMapIt : psduMap.begin())->second; if (GetWifiRemoteStationManager()->GetEmlsrEnabled(*clientIt) && (aidNotFoundAndNotTf || GetEmlsrSwitchToListening(psdu, aid, *clientIt))) diff --git a/src/wifi/model/eht/eht-phy.cc b/src/wifi/model/eht/eht-phy.cc index c5669b63d..97095c59a 100644 --- a/src/wifi/model/eht/eht-phy.cc +++ b/src/wifi/model/eht/eht-phy.cc @@ -565,7 +565,7 @@ class ConstructorEht ConstructorEht() { ns3::EhtPhy::InitializeModes(); - ns3::WifiPhy::AddStaticPhyEntity(ns3::WIFI_MOD_CLASS_EHT, ns3::Create()); + ns3::WifiPhy::AddStaticPhyEntity(ns3::WIFI_MOD_CLASS_EHT, std::make_shared()); } } g_constructor_eht; ///< the constructor for EHT modes diff --git a/src/wifi/model/he/constant-obss-pd-algorithm.cc b/src/wifi/model/he/constant-obss-pd-algorithm.cc index f97a896d3..5ef1a395a 100644 --- a/src/wifi/model/he/constant-obss-pd-algorithm.cc +++ b/src/wifi/model/he/constant-obss-pd-algorithm.cc @@ -48,11 +48,12 @@ ConstantObssPdAlgorithm::ConnectWifiNetDevice(const Ptr device) auto phy = device->GetPhy(); if (phy->GetStandard() >= WIFI_STANDARD_80211be) { - auto ehtPhy = DynamicCast(device->GetPhy()->GetPhyEntity(WIFI_MOD_CLASS_EHT)); + auto ehtPhy = + std::dynamic_pointer_cast(device->GetPhy()->GetPhyEntity(WIFI_MOD_CLASS_EHT)); NS_ASSERT(ehtPhy); ehtPhy->SetEndOfHeSigACallback(MakeCallback(&ConstantObssPdAlgorithm::ReceiveHeSigA, this)); } - auto hePhy = DynamicCast(phy->GetPhyEntity(WIFI_MOD_CLASS_HE)); + auto hePhy = std::dynamic_pointer_cast(phy->GetPhyEntity(WIFI_MOD_CLASS_HE)); NS_ASSERT(hePhy); hePhy->SetEndOfHeSigACallback(MakeCallback(&ConstantObssPdAlgorithm::ReceiveHeSigA, this)); ObssPdAlgorithm::ConnectWifiNetDevice(device); diff --git a/src/wifi/model/he/he-frame-exchange-manager.cc b/src/wifi/model/he/he-frame-exchange-manager.cc index eab1cc56a..dd175cc16 100644 --- a/src/wifi/model/he/he-frame-exchange-manager.cc +++ b/src/wifi/model/he/he-frame-exchange-manager.cc @@ -644,8 +644,8 @@ HeFrameExchangeManager::SendPsduMap() ForwardPsduDown(triggerPsdu, acknowledgment->muBarTxVector); // Pass TRIGVECTOR to HE PHY (equivalent to PHY-TRIGGER.request primitive) - auto hePhy = - StaticCast(m_phy->GetPhyEntity(responseTxVector->GetModulationClass())); + auto hePhy = std::static_pointer_cast( + m_phy->GetPhyEntity(responseTxVector->GetModulationClass())); hePhy->SetTrigVector(m_trigVector, timeout); return; @@ -892,7 +892,8 @@ HeFrameExchangeManager::SendPsduMap() timerType == WifiTxTimer::WAIT_QOS_NULL_AFTER_BSRP_TF) { // Pass TRIGVECTOR to HE PHY (equivalent to PHY-TRIGGER.request primitive) - auto hePhy = StaticCast(m_phy->GetPhyEntity(responseTxVector->GetModulationClass())); + auto hePhy = std::static_pointer_cast( + m_phy->GetPhyEntity(responseTxVector->GetModulationClass())); hePhy->SetTrigVector(m_trigVector, m_txTimer.GetDelayLeft()); } else if (timerType == WifiTxTimer::NOT_RUNNING && @@ -929,7 +930,8 @@ HeFrameExchangeManager::ForwardPsduMapDown(WifiConstPsduMap psduMap, WifiTxVecto if (ns3::IsDlMu(txVector.GetPreambleType())) { - auto hePhy = StaticCast(m_phy->GetPhyEntity(txVector.GetModulationClass())); + auto hePhy = + std::static_pointer_cast(m_phy->GetPhyEntity(txVector.GetModulationClass())); auto sigBMode = hePhy->GetSigBMode(txVector); txVector.SetSigBMode(sigBMode); } diff --git a/src/wifi/model/he/he-phy.cc b/src/wifi/model/he/he-phy.cc index c2ad01ec5..b05b52afd 100644 --- a/src/wifi/model/he/he-phy.cc +++ b/src/wifi/model/he/he-phy.cc @@ -1888,7 +1888,7 @@ class ConstructorHe ConstructorHe() { ns3::HePhy::InitializeModes(); - ns3::WifiPhy::AddStaticPhyEntity(ns3::WIFI_MOD_CLASS_HE, ns3::Create()); + ns3::WifiPhy::AddStaticPhyEntity(ns3::WIFI_MOD_CLASS_HE, std::make_shared()); } } g_constructor_he; ///< the constructor for HE modes diff --git a/src/wifi/model/he/obss-pd-algorithm.cc b/src/wifi/model/he/obss-pd-algorithm.cc index 3d172b2c6..6c23e9a04 100644 --- a/src/wifi/model/he/obss-pd-algorithm.cc +++ b/src/wifi/model/he/obss-pd-algorithm.cc @@ -76,11 +76,13 @@ ObssPdAlgorithm::ConnectWifiNetDevice(const Ptr device) auto phy = device->GetPhy(); if (phy->GetStandard() >= WIFI_STANDARD_80211be) { - auto ehtPhy = DynamicCast(device->GetPhy()->GetPhyEntity(WIFI_MOD_CLASS_EHT)); + auto ehtPhy = + std::dynamic_pointer_cast(device->GetPhy()->GetPhyEntity(WIFI_MOD_CLASS_EHT)); NS_ASSERT(ehtPhy); ehtPhy->SetObssPdAlgorithm(this); } - auto hePhy = DynamicCast(device->GetPhy()->GetPhyEntity(WIFI_MOD_CLASS_HE)); + auto hePhy = + std::dynamic_pointer_cast(device->GetPhy()->GetPhyEntity(WIFI_MOD_CLASS_HE)); NS_ASSERT(hePhy); hePhy->SetObssPdAlgorithm(this); } diff --git a/src/wifi/model/ht/ht-phy.cc b/src/wifi/model/ht/ht-phy.cc index ae77fee1b..ab4cb2d3c 100644 --- a/src/wifi/model/ht/ht-phy.cc +++ b/src/wifi/model/ht/ht-phy.cc @@ -938,7 +938,7 @@ class ConstructorHt { ns3::HtPhy::InitializeModes(); ns3::WifiPhy::AddStaticPhyEntity(ns3::WIFI_MOD_CLASS_HT, - ns3::Create()); // dummy Nss + std::make_shared()); // dummy Nss } } g_constructor_ht; ///< the constructor for HT modes diff --git a/src/wifi/model/interference-helper.cc b/src/wifi/model/interference-helper.cc index b7c7273e2..18036d1ce 100644 --- a/src/wifi/model/interference-helper.cc +++ b/src/wifi/model/interference-helper.cc @@ -10,6 +10,7 @@ #include "interference-helper.h" #include "error-rate-model.h" +#include "phy-entity.h" #include "wifi-phy-operating-channel.h" #include "wifi-phy.h" #include "wifi-psdu.h" @@ -641,12 +642,11 @@ InterferenceHelper::CalculatePayloadPer(Ptr event, } double -InterferenceHelper::CalculatePhyHeaderSectionPsr( - Ptr event, - NiChangesPerBand* nis, - MHz_u channelWidth, - const WifiSpectrumBandInfo& band, - PhyEntity::PhyHeaderSections phyHeaderSections) const +InterferenceHelper::CalculatePhyHeaderSectionPsr(Ptr event, + NiChangesPerBand* nis, + MHz_u channelWidth, + const WifiSpectrumBandInfo& band, + PhyHeaderSections phyHeaderSections) const { NS_LOG_FUNCTION(this << band); double psr = 1.0; /* Packet Success Rate */ @@ -716,7 +716,7 @@ InterferenceHelper::CalculatePhyHeaderPer(Ptr event, auto phyEntity = WifiPhy::GetStaticPhyEntity(event->GetPpdu()->GetTxVector().GetModulationClass()); - PhyEntity::PhyHeaderSections sections; + PhyHeaderSections sections; for (const auto& section : phyEntity->GetPhyHeaderSections(event->GetPpdu()->GetTxVector(), niIt.begin()->first)) { @@ -734,7 +734,7 @@ InterferenceHelper::CalculatePhyHeaderPer(Ptr event, return 1 - psr; } -PhyEntity::SnrPer +SnrPer InterferenceHelper::CalculatePayloadSnrPer(Ptr event, MHz_u channelWidth, const WifiSpectrumBandInfo& band, @@ -756,7 +756,7 @@ InterferenceHelper::CalculatePayloadSnrPer(Ptr event, const auto per = CalculatePayloadPer(event, channelWidth, &ni, band, staId, relativeMpduStartStop); - return PhyEntity::SnrPer(snr, per); + return SnrPer(snr, per); } double @@ -770,7 +770,7 @@ InterferenceHelper::CalculateSnr(Ptr event, return CalculateSnr(event->GetRxPower(band), noiseInterference, channelWidth, nss); } -PhyEntity::SnrPer +SnrPer InterferenceHelper::CalculatePhyHeaderSnrPer(Ptr event, MHz_u channelWidth, const WifiSpectrumBandInfo& band, @@ -786,7 +786,7 @@ InterferenceHelper::CalculatePhyHeaderSnrPer(Ptr event, */ const auto per = CalculatePhyHeaderPer(event, &ni, channelWidth, band, header); - return PhyEntity::SnrPer(snr, per); + return SnrPer(snr, per); } InterferenceHelper::NiChanges::iterator diff --git a/src/wifi/model/interference-helper.h b/src/wifi/model/interference-helper.h index 8513ee165..4e884501a 100644 --- a/src/wifi/model/interference-helper.h +++ b/src/wifi/model/interference-helper.h @@ -9,10 +9,14 @@ #ifndef INTERFERENCE_HELPER_H #define INTERFERENCE_HELPER_H -#include "phy-entity.h" +#include "wifi-phy-common.h" +#include "wifi-ppdu.h" +#include "wifi-tx-vector.h" #include "ns3/object.h" +#include + namespace ns3 { @@ -20,6 +24,11 @@ class WifiPpdu; class WifiPsdu; class ErrorRateModel; +/** + * A map of the received power for each band + */ +using RxPowerWattPerChannelBand = std::map; + /** * @ingroup wifi * @brief handles interference calculations @@ -241,11 +250,11 @@ class InterferenceHelper : public Object * * @return struct of SNR and PER (with PER being evaluated over the provided time window) */ - PhyEntity::SnrPer CalculatePayloadSnrPer(Ptr event, - MHz_u channelWidth, - const WifiSpectrumBandInfo& band, - uint16_t staId, - std::pair relativeMpduStartStop) const; + SnrPer CalculatePayloadSnrPer(Ptr event, + MHz_u channelWidth, + const WifiSpectrumBandInfo& band, + uint16_t staId, + std::pair relativeMpduStartStop) const; /** * Calculate the SNIR for the event (starting from now until the event end). * @@ -271,10 +280,10 @@ class InterferenceHelper : public Object * * @return struct of SNR and PER */ - PhyEntity::SnrPer CalculatePhyHeaderSnrPer(Ptr event, - MHz_u channelWidth, - const WifiSpectrumBandInfo& band, - WifiPpduField header) const; + SnrPer CalculatePhyHeaderSnrPer(Ptr event, + MHz_u channelWidth, + const WifiSpectrumBandInfo& band, + WifiPpduField header) const; /** * Notify that RX has started. @@ -505,7 +514,7 @@ class InterferenceHelper : public Object * @param nis the NiChanges * @param channelWidth the channel width for header measurement * @param band the band - * @param phyHeaderSections the map of PHY header sections (\see PhyEntity::PhyHeaderSections) + * @param phyHeaderSections the map of PHY header sections (\see PhyHeaderSections) * * @return the success rate of the PHY header sections */ @@ -513,7 +522,7 @@ class InterferenceHelper : public Object NiChangesPerBand* nis, MHz_u channelWidth, const WifiSpectrumBandInfo& band, - PhyEntity::PhyHeaderSections phyHeaderSections) const; + PhyHeaderSections phyHeaderSections) const; double m_noiseFigure; //!< noise figure (linear) Ptr m_errorRateModel; //!< error rate model diff --git a/src/wifi/model/non-ht/dsss-phy.cc b/src/wifi/model/non-ht/dsss-phy.cc index c8ee6d890..19a1bc4d4 100644 --- a/src/wifi/model/non-ht/dsss-phy.cc +++ b/src/wifi/model/non-ht/dsss-phy.cc @@ -404,7 +404,7 @@ class ConstructorDsss ConstructorDsss() { ns3::DsssPhy::InitializeModes(); - ns3::Ptr phyEntity = ns3::Create(); + auto phyEntity = std::make_shared(); ns3::WifiPhy::AddStaticPhyEntity(ns3::WIFI_MOD_CLASS_HR_DSSS, phyEntity); ns3::WifiPhy::AddStaticPhyEntity( ns3::WIFI_MOD_CLASS_DSSS, diff --git a/src/wifi/model/non-ht/erp-ofdm-phy.cc b/src/wifi/model/non-ht/erp-ofdm-phy.cc index c25413eff..43ef337b5 100644 --- a/src/wifi/model/non-ht/erp-ofdm-phy.cc +++ b/src/wifi/model/non-ht/erp-ofdm-phy.cc @@ -252,7 +252,7 @@ class ConstructorErpOfdm { ns3::ErpOfdmPhy::InitializeModes(); ns3::WifiPhy::AddStaticPhyEntity(ns3::WIFI_MOD_CLASS_ERP_OFDM, - ns3::Create()); + std::make_shared()); } } g_constructor_erp_ofdm; ///< the constructor for ERP-OFDM modes diff --git a/src/wifi/model/non-ht/ofdm-phy.cc b/src/wifi/model/non-ht/ofdm-phy.cc index 060040016..ffda00fba 100644 --- a/src/wifi/model/non-ht/ofdm-phy.cc +++ b/src/wifi/model/non-ht/ofdm-phy.cc @@ -709,8 +709,9 @@ class ConstructorOfdm ConstructorOfdm() { ns3::OfdmPhy::InitializeModes(); - ns3::WifiPhy::AddStaticPhyEntity(ns3::WIFI_MOD_CLASS_OFDM, - ns3::Create()); // default variant will do + ns3::WifiPhy::AddStaticPhyEntity( + ns3::WIFI_MOD_CLASS_OFDM, + std::make_shared()); // default variant will do } } g_constructor_ofdm; ///< the constructor for OFDM modes diff --git a/src/wifi/model/phy-entity.cc b/src/wifi/model/phy-entity.cc index 97fab508f..829e3276b 100644 --- a/src/wifi/model/phy-entity.cc +++ b/src/wifi/model/phy-entity.cc @@ -15,13 +15,16 @@ #include "interference-helper.h" #include "preamble-detection-model.h" #include "spectrum-wifi-phy.h" +#include "wifi-net-device.h" #include "wifi-psdu.h" +#include "wifi-radio-energy-model.h" #include "wifi-spectrum-signal-parameters.h" #include "wifi-utils.h" #include "ns3/assert.h" #include "ns3/data-rate.h" #include "ns3/log.h" +#include "ns3/mobility-model.h" #include "ns3/packet.h" #include "ns3/simulator.h" @@ -212,7 +215,7 @@ PhyEntity::GetAddressedPsduInPpdu(Ptr ppdu) const return ppdu->GetPsdu(); } -PhyEntity::PhyHeaderSections +PhyHeaderSections PhyEntity::GetPhyHeaderSections(const WifiTxVector& txVector, Time ppduStart) const { PhyHeaderSections map; @@ -257,7 +260,7 @@ PhyEntity::GetDurationUpToField(WifiPpduField field, const WifiTxVector& txVecto .first; // return the start time of field relatively to the beginning of the PPDU } -PhyEntity::SnrPer +SnrPer PhyEntity::GetPhyHeaderSnrPer(WifiPpduField field, Ptr event) const { const auto measurementChannelWidth = GetMeasurementChannelWidth(event->GetPpdu()); diff --git a/src/wifi/model/phy-entity.h b/src/wifi/model/phy-entity.h index 1b903cd70..b86fa1138 100644 --- a/src/wifi/model/phy-entity.h +++ b/src/wifi/model/phy-entity.h @@ -13,6 +13,8 @@ #define PHY_ENTITY_H #include "wifi-phy-band.h" +#include "wifi-phy-state-helper.h" +#include "wifi-phy.h" #include "wifi-ppdu.h" #include "wifi-tx-vector.h" #include "wifi-types.h" @@ -20,6 +22,7 @@ #include "ns3/event-id.h" #include "ns3/nstime.h" #include "ns3/simple-ref-count.h" +#include "ns3/wifi-export.h" #include #include @@ -60,7 +63,7 @@ class WifiPpdu; * to be used by each PHY entity, corresponding to * the different amendments of the IEEE 802.11 standard. */ -class PhyEntity : public SimpleRefCount +class WIFI_EXPORT PhyEntity { public: /** @@ -108,34 +111,6 @@ class PhyEntity : public SimpleRefCount } }; - /** - * A struct for both SNR and PER - */ - struct SnrPer - { - double snr{0.0}; ///< SNR in linear scale - double per{1.0}; ///< PER - - /** - * Default constructor. - */ - SnrPer() - { - } - - /** - * Constructor for SnrPer. - * - * @param s the SNR in linear scale - * @param p the PER - */ - SnrPer(double s, double p) - : snr(s), - per(p) - { - } - }; - /** * Destructor for PHY entity */ @@ -282,16 +257,6 @@ class PhyEntity : public SimpleRefCount */ virtual uint32_t GetMaxPsduSize() const = 0; - /** - * A pair containing information on the PHY header chunk, namely - * the start and stop times of the chunk and the WifiMode used. - */ - typedef std::pair, WifiMode> PhyHeaderChunkInfo; - /** - * A map of PhyHeaderChunkInfo elements per PPDU field. - * @see PhyHeaderChunkInfo - */ - typedef std::map PhyHeaderSections; /** * Return a map of PHY header chunk information per PPDU field. * This map will contain the PPDU fields that are actually present based diff --git a/src/wifi/model/qos-utils.h b/src/wifi/model/qos-utils.h index 4b4e26efe..bba6878bc 100644 --- a/src/wifi/model/qos-utils.h +++ b/src/wifi/model/qos-utils.h @@ -11,6 +11,7 @@ #include "ns3/fatal-error.h" #include "ns3/ptr.h" +#include "ns3/wifi-export.h" #include @@ -195,7 +196,7 @@ bool operator<=(AcIndex left, AcIndex right); * Map containing the four ACs in increasing order of priority (according to * Table 10-1 "UP-to-AC Mappings" of 802.11-2016) */ -extern const std::map wifiAcList; +WIFI_EXPORT extern const std::map wifiAcList; /** * @ingroup wifi diff --git a/src/wifi/model/vht/vht-phy.cc b/src/wifi/model/vht/vht-phy.cc index 27554be72..f36479a52 100644 --- a/src/wifi/model/vht/vht-phy.cc +++ b/src/wifi/model/vht/vht-phy.cc @@ -583,7 +583,7 @@ class ConstructorVht ConstructorVht() { ns3::VhtPhy::InitializeModes(); - ns3::WifiPhy::AddStaticPhyEntity(ns3::WIFI_MOD_CLASS_VHT, ns3::Create()); + ns3::WifiPhy::AddStaticPhyEntity(ns3::WIFI_MOD_CLASS_VHT, std::make_shared()); } } g_constructor_vht; ///< the constructor for VHT modes diff --git a/src/wifi/model/wifi-constants.h b/src/wifi/model/wifi-constants.h index 71cccbe26..f238df0e9 100644 --- a/src/wifi/model/wifi-constants.h +++ b/src/wifi/model/wifi-constants.h @@ -10,6 +10,7 @@ #define WIFI_CONSTANTS_H #include "ns3/nstime.h" +#include "ns3/wifi-export.h" /** * @file @@ -22,7 +23,7 @@ namespace ns3 /// Wi-Fi Time Unit value in microseconds (see IEEE 802.11-2020 sec. 3.1) /// Used to initialize WIFI_TU -extern const Time WIFI_TU; +WIFI_EXPORT extern const Time WIFI_TU; /// aRxPHYStartDelay value to use when waiting for a new frame in the context of EMLSR operations /// (Sec. 35.3.17 of 802.11be D3.1) @@ -59,10 +60,10 @@ extern const Time DSSS_SIFS_TIME; extern const Time DSSS_SLOT_TIME; /// maximum propagation delay -extern const Time MAX_PROPAGATION_DELAY; +WIFI_EXPORT extern const Time MAX_PROPAGATION_DELAY; /// The aMediumSyncThreshold defined by Sec. 35.3.16.18.1 of 802.11be D4.0 -extern const Time MEDIUM_SYNC_THRESHOLD; +WIFI_EXPORT extern const Time MEDIUM_SYNC_THRESHOLD; /// Subcarrier frequency spacing in Hz (Table 19-6 "Timing-related constants" of 802.11-2020) static constexpr uint32_t SUBCARRIER_FREQUENCY_SPACING{312500}; diff --git a/src/wifi/model/wifi-phy-common.h b/src/wifi/model/wifi-phy-common.h index 626f5f58b..ef93ad077 100644 --- a/src/wifi/model/wifi-phy-common.h +++ b/src/wifi/model/wifi-phy-common.h @@ -728,6 +728,45 @@ const std::map channelTypeToScalingFactor{ {WIFI_CHANLIST_SECONDARY160, 12.0}, }; +/** + * A struct for both SNR and PER + */ +struct SnrPer +{ + double snr{0.0}; ///< SNR in linear scale + double per{1.0}; ///< PER + + /** + * Default constructor. + */ + SnrPer() + { + } + + /** + * Constructor for SnrPer. + * + * @param s the SNR in linear scale + * @param p the PER + */ + SnrPer(double s, double p) + : snr(s), + per(p) + { + } +}; + +/** + * A pair containing information on the PHY header chunk, namely + * the start and stop times of the chunk and the WifiMode used. + */ +typedef std::pair, WifiMode> PhyHeaderChunkInfo; +/** + * A map of PhyHeaderChunkInfo elements per PPDU field. + * @see PhyHeaderChunkInfo + */ +typedef std::map PhyHeaderSections; + } // namespace ns3 #endif /* WIFI_PHY_COMMON_H */ diff --git a/src/wifi/model/wifi-phy-operating-channel.cc b/src/wifi/model/wifi-phy-operating-channel.cc index 056782df4..5cb95de42 100644 --- a/src/wifi/model/wifi-phy-operating-channel.cc +++ b/src/wifi/model/wifi-phy-operating-channel.cc @@ -276,6 +276,12 @@ operator<<(std::ostream& os, const FrequencyChannelInfo& info) return os; } +const std::set& +WifiPhyOperatingChannel::GetFrequencyChannels() +{ + return m_frequencyChannels; +} + bool WifiPhyOperatingChannel::Compare::operator()(const ConstIterator& first, const ConstIterator& second) const diff --git a/src/wifi/model/wifi-phy-operating-channel.h b/src/wifi/model/wifi-phy-operating-channel.h index 3152042cf..1be897174 100644 --- a/src/wifi/model/wifi-phy-operating-channel.h +++ b/src/wifi/model/wifi-phy-operating-channel.h @@ -14,6 +14,8 @@ #include "wifi-phy-common.h" #include "wifi-ru.h" +#include "ns3/wifi-export.h" + #include #include #include @@ -25,7 +27,7 @@ namespace ns3 /** * A structure containing the information about a frequency channel */ -struct FrequencyChannelInfo +struct WIFI_EXPORT FrequencyChannelInfo { /** * @brief spaceship operator. @@ -57,7 +59,7 @@ std::ostream& operator<<(std::ostream& os, const FrequencyChannelInfo& info); * * Class that keeps track of all information about the current PHY operating channel. */ -class WifiPhyOperatingChannel +class WIFI_EXPORT WifiPhyOperatingChannel { public: /// Typedef for a const iterator pointing to a channel in the set of available channels @@ -127,6 +129,13 @@ class WifiPhyOperatingChannel static const std::set m_frequencyChannels; //!< Available frequency channels + /** + * Return a reference to the set of all available frequency channels + * + * @return reference to the set of frequency channels + */ + static const std::set& GetFrequencyChannels(); + /** * Return true if a valid channel has been set, false otherwise. * @@ -359,7 +368,7 @@ class WifiPhyOperatingChannel MHz_u width, WifiStandard standard, WifiPhyBand band, - ConstIterator start = m_frequencyChannels.begin()); + ConstIterator start = GetFrequencyChannels().begin()); /** * Get channel number of the primary channel diff --git a/src/wifi/model/wifi-phy-state-helper.h b/src/wifi/model/wifi-phy-state-helper.h index c9a22fb1d..84bec55fb 100644 --- a/src/wifi/model/wifi-phy-state-helper.h +++ b/src/wifi/model/wifi-phy-state-helper.h @@ -9,7 +9,6 @@ #ifndef WIFI_PHY_STATE_HELPER_H #define WIFI_PHY_STATE_HELPER_H -#include "phy-entity.h" #include "wifi-phy-common.h" #include "wifi-phy-state.h" #include "wifi-ppdu.h" @@ -18,6 +17,7 @@ #include "ns3/nstime.h" #include "ns3/object.h" #include "ns3/traced-callback.h" +#include "ns3/wifi-export.h" #include #include @@ -62,7 +62,7 @@ typedef Callback> RxErrorCallback; * * This objects implements the PHY state machine of the Wifi device. */ -class WifiPhyStateHelper : public Object +class WIFI_EXPORT WifiPhyStateHelper : public Object { public: /** diff --git a/src/wifi/model/wifi-phy.cc b/src/wifi/model/wifi-phy.cc index b0b8a37df..3a201e71e 100644 --- a/src/wifi/model/wifi-phy.cc +++ b/src/wifi/model/wifi-phy.cc @@ -12,6 +12,7 @@ #include "error-rate-model.h" #include "frame-capture-model.h" #include "interference-helper.h" +#include "phy-entity.h" #include "preamble-detection-model.h" #include "wifi-net-device.h" #include "wifi-ppdu.h" @@ -470,10 +471,10 @@ WifiPhy::DoDispose() m_phyEntities.clear(); } -std::map>& +std::map>& WifiPhy::GetStaticPhyEntities() { - static std::map> g_staticPhyEntities; + static std::map> g_staticPhyEntities; return g_staticPhyEntities; } @@ -756,7 +757,7 @@ WifiPhy::CalculateSnr(const WifiTxVector& txVector, double ber) const return m_interference->GetErrorRateModel()->CalculateSnr(txVector, ber); } -const Ptr +const std::shared_ptr WifiPhy::GetStaticPhyEntity(WifiModulationClass modulation) { const auto it = GetStaticPhyEntities().find(modulation); @@ -765,7 +766,7 @@ WifiPhy::GetStaticPhyEntity(WifiModulationClass modulation) return it->second; } -Ptr +std::shared_ptr WifiPhy::GetPhyEntity(WifiModulationClass modulation) const { const auto it = m_phyEntities.find(modulation); @@ -774,19 +775,19 @@ WifiPhy::GetPhyEntity(WifiModulationClass modulation) const return it->second; } -Ptr +std::shared_ptr WifiPhy::GetPhyEntity(WifiStandard standard) const { return GetPhyEntity(GetModulationClassForStandard(standard)); } -Ptr +std::shared_ptr WifiPhy::GetLatestPhyEntity() const { return GetPhyEntity(m_standard); } -Ptr +std::shared_ptr WifiPhy::GetPhyEntityForPpdu(const Ptr ppdu) const { NS_ABORT_IF(!ppdu); @@ -807,7 +808,7 @@ WifiPhy::GetPhyEntityForPpdu(const Ptr ppdu) const } void -WifiPhy::AddStaticPhyEntity(WifiModulationClass modulation, Ptr phyEntity) +WifiPhy::AddStaticPhyEntity(WifiModulationClass modulation, std::shared_ptr phyEntity) { NS_ASSERT_MSG(!GetStaticPhyEntities().contains(modulation), "The PHY entity has already been added. The setting should only be done once per " @@ -816,7 +817,7 @@ WifiPhy::AddStaticPhyEntity(WifiModulationClass modulation, Ptr phyEn } void -WifiPhy::AddPhyEntity(WifiModulationClass modulation, Ptr phyEntity) +WifiPhy::AddPhyEntity(WifiModulationClass modulation, std::shared_ptr phyEntity) { NS_LOG_FUNCTION(this << modulation); NS_ABORT_MSG_IF(!GetStaticPhyEntities().contains(modulation), @@ -868,7 +869,7 @@ void WifiPhy::Configure80211a() { NS_LOG_FUNCTION(this); - AddPhyEntity(WIFI_MOD_CLASS_OFDM, Create()); + AddPhyEntity(WIFI_MOD_CLASS_OFDM, std::make_shared()); // See Table 17-21 "OFDM PHY characteristics" of 802.11-2016 SetSifs(OFDM_SIFS_TIME_20MHZ); @@ -882,7 +883,7 @@ void WifiPhy::Configure80211b() { NS_LOG_FUNCTION(this); - Ptr phyEntity = Create(); + std::shared_ptr phyEntity = std::make_shared(); AddPhyEntity(WIFI_MOD_CLASS_HR_DSSS, phyEntity); AddPhyEntity(WIFI_MOD_CLASS_DSSS, phyEntity); // when plain DSSS modes are used @@ -903,7 +904,7 @@ WifiPhy::Configure80211g() // if the user sets the ShortSlotTimeSupported flag to true and when the BSS // consists of only ERP STAs capable of supporting this option. Configure80211b(); - AddPhyEntity(WIFI_MOD_CLASS_ERP_OFDM, Create()); + AddPhyEntity(WIFI_MOD_CLASS_ERP_OFDM, std::make_shared()); } void @@ -912,7 +913,7 @@ WifiPhy::Configure80211p() NS_LOG_FUNCTION(this); if (GetChannelWidth() == MHz_u{10}) { - AddPhyEntity(WIFI_MOD_CLASS_OFDM, Create(OFDM_PHY_10_MHZ)); + AddPhyEntity(WIFI_MOD_CLASS_OFDM, std::make_shared(OFDM_PHY_10_MHZ)); // See Table 17-21 "OFDM PHY characteristics" of 802.11-2016 SetSifs(OFDM_SIFS_TIME_10MHZ); @@ -921,7 +922,7 @@ WifiPhy::Configure80211p() } else if (GetChannelWidth() == MHz_u{5}) { - AddPhyEntity(WIFI_MOD_CLASS_OFDM, Create(OFDM_PHY_5_MHZ)); + AddPhyEntity(WIFI_MOD_CLASS_OFDM, std::make_shared(OFDM_PHY_5_MHZ)); // See Table 17-21 "OFDM PHY characteristics" of 802.11-2016 SetSifs(OFDM_SIFS_TIME_5MHZ); @@ -946,7 +947,7 @@ WifiPhy::Configure80211n() { Configure80211a(); } - AddPhyEntity(WIFI_MOD_CLASS_HT, Create(m_txSpatialStreams)); + AddPhyEntity(WIFI_MOD_CLASS_HT, std::make_shared(m_txSpatialStreams)); } void @@ -954,7 +955,7 @@ WifiPhy::Configure80211ac() { NS_LOG_FUNCTION(this); Configure80211n(); - AddPhyEntity(WIFI_MOD_CLASS_VHT, Create()); + AddPhyEntity(WIFI_MOD_CLASS_VHT, std::make_shared()); } void @@ -969,7 +970,7 @@ WifiPhy::Configure80211ax() { Configure80211ac(); } - AddPhyEntity(WIFI_MOD_CLASS_HE, Create()); + AddPhyEntity(WIFI_MOD_CLASS_HE, std::make_shared()); } void @@ -977,7 +978,7 @@ WifiPhy::Configure80211be() { NS_LOG_FUNCTION(this); Configure80211ax(); - AddPhyEntity(WIFI_MOD_CLASS_EHT, Create()); + AddPhyEntity(WIFI_MOD_CLASS_EHT, std::make_shared()); } void @@ -1335,7 +1336,7 @@ WifiPhy::SetMaxSupportedTxSpatialStreams(uint8_t streams) auto phyEntity = m_phyEntities.find(WIFI_MOD_CLASS_HT); if (phyEntity != m_phyEntities.end()) { - Ptr htPhy = DynamicCast(phyEntity->second); + std::shared_ptr htPhy = std::dynamic_pointer_cast(phyEntity->second); if (htPhy) { htPhy->SetMaxSupportedNss( @@ -1380,7 +1381,7 @@ WifiPhy::GetBssMembershipSelectorList() const std::list list; for (const auto& phyEntity : m_phyEntities) { - Ptr htPhy = DynamicCast(phyEntity.second); + std::shared_ptr htPhy = std::dynamic_pointer_cast(phyEntity.second); if (htPhy) { list.emplace_back(htPhy->GetBssMembershipSelector()); diff --git a/src/wifi/model/wifi-phy.h b/src/wifi/model/wifi-phy.h index baccaae15..b20426542 100644 --- a/src/wifi/model/wifi-phy.h +++ b/src/wifi/model/wifi-phy.h @@ -10,12 +10,18 @@ #ifndef WIFI_PHY_H #define WIFI_PHY_H -#include "phy-entity.h" +#include "frame-capture-model.h" +#include "interference-helper.h" +#include "preamble-detection-model.h" +#include "wifi-net-device.h" #include "wifi-phy-operating-channel.h" #include "wifi-phy-state-helper.h" +#include "wifi-radio-energy-model.h" #include "wifi-standards.h" #include "ns3/error-model.h" +#include "ns3/mobility-model.h" +#include "ns3/wifi-export.h" #include @@ -35,6 +41,7 @@ namespace ns3 { class Channel; +class PhyEntity; class WifiNetDevice; class MobilityModel; class WifiPhyStateHelper; @@ -51,7 +58,7 @@ class WifiMacHeader; * @ingroup wifi * */ -class WifiPhy : public Object +class WIFI_EXPORT WifiPhy : public Object { public: friend class PhyEntity; @@ -1162,7 +1169,8 @@ class WifiPhy : public Object * @param modulation the modulation class * @param phyEntity the PHY entity */ - static void AddStaticPhyEntity(WifiModulationClass modulation, Ptr phyEntity); + static void AddStaticPhyEntity(WifiModulationClass modulation, + std::shared_ptr phyEntity); /** * Get the __implemented__ PHY entity corresponding to the modulation class. @@ -1172,7 +1180,8 @@ class WifiPhy : public Object * @param modulation the modulation class * @return the pointer to the static implemented PHY entity */ - static const Ptr GetStaticPhyEntity(WifiModulationClass modulation); + static const std::shared_ptr GetStaticPhyEntity( + WifiModulationClass modulation); /** * Get the supported PHY entity to use for a received PPDU. @@ -1185,7 +1194,7 @@ class WifiPhy : public Object * @param ppdu the received PPDU * @return the pointer to the supported PHY entity */ - Ptr GetPhyEntityForPpdu(const Ptr ppdu) const; + std::shared_ptr GetPhyEntityForPpdu(const Ptr ppdu) const; /** * Get the supported PHY entity corresponding to the modulation class. @@ -1193,20 +1202,20 @@ class WifiPhy : public Object * @param modulation the modulation class * @return the pointer to the supported PHY entity */ - Ptr GetPhyEntity(WifiModulationClass modulation) const; + std::shared_ptr GetPhyEntity(WifiModulationClass modulation) const; /** * Get the supported PHY entity corresponding to the wifi standard. * * @param standard the wifi standard * @return the pointer to the supported PHY entity */ - Ptr GetPhyEntity(WifiStandard standard) const; + std::shared_ptr GetPhyEntity(WifiStandard standard) const; /** * Get the latest PHY entity supported by this PHY instance. * * @return the latest PHY entity supported by this PHY instance */ - Ptr GetLatestPhyEntity() const; + std::shared_ptr GetLatestPhyEntity() const; /** * @return the UID of the previously received PPDU (reset to UINT64_MAX upon transmission) @@ -1335,7 +1344,7 @@ class WifiPhy : public Object * @param modulation the modulation class * @param phyEntity the PHY entity */ - void AddPhyEntity(WifiModulationClass modulation, Ptr phyEntity); + void AddPhyEntity(WifiModulationClass modulation, std::shared_ptr phyEntity); uint8_t m_phyId; //!< the index of the PHY in the vector of PHYs held by the WifiNetDevice @@ -1378,7 +1387,7 @@ class WifiPhy : public Object * looking for WifiMode objects for which * WifiMode::IsMandatory() is true. */ - std::map> m_phyEntities; + std::map> m_phyEntities; TracedCallback, const WifiTxVector&> m_signalTransmissionCb; //!< Signal Transmission callback @@ -1599,7 +1608,7 @@ class WifiPhy : public Object * For PHY entities supported by a given WifiPhy instance, * @see m_phyEntities. */ - static std::map>& GetStaticPhyEntities(); + static std::map>& GetStaticPhyEntities(); WifiStandard m_standard; //!< WifiStandard WifiModulationClass m_maxModClassSupported; //!< max modulation class supported diff --git a/src/wifi/model/wifi-standards.h b/src/wifi/model/wifi-standards.h index 0874ad73f..783b339ff 100644 --- a/src/wifi/model/wifi-standards.h +++ b/src/wifi/model/wifi-standards.h @@ -14,6 +14,7 @@ #include "wifi-units.h" #include "ns3/abort.h" +#include "ns3/wifi-export.h" #include #include @@ -78,7 +79,7 @@ operator<<(std::ostream& os, WifiStandard standard) /** * @brief map a given standard configured by the user to the allowed PHY bands */ -extern const std::map> wifiStandards; +WIFI_EXPORT extern const std::map> wifiStandards; /** * Get the type of the frequency channel for the given standard diff --git a/src/wifi/test/tx-duration-test.cc b/src/wifi/test/tx-duration-test.cc index 523d1452e..d548fa19e 100644 --- a/src/wifi/test/tx-duration-test.cc +++ b/src/wifi/test/tx-duration-test.cc @@ -2235,8 +2235,7 @@ class PhyHeaderSectionsTest : public TestCase * @param obtained the map of PHY header sections to check * @param expected the expected map of PHY header sections */ - void CheckPhyHeaderSections(PhyEntity::PhyHeaderSections obtained, - PhyEntity::PhyHeaderSections expected); + void CheckPhyHeaderSections(PhyHeaderSections obtained, PhyHeaderSections expected); }; PhyHeaderSectionsTest::PhyHeaderSectionsTest() @@ -2249,8 +2248,8 @@ PhyHeaderSectionsTest::~PhyHeaderSectionsTest() } void -PhyHeaderSectionsTest::CheckPhyHeaderSections(PhyEntity::PhyHeaderSections obtained, - PhyEntity::PhyHeaderSections expected) +PhyHeaderSectionsTest::CheckPhyHeaderSections(PhyHeaderSections obtained, + PhyHeaderSections expected) { NS_ASSERT_MSG(obtained.size() == expected.size(), "The expected map size (" << expected.size() << ") was not obtained (" @@ -2295,14 +2294,14 @@ void PhyHeaderSectionsTest::DoRun() { Time ppduStart = Seconds(1); - Ptr phyEntity; - PhyEntity::PhyHeaderSections sections; + std::shared_ptr phyEntity; + PhyHeaderSections sections; WifiTxVector txVector; WifiMode nonHtMode; // ================================================================================== // 11b (HR/DSSS) - phyEntity = Create(); + phyEntity = std::make_shared(); txVector.SetMode(DsssPhy::GetDsssRate1Mbps()); txVector.SetChannelWidth(MHz_u{22}); @@ -2344,7 +2343,7 @@ PhyHeaderSectionsTest::DoRun() }; for (auto variant : variants) { - phyEntity = Create(variant.first); + phyEntity = std::make_shared(variant.first); std::size_t ratio = variant.second; const auto bw = MHz_u{20} / ratio; txVector.SetChannelWidth(bw); @@ -2362,7 +2361,7 @@ PhyHeaderSectionsTest::DoRun() // ================================================================================== // 11g (ERP-OFDM) - phyEntity = Create(); + phyEntity = std::make_shared(); txVector.SetChannelWidth(MHz_u{20}); txVector.SetMode(ErpOfdmPhy::GetErpOfdmRate(54000000)); nonHtMode = ErpOfdmPhy::GetErpOfdmRate6Mbps(); @@ -2375,7 +2374,7 @@ PhyHeaderSectionsTest::DoRun() // ================================================================================== // 11n (HT) - phyEntity = Create(4); + phyEntity = std::make_shared(4); txVector.SetChannelWidth(MHz_u{20}); txVector.SetMode(HtPhy::GetHtMcs6()); nonHtMode = OfdmPhy::GetOfdmRate6Mbps(); @@ -2410,7 +2409,7 @@ PhyHeaderSectionsTest::DoRun() // ================================================================================== // 11ac (VHT) - phyEntity = Create(); + phyEntity = std::make_shared(); txVector.SetChannelWidth(MHz_u{20}); txVector.SetNess(0); txVector.SetMode(VhtPhy::GetVhtMcs7()); @@ -2453,7 +2452,7 @@ PhyHeaderSectionsTest::DoRun() // ================================================================================== // 11ax (HE) - phyEntity = Create(); + phyEntity = std::make_shared(); txVector.SetChannelWidth(MHz_u{20}); txVector.SetNss(2); // HE-LTF duration assumed to be always 8 us for the time being (see note in // HePhy::GetTrainingDuration) @@ -2526,7 +2525,7 @@ PhyHeaderSectionsTest::DoRun() // 11be (EHT) sections.erase(WIFI_PPDU_FIELD_SIG_A); // FIXME: do we keep using separate type for 11be? sections.erase(WIFI_PPDU_FIELD_SIG_B); // FIXME: do we keep using separate type for 11be? - phyEntity = Create(); + phyEntity = std::make_shared(); txVector.SetChannelWidth(MHz_u{20}); txVector.SetNss(2); // EHT-LTF duration assumed to be always 8 us for the time being (see note // in HePhy::GetTrainingDuration) diff --git a/src/wifi/test/wifi-eht-info-elems-test.cc b/src/wifi/test/wifi-eht-info-elems-test.cc index fa8f814d6..bbf7213ab 100644 --- a/src/wifi/test/wifi-eht-info-elems-test.cc +++ b/src/wifi/test/wifi-eht-info-elems-test.cc @@ -635,7 +635,7 @@ ReducedNeighborReportTest::GetReducedNeighborReport(PhyOpChannelIt channel2_4It, std::stringstream info; - if (channel2_4It != WifiPhyOperatingChannel::m_frequencyChannels.cend()) + if (channel2_4It != WifiPhyOperatingChannel::GetFrequencyChannels().cend()) { WifiPhyOperatingChannel channel(channel2_4It); @@ -652,7 +652,7 @@ ReducedNeighborReportTest::GetReducedNeighborReport(PhyOpChannelIt channel2_4It, rnr.SetMldParameters(nbrId, 0, {0, 2, 3, 1, 1}); } - if (channel5It != WifiPhyOperatingChannel::m_frequencyChannels.cend()) + if (channel5It != WifiPhyOperatingChannel::GetFrequencyChannels().cend()) { WifiPhyOperatingChannel channel(channel5It); @@ -676,7 +676,7 @@ ReducedNeighborReportTest::GetReducedNeighborReport(PhyOpChannelIt channel2_4It, rnr.SetMldParameters(nbrId, 1, {0, 4, 5, 1, 0}); } - if (channel6It != WifiPhyOperatingChannel::m_frequencyChannels.cend()) + if (channel6It != WifiPhyOperatingChannel::GetFrequencyChannels().cend()) { WifiPhyOperatingChannel channel(channel6It); @@ -703,14 +703,15 @@ ReducedNeighborReportTest::DoRun() PhyOpChannelIt channel2_4It; PhyOpChannelIt channel5It; PhyOpChannelIt channel6It; - channel2_4It = channel5It = channel6It = WifiPhyOperatingChannel::m_frequencyChannels.cbegin(); + channel2_4It = channel5It = channel6It = + WifiPhyOperatingChannel::GetFrequencyChannels().cbegin(); // Test all available frequency channels - while (channel2_4It != WifiPhyOperatingChannel::m_frequencyChannels.cend() || - channel5It != WifiPhyOperatingChannel::m_frequencyChannels.cend() || - channel6It != WifiPhyOperatingChannel::m_frequencyChannels.cend()) + while (channel2_4It != WifiPhyOperatingChannel::GetFrequencyChannels().cend() || + channel5It != WifiPhyOperatingChannel::GetFrequencyChannels().cend() || + channel6It != WifiPhyOperatingChannel::GetFrequencyChannels().cend()) { - if (channel2_4It != WifiPhyOperatingChannel::m_frequencyChannels.cend()) + if (channel2_4It != WifiPhyOperatingChannel::GetFrequencyChannels().cend()) { channel2_4It = WifiPhyOperatingChannel::FindFirst(0, MHz_u{0}, @@ -719,7 +720,7 @@ ReducedNeighborReportTest::DoRun() WIFI_PHY_BAND_2_4GHZ, channel2_4It); } - if (channel5It != WifiPhyOperatingChannel::m_frequencyChannels.cend()) + if (channel5It != WifiPhyOperatingChannel::GetFrequencyChannels().cend()) { channel5It = WifiPhyOperatingChannel::FindFirst(0, MHz_u{0}, @@ -728,7 +729,7 @@ ReducedNeighborReportTest::DoRun() WIFI_PHY_BAND_5GHZ, channel5It); } - if (channel6It != WifiPhyOperatingChannel::m_frequencyChannels.cend()) + if (channel6It != WifiPhyOperatingChannel::GetFrequencyChannels().cend()) { channel6It = WifiPhyOperatingChannel::FindFirst(0, MHz_u{0}, @@ -741,15 +742,15 @@ ReducedNeighborReportTest::DoRun() TestHeaderSerialization(GetReducedNeighborReport(channel2_4It, channel5It, channel6It)); // advance all channel iterators - if (channel2_4It != WifiPhyOperatingChannel::m_frequencyChannels.cend()) + if (channel2_4It != WifiPhyOperatingChannel::GetFrequencyChannels().cend()) { channel2_4It++; } - if (channel5It != WifiPhyOperatingChannel::m_frequencyChannels.cend()) + if (channel5It != WifiPhyOperatingChannel::GetFrequencyChannels().cend()) { channel5It++; } - if (channel6It != WifiPhyOperatingChannel::m_frequencyChannels.cend()) + if (channel6It != WifiPhyOperatingChannel::GetFrequencyChannels().cend()) { channel6It++; } diff --git a/src/wifi/test/wifi-non-ht-dup-test.cc b/src/wifi/test/wifi-non-ht-dup-test.cc index 9a2310000..2d9ac8f3c 100644 --- a/src/wifi/test/wifi-non-ht-dup-test.cc +++ b/src/wifi/test/wifi-non-ht-dup-test.cc @@ -127,7 +127,8 @@ class MuRtsCtsSpectrumWifiPhy : public SpectrumWifiPhy void SetMuRtsTxVector(const WifiTxVector& muRtsTxVector); private: - Ptr m_muRtsCtsHePhy; ///< Pointer to HE PHY instance used for MU-RTS/CTS PHY test + std::shared_ptr + m_muRtsCtsHePhy; ///< Pointer to HE PHY instance used for MU-RTS/CTS PHY test // end of class MuRtsCtsSpectrumWifiPhy }; @@ -144,7 +145,7 @@ MuRtsCtsSpectrumWifiPhy::MuRtsCtsSpectrumWifiPhy() : SpectrumWifiPhy() { NS_LOG_FUNCTION(this); - m_muRtsCtsHePhy = Create(); + m_muRtsCtsHePhy = std::make_shared(); m_muRtsCtsHePhy->SetOwner(this); } diff --git a/src/wifi/test/wifi-phy-cca-test.cc b/src/wifi/test/wifi-phy-cca-test.cc index 3da2d2726..af5c98804 100644 --- a/src/wifi/test/wifi-phy-cca-test.cc +++ b/src/wifi/test/wifi-phy-cca-test.cc @@ -140,7 +140,7 @@ class WifiPhyCcaThresholdsTest : public TestCase * signal occupies * @param expectedCcaThreshold the CCA threshold that is expected to be reported */ - void VerifyCcaThreshold(const Ptr phy, + void VerifyCcaThreshold(const std::shared_ptr phy, const Ptr ppdu, WifiChannelListType channelType, dBm_u expectedCcaThreshold); @@ -273,7 +273,7 @@ WifiPhyCcaThresholdsTest::CreateDummyEhtPpdu(MHz_u bandwidth, } void -WifiPhyCcaThresholdsTest::VerifyCcaThreshold(const Ptr phy, +WifiPhyCcaThresholdsTest::VerifyCcaThreshold(const std::shared_ptr phy, const Ptr ppdu, WifiChannelListType channelType, dBm_u expectedCcaThreshold) diff --git a/src/wifi/test/wifi-phy-mu-mimo-test.cc b/src/wifi/test/wifi-phy-mu-mimo-test.cc index e2616b3b4..fcc49ff0a 100644 --- a/src/wifi/test/wifi-phy-mu-mimo-test.cc +++ b/src/wifi/test/wifi-phy-mu-mimo-test.cc @@ -273,7 +273,8 @@ class MuMimoSpectrumWifiPhy : public SpectrumWifiPhy void DoInitialize() override; void DoDispose() override; - Ptr m_ofdmTestHePhy; ///< Pointer to HE PHY instance used for MU-MIMO test + std::shared_ptr + m_ofdmTestHePhy; ///< Pointer to HE PHY instance used for MU-MIMO test // end of class MuMimoSpectrumWifiPhy }; @@ -289,7 +290,7 @@ MuMimoSpectrumWifiPhy::GetTypeId() MuMimoSpectrumWifiPhy::MuMimoSpectrumWifiPhy(uint16_t staId) : SpectrumWifiPhy() { - m_ofdmTestHePhy = Create(staId); + m_ofdmTestHePhy = std::make_shared(staId); m_ofdmTestHePhy->SetOwner(this); } @@ -1373,7 +1374,7 @@ TestUlMuMimoPhyTransmission::SetTrigVector(const std::vector& staIds, txVector, m_phyAp->GetPhyBand()); txVector.SetLength(length); - auto hePhyAp = DynamicCast(m_phyAp->GetPhyEntity(WIFI_MOD_CLASS_HE)); + auto hePhyAp = std::dynamic_pointer_cast(m_phyAp->GetPhyEntity(WIFI_MOD_CLASS_HE)); hePhyAp->SetTrigVector(txVector, m_expectedPpduDuration); } diff --git a/src/wifi/test/wifi-phy-ofdma-test.cc b/src/wifi/test/wifi-phy-ofdma-test.cc index 306e77c99..2c05b68e5 100644 --- a/src/wifi/test/wifi-phy-ofdma-test.cc +++ b/src/wifi/test/wifi-phy-ofdma-test.cc @@ -243,11 +243,11 @@ class OfdmaSpectrumWifiPhy : public SpectrumWifiPhy /** * @return a const pointer to the latest PHY entity instance */ - Ptr GetPhyEntity() const; + std::shared_ptr GetPhyEntity() const; private: /// Pointer to latest PHY entity instance used for OFDMA test - Ptr> m_ofdmaTestPhy; + std::shared_ptr> m_ofdmaTestPhy; /// Callback providing UID of the PPDU that is about to be transmitted TracedCallback m_phyTxPpduUidTrace; @@ -276,7 +276,7 @@ template OfdmaSpectrumWifiPhy::OfdmaSpectrumWifiPhy(uint16_t staId) : SpectrumWifiPhy() { - m_ofdmaTestPhy = Create>(staId); + m_ofdmaTestPhy = std::make_shared>(staId); m_ofdmaTestPhy->SetOwner(this); } @@ -344,10 +344,10 @@ OfdmaSpectrumWifiPhy::GetEnergyDuration(Watt_u energy, } template -Ptr +std::shared_ptr OfdmaSpectrumWifiPhy::GetPhyEntity() const { - return DynamicCast(m_ofdmaTestPhy /*GetLatestPhyEntity()*/); + return std::dynamic_pointer_cast(m_ofdmaTestPhy /*GetLatestPhyEntity()*/); } /** @@ -2706,7 +2706,7 @@ TestMultipleHeTbPreambles::RxHeTbPpdu(uint64_t uid, HePhy::ConvertHeTbPpduDurationToLSigLength(ppduDuration, txVector, m_phy->GetPhyBand()); txVector.SetLength(length); m_trigVector.SetLength(length); - auto hePhy = DynamicCast(m_phy->GetLatestPhyEntity()); + auto hePhy = std::dynamic_pointer_cast(m_phy->GetLatestPhyEntity()); hePhy->SetTrigVector(m_trigVector, ppduDuration); ppdu->ResetTxVector(); m_phy->StartRx(rxParams, nullptr); @@ -4348,7 +4348,8 @@ TestUlOfdmaPhyTransmission::SchedulePowerMeasurementChecks( const auto detectionDuration = WifiPhy::GetPreambleDetectionDuration(); const auto txVectorSta1 = GetTxVectorForTbPpdu(1, 1, 0); const auto txVectorSta2 = GetTxVectorForTbPpdu(2, 2, 0); - const auto phyEntity = DynamicCast>(m_phyAp->GetPhyEntity()); + const auto phyEntity = + std::dynamic_pointer_cast>(m_phyAp->GetPhyEntity()); const auto nonOfdmaDuration = phyEntity->CalculateNonHeDurationForHeTb(txVectorSta2); NS_ASSERT(nonOfdmaDuration == phyEntity->CalculateNonHeDurationForHeTb(txVectorSta1)); @@ -5589,7 +5590,7 @@ TestPhyPaddingExclusion::SetTrigVector(Time ppduDuration) std::tie(length, ppduDuration) = HePhy::ConvertHeTbPpduDurationToLSigLength(ppduDuration, trigVector, m_phyAp->GetPhyBand()); trigVector.SetLength(length); - auto hePhyAp = DynamicCast(m_phyAp->GetLatestPhyEntity()); + auto hePhyAp = std::dynamic_pointer_cast(m_phyAp->GetLatestPhyEntity()); hePhyAp->SetTrigVector(trigVector, ppduDuration); } diff --git a/src/wifi/test/wifi-primary-channels-test.cc b/src/wifi/test/wifi-primary-channels-test.cc index e0676510e..73c496428 100644 --- a/src/wifi/test/wifi-primary-channels-test.cc +++ b/src/wifi/test/wifi-primary-channels-test.cc @@ -1010,7 +1010,7 @@ WifiPrimaryChannelsTest::DoSendHeTbPpdu(uint8_t bss, // AP's PHY expects to receive a TRIGVECTOR (just once) trigVector.SetLength(length); - auto apHePhy = StaticCast(apDev->GetPhy()->GetLatestPhyEntity()); + auto apHePhy = std::static_pointer_cast(apDev->GetPhy()->GetLatestPhyEntity()); apHePhy->SetTrigVector(trigVector, duration); } diff --git a/src/wifi/test/wifi-tx-stats-helper-test.cc b/src/wifi/test/wifi-tx-stats-helper-test.cc index be6e4b35d..bd3774b25 100644 --- a/src/wifi/test/wifi-tx-stats-helper-test.cc +++ b/src/wifi/test/wifi-tx-stats-helper-test.cc @@ -235,7 +235,8 @@ WifiTxStatsHelperTest::DoRun() if (freq == 6) { mldChannelStr[1] = "{0, 20, BAND_6GHZ, 0}"; - wifi.SetRemoteStationManager(static_cast(1), + uint8_t linkId = 1; + wifi.SetRemoteStationManager(linkId, "ns3::ConstantRateWifiManager", "DataMode", StringValue(dataMode), @@ -245,7 +246,13 @@ WifiTxStatsHelperTest::DoRun() else { mldChannelStr[0] = "{0, 20, BAND_5GHZ, 0}"; - wifi.SetRemoteStationManager(static_cast(0), + // linkId is passed as a variable here because MSVC + // interprets uint8_t as a char, and the 0 value as a + // c-string null terminator \0. This results into a + // compilation error due to SetRemoteStationManager(uint8_t,...) + // and SetRemoteStationManager(std::string, ...) signatures. + uint8_t linkId = 0; + wifi.SetRemoteStationManager(linkId, "ns3::ConstantRateWifiManager", "DataMode", StringValue(dataMode),