wifi: Rename range to avoid potential clashes

This commit is contained in:
Sébastien Deronne
2023-02-16 18:11:47 +01:00
committed by Sébastien Deronne
parent f68fc46a8c
commit 2ea8b33534
11 changed files with 186 additions and 184 deletions

View File

@@ -217,8 +217,8 @@ InterferenceExperiment::Run(InterferenceExperiment::Input input)
{
m_input = input;
double range = std::max(std::abs(input.xA), input.xB);
Config::SetDefault("ns3::RangePropagationLossModel::MaxRange", DoubleValue(range));
double maxRange = std::max(std::abs(input.xA), input.xB);
Config::SetDefault("ns3::RangePropagationLossModel::MaxRange", DoubleValue(maxRange));
Ptr<SingleModelSpectrumChannel> channel = CreateObject<SingleModelSpectrumChannel>();
channel->SetPropagationDelayModel(CreateObject<ConstantSpeedPropagationDelayModel>());

View File

@@ -1003,11 +1003,14 @@ HePhy::GetRuBandForTx(const WifiTxVector& txVector, uint16_t staId) const
channelWidth,
ru.GetRuType(),
ru.GetPhyIndex(channelWidth, m_wifiPhy->GetOperatingChannel().GetPrimaryChannelIndex(20)));
HeRu::SubcarrierRange range = std::make_pair(group.front().first, group.back().second);
HeRu::SubcarrierRange subcarrierRange =
std::make_pair(group.front().first, group.back().second);
// for a TX spectrum, the guard bandwidth is a function of the transmission channel width
// and the spectrum width equals the transmission channel width (hence bandIndex equals 0)
band =
m_wifiPhy->ConvertHeRuSubcarriers(channelWidth, GetGuardBandwidth(channelWidth), range, 0);
band = m_wifiPhy->ConvertHeRuSubcarriers(channelWidth,
GetGuardBandwidth(channelWidth),
subcarrierRange,
0);
return band;
}
@@ -1023,13 +1026,14 @@ HePhy::GetRuBandForRx(const WifiTxVector& txVector, uint16_t staId) const
channelWidth,
ru.GetRuType(),
ru.GetPhyIndex(channelWidth, m_wifiPhy->GetOperatingChannel().GetPrimaryChannelIndex(20)));
HeRu::SubcarrierRange range = std::make_pair(group.front().first, group.back().second);
HeRu::SubcarrierRange subcarrierRange =
std::make_pair(group.front().first, group.back().second);
// for an RX spectrum, the guard bandwidth is a function of the operating channel width
// and the spectrum width equals the operating channel width
band = m_wifiPhy->ConvertHeRuSubcarriers(
channelWidth,
GetGuardBandwidth(m_wifiPhy->GetChannelWidth()),
range,
subcarrierRange,
m_wifiPhy->GetOperatingChannel().GetPrimaryChannelIndex(channelWidth));
return band;
}
@@ -1053,12 +1057,12 @@ HePhy::GetNonOfdmaBand(const WifiTxVector& txVector, uint16_t staId) const
nonOfdmaRu.GetRuType(),
nonOfdmaRu.GetPhyIndex(channelWidth,
m_wifiPhy->GetOperatingChannel().GetPrimaryChannelIndex(20)));
HeRu::SubcarrierRange range =
HeRu::SubcarrierRange subcarrierRange =
std::make_pair(groupPreamble.front().first, groupPreamble.back().second);
return m_wifiPhy->ConvertHeRuSubcarriers(
channelWidth,
GetGuardBandwidth(m_wifiPhy->GetChannelWidth()),
range,
subcarrierRange,
m_wifiPhy->GetOperatingChannel().GetPrimaryChannelIndex(channelWidth));
}

View File

@@ -231,18 +231,18 @@ InterferenceHelper::Add(Ptr<const WifiPpdu> ppdu,
const WifiTxVector& txVector,
Time duration,
RxPowerWattPerChannelBand& rxPowerW,
const FrequencyRange& range,
const FrequencyRange& freqRange,
bool isStartOfdmaRxing)
{
Ptr<Event> event = Create<Event>(ppdu, txVector, duration, std::move(rxPowerW));
AppendEvent(event, range, isStartOfdmaRxing);
AppendEvent(event, freqRange, isStartOfdmaRxing);
return event;
}
void
InterferenceHelper::AddForeignSignal(Time duration,
RxPowerWattPerChannelBand& rxPowerW,
const FrequencyRange& range)
const FrequencyRange& freqRange)
{
// Parameters other than duration and rxPowerW are unused for this type
// of signal, so we provide dummy versions
@@ -252,58 +252,58 @@ InterferenceHelper::AddForeignSignal(Time duration,
Ptr<WifiPpdu> fakePpdu = Create<WifiPpdu>(Create<WifiPsdu>(Create<Packet>(0), hdr),
WifiTxVector(),
WifiPhyOperatingChannel());
Add(fakePpdu, WifiTxVector(), duration, rxPowerW, range);
Add(fakePpdu, WifiTxVector(), duration, rxPowerW, freqRange);
}
void
InterferenceHelper::RemoveBands(FrequencyRange range)
InterferenceHelper::RemoveBands(FrequencyRange freqRange)
{
NS_LOG_FUNCTION(this << range);
if ((m_niChanges.count(range) == 0) && (m_firstPowers.count(range) == 0))
NS_LOG_FUNCTION(this << freqRange);
if ((m_niChanges.count(freqRange) == 0) && (m_firstPowers.count(freqRange) == 0))
{
return;
}
auto niChangesPerBand = m_niChanges.at(range);
auto niChangesPerBand = m_niChanges.at(freqRange);
for (auto it : niChangesPerBand)
{
it.second.clear();
}
niChangesPerBand.clear();
m_niChanges.erase(range);
m_firstPowers.at(range).clear();
m_firstPowers.erase(range);
m_niChanges.erase(freqRange);
m_firstPowers.at(freqRange).clear();
m_firstPowers.erase(freqRange);
}
bool
InterferenceHelper::HasBand(WifiSpectrumBand band, const FrequencyRange& range) const
InterferenceHelper::HasBand(WifiSpectrumBand band, const FrequencyRange& freqRange) const
{
NS_LOG_FUNCTION(this << band.first << band.second << range);
return (m_niChanges.count(range) > 0 && m_niChanges.at(range).count(band) > 0);
NS_LOG_FUNCTION(this << band.first << band.second << freqRange);
return (m_niChanges.count(freqRange) > 0 && m_niChanges.at(freqRange).count(band) > 0);
}
void
InterferenceHelper::AddBand(WifiSpectrumBand band, const FrequencyRange& range)
InterferenceHelper::AddBand(WifiSpectrumBand band, const FrequencyRange& freqRange)
{
NS_LOG_FUNCTION(this << band.first << band.second << range);
NS_ASSERT(m_niChanges.count(range) == 0 || m_niChanges.at(range).count(band) == 0);
NS_ASSERT(m_firstPowers.count(range) == 0 || m_firstPowers.at(range).count(band) == 0);
NS_LOG_FUNCTION(this << band.first << band.second << freqRange);
NS_ASSERT(m_niChanges.count(freqRange) == 0 || m_niChanges.at(freqRange).count(band) == 0);
NS_ASSERT(m_firstPowers.count(freqRange) == 0 || m_firstPowers.at(freqRange).count(band) == 0);
NiChanges niChanges;
auto result = m_niChanges[range].insert({band, niChanges});
auto result = m_niChanges[freqRange].insert({band, niChanges});
NS_ASSERT(result.second);
// Always have a zero power noise event in the list
AddNiChangeEvent(Time(0), NiChange(0.0, nullptr), result.first);
m_firstPowers[range].insert({band, 0.0});
m_firstPowers[freqRange].insert({band, 0.0});
}
void
InterferenceHelper::UpdateBands(const std::vector<WifiSpectrumBand>& bands,
const FrequencyRange& range,
const FrequencyRange& freqRange,
int32_t offset)
{
NS_LOG_FUNCTION(this << range << offset);
NS_ABORT_IF(m_niChanges.count(range) == 0);
auto& niChangesPerBand = m_niChanges.at(range);
auto& firstPowerPerBand = m_firstPowers.at(range);
NS_LOG_FUNCTION(this << freqRange << offset);
NS_ABORT_IF(m_niChanges.count(freqRange) == 0);
auto& niChangesPerBand = m_niChanges.at(freqRange);
auto& firstPowerPerBand = m_firstPowers.at(freqRange);
// start index of the lowest band
const auto minStartIndex =
(std::min_element(bands.cbegin(), bands.cend(), [](const auto& lhs, const auto& rhs) {
@@ -355,10 +355,10 @@ InterferenceHelper::UpdateBands(const std::vector<WifiSpectrumBand>& bands,
firstPowerPerBand.swap(newFirstPowerPerBand);
for (const auto& band : bands)
{
if (!HasBand(band, range))
if (!HasBand(band, freqRange))
{
// this is a new band, add it
AddBand(band, range);
AddBand(band, freqRange);
}
}
}
@@ -390,13 +390,13 @@ InterferenceHelper::SetNumberOfReceiveAntennas(uint8_t rx)
Time
InterferenceHelper::GetEnergyDuration(double energyW,
WifiSpectrumBand band,
const FrequencyRange& range)
const FrequencyRange& freqRange)
{
NS_LOG_FUNCTION(this << energyW << band.first << band.second << range);
NS_LOG_FUNCTION(this << energyW << band.first << band.second << freqRange);
Time now = Simulator::Now();
NS_ABORT_IF(m_niChanges.count(range) == 0);
auto niIt = m_niChanges.at(range).find(band);
NS_ABORT_IF(niIt == m_niChanges.at(range).end());
NS_ABORT_IF(m_niChanges.count(freqRange) == 0);
auto niIt = m_niChanges.at(freqRange).find(band);
NS_ABORT_IF(niIt == m_niChanges.at(freqRange).end());
auto i = GetPreviousPosition(now, niIt);
Time end = i->first;
for (; i != niIt->second.end(); ++i)
@@ -413,17 +413,17 @@ InterferenceHelper::GetEnergyDuration(double energyW,
void
InterferenceHelper::AppendEvent(Ptr<Event> event,
const FrequencyRange& range,
const FrequencyRange& freqRange,
bool isStartOfdmaRxing)
{
NS_LOG_FUNCTION(this << event << range << isStartOfdmaRxing);
NS_ABORT_IF(m_niChanges.count(range) == 0);
NS_ABORT_IF(m_firstPowers.count(range) == 0);
NS_LOG_FUNCTION(this << event << freqRange << isStartOfdmaRxing);
NS_ABORT_IF(m_niChanges.count(freqRange) == 0);
NS_ABORT_IF(m_firstPowers.count(freqRange) == 0);
for (const auto& it : event->GetRxPowerWPerBand())
{
WifiSpectrumBand band = it.first;
auto niIt = m_niChanges.at(range).find(band);
NS_ABORT_IF(niIt == m_niChanges.at(range).end());
auto niIt = m_niChanges.at(freqRange).find(band);
NS_ABORT_IF(niIt == m_niChanges.at(freqRange).end());
double previousPowerStart = 0;
double previousPowerEnd = 0;
auto previousPowerPosition = GetPreviousPosition(event->GetStartTime(), niIt);
@@ -431,7 +431,7 @@ InterferenceHelper::AppendEvent(Ptr<Event> event,
previousPowerEnd = GetPreviousPosition(event->GetEndTime(), niIt)->second.GetPower();
if (!m_rxing)
{
m_firstPowers.at(range).find(band)->second = previousPowerStart;
m_firstPowers.at(freqRange).find(band)->second = previousPowerStart;
// Always leave the first zero power noise event in the list
niIt->second.erase(++(niIt->second.begin()), ++previousPowerPosition);
}
@@ -440,7 +440,7 @@ InterferenceHelper::AppendEvent(Ptr<Event> event,
// When the first UL-OFDMA payload is received, we need to set m_firstPowers
// so that it takes into account interferences that arrived between the start of the
// UL MU transmission and the start of UL-OFDMA payload.
m_firstPowers.at(range).find(band)->second = previousPowerStart;
m_firstPowers.at(freqRange).find(band)->second = previousPowerStart;
}
auto first =
AddNiChangeEvent(event->GetStartTime(), NiChange(previousPowerStart, event), niIt);
@@ -455,16 +455,16 @@ InterferenceHelper::AppendEvent(Ptr<Event> event,
void
InterferenceHelper::UpdateEvent(Ptr<Event> event,
const RxPowerWattPerChannelBand& rxPower,
const FrequencyRange& range)
const FrequencyRange& freqRange)
{
NS_LOG_FUNCTION(this << event << range);
NS_ABORT_IF(m_niChanges.count(range) == 0);
NS_LOG_FUNCTION(this << event << freqRange);
NS_ABORT_IF(m_niChanges.count(freqRange) == 0);
// This is called for UL MU events, in order to scale power as long as UL MU PPDUs arrive
for (const auto& it : rxPower)
{
WifiSpectrumBand band = it.first;
auto niIt = m_niChanges.at(range).find(band);
NS_ABORT_IF(niIt == m_niChanges.at(range).end());
auto niIt = m_niChanges.at(freqRange).find(band);
NS_ABORT_IF(niIt == m_niChanges.at(freqRange).end());
auto first = GetPreviousPosition(event->GetStartTime(), niIt);
auto last = GetPreviousPosition(event->GetEndTime(), niIt);
for (auto i = first; i != last; ++i)
@@ -511,16 +511,16 @@ double
InterferenceHelper::CalculateNoiseInterferenceW(Ptr<Event> event,
NiChangesPerBand* nis,
WifiSpectrumBand band,
const FrequencyRange& range) const
const FrequencyRange& freqRange) const
{
NS_LOG_FUNCTION(this << band.first << band.second << range);
NS_ABORT_IF(m_firstPowers.count(range) == 0);
auto firstPower_it = m_firstPowers.at(range).find(band);
NS_ABORT_IF(firstPower_it == m_firstPowers.at(range).end());
NS_LOG_FUNCTION(this << band.first << band.second << freqRange);
NS_ABORT_IF(m_firstPowers.count(freqRange) == 0);
auto firstPower_it = m_firstPowers.at(freqRange).find(band);
NS_ABORT_IF(firstPower_it == m_firstPowers.at(freqRange).end());
double noiseInterferenceW = firstPower_it->second;
NS_ABORT_IF(m_niChanges.count(range) == 0);
auto niIt = m_niChanges.at(range).find(band);
NS_ABORT_IF(niIt == m_niChanges.at(range).end());
NS_ABORT_IF(m_niChanges.count(freqRange) == 0);
auto niIt = m_niChanges.at(freqRange).find(band);
NS_ABORT_IF(niIt == m_niChanges.at(freqRange).end());
auto it = niIt->second.find(event->GetStartTime());
for (; it != niIt->second.end() && it->first < Simulator::Now(); ++it)
{
@@ -593,7 +593,7 @@ InterferenceHelper::CalculatePayloadPer(Ptr<const Event> event,
uint16_t channelWidth,
NiChangesPerBand* nis,
WifiSpectrumBand band,
const FrequencyRange& range,
const FrequencyRange& freqRange,
uint16_t staId,
std::pair<Time, Time> window) const
{
@@ -614,9 +614,9 @@ InterferenceHelper::CalculatePayloadPer(Ptr<const Event> event,
}
Time windowStart = phyPayloadStart + window.first;
Time windowEnd = phyPayloadStart + window.second;
NS_ABORT_IF(m_firstPowers.count(range) == 0);
NS_ABORT_IF(m_firstPowers.at(range).count(band) == 0);
double noiseInterferenceW = m_firstPowers.at(range).at(band);
NS_ABORT_IF(m_firstPowers.count(freqRange) == 0);
NS_ABORT_IF(m_firstPowers.at(freqRange).count(band) == 0);
double noiseInterferenceW = m_firstPowers.at(freqRange).at(band);
double powerW = event->GetRxPowerW(band);
while (++j != niIt.cend())
{
@@ -667,10 +667,10 @@ InterferenceHelper::CalculatePhyHeaderSectionPsr(
NiChangesPerBand* nis,
uint16_t channelWidth,
WifiSpectrumBand band,
const FrequencyRange& range,
const FrequencyRange& freqRange,
PhyEntity::PhyHeaderSections phyHeaderSections) const
{
NS_LOG_FUNCTION(this << band.first << band.second << range);
NS_LOG_FUNCTION(this << band.first << band.second << freqRange);
double psr = 1.0; /* Packet Success Rate */
auto niIt = nis->find(band)->second;
auto j = niIt.begin();
@@ -683,9 +683,9 @@ InterferenceHelper::CalculatePhyHeaderSectionPsr(
}
Time previous = j->first;
NS_ABORT_IF(m_firstPowers.count(range) == 0);
NS_ABORT_IF(m_firstPowers.at(range).count(band) == 0);
double noiseInterferenceW = m_firstPowers.at(range).at(band);
NS_ABORT_IF(m_firstPowers.count(freqRange) == 0);
NS_ABORT_IF(m_firstPowers.at(freqRange).count(band) == 0);
double noiseInterferenceW = m_firstPowers.at(freqRange).at(band);
double powerW = event->GetRxPowerW(band);
while (++j != niIt.end())
{
@@ -732,10 +732,10 @@ InterferenceHelper::CalculatePhyHeaderPer(Ptr<const Event> event,
NiChangesPerBand* nis,
uint16_t channelWidth,
WifiSpectrumBand band,
const FrequencyRange& range,
const FrequencyRange& freqRange,
WifiPpduField header) const
{
NS_LOG_FUNCTION(this << band.first << band.second << range << header);
NS_LOG_FUNCTION(this << band.first << band.second << freqRange << header);
auto niIt = nis->find(band)->second;
auto phyEntity = WifiPhy::GetStaticPhyEntity(event->GetTxVector().GetModulationClass());
@@ -752,7 +752,7 @@ InterferenceHelper::CalculatePhyHeaderPer(Ptr<const Event> event,
double psr = 1.0;
if (!sections.empty())
{
psr = CalculatePhyHeaderSectionPsr(event, nis, channelWidth, band, range, sections);
psr = CalculatePhyHeaderSectionPsr(event, nis, channelWidth, band, freqRange, sections);
}
return 1 - psr;
}
@@ -761,14 +761,14 @@ PhyEntity::SnrPer
InterferenceHelper::CalculatePayloadSnrPer(Ptr<Event> event,
uint16_t channelWidth,
WifiSpectrumBand band,
const FrequencyRange& range,
const FrequencyRange& freqRange,
uint16_t staId,
std::pair<Time, Time> relativeMpduStartStop) const
{
NS_LOG_FUNCTION(this << channelWidth << band.first << band.second << range << staId
NS_LOG_FUNCTION(this << channelWidth << band.first << band.second << freqRange << staId
<< relativeMpduStartStop.first << relativeMpduStartStop.second);
NiChangesPerBand ni;
double noiseInterferenceW = CalculateNoiseInterferenceW(event, &ni, band, range);
double noiseInterferenceW = CalculateNoiseInterferenceW(event, &ni, band, freqRange);
double snr = CalculateSnr(event->GetRxPowerW(band),
noiseInterferenceW,
channelWidth,
@@ -777,8 +777,13 @@ InterferenceHelper::CalculatePayloadSnrPer(Ptr<Event> event,
/* calculate the SNIR at the start of the MPDU (located through windowing) and accumulate
* all SNIR changes in the SNIR vector.
*/
double per =
CalculatePayloadPer(event, channelWidth, &ni, band, range, staId, relativeMpduStartStop);
double per = CalculatePayloadPer(event,
channelWidth,
&ni,
band,
freqRange,
staId,
relativeMpduStartStop);
return PhyEntity::SnrPer(snr, per);
}
@@ -788,10 +793,10 @@ InterferenceHelper::CalculateSnr(Ptr<Event> event,
uint16_t channelWidth,
uint8_t nss,
WifiSpectrumBand band,
const FrequencyRange& range) const
const FrequencyRange& freqRange) const
{
NiChangesPerBand ni;
double noiseInterferenceW = CalculateNoiseInterferenceW(event, &ni, band, range);
double noiseInterferenceW = CalculateNoiseInterferenceW(event, &ni, band, freqRange);
double snr = CalculateSnr(event->GetRxPowerW(band), noiseInterferenceW, channelWidth, nss);
return snr;
}
@@ -800,18 +805,18 @@ PhyEntity::SnrPer
InterferenceHelper::CalculatePhyHeaderSnrPer(Ptr<Event> event,
uint16_t channelWidth,
WifiSpectrumBand band,
const FrequencyRange& range,
const FrequencyRange& freqRange,
WifiPpduField header) const
{
NS_LOG_FUNCTION(this << band.first << band.second << header);
NiChangesPerBand ni;
double noiseInterferenceW = CalculateNoiseInterferenceW(event, &ni, band, range);
double noiseInterferenceW = CalculateNoiseInterferenceW(event, &ni, band, freqRange);
double snr = CalculateSnr(event->GetRxPowerW(band), noiseInterferenceW, channelWidth, 1);
/* calculate the SNIR at the start of the PHY header and accumulate
* all SNIR changes in the SNIR vector.
*/
double per = CalculatePhyHeaderPer(event, &ni, channelWidth, band, range, header);
double per = CalculatePhyHeaderPer(event, &ni, channelWidth, band, freqRange, header);
return PhyEntity::SnrPer(snr, per);
}
@@ -846,19 +851,20 @@ InterferenceHelper::NotifyRxStart()
}
void
InterferenceHelper::NotifyRxEnd(Time endTime, const FrequencyRange& range)
InterferenceHelper::NotifyRxEnd(Time endTime, const FrequencyRange& freqRange)
{
NS_LOG_FUNCTION(this << endTime << range);
NS_ABORT_IF(m_niChanges.count(range) == 0);
NS_ABORT_IF(m_firstPowers.count(range) == 0);
NS_LOG_FUNCTION(this << endTime << freqRange);
NS_ABORT_IF(m_niChanges.count(freqRange) == 0);
NS_ABORT_IF(m_firstPowers.count(freqRange) == 0);
m_rxing = false;
// Update m_firstPowers for frame capture
for (auto niIt = m_niChanges.at(range).begin(); niIt != m_niChanges.at(range).end(); ++niIt)
for (auto niIt = m_niChanges.at(freqRange).begin(); niIt != m_niChanges.at(freqRange).end();
++niIt)
{
NS_ASSERT(niIt->second.size() > 1);
auto it = GetPreviousPosition(endTime, niIt);
it--;
m_firstPowers.at(range).find(niIt->first)->second = it->second.GetPower();
m_firstPowers.at(freqRange).find(niIt->first)->second = it->second.GetPower();
}
}

View File

@@ -148,35 +148,35 @@ class InterferenceHelper : public Object
* Add a frequency band.
*
* \param band the band to be added
* \param range the frequency range the band to add belongs to
* \param freqRange the frequency range the band to add belongs to
*/
void AddBand(WifiSpectrumBand band, const FrequencyRange& range);
void AddBand(WifiSpectrumBand band, const FrequencyRange& freqRange);
/**
* Remove the frequency bands for a given frequency range.
*
* \param range the frequency range the bands to remove belong to
* \param freqRange the frequency range the bands to remove belong to
*/
void RemoveBands(FrequencyRange range);
void RemoveBands(FrequencyRange freqRange);
/**
* Check whether a given band is tracked by this interference helper.
*
* \param band the band to be checked
* \param range the frequency range the band to check belongs to
* \param freqRange the frequency range the band to check belongs to
* \return true if the band is already tracked by this interference helper, false otherwise
*/
bool HasBand(WifiSpectrumBand band, const FrequencyRange& range) const;
bool HasBand(WifiSpectrumBand band, const FrequencyRange& freqRange) const;
/**
* Update the frequency bands for a given frequency range when the spectrum model is changed.
*
* \param bands the bands to be added in the new spectrum model
* \param range the frequency range the bands belong to
* \param freqRange the frequency range the bands belong to
* \param offset the offset to convert start and stop indices from old to new spectrum model
*/
void UpdateBands(const std::vector<WifiSpectrumBand>& bands,
const FrequencyRange& range,
const FrequencyRange& freqRange,
int32_t offset);
/**
@@ -209,13 +209,13 @@ class InterferenceHelper : public Object
/**
* \param energyW the minimum energy (W) requested
* \param band identify the requested band
* \param range the frequency range the requested band belongs to
* \param freqRange the frequency range the requested band belongs to
*
* \returns the expected amount of time the observed
* energy on the medium for a given band will
* be higher than the requested threshold.
*/
Time GetEnergyDuration(double energyW, WifiSpectrumBand band, const FrequencyRange& range);
Time GetEnergyDuration(double energyW, WifiSpectrumBand band, const FrequencyRange& freqRange);
/**
* Add the PPDU-related signal to interference helper.
@@ -224,7 +224,7 @@ class InterferenceHelper : public Object
* \param txVector the TXVECTOR
* \param duration the PPDU duration
* \param rxPower received power per band (W)
* \param range the frequency range in which the signal has been detected
* \param freqRange the frequency range in which the signal has been detected
* \param isStartOfdmaRxing flag whether the event corresponds to the start of the OFDMA payload
* reception (only used for UL-OFDMA) //TODO simplify this once WifiPpdu is subclassed by adding
* an attribute
@@ -235,18 +235,18 @@ class InterferenceHelper : public Object
const WifiTxVector& txVector,
Time duration,
RxPowerWattPerChannelBand& rxPower,
const FrequencyRange& range,
const FrequencyRange& freqRange,
bool isStartOfdmaRxing = false);
/**
* Add a non-Wifi signal to interference helper.
* \param duration the duration of the signal
* \param rxPower received power per band (W)
* \param range the frequency range in which the non-wifi signal has been detected
* \param freqRange the frequency range in which the non-wifi signal has been detected
*/
void AddForeignSignal(Time duration,
RxPowerWattPerChannelBand& rxPower,
const FrequencyRange& range);
const FrequencyRange& freqRange);
/**
* Calculate the SNIR at the start of the payload and accumulate
* all SNIR changes in the SNIR vector for each MPDU of an A-MPDU.
@@ -257,7 +257,7 @@ class InterferenceHelper : public Object
* \param event the event corresponding to the first time the corresponding PPDU arrives
* \param channelWidth the channel width used to transmit the PSDU (in MHz)
* \param band identify the band used by the PSDU
* \param range the frequency range the band belongs to
* \param freqRange the frequency range the band belongs to
* \param staId the station ID of the PSDU (only used for MU)
* \param relativeMpduStartStop the time window (pair of start and end times) of PHY payload to
* focus on
@@ -267,7 +267,7 @@ class InterferenceHelper : public Object
PhyEntity::SnrPer CalculatePayloadSnrPer(Ptr<Event> event,
uint16_t channelWidth,
WifiSpectrumBand band,
const FrequencyRange& range,
const FrequencyRange& freqRange,
uint16_t staId,
std::pair<Time, Time> relativeMpduStartStop) const;
/**
@@ -277,7 +277,7 @@ class InterferenceHelper : public Object
* \param channelWidth the channel width (in MHz)
* \param nss the number of spatial streams
* \param band identify the band used by the PSDU
* \param range the frequency range the band belongs to
* \param freqRange the frequency range the band belongs to
*
* \return the SNR for the PPDU in linear scale
*/
@@ -285,7 +285,7 @@ class InterferenceHelper : public Object
uint16_t channelWidth,
uint8_t nss,
WifiSpectrumBand band,
const FrequencyRange& range) const;
const FrequencyRange& freqRange) const;
/**
* Calculate the SNIR at the start of the PHY header and accumulate
* all SNIR changes in the SNIR vector.
@@ -293,7 +293,7 @@ class InterferenceHelper : public Object
* \param event the event corresponding to the first time the corresponding PPDU arrives
* \param channelWidth the channel width (in MHz) for header measurement
* \param band identify the band used by the PSDU
* \param range the frequency range the band belongs to
* \param freqRange the frequency range the band belongs to
* \param header the PHY header to consider
*
* \return struct of SNR and PER
@@ -301,7 +301,7 @@ class InterferenceHelper : public Object
PhyEntity::SnrPer CalculatePhyHeaderSnrPer(Ptr<Event> event,
uint16_t channelWidth,
WifiSpectrumBand band,
const FrequencyRange& range,
const FrequencyRange& freqRange,
WifiPpduField header) const;
/**
@@ -312,20 +312,20 @@ class InterferenceHelper : public Object
* Notify that RX has ended.
*
* \param endTime the end time of the signal
* \param range the frequency range in which the signal event has been detected
* \param freqRange the frequency range in which the signal event has been detected
*/
void NotifyRxEnd(Time endTime, const FrequencyRange& range);
void NotifyRxEnd(Time endTime, const FrequencyRange& freqRange);
/**
* Update event to scale its received power (W) per band.
*
* \param event the event to be updated
* \param rxPower the received power (W) per band to be added to the current event
* \param range the frequency range in which the signal event has been detected
* \param freqRange the frequency range in which the signal event has been detected
*/
void UpdateEvent(Ptr<Event> event,
const RxPowerWattPerChannelBand& rxPower,
const FrequencyRange& range);
const FrequencyRange& freqRange);
protected:
void DoDispose() override;
@@ -446,11 +446,11 @@ class InterferenceHelper : public Object
* Append the given Event.
*
* \param event the event to be appended
* \param range the frequency range in which the signal event has been detected
* \param freqRange the frequency range in which the signal event has been detected
* \param isStartOfdmaRxing flag whether event corresponds to the start of the OFDMA payload
* reception (only used for UL-OFDMA)
*/
void AppendEvent(Ptr<Event> event, const FrequencyRange& range, bool isStartOfdmaRxing);
void AppendEvent(Ptr<Event> event, const FrequencyRange& freqRange, bool isStartOfdmaRxing);
/**
* Calculate noise and interference power in W.
@@ -458,14 +458,14 @@ class InterferenceHelper : public Object
* \param event the event
* \param nis the NiChanges
* \param band the band
* \param range the frequency range
* \param freqRange the frequency range
*
* \return noise and interference power
*/
double CalculateNoiseInterferenceW(Ptr<Event> event,
NiChangesPerBand* nis,
WifiSpectrumBand band,
const FrequencyRange& range) const;
const FrequencyRange& freqRange) const;
/**
* Calculate the error rate of the given PHY payload only in the provided time
* window (thus enabling per MPDU PER information). The PHY payload can be divided into
@@ -475,7 +475,7 @@ class InterferenceHelper : public Object
* \param channelWidth the channel width used to transmit the PSDU (in MHz)
* \param nis the NiChanges
* \param band identify the band used by the PSDU
* \param range the frequency range the band belongs to
* \param freqRange the frequency range the band belongs to
* \param staId the station ID of the PSDU (only used for MU)
* \param window time window (pair of start and end times) of PHY payload to focus on
*
@@ -485,7 +485,7 @@ class InterferenceHelper : public Object
uint16_t channelWidth,
NiChangesPerBand* nis,
WifiSpectrumBand band,
const FrequencyRange& range,
const FrequencyRange& freqRange,
uint16_t staId,
std::pair<Time, Time> window) const;
/**
@@ -496,7 +496,7 @@ class InterferenceHelper : public Object
* \param nis the NiChanges
* \param channelWidth the channel width (in MHz) for header measurement
* \param band the band
* \param range the frequency range
* \param freqRange the frequency range
* \param header the PHY header to consider
*
* \return the error rate of the HT PHY header
@@ -505,7 +505,7 @@ class InterferenceHelper : public Object
NiChangesPerBand* nis,
uint16_t channelWidth,
WifiSpectrumBand band,
const FrequencyRange& range,
const FrequencyRange& freqRange,
WifiPpduField header) const;
/**
* Calculate the success rate of the PHY header sections for the provided event.
@@ -514,7 +514,7 @@ class InterferenceHelper : public Object
* \param nis the NiChanges
* \param channelWidth the channel width (in MHz) for header measurement
* \param band the band
* \param range the frequency range
* \param freqRange the frequency range
* \param phyHeaderSections the map of PHY header sections (\see PhyEntity::PhyHeaderSections)
*
* \return the success rate of the PHY header sections
@@ -523,7 +523,7 @@ class InterferenceHelper : public Object
NiChangesPerBand* nis,
uint16_t channelWidth,
WifiSpectrumBand band,
const FrequencyRange& range,
const FrequencyRange& freqRange,
PhyEntity::PhyHeaderSections phyHeaderSections) const;
double m_noiseFigure; //!< noise figure (linear)

View File

@@ -165,12 +165,12 @@ SpectrumWifiPhy::UpdateInterferenceHelperBands(std::optional<int32_t> indicesOff
{
HeRu::SubcarrierGroup group =
HeRu::GetSubcarrierGroup(bw, ruType, phyIndex);
HeRu::SubcarrierRange range =
HeRu::SubcarrierRange subcarrierRange =
std::make_pair(group.front().first, group.back().second);
WifiSpectrumBand band =
ConvertHeRuSubcarriers(bw,
GetGuardBandwidth(channelWidth),
range,
subcarrierRange,
i);
std::size_t index =
(bw == 160 && phyIndex > nRus / 2 ? phyIndex - nRus / 2 : phyIndex);
@@ -351,8 +351,8 @@ void
SpectrumWifiPhy::StartRx(Ptr<SpectrumSignalParameters> rxParams,
Ptr<const WifiSpectrumPhyInterface> interface)
{
const auto range = interface ? interface->GetFrequencyRange() : GetCurrentFrequencyRange();
NS_LOG_FUNCTION(this << rxParams << interface << range);
const auto freqRange = interface ? interface->GetFrequencyRange() : GetCurrentFrequencyRange();
NS_LOG_FUNCTION(this << rxParams << interface << freqRange);
Time rxDuration = rxParams->duration;
Ptr<SpectrumValue> receivedSignalPsd = rxParams->psd;
NS_LOG_DEBUG("Received signal with PSD " << *receivedSignalPsd << " and duration "
@@ -375,7 +375,8 @@ SpectrumWifiPhy::StartRx(Ptr<SpectrumSignalParameters> rxParams,
if ((channelWidth == 5) || (channelWidth == 10))
{
WifiSpectrumBand filteredBand = GetBandForInterface(channelWidth, 0, range, channelWidth);
WifiSpectrumBand filteredBand =
GetBandForInterface(channelWidth, 0, freqRange, channelWidth);
double rxPowerPerBandW =
WifiSpectrumValueHelper::GetBandPowerW(receivedSignalPsd, filteredBand);
NS_LOG_DEBUG("Signal power received (watts) before antenna gain: " << rxPowerPerBandW);
@@ -393,7 +394,7 @@ SpectrumWifiPhy::StartRx(Ptr<SpectrumSignalParameters> rxParams,
for (uint32_t i = 0; i < (channelWidth / bw); i++)
{
NS_ASSERT(channelWidth >= bw);
WifiSpectrumBand filteredBand = GetBandForInterface(bw, i, range, channelWidth);
WifiSpectrumBand filteredBand = GetBandForInterface(bw, i, freqRange, channelWidth);
double rxPowerPerBandW =
WifiSpectrumValueHelper::GetBandPowerW(receivedSignalPsd, filteredBand);
NS_LOG_DEBUG("Signal power received (watts) before antenna gain for "
@@ -408,7 +409,7 @@ SpectrumWifiPhy::StartRx(Ptr<SpectrumSignalParameters> rxParams,
for (uint32_t i = 0; i < (channelWidth / 20); i++)
{
WifiSpectrumBand filteredBand = GetBandForInterface(20, i, range, channelWidth);
WifiSpectrumBand filteredBand = GetBandForInterface(20, i, freqRange, channelWidth);
double rxPowerPerBandW =
WifiSpectrumValueHelper::GetBandPowerW(receivedSignalPsd, filteredBand);
NS_LOG_DEBUG("Signal power received (watts) before antenna gain for 20 MHz channel band "
@@ -454,7 +455,7 @@ SpectrumWifiPhy::StartRx(Ptr<SpectrumSignalParameters> rxParams,
if (!wifiRxParams)
{
NS_LOG_INFO("Received non Wi-Fi signal");
m_interference->AddForeignSignal(rxDuration, rxPowerW, range);
m_interference->AddForeignSignal(rxDuration, rxPowerW, freqRange);
SwitchMaybeToCcaBusy(nullptr);
return;
}
@@ -462,7 +463,7 @@ SpectrumWifiPhy::StartRx(Ptr<SpectrumSignalParameters> rxParams,
if (wifiRxParams && m_disableWifiReception)
{
NS_LOG_INFO("Received Wi-Fi signal but blocked from syncing");
m_interference->AddForeignSignal(rxDuration, rxPowerW, range);
m_interference->AddForeignSignal(rxDuration, rxPowerW, freqRange);
SwitchMaybeToCcaBusy(nullptr);
return;
}
@@ -471,7 +472,7 @@ SpectrumWifiPhy::StartRx(Ptr<SpectrumSignalParameters> rxParams,
(interface != m_currentSpectrumPhyInterface))
{
NS_LOG_INFO("Received Wi-Fi signal from a non-active PHY interface");
m_interference->AddForeignSignal(rxDuration, rxPowerW, range);
m_interference->AddForeignSignal(rxDuration, rxPowerW, freqRange);
SwitchMaybeToCcaBusy(nullptr);
return;
}
@@ -485,7 +486,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, range);
m_interference->Add(ppdu, txVector, rxDuration, rxPowerW, freqRange);
SwitchMaybeToCcaBusy(nullptr);
return;
}
@@ -495,7 +496,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, range);
m_interference->Add(ppdu, txVector, rxDuration, rxPowerW, freqRange);
SwitchMaybeToCcaBusy(ppdu);
return;
}
@@ -619,7 +620,7 @@ SpectrumWifiPhy::GetBand(uint16_t bandWidth, uint8_t bandIndex /* = 0 */)
WifiSpectrumBand
SpectrumWifiPhy::GetBandForInterface(uint16_t bandWidth,
uint8_t bandIndex,
FrequencyRange range,
FrequencyRange freqRange,
uint16_t channelWidth)
{
uint32_t bandBandwidth = GetBandBandwidth();
@@ -629,7 +630,8 @@ SpectrumWifiPhy::GetBandForInterface(uint16_t bandWidth,
{
numBandsInChannel += 1; // symmetry around center frequency
}
size_t totalNumBands = m_spectrumPhyInterfaces.at(range)->GetRxSpectrumModel()->GetNumBands();
size_t totalNumBands =
m_spectrumPhyInterfaces.at(freqRange)->GetRxSpectrumModel()->GetNumBands();
NS_ASSERT_MSG((numBandsInChannel % 2 == 1) && (totalNumBands % 2 == 1),
"Should have odd number of bands");
NS_ASSERT_MSG((bandIndex * bandWidth) < channelWidth, "Band index is out of bound");
@@ -648,7 +650,7 @@ SpectrumWifiPhy::GetBandForInterface(uint16_t bandWidth,
WifiSpectrumBand
SpectrumWifiPhy::ConvertHeRuSubcarriers(uint16_t bandWidth,
uint16_t guardBandwidth,
HeRu::SubcarrierRange range,
HeRu::SubcarrierRange subcarrierRange,
uint8_t bandIndex) const
{
WifiSpectrumBand convertedSubcarriers;
@@ -677,8 +679,8 @@ SpectrumWifiPhy::ConvertHeRuSubcarriers(uint16_t bandWidth,
size_t numBandsInBand = static_cast<size_t>(bandWidth * 1e6 / GetBandBandwidth());
centerFrequencyIndex += numBandsInBand * bandIndex;
convertedSubcarriers.first = centerFrequencyIndex + range.first;
convertedSubcarriers.second = centerFrequencyIndex + range.second;
convertedSubcarriers.first = centerFrequencyIndex + subcarrierRange.first;
convertedSubcarriers.second = centerFrequencyIndex + subcarrierRange.second;
return convertedSubcarriers;
}

View File

@@ -134,7 +134,7 @@ class SpectrumWifiPhy : public WifiPhy
*/
WifiSpectrumBand GetBandForInterface(uint16_t bandWidth,
uint8_t bandIndex,
FrequencyRange range,
FrequencyRange freqRange,
uint16_t channelWidth);
/**
@@ -189,20 +189,9 @@ class SpectrumWifiPhy : public WifiPhy
//!< reasons)
private:
/**
* \param bandWidth the width (MHz) of the band used for the OFDMA transmission. Must be
* a multiple of 20 MHz
* \param guardBandwidth width of the guard band (MHz)
* \param range the subcarrier range of the HE RU
* \param bandIndex the index (starting at 0) of the band within the operating channel
* \return the converted subcarriers
*
* This is a helper function to convert HE RU subcarriers, which are relative to the center
* frequency subcarrier, to the indexes used by the Spectrum model.
*/
WifiSpectrumBand ConvertHeRuSubcarriers(uint16_t bandWidth,
uint16_t guardBandwidth,
HeRu::SubcarrierRange range,
HeRu::SubcarrierRange subcarrierRange,
uint8_t bandIndex = 0) const override;
/**

View File

@@ -1856,14 +1856,13 @@ WifiPhy::StartReceivePreamble(Ptr<const WifiPpdu> ppdu,
}
WifiSpectrumBand
WifiPhy::ConvertHeRuSubcarriers(uint16_t bandWidth,
uint16_t guardBandwidth,
HeRu::SubcarrierRange range,
uint8_t bandIndex) const
WifiPhy::ConvertHeRuSubcarriers(uint16_t /*bandWidth*/,
uint16_t /*guardBandwidth*/,
HeRu::SubcarrierRange /*subcarrierRange*/,
uint8_t /*bandIndex*/) const
{
NS_ASSERT_MSG(false, "802.11ax can only be used with SpectrumWifiPhy");
WifiSpectrumBand convertedSubcarriers;
return convertedSubcarriers;
return {0, 0};
}
void

View File

@@ -1057,7 +1057,7 @@ class WifiPhy : public Object
* \param bandWidth the width (MHz) of the band used for the OFDMA transmission. Must be
* a multiple of 20 MHz
* \param guardBandwidth width of the guard band (MHz)
* \param range the subcarrier range of the HE RU
* \param subcarrierRange the subcarrier range of the HE RU
* \param bandIndex the index (starting at 0) of the band within the operating channel
* \return the converted subcarriers
*
@@ -1066,7 +1066,7 @@ class WifiPhy : public Object
*/
virtual WifiSpectrumBand ConvertHeRuSubcarriers(uint16_t bandWidth,
uint16_t guardBandwidth,
HeRu::SubcarrierRange range,
HeRu::SubcarrierRange subcarrierRange,
uint8_t bandIndex = 0) const;
/**

View File

@@ -40,12 +40,12 @@ WifiSpectrumPhyInterface::GetTypeId()
return tid;
}
WifiSpectrumPhyInterface::WifiSpectrumPhyInterface(FrequencyRange range)
: m_range{range},
WifiSpectrumPhyInterface::WifiSpectrumPhyInterface(FrequencyRange freqRange)
: m_frequencyRange{freqRange},
m_centerFrequency{0},
m_channelWidth{0}
{
NS_LOG_FUNCTION(this << range);
NS_LOG_FUNCTION(this << freqRange);
}
void
@@ -138,7 +138,7 @@ WifiSpectrumPhyInterface::GetAntenna() const
const FrequencyRange&
WifiSpectrumPhyInterface::GetFrequencyRange() const
{
return m_range;
return m_frequencyRange;
}
uint16_t

View File

@@ -51,9 +51,9 @@ class WifiSpectrumPhyInterface : public SpectrumPhy
/**
* Constructor
*
* \param range the frequency range covered by the interface
* \param freqRange the frequency range covered by the interface
*/
WifiSpectrumPhyInterface(FrequencyRange range);
WifiSpectrumPhyInterface(FrequencyRange freqRange);
/**
* Connect SpectrumWifiPhy object
* \param phy SpectrumWifiPhy object to be connected to this object
@@ -128,7 +128,7 @@ class WifiSpectrumPhyInterface : public SpectrumPhy
private:
void DoDispose() override;
FrequencyRange m_range; ///< frequency range
FrequencyRange m_frequencyRange; ///< frequency range
Ptr<SpectrumWifiPhy> m_spectrumWifiPhy; ///< spectrum PHY
Ptr<NetDevice> m_netDevice; ///< the device
Ptr<SpectrumChannel> m_channel; ///< spectrum channel

View File

@@ -691,13 +691,15 @@ SpectrumWifiPhyFilterTest::RunOne()
HeRu::RuType ruType = static_cast<HeRu::RuType>(type);
for (std::size_t index = 1; index <= HeRu::GetNRus(bw, ruType); index++)
{
HeRu::SubcarrierGroup group = HeRu::GetSubcarrierGroup(bw, ruType, index);
HeRu::SubcarrierRange range =
std::make_pair(group.front().first, group.back().second);
HeRu::SubcarrierGroup subcarrierGroup =
HeRu::GetSubcarrierGroup(bw, ruType, index);
HeRu::SubcarrierRange subcarrierRange =
std::make_pair(subcarrierGroup.front().first,
subcarrierGroup.back().second);
WifiSpectrumBand band = m_rxPhy->ConvertHeRuSubcarriers(
bw,
m_rxPhy->GetGuardBandwidth(m_rxChannelWidth),
range,
subcarrierRange,
i);
m_ruBands.insert(band);
}
@@ -853,24 +855,24 @@ class SpectrumWifiPhyMultipleInterfacesTest : public TestCase
/**
* Schedule now to check the interferences
* \param phy the PHY for which the check has to be executed
* \param range the frequency range for which the check has to be executed
* \param freqRange the frequency range for which the check has to be executed
* \param channelWidth the channel width for which the check has to be executed
* \param interferencesExpected flag whether interferences are expected to have been tracked
*/
void CheckInterferences(Ptr<ExtSpectrumWifiPhy> phy,
const FrequencyRange& range,
const FrequencyRange& freqRange,
uint16_t channelWidth,
bool interferencesExpected);
/**
* Check the interferences
* \param phy the PHY for which the check has to be executed
* \param range the frequency range for which the check has to be executed
* \param freqRange the frequency range for which the check has to be executed
* \param channelWidth the channel width for which the check has to be executed
* \param interferencesExpected flag whether interferences are expected to have been tracked
*/
void DoCheckInterferences(Ptr<ExtSpectrumWifiPhy> phy,
const FrequencyRange& range,
const FrequencyRange& freqRange,
uint16_t channelWidth,
bool interferencesExpected);
@@ -982,11 +984,11 @@ SpectrumWifiPhyMultipleInterfacesTest::RxCallback(std::size_t index,
void
SpectrumWifiPhyMultipleInterfacesTest::CheckInterferences(Ptr<ExtSpectrumWifiPhy> phy,
const FrequencyRange& range,
const FrequencyRange& freqRange,
uint16_t channelWidth,
bool interferencesExpected)
{
if ((!m_trackSignalsInactiveInterfaces) && (phy->GetCurrentFrequencyRange() != range))
if ((!m_trackSignalsInactiveInterfaces) && (phy->GetCurrentFrequencyRange() != freqRange))
{
// ignore since no bands for that range exists in interference helper in that case
return;
@@ -996,24 +998,24 @@ SpectrumWifiPhyMultipleInterfacesTest::CheckInterferences(Ptr<ExtSpectrumWifiPhy
Simulator::ScheduleNow(&SpectrumWifiPhyMultipleInterfacesTest::DoCheckInterferences,
this,
phy,
range,
freqRange,
channelWidth,
interferencesExpected);
}
void
SpectrumWifiPhyMultipleInterfacesTest::DoCheckInterferences(Ptr<ExtSpectrumWifiPhy> phy,
const FrequencyRange& range,
const FrequencyRange& freqRange,
uint16_t channelWidth,
bool interferencesExpected)
{
NS_LOG_FUNCTION(this << phy << range << interferencesExpected);
NS_LOG_FUNCTION(this << phy << freqRange << interferencesExpected);
PointerValue ptr;
phy->GetAttribute("InterferenceHelper", ptr);
auto interferenceHelper = DynamicCast<InterferenceHelper>(ptr.Get<InterferenceHelper>());
NS_ASSERT(interferenceHelper);
const auto band = phy->GetBandForInterface(channelWidth, 0, range, channelWidth);
const auto energyDuration = interferenceHelper->GetEnergyDuration(0, band, range);
const auto band = phy->GetBandForInterface(channelWidth, 0, freqRange, channelWidth);
const auto energyDuration = interferenceHelper->GetEnergyDuration(0, band, freqRange);
NS_TEST_ASSERT_MSG_EQ(energyDuration.IsStrictlyPositive(),
interferencesExpected,
"Incorrect interferences detection");