wifi: Add function to retrieve frequency range of the currently active spectrum PHY interface

This commit is contained in:
Sébastien Deronne
2023-01-24 22:27:06 +01:00
committed by Sebastien Deronne
parent 38ed82a8ee
commit c622338aaa
7 changed files with 56 additions and 24 deletions

View File

@@ -273,7 +273,7 @@ PhyEntity::GetPhyHeaderSnrPer(WifiPpduField field, Ptr<Event> event) const
event,
measurementChannelWidth,
GetPrimaryBand(measurementChannelWidth),
WHOLE_WIFI_SPECTRUM,
m_wifiPhy->GetCurrentFrequencyRange(),
field);
}
@@ -715,7 +715,7 @@ PhyEntity::EndReceivePayload(Ptr<Event> event)
channelWidthAndBand.first,
txVector.GetNss(staId),
channelWidthAndBand.second,
WHOLE_WIFI_SPECTRUM);
m_wifiPhy->GetCurrentFrequencyRange());
Ptr<const WifiPsdu> psdu = GetAddressedPsduInPpdu(ppdu);
m_wifiPhy->NotifyRxEnd(psdu);
@@ -796,7 +796,7 @@ PhyEntity::GetReceptionStatus(Ptr<const WifiPsdu> psdu,
event,
channelWidthAndBand.first,
channelWidthAndBand.second,
WHOLE_WIFI_SPECTRUM,
m_wifiPhy->GetCurrentFrequencyRange(),
staId,
std::make_pair(relativeMpduStart, relativeMpduStart + mpduDuration));
@@ -872,20 +872,24 @@ PhyEntity::CreateInterferenceEvent(Ptr<const WifiPpdu> ppdu,
RxPowerWattPerChannelBand& rxPower,
bool isStartOfdmaRxing /* = false */)
{
return m_wifiPhy->m_interference
->Add(ppdu, txVector, duration, rxPower, WHOLE_WIFI_SPECTRUM, isStartOfdmaRxing);
return m_wifiPhy->m_interference->Add(ppdu,
txVector,
duration,
rxPower,
m_wifiPhy->GetCurrentFrequencyRange(),
isStartOfdmaRxing);
}
void
PhyEntity::UpdateInterferenceEvent(Ptr<Event> event, const RxPowerWattPerChannelBand& rxPower)
{
m_wifiPhy->m_interference->UpdateEvent(event, rxPower, WHOLE_WIFI_SPECTRUM);
m_wifiPhy->m_interference->UpdateEvent(event, rxPower, m_wifiPhy->GetCurrentFrequencyRange());
}
void
PhyEntity::NotifyInterferenceRxEndAndClear(bool reset)
{
m_wifiPhy->m_interference->NotifyRxEnd(Simulator::Now(), WHOLE_WIFI_SPECTRUM);
m_wifiPhy->m_interference->NotifyRxEnd(Simulator::Now(), m_wifiPhy->GetCurrentFrequencyRange());
m_signalNoiseMap.clear();
m_statusPerMpduMap.clear();
for (const auto& endOfMpduEvent : m_endOfMpduEvents)
@@ -961,7 +965,8 @@ PhyEntity::EndPreambleDetectionPeriod(Ptr<Event> event)
m_wifiPhy->m_currentPreambleEvents.erase(it);
// This is needed to cleanup the m_firstPowerPerBand so that the first power corresponds to
// the power at the start of the PPDU
m_wifiPhy->m_interference->NotifyRxEnd(maxEvent->GetStartTime(), WHOLE_WIFI_SPECTRUM);
m_wifiPhy->m_interference->NotifyRxEnd(maxEvent->GetStartTime(),
m_wifiPhy->GetCurrentFrequencyRange());
// Make sure InterferenceHelper keeps recording events
m_wifiPhy->m_interference->NotifyRxStart();
return;
@@ -973,7 +978,7 @@ PhyEntity::EndPreambleDetectionPeriod(Ptr<Event> event)
measurementChannelWidth,
1,
measurementBand,
WHOLE_WIFI_SPECTRUM);
m_wifiPhy->GetCurrentFrequencyRange());
NS_LOG_DEBUG("SNR(dB)=" << RatioToDb(snr) << " at end of preamble detection period");
if ((!m_wifiPhy->m_preambleDetectionModel && maxRxPowerW > 0.0) ||
@@ -1005,7 +1010,7 @@ PhyEntity::EndPreambleDetectionPeriod(Ptr<Event> event)
// corresponds to the power at the start of the PPDU
m_wifiPhy->m_interference->NotifyRxEnd(
m_wifiPhy->m_currentEvent->GetStartTime(),
WHOLE_WIFI_SPECTRUM);
m_wifiPhy->GetCurrentFrequencyRange());
}
else
{
@@ -1049,7 +1054,8 @@ PhyEntity::EndPreambleDetectionPeriod(Ptr<Event> event)
if (m_wifiPhy->m_currentPreambleEvents.empty())
{
// Do not erase events if there are still pending preamble events to be processed
m_wifiPhy->m_interference->NotifyRxEnd(Simulator::Now(), WHOLE_WIFI_SPECTRUM);
m_wifiPhy->m_interference->NotifyRxEnd(Simulator::Now(),
m_wifiPhy->GetCurrentFrequencyRange());
}
m_wifiPhy->m_currentEvent = nullptr;
// Cancel preamble reception
@@ -1142,7 +1148,7 @@ PhyEntity::ResetReceive(Ptr<Event> event)
NS_LOG_FUNCTION(this << *event);
DoResetReceive(event);
NS_ASSERT(!m_wifiPhy->IsStateRx());
m_wifiPhy->m_interference->NotifyRxEnd(Simulator::Now(), WHOLE_WIFI_SPECTRUM);
m_wifiPhy->m_interference->NotifyRxEnd(Simulator::Now(), m_wifiPhy->GetCurrentFrequencyRange());
NS_ASSERT(m_endRxPayloadEvents.size() == 1 && m_endRxPayloadEvents.front().IsExpired());
m_endRxPayloadEvents.clear();
m_wifiPhy->m_currentEvent = nullptr;
@@ -1212,7 +1218,7 @@ PhyEntity::GetDelayUntilCcaEnd(double thresholdDbm, WifiSpectrumBand band)
{
return m_wifiPhy->m_interference->GetEnergyDuration(DbmToW(thresholdDbm),
band,
WHOLE_WIFI_SPECTRUM);
m_wifiPhy->GetCurrentFrequencyRange());
}
void

View File

@@ -188,16 +188,16 @@ SpectrumWifiPhy::UpdateInterferenceHelperBands()
}
}
const auto bandsChanged = std::any_of(bands.cbegin(), bands.cend(), [&](const auto& band) {
return !m_interference->HasBand(band, WHOLE_WIFI_SPECTRUM);
return !m_interference->HasBand(band, GetCurrentFrequencyRange());
});
if (!bandsChanged)
{
return;
}
m_interference->RemoveBands(WHOLE_WIFI_SPECTRUM);
m_interference->RemoveBands(GetCurrentFrequencyRange());
for (const auto& band : bands)
{
m_interference->AddBand(band, WHOLE_WIFI_SPECTRUM);
m_interference->AddBand(band, GetCurrentFrequencyRange());
}
}
@@ -407,14 +407,14 @@ SpectrumWifiPhy::StartRx(Ptr<SpectrumSignalParameters> rxParams)
if (!wifiRxParams)
{
NS_LOG_INFO("Received non Wi-Fi signal");
m_interference->AddForeignSignal(rxDuration, rxPowerW, WHOLE_WIFI_SPECTRUM);
m_interference->AddForeignSignal(rxDuration, rxPowerW, GetCurrentFrequencyRange());
SwitchMaybeToCcaBusy(nullptr);
return;
}
if (wifiRxParams && m_disableWifiReception)
{
NS_LOG_INFO("Received Wi-Fi signal but blocked from syncing");
m_interference->AddForeignSignal(rxDuration, rxPowerW, WHOLE_WIFI_SPECTRUM);
m_interference->AddForeignSignal(rxDuration, rxPowerW, GetCurrentFrequencyRange());
SwitchMaybeToCcaBusy(nullptr);
return;
}
@@ -427,7 +427,7 @@ SpectrumWifiPhy::StartRx(Ptr<SpectrumSignalParameters> rxParams)
if (totalRxPowerW < DbmToW(GetRxSensitivity()) * (txWidth / 20.0))
{
NS_LOG_INFO("Received signal too weak to process: " << WToDbm(totalRxPowerW) << " dBm");
m_interference->Add(ppdu, txVector, rxDuration, rxPowerW, WHOLE_WIFI_SPECTRUM);
m_interference->Add(ppdu, txVector, rxDuration, rxPowerW, GetCurrentFrequencyRange());
SwitchMaybeToCcaBusy(nullptr);
return;
}
@@ -437,7 +437,7 @@ SpectrumWifiPhy::StartRx(Ptr<SpectrumSignalParameters> rxParams)
if (!CanStartRx(ppdu, txWidth))
{
NS_LOG_INFO("Cannot start reception of the PPDU, consider it as interference");
m_interference->Add(ppdu, txVector, rxDuration, rxPowerW, WHOLE_WIFI_SPECTRUM);
m_interference->Add(ppdu, txVector, rxDuration, rxPowerW, GetCurrentFrequencyRange());
SwitchMaybeToCcaBusy(ppdu);
return;
}
@@ -624,6 +624,13 @@ SpectrumWifiPhy::GetTxMaskRejectionParams() const
m_txMaskOuterBandMaximumRejection);
}
FrequencyRange
SpectrumWifiPhy::GetCurrentFrequencyRange() const
{
NS_ABORT_IF(!m_currentSpectrumPhyInterface);
return m_currentSpectrumPhyInterface->GetFrequencyRange();
}
Ptr<WifiSpectrumPhyInterface>
SpectrumWifiPhy::GetInterfaceCoveringChannelBand(uint16_t frequency, uint16_t width) const
{

View File

@@ -75,6 +75,7 @@ class SpectrumWifiPhy : public WifiPhy
uint16_t GetGuardBandwidth(uint16_t currentChannelWidth) const override;
std::tuple<double, double, double> GetTxMaskRejectionParams() const override;
WifiSpectrumBand GetBand(uint16_t bandWidth, uint8_t bandIndex = 0) override;
FrequencyRange GetCurrentFrequencyRange() const override;
/**
* Attach a SpectrumChannel to use for a given frequency range.

View File

@@ -1222,7 +1222,7 @@ WifiPhy::DoChannelSwitch()
{
// notify channel switching
m_state->SwitchToChannelSwitching(GetChannelSwitchDelay());
m_interference->EraseEvents(WHOLE_WIFI_SPECTRUM);
m_interference->EraseEvents(GetCurrentFrequencyRange());
/*
* Needed here to be able to correctly sensed the medium for the first
* time after the switching. The actual switching is not performed until
@@ -1834,7 +1834,11 @@ WifiPhy::StartReceivePreamble(Ptr<const WifiPpdu> ppdu,
// TODO find a fallback PHY for receiving the PPDU (e.g. 11a for 11ax due to preamble
// structure)
NS_LOG_DEBUG("Unsupported modulation received (" << modulation << "), consider as noise");
m_interference->Add(ppdu, ppdu->GetTxVector(), rxDuration, rxPowersW, WHOLE_WIFI_SPECTRUM);
m_interference->Add(ppdu,
ppdu->GetTxVector(),
rxDuration,
rxPowersW,
GetCurrentFrequencyRange());
SwitchMaybeToCcaBusy(nullptr);
}
}
@@ -2087,7 +2091,7 @@ WifiPhy::AbortCurrentReception(WifiPhyRxfailureReason reason)
{
m_endPhyRxEvent.Cancel();
}
m_interference->NotifyRxEnd(Simulator::Now(), WHOLE_WIFI_SPECTRUM);
m_interference->NotifyRxEnd(Simulator::Now(), GetCurrentFrequencyRange());
if (!m_currentEvent)
{
return;

View File

@@ -1157,6 +1157,13 @@ class WifiPhy : public Object
*/
virtual WifiSpectrumBand GetBand(uint16_t bandWidth, uint8_t bandIndex = 0) = 0;
/**
* Get the frequency range of the current RF interface.
*
* \return the frequency range of the current RF interface
*/
virtual FrequencyRange GetCurrentFrequencyRange() const = 0;
protected:
void DoInitialize() override;
void DoDispose() override;

View File

@@ -56,7 +56,7 @@ YansWifiPhy::SetInterferenceHelper(const Ptr<InterferenceHelper> helper)
WifiSpectrumBand band;
band.first = 0;
band.second = 0;
m_interference->AddBand(band, WHOLE_WIFI_SPECTRUM);
m_interference->AddBand(band, GetCurrentFrequencyRange());
}
YansWifiPhy::~YansWifiPhy()
@@ -118,4 +118,10 @@ YansWifiPhy::GetBand(uint16_t /*bandWidth*/, uint8_t /*bandIndex*/)
return band;
}
FrequencyRange
YansWifiPhy::GetCurrentFrequencyRange() const
{
return WHOLE_WIFI_SPECTRUM;
}
} // namespace ns3

View File

@@ -62,6 +62,7 @@ class YansWifiPhy : public WifiPhy
uint16_t GetGuardBandwidth(uint16_t currentChannelWidth) const override;
std::tuple<double, double, double> GetTxMaskRejectionParams() const override;
WifiSpectrumBand GetBand(uint16_t bandWidth, uint8_t bandIndex = 0) override;
FrequencyRange GetCurrentFrequencyRange() const override;
/**
* Set the YansWifiChannel this YansWifiPhy is to be connected to.