23#include "ns3/boolean.h" 
   24#include "ns3/double.h" 
   25#include "ns3/he-phy.h" 
   28#include "ns3/simulator.h" 
   29#include "ns3/spectrum-channel.h" 
   34#undef NS_LOG_APPEND_CONTEXT 
   35#define NS_LOG_APPEND_CONTEXT WIFI_PHY_NS_LOG_APPEND_CONTEXT(Ptr(this, false)) 
   48        TypeId(
"ns3::SpectrumWifiPhy")
 
   52            .AddAttribute(
"DisableWifiReception",
 
   53                          "Prevent Wi-Fi frame sync from ever happening",
 
   58                "TrackSignalsFromInactiveInterfaces",
 
   59                "Enable or disable tracking signals coming from inactive spectrum PHY interfaces",
 
   64                "TxMaskInnerBandMinimumRejection",
 
   65                "Minimum rejection (dBr) for the inner band of the transmit spectrum mask",
 
   70                "TxMaskOuterBandMinimumRejection",
 
   71                "Minimum rejection (dBr) for the outer band of the transmit spectrum mask",
 
   76                "TxMaskOuterBandMaximumRejection",
 
   77                "Maximum rejection (dBr) for the outer band of the transmit spectrum mask",
 
   83                "Trace start of all signal arrivals, including weak and foreign signals",
 
   85                "ns3::SpectrumWifiPhy::SignalArrivalCallback");
 
 
   90    : m_spectrumPhyInterfaces{},
 
   91      m_currentSpectrumPhyInterface{nullptr},
 
   92      m_frequenciesBeforeSwitch{},
 
   93      m_widthsBeforeSwitch{}
 
 
  126    const auto channelWidth = spectrumPhyInterface->GetChannelWidth();
 
  127    if (channelWidth < 
MHz_u{20})
 
  133        for (
MHz_u bw = channelWidth; bw >= 
MHz_u{20}; bw = bw / 2)
 
  135            for (uint16_t i = 0; i < (channelWidth / bw); ++i)
 
 
  146                            MHz_u guardBandwidth)
 
  149    const auto channelWidth = spectrumPhyInterface->GetChannelWidth();
 
  156    for (
const auto modClass : modClasses)
 
  158        for (
MHz_u bw = channelWidth; bw >= 
MHz_u{20}; bw = bw / 2)
 
  164            for (uint8_t i = 0; i < (channelWidth / bw); ++i)
 
  170                    const auto ruType = 
static_cast<RuType>(type);
 
  172                    std::size_t undefRus{0};
 
  173                    for (std::size_t phyIndex = 1; phyIndex <= nRus + undefRus; ++phyIndex)
 
  182                        const auto subcarrierRange =
 
  183                            std::make_pair(group.front().first, group.back().second);
 
  187                             spectrumPhyInterface->GetCenterFrequencies(),
 
  188                             spectrumPhyInterface->GetChannelWidth(),
 
  195                        for (
const auto& indicesPerSegment : bandIndices)
 
  197                            band.
indices.emplace_back(indicesPerSegment);
 
  198                            band.frequencies.emplace_back(
 
  206                            const auto primary80 =
 
  213                            const auto& [primary160, primary80OrLow80] =
 
  215                            ru = 
EhtRu::RuSpec{ruType, index, primary160, primary80OrLow80};
 
  218                        ruBands.insert({band, ru});
 
 
  235        const auto channelWidth = spectrumPhyInterface->GetChannelWidth();
 
  237        for (
const auto& bandRuPair : ruBands)
 
  239            allBands.push_back(bandRuPair.first);
 
  241        spectrumPhyInterface->SetRuBands(std::move(ruBands));
 
  244    spectrumPhyInterface->SetBands(std::move(bands));
 
  248        m_interference->UpdateBands(allBands, spectrumPhyInterface->GetFrequencyRange());
 
  252        for (
const auto& band : allBands)
 
 
  271    const auto foundOverlappingChannel =
 
  274                    [freqRange, channel](
const auto& item) {
 
  275                        const auto spectrumRange = item.first;
 
  276                        const auto noOverlap =
 
  277                            ((freqRange.minFrequency >= spectrumRange.maxFrequency) ||
 
  278                             (freqRange.maxFrequency <= spectrumRange.minFrequency));
 
  282                    "Added a wifi spectrum channel that overlaps with another existing wifi " 
  286    wifiSpectrumPhyInterface->SetSpectrumWifiPhy(
this);
 
  287    wifiSpectrumPhyInterface->SetChannel(channel);
 
  290        wifiSpectrumPhyInterface->SetDevice(
GetDevice());
 
 
  297                                    const std::vector<MHz_u>& centerFrequencies,
 
  300    std::stringstream ss;
 
  301    for (
const auto& centerFrequency : centerFrequencies)
 
  303        ss << centerFrequency << 
" ";
 
  305    NS_LOG_FUNCTION(
this << spectrumPhyInterface << ss.str() << channelWidth);
 
  316    spectrumPhyInterface->SetRxSpectrumModel(centerFrequencies,
 
  321    spectrumPhyInterface->GetChannel()->AddRx(spectrumPhyInterface);
 
 
  332                                    : std::vector<MHz_u>{};
 
 
  356    NS_ASSERT(numSegments == frequenciesAfter.size() && numSegments == widthsAfter.size());
 
  357    for (std::size_t i = 0; i < numSegments; ++i)
 
  359        auto interfaceCoveringBand =
 
  362                        "No spectrum channel covers frequency range [" 
  363                            << frequenciesAfter.at(i) - (widthsAfter.at(i) / 2) << 
" MHz - " 
  364                            << frequenciesAfter.at(i) + (widthsAfter.at(i) / 2) << 
" MHz]");
 
  365        if (!newSpectrumPhyInterface)
 
  367            newSpectrumPhyInterface = interfaceCoveringBand;
 
  372                            "All segments are not covered by the same spectrum channel");
 
  377    if (interfaceChanged)
 
  379        std::stringstream ss;
 
  380        for (std::size_t i = 0; i < frequenciesAfter.size(); ++i)
 
  382            ss << 
"(" << frequenciesAfter.at(i) << 
", " << widthsAfter.at(i) << 
") ";
 
  384        NS_LOG_DEBUG(
"Switch to existing RF interface with frequency/width " 
  385                     << (numSegments > 1 ? 
"pair" : 
"pairs") << 
" of " << ss.str());
 
 
  438    std::stringstream ss;
 
  439    for (
const auto& centerFrequency : frequencies)
 
  441        ss << centerFrequency << 
" ";
 
  447        NS_LOG_DEBUG(
"Tracking of signals on inactive interfaces is not enabled");
 
  452    const auto numSegments = frequencies.size();
 
  453    const auto segmentWidth = width / numSegments;
 
  454    for (std::size_t i = 0; i < numSegments; ++i)
 
  456        auto interfaceCoveringBand =
 
  459                        "No spectrum channel covers frequency range [" 
  460                            << frequencies.at(i) - (segmentWidth / 2) << 
" MHz - " 
  461                            << frequencies.at(i) + (segmentWidth / 2) << 
" MHz]");
 
  462        if (!spectrumPhyInterface)
 
  464            spectrumPhyInterface = interfaceCoveringBand;
 
  469                            "All segments are not covered by the same spectrum channel");
 
  474                    "This method should not be called for the current interface");
 
  476    if ((frequencies == spectrumPhyInterface->GetCenterFrequencies()) &&
 
  477        (width == spectrumPhyInterface->GetChannelWidth()))
 
  479        NS_LOG_DEBUG(
"Same RF channel as before on that interface, do nothing");
 
 
  497    Time rxDuration = rxParams->duration;
 
  502                          interface->GetRxSpectrumModel()->GetNumBands(),
 
  503                      "Incorrect spectrum conversion or multi model spectrum channel is not used!");
 
  505    NS_LOG_DEBUG(
"Received signal with PSD " << *receivedSignalPsd << 
" and duration " 
  510        senderNodeId = rxParams->txPhy->GetDevice()->GetNode()->GetId();
 
  512    NS_LOG_DEBUG(
"Received signal from " << senderNodeId << 
" with unfiltered power " 
  527    std::size_t index = 0;
 
  529    for (
const auto& band : bands)
 
  532            std::accumulate(band.frequencies.cbegin(),
 
  533                            band.frequencies.cend(),
 
  535                            [](
MHz_u sum, 
const auto& startStopFreqs) {
 
  536                                return sum + HzToMHz(startStopFreqs.second - startStopFreqs.first);
 
  539        index = ((bw != prevBw) ? 0 : (index + 1));
 
  540        auto rxPowerPerBand =
 
  542        NS_LOG_DEBUG(
"Signal power received (watts) before antenna gain for " 
  543                     << bw << 
" MHz channel band " << index << 
": " << band);
 
  544        rxPowerPerBand *= rxGainRatio;
 
  545        rxPowers.insert({band, rxPowerPerBand});
 
  546        NS_LOG_DEBUG(
"Signal power received after antenna gain for " 
  547                     << bw << 
" MHz channel band " << index << 
": " << rxPowerPerBand << 
" W" 
  548                     << (rxPowerPerBand > 
Watt_u{0.0}
 
  549                             ? 
" (" + std::to_string(
WToDbm(rxPowerPerBand)) + 
" dBm)" 
  553            totalRxPower += rxPowerPerBand;
 
  560        const auto& ruBands =
 
  563        for (const auto& [band, ru] : ruBands)
 
  565            auto rxPowerPerBand =
 
  566                WifiSpectrumValueHelper::GetBandPowerW(receivedSignalPsd, band.indices);
 
  567            rxPowerPerBand *= rxGainRatio;
 
  568            rxPowers.insert({band, rxPowerPerBand});
 
  573    NS_LOG_DEBUG(
"Total signal power received after antenna gain: " 
  574                 << totalRxPower << 
" W" 
  575                 << (totalRxPower > 
Watt_u{0.0}
 
  576                         ? 
" (" + std::to_string(
WToDbm(totalRxPower)) + 
" dBm)" 
  583    if (totalRxPower > 
Watt_u{0.0})
 
  591        NS_LOG_INFO(
"Received Wi-Fi signal from a non-active PHY interface " 
  592                    << interface->GetFrequencyRange());
 
  593        m_interference->AddForeignSignal(rxDuration, rxPowers, interface->GetFrequencyRange());
 
  602                                         interface ? interface->GetFrequencyRange()
 
  610        NS_LOG_INFO(
"Received Wi-Fi signal but blocked from syncing");
 
  612        m_interference->AddForeignSignal(rxDuration, rxPowers, interface->GetFrequencyRange());
 
  623        NS_LOG_INFO(
"Received signal too weak to process: " 
  624                    << totalRxPower << 
" W" 
  625                    << (totalRxPower > 
Watt_u{0.0}
 
  626                            ? 
" (" + std::to_string(
WToDbm(totalRxPower)) + 
" dBm)" 
  633    if (wifiRxParams->txPhy)
 
  637            NS_LOG_INFO(
"Cannot start reception of the PPDU, consider it as interference");
 
 
  674        spectrumPhyInterface.second->SetDevice(device);
 
 
  697    MHz_u guardBandwidth{0};
 
  698    if (currentChannelWidth == 
MHz_u{22})
 
  701        guardBandwidth = 
MHz_u{10};
 
  711        guardBandwidth = currentChannelWidth;
 
  713    return guardBandwidth;
 
 
  719                                            Hz_u subcarrierSpacing)
 
  721    const auto numSegments = centerFrequencies.size();
 
  722    NS_ABORT_MSG_IF(numSegments > 2, 
"Only 2 non-contiguous frequency segments are supported");
 
  727    const auto lowFrequency = *centerFrequencies.cbegin();
 
  728    const auto highFrequency = *centerFrequencies.crbegin();
 
  729    NS_ASSERT(lowFrequency != highFrequency);
 
  731    const auto segmentsWidth = totalWidth / numSegments;
 
  732    const auto widthBetweenSegments = highFrequency - lowFrequency - segmentsWidth;
 
  733    return MHzToHz(widthBetweenSegments) / subcarrierSpacing;
 
 
  741    const auto channelWidth = spectrumPhyInterface->GetChannelWidth();
 
  743                  "Bandwidth (" << bandWidth << 
") cannot exceed total operating channel width (" 
  744                                << channelWidth << 
")");
 
  747    std::size_t numSegments = 1;
 
  748    if (
const auto segmentWidth =
 
  749            (channelWidth / spectrumPhyInterface->GetCenterFrequencies().size());
 
  750        bandWidth > segmentWidth)
 
  753        numSegments = spectrumPhyInterface->GetCenterFrequencies().size();
 
  754        bandWidth /= spectrumPhyInterface->GetCenterFrequencies().size();
 
  756    const auto numBandsInBand = 
static_cast<size_t>(
MHzToHz(bandWidth) / subcarrierSpacing);
 
  757    auto numBandsInChannel = 
static_cast<size_t>(
MHzToHz(channelWidth) / subcarrierSpacing);
 
  758    const auto numBands = channelWidth / bandWidth;
 
  759    if (numBandsInBand % 2 == 0)
 
  761        numBandsInChannel += 1; 
 
  763    auto rxSpectrumModel = spectrumPhyInterface->GetRxSpectrumModel();
 
  764    size_t totalNumBands = rxSpectrumModel->GetNumBands();
 
  765    NS_ASSERT_MSG((numBandsInChannel % 2 == 1) && (totalNumBands % 2 == 1),
 
  766                  "Should have odd number of bands");
 
  767    for (std::size_t segmentIndex = 0; segmentIndex < numSegments; ++segmentIndex)
 
  769        NS_ASSERT_MSG(bandIndex < numBands, 
"Band index is out of bound");
 
  770        NS_ASSERT(totalNumBands >= numBandsInChannel);
 
  771        const auto numBandsBetweenSegments =
 
  775        auto startIndex = ((totalNumBands - numBandsInChannel - numBandsBetweenSegments) / 2) +
 
  776                          (bandIndex * numBandsInBand);
 
  777        if (bandIndex >= (numBands / 2))
 
  779            startIndex += numBandsBetweenSegments;
 
  781        auto stopIndex = startIndex + numBandsInBand - 1;
 
  784        auto freqRange = spectrumPhyInterface->GetFrequencyRange();
 
  788        if (startIndex >= totalNumBands / 2)
 
  793        bandInfo.
indices.emplace_back(startIndex, stopIndex);
 
 
  820    auto rxSpectrumModel = spectrumPhyInterface->GetRxSpectrumModel();
 
  821    auto startGuardBand = rxSpectrumModel->Begin();
 
  822    auto startChannel = std::next(startGuardBand, indices.first);
 
  823    auto endChannel = std::next(startGuardBand, indices.second + 1);
 
  824    return {
Hz_u{startChannel->fc}, 
Hz_u{endChannel->fc}};
 
 
  827std::tuple<dBr_u, dBr_u, dBr_u>
 
  842const std::map<FrequencyRange, Ptr<WifiSpectrumPhyInterface>>&
 
  851    const auto lowFreq = frequency - (width / 2);
 
  852    const auto highFreq = frequency + (width / 2);
 
  855                                 [lowFreq, highFreq](
const auto& item) {
 
  856                                     return ((lowFreq >= item.first.minFrequency) &&
 
  857                                             (highFreq <= item.first.maxFrequency));
 
 
AttributeValue implementation for Boolean.
void Nullify()
Discard the implementation, set it to null.
bool IsNull() const
Check for null implementation.
This class can be used to hold variables of floating point type such as 'double' or 'float'.
static std::pair< bool, bool > GetPrimaryFlags(MHz_u bw, RuType ruType, std::size_t phyIndex, uint8_t p20Index)
Get the primary flags of a given RU transmitted in a PPDU.
static std::size_t GetIndexIn80MHzSegment(MHz_u bw, RuType ruType, std::size_t phyIndex)
Get the index of a given RU transmitted in a PPDU within its 80 MHz segment.
static std::vector< WifiSpectrumBandIndices > ConvertRuSubcarriers(const RuSubcarriersInfo &info)
This is a helper function to convert RU subcarriers, which are relative to the center frequency subca...
static std::size_t GetIndexIn80MHzSegment(MHz_u bw, RuType ruType, std::size_t phyIndex)
Get the index of a given RU transmitted in a PPDU within its 80 MHz segment.
static bool GetPrimary80MHzFlag(MHz_u bw, RuType ruType, std::size_t phyIndex, uint8_t p20Index)
Get the primary 80 MHz flag of a given RU transmitted in a PPDU.
bool IsInitialized() const
Check if the object has been initialized.
Smart pointer class similar to boost::intrusive_ptr.
static EventId ScheduleNow(FUNC f, Ts &&... args)
Schedule an event to expire Now.
~SpectrumWifiPhy() override
std::vector< MHz_u > m_frequenciesBeforeSwitch
center frequency before channel switch
WifiSpectrumBandInfo GetBand(MHz_u bandWidth, uint8_t bandIndex=0) override
Get the info of a given band.
void SetDevice(const Ptr< WifiNetDevice > device) override
Sets the device this PHY is associated with.
void Transmit(Ptr< WifiSpectrumSignalParameters > txParams)
This function is sending the signal to the Spectrum channel after finishing the configuration of the ...
dBr_u m_txMaskInnerBandMinimumRejection
The minimum rejection for the inner band of the transmit spectrum mask.
std::vector< MHz_u > m_widthsBeforeSwitch
channel width before channel switch
WifiSpectrumBands ComputeBands(Ptr< WifiSpectrumPhyInterface > spectrumPhyInterface)
This function computes the bands that belong to a given spectrum PHY interface.
void StartRx(Ptr< SpectrumSignalParameters > rxParams, Ptr< const WifiSpectrumPhyInterface > interface)
Input method for delivering a signal from the spectrum channel and low-level PHY interface to this Sp...
void DoInitialize() override
Initialize() implementation.
void FinalizeChannelSwitch() override
Method that can be overridden by subclasses to perform operations after the channel is actually switc...
dBr_u m_txMaskOuterBandMinimumRejection
The minimum rejection for the outer band of the transmit spectrum mask.
std::map< FrequencyRange, Ptr< WifiSpectrumPhyInterface > > m_spectrumPhyInterfaces
Spectrum PHY interfaces.
WifiSpectrumBandFrequencies ConvertIndicesToFrequenciesForInterface(Ptr< WifiSpectrumPhyInterface > spectrumPhyInterface, const WifiSpectrumBandIndices &indices) const
This is a helper function to convert start and stop indices to start and stop frequencies.
Ptr< AntennaModel > m_antenna
antenna model
FrequencyRange GetCurrentFrequencyRange() const override
Get the frequency range of the current RF interface.
Ptr< const WifiPpdu > GetRxPpduFromTxPpdu(Ptr< const WifiPpdu > ppdu)
Determine the WifiPpdu to be used by the RX PHY based on the WifiPpdu sent by the TX PHY.
MHz_u GetGuardBandwidth(MHz_u currentChannelWidth) const override
Ptr< WifiSpectrumPhyInterface > GetInterfaceCoveringChannelBand(MHz_u frequency, MHz_u width) const
Get the spectrum PHY interface that covers a band portion of the RF channel.
Ptr< AntennaModel > GetAntenna() const
Get the antenna model used for reception.
std::tuple< dBr_u, dBr_u, dBr_u > GetTxMaskRejectionParams() const override
Ptr< Channel > GetChannel() const override
Return the Channel this WifiPhy is connected to.
void AddChannel(const Ptr< SpectrumChannel > channel, const FrequencyRange &freqRange=WHOLE_WIFI_SPECTRUM)
Attach a SpectrumChannel to use for a given frequency range.
void SetChannelSwitchedCallback(Callback< void > callback)
Ptr< WifiSpectrumPhyInterface > m_currentSpectrumPhyInterface
The current Spectrum PHY interface (held for performance reasons)
Ptr< WifiSpectrumPhyInterface > GetCurrentInterface() const
Get the currently active spectrum PHY interface.
bool m_trackSignalsInactiveInterfaces
flag whether signals coming from inactive spectrum PHY interfaces are tracked
void DoDispose() override
Destructor implementation.
const std::map< FrequencyRange, Ptr< WifiSpectrumPhyInterface > > & GetSpectrumPhyInterfaces() const
Get the map of interfaces attached to this spectrum PHY.
static TypeId GetTypeId()
Get the type ID.
TracedCallback< Ptr< const SpectrumSignalParameters >, uint32_t, double, Time > m_signalCb
Signal callback.
Callback< void > m_channelSwitchedCallback
Callback when channel switched.
void SetAntenna(const Ptr< AntennaModel > antenna)
void ResetSpectrumModel(Ptr< WifiSpectrumPhyInterface > spectrumPhyInterface, const std::vector< MHz_u > ¢erFrequencies, MHz_u channelWidth)
Perform run-time spectrum model change.
void ConfigureInterface(const std::vector< MHz_u > &frequencies, MHz_u width)
Configure a non-active spectrum PHY interface to operate on a given frequency (or several frequencies...
bool m_disableWifiReception
forces this PHY to fail to sync on any signal
bool CanStartRx(Ptr< const WifiPpdu > ppdu) const
Determine whether the PHY shall issue a PHY-RXSTART.indication primitive in response to a given PPDU.
void UpdateInterferenceHelperBands(Ptr< WifiSpectrumPhyInterface > spectrumPhyInterface)
This function is called to update the bands handled by the InterferenceHelper.
void StartTx(Ptr< const WifiPpdu > ppdu) override
dBr_u m_txMaskOuterBandMaximumRejection
The maximum rejection for the outer band of the transmit spectrum mask.
void NotifyChannelSwitched()
Notify the spectrum channel has switched.
void DoChannelSwitch() override
Actually switch channel based on the stored channel settings.
static uint32_t GetNumBandsBetweenSegments(const std::vector< MHz_u > ¢erFrequencies, MHz_u totalWidth, Hz_u subcarrierSpacing)
Determine the number of bands between the two segments if the operating channel is made of non-contig...
WifiSpectrumBandFrequencies ConvertIndicesToFrequencies(const WifiSpectrumBandIndices &indices) const override
This is a helper function to convert start and stop indices to start and stop frequencies.
RuBands GetRuBands(Ptr< WifiSpectrumPhyInterface > spectrumPhyInterface, MHz_u guardBandwidth)
This function computes the RU bands that belong to a given spectrum PHY interface.
WifiSpectrumBandInfo GetBandForInterface(Ptr< WifiSpectrumPhyInterface > spectrumPhyInterface, MHz_u bandWidth, uint8_t bandIndex=0)
Get the info of a given band that belongs to a given spectrum PHY interface.
Simulation virtual time values and global simulation resolution.
TimeWithUnit As(const Unit unit=Time::AUTO) const
Attach a unit to a Time, to facilitate output in a specific unit.
a unique identifier for an interface.
TypeId SetParent(TypeId tid)
Set the parent TypeId.
dBm_u GetRxSensitivity() const
Return the receive sensitivity threshold.
Hz_u GetSubcarrierSpacing() const
TracedCallback< Ptr< const WifiPpdu >, const WifiTxVector & > m_signalTransmissionCb
Signal Transmission callback.
Ptr< PhyEntity > GetPhyEntity(WifiModulationClass modulation) const
Get the supported PHY entity corresponding to the modulation class.
virtual void SetDevice(const Ptr< WifiNetDevice > device)
Sets the device this PHY is associated with.
void StartReceivePreamble(Ptr< const WifiPpdu > ppdu, RxPowerWattPerChannelBand &rxPowersW, Time rxDuration)
Start receiving the PHY preamble of a PPDU (i.e.
MHz_u GetChannelWidth() const
Ptr< WifiNetDevice > GetDevice() const
Return the device this PHY is associated with.
void DoDispose() override
Destructor implementation.
dB_u GetRxGain() const
Return the reception gain.
virtual void DoChannelSwitch()
Actually switch channel based on the stored channel settings.
void SwitchMaybeToCcaBusy(const Ptr< const WifiPpdu > ppdu=nullptr)
Check if PHY state should move to CCA busy state based on current state of interference tracker.
Ptr< InterferenceHelper > m_interference
Pointer to a helper responsible for interference computations.
void DoInitialize() override
Initialize() implementation.
WifiStandard GetStandard() const
Get the configured Wi-Fi standard.
Ptr< PhyEntity > GetPhyEntityForPpdu(const Ptr< const WifiPpdu > ppdu) const
Get the supported PHY entity to use for a received PPDU.
const WifiPhyOperatingChannel & GetOperatingChannel() const
Get a const reference to the operating channel.
Ptr< PhyEntity > GetLatestPhyEntity() const
Get the latest PHY entity supported by this PHY instance.
bool IsSet() const
Return true if a valid channel has been set, false otherwise.
std::size_t GetNSegments() const
Get the number of frequency segments in the operating channel.
uint8_t GetPrimaryChannelIndex(MHz_u primaryChannelWidth) const
If the operating channel width is a multiple of 20 MHz, return the index of the primary channel of th...
std::vector< MHz_u > GetFrequencies() const
Return the center frequency per segment.
std::vector< MHz_u > GetWidths() const
Return the channel width per segment.
static std::size_t GetNRus(MHz_u bw, RuType ruType, WifiModulationClass mc)
Get the number of distinct RUs of the given type (number of tones) available in a PPDU of the given b...
std::variant< HeRu::RuSpec, EhtRu::RuSpec > RuSpec
variant of the RU specification
static SubcarrierGroup GetSubcarrierGroup(MHz_u bw, RuType ruType, std::size_t phyIndex, WifiModulationClass mc)
Get the subcarrier group of the RU having the given PHY index among all the RUs of the given type (nu...
static std::size_t GetPhyIndex(RuSpec ru, MHz_u bw, uint8_t p20Index)
Get the RU PHY index.
static RuType GetMaxRuType(WifiModulationClass mc)
Get the maximum RU type supported by a given modulation class.
static Watt_u GetBandPowerW(Ptr< SpectrumValue > psd, const std::vector< WifiSpectrumBandIndices > &segments)
Calculate the power of the specified band composed of uniformly-sized sub-bands.
#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...
Ptr< const AttributeChecker > MakeBooleanChecker()
Ptr< const AttributeAccessor > MakeBooleanAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method.
Ptr< const AttributeChecker > MakeDoubleChecker()
Ptr< const AttributeAccessor > MakeDoubleAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method.
#define NS_ABORT_MSG_IF(cond, msg)
Abnormal program termination if a condition is true, with a message.
#define NS_ABORT_IF(cond)
Abnormal program termination if a condition is true.
#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.
Ptr< T > CreateObject(Args &&... args)
Create an object by type, with varying number of constructor parameters.
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Ptr< const TraceSourceAccessor > MakeTraceSourceAccessor(T a)
Create a TraceSourceAccessor which will control access to the underlying trace source.
@ WIFI_MOD_CLASS_EHT
EHT (Clause 36)
@ WIFI_MOD_CLASS_HE
HE (Clause 27)
Every class exported by the ns3 library is enclosed in the ns3 namespace.
double Integral(const SpectrumValue &arg)
RuType
The different Resource Unit (RU) types.
dBm_u WToDbm(Watt_u val)
Convert from Watts to dBm.
std::vector< WifiSpectrumBandInfo > WifiSpectrumBands
vector of spectrum bands
double MHz_u
MHz weak type.
Ptr< T1 > DynamicCast(const Ptr< T2 > &p)
Cast a Ptr.
std::pair< Hz_u, Hz_u > WifiSpectrumBandFrequencies
typedef for a pair of start and stop frequencies to represent a band
std::map< WifiSpectrumBandInfo, Watt_u > RxPowerWattPerChannelBand
A map of the received power for each band.
MHz_u GetMaximumChannelWidth(WifiModulationClass modulation)
Get the maximum channel width allowed for the given modulation class.
std::map< WifiSpectrumBandInfo, WifiRu::RuSpec > RuBands
Map a spectrum band associated with an RU to the RU specification.
double DbToRatio(dB_u val)
Convert from dB to ratio.
Watt_u DbmToW(dBm_u val)
Convert from dBm to Watts.
Hz_u MHzToHz(MHz_u val)
Convert from MHz to Hz.
std::pair< uint32_t, uint32_t > WifiSpectrumBandIndices
typedef for a pair of start and stop sub-band indices
Struct defining a frequency range between minFrequency and maxFrequency.
WifiSpectrumBandInfo structure containing info about a spectrum band.
std::vector< WifiSpectrumBandFrequencies > frequencies
the start and stop frequencies for each segment of the band
std::vector< WifiSpectrumBandIndices > indices
the start and stop indices for each segment of the band