wifi: Cleanup extra dimension in InterferenceHelper
This commit is contained in:
committed by
Sébastien Deronne
parent
57f5d8d1b7
commit
015b711bc8
@@ -208,19 +208,11 @@ void
|
||||
InterferenceHelper::DoDispose()
|
||||
{
|
||||
NS_LOG_FUNCTION(this);
|
||||
for (auto [range, niChangesPerBand] : m_niChanges)
|
||||
{
|
||||
for (auto it : niChangesPerBand)
|
||||
{
|
||||
it.second.clear();
|
||||
}
|
||||
niChangesPerBand.clear();
|
||||
}
|
||||
m_niChanges.clear();
|
||||
for (auto it : m_firstPowers)
|
||||
for (auto it : m_niChanges)
|
||||
{
|
||||
it.second.clear();
|
||||
}
|
||||
m_niChanges.clear();
|
||||
m_firstPowers.clear();
|
||||
m_errorRateModel = nullptr;
|
||||
}
|
||||
@@ -230,18 +222,15 @@ InterferenceHelper::Add(Ptr<const WifiPpdu> ppdu,
|
||||
const WifiTxVector& txVector,
|
||||
Time duration,
|
||||
RxPowerWattPerChannelBand& rxPowerW,
|
||||
const FrequencyRange& freqRange,
|
||||
bool isStartOfdmaRxing)
|
||||
{
|
||||
Ptr<Event> event = Create<Event>(ppdu, txVector, duration, std::move(rxPowerW));
|
||||
AppendEvent(event, freqRange, isStartOfdmaRxing);
|
||||
AppendEvent(event, isStartOfdmaRxing);
|
||||
return event;
|
||||
}
|
||||
|
||||
void
|
||||
InterferenceHelper::AddForeignSignal(Time duration,
|
||||
RxPowerWattPerChannelBand& rxPowerW,
|
||||
const FrequencyRange& freqRange)
|
||||
InterferenceHelper::AddForeignSignal(Time duration, RxPowerWattPerChannelBand& rxPowerW)
|
||||
{
|
||||
// Parameters other than duration and rxPowerW are unused for this type
|
||||
// of signal, so we provide dummy versions
|
||||
@@ -251,35 +240,33 @@ InterferenceHelper::AddForeignSignal(Time duration,
|
||||
Ptr<WifiPpdu> fakePpdu = Create<WifiPpdu>(Create<WifiPsdu>(Create<Packet>(0), hdr),
|
||||
WifiTxVector(),
|
||||
WifiPhyOperatingChannel());
|
||||
Add(fakePpdu, WifiTxVector(), duration, rxPowerW, freqRange);
|
||||
Add(fakePpdu, WifiTxVector(), duration, rxPowerW);
|
||||
}
|
||||
|
||||
bool
|
||||
InterferenceHelper::HasBands(const FrequencyRange& freqRange) const
|
||||
InterferenceHelper::HasBands() const
|
||||
{
|
||||
NS_LOG_FUNCTION(this << freqRange);
|
||||
return (m_niChanges.count(freqRange) > 0);
|
||||
return !m_niChanges.empty();
|
||||
}
|
||||
|
||||
bool
|
||||
InterferenceHelper::HasBand(const WifiSpectrumBandInfo& band, const FrequencyRange& freqRange) const
|
||||
InterferenceHelper::HasBand(const WifiSpectrumBandInfo& band) const
|
||||
{
|
||||
NS_LOG_FUNCTION(this << band << freqRange);
|
||||
return (m_niChanges.count(freqRange) > 0 && m_niChanges.at(freqRange).count(band) > 0);
|
||||
return (m_niChanges.count(band) > 0);
|
||||
}
|
||||
|
||||
void
|
||||
InterferenceHelper::AddBand(const WifiSpectrumBandInfo& band, const FrequencyRange& freqRange)
|
||||
InterferenceHelper::AddBand(const WifiSpectrumBandInfo& band)
|
||||
{
|
||||
NS_LOG_FUNCTION(this << band << 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);
|
||||
NS_LOG_FUNCTION(this << band);
|
||||
NS_ASSERT(m_niChanges.count(band) == 0);
|
||||
NS_ASSERT(m_firstPowers.count(band) == 0);
|
||||
NiChanges niChanges;
|
||||
auto result = m_niChanges[freqRange].insert({band, niChanges});
|
||||
auto result = m_niChanges.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[freqRange].insert({band, 0.0});
|
||||
m_firstPowers.insert({band, 0.0});
|
||||
}
|
||||
|
||||
void
|
||||
@@ -287,48 +274,36 @@ InterferenceHelper::UpdateBands(const std::vector<WifiSpectrumBandInfo>& bands,
|
||||
const FrequencyRange& freqRange)
|
||||
{
|
||||
NS_LOG_FUNCTION(this << freqRange);
|
||||
NS_ABORT_IF(m_niChanges.count(freqRange) == 0);
|
||||
auto& niChangesPerBand = m_niChanges.at(freqRange);
|
||||
auto& firstPowerPerBand = m_firstPowers.at(freqRange);
|
||||
NiChangesPerBand newNiChangesPerBand{};
|
||||
FirstPowerPerBand newFirstPowerPerBand{};
|
||||
for (auto it = niChangesPerBand.begin(); it != niChangesPerBand.end();)
|
||||
for (auto it = m_niChanges.begin(); it != m_niChanges.end();)
|
||||
{
|
||||
const auto frequencies = it->first.frequencies;
|
||||
const auto isInFrequencyRange = ((frequencies.second > (freqRange.minFrequency * 1e6)) &&
|
||||
(frequencies.first < (freqRange.maxFrequency * 1e6)));
|
||||
if (!isInFrequencyRange)
|
||||
if (!IsBandInFrequencyRange(it->first, freqRange))
|
||||
{
|
||||
NS_ASSERT(newNiChangesPerBand.count(it->first) == 0);
|
||||
newNiChangesPerBand.insert({it->first, std::move(it->second)});
|
||||
newFirstPowerPerBand.insert({it->first, firstPowerPerBand.at(it->first)});
|
||||
it++;
|
||||
continue;
|
||||
}
|
||||
const auto itEqual =
|
||||
const auto frequencies = it->first.frequencies;
|
||||
const auto found =
|
||||
std::find_if(bands.cbegin(), bands.cend(), [frequencies](const auto& item) {
|
||||
return frequencies == item.frequencies;
|
||||
});
|
||||
if (itEqual == std::end(bands))
|
||||
}) != std::end(bands);
|
||||
if (!found)
|
||||
{
|
||||
// band does not belong to the new bands, erase it
|
||||
m_firstPowers.erase(it->first);
|
||||
it->second.clear();
|
||||
it = m_niChanges.erase(it);
|
||||
}
|
||||
else
|
||||
{
|
||||
newNiChangesPerBand.insert({*itEqual, std::move(it->second)});
|
||||
newFirstPowerPerBand.insert({*itEqual, firstPowerPerBand.at(it->first)});
|
||||
it++;
|
||||
}
|
||||
firstPowerPerBand.erase(it->first);
|
||||
it = niChangesPerBand.erase(it);
|
||||
}
|
||||
niChangesPerBand.swap(newNiChangesPerBand);
|
||||
firstPowerPerBand.swap(newFirstPowerPerBand);
|
||||
for (const auto& band : bands)
|
||||
{
|
||||
if (!HasBand(band, freqRange))
|
||||
if (!HasBand(band))
|
||||
{
|
||||
// this is a new band, add it
|
||||
AddBand(band, freqRange);
|
||||
AddBand(band);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -358,15 +333,12 @@ InterferenceHelper::SetNumberOfReceiveAntennas(uint8_t rx)
|
||||
}
|
||||
|
||||
Time
|
||||
InterferenceHelper::GetEnergyDuration(double energyW,
|
||||
const WifiSpectrumBandInfo& band,
|
||||
const FrequencyRange& freqRange)
|
||||
InterferenceHelper::GetEnergyDuration(double energyW, const WifiSpectrumBandInfo& band)
|
||||
{
|
||||
NS_LOG_FUNCTION(this << energyW << band << freqRange);
|
||||
NS_LOG_FUNCTION(this << energyW << band);
|
||||
Time now = Simulator::Now();
|
||||
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 niIt = m_niChanges.find(band);
|
||||
NS_ABORT_IF(niIt == m_niChanges.end());
|
||||
auto i = GetPreviousPosition(now, niIt);
|
||||
Time end = i->first;
|
||||
for (; i != niIt->second.end(); ++i)
|
||||
@@ -382,17 +354,13 @@ InterferenceHelper::GetEnergyDuration(double energyW,
|
||||
}
|
||||
|
||||
void
|
||||
InterferenceHelper::AppendEvent(Ptr<Event> event,
|
||||
const FrequencyRange& freqRange,
|
||||
bool isStartOfdmaRxing)
|
||||
InterferenceHelper::AppendEvent(Ptr<Event> event, bool isStartOfdmaRxing)
|
||||
{
|
||||
NS_LOG_FUNCTION(this << event << freqRange << isStartOfdmaRxing);
|
||||
NS_ABORT_IF(m_niChanges.count(freqRange) == 0);
|
||||
NS_ABORT_IF(m_firstPowers.count(freqRange) == 0);
|
||||
NS_LOG_FUNCTION(this << event << isStartOfdmaRxing);
|
||||
for (const auto& [band, power] : event->GetRxPowerWPerBand())
|
||||
{
|
||||
auto niIt = m_niChanges.at(freqRange).find(band);
|
||||
NS_ABORT_IF(niIt == m_niChanges.at(freqRange).end());
|
||||
auto niIt = m_niChanges.find(band);
|
||||
NS_ABORT_IF(niIt == m_niChanges.end());
|
||||
double previousPowerStart = 0;
|
||||
double previousPowerEnd = 0;
|
||||
auto previousPowerPosition = GetPreviousPosition(event->GetStartTime(), niIt);
|
||||
@@ -400,7 +368,7 @@ InterferenceHelper::AppendEvent(Ptr<Event> event,
|
||||
previousPowerEnd = GetPreviousPosition(event->GetEndTime(), niIt)->second.GetPower();
|
||||
if (!m_rxing)
|
||||
{
|
||||
m_firstPowers.at(freqRange).find(band)->second = previousPowerStart;
|
||||
m_firstPowers.find(band)->second = previousPowerStart;
|
||||
// Always leave the first zero power noise event in the list
|
||||
niIt->second.erase(++(niIt->second.begin()), ++previousPowerPosition);
|
||||
}
|
||||
@@ -409,7 +377,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(freqRange).find(band)->second = previousPowerStart;
|
||||
m_firstPowers.find(band)->second = previousPowerStart;
|
||||
}
|
||||
auto first =
|
||||
AddNiChangeEvent(event->GetStartTime(), NiChange(previousPowerStart, event), niIt);
|
||||
@@ -422,17 +390,14 @@ InterferenceHelper::AppendEvent(Ptr<Event> event,
|
||||
}
|
||||
|
||||
void
|
||||
InterferenceHelper::UpdateEvent(Ptr<Event> event,
|
||||
const RxPowerWattPerChannelBand& rxPower,
|
||||
const FrequencyRange& freqRange)
|
||||
InterferenceHelper::UpdateEvent(Ptr<Event> event, const RxPowerWattPerChannelBand& rxPower)
|
||||
{
|
||||
NS_LOG_FUNCTION(this << event << freqRange);
|
||||
NS_ABORT_IF(m_niChanges.count(freqRange) == 0);
|
||||
NS_LOG_FUNCTION(this << event);
|
||||
// This is called for UL MU events, in order to scale power as long as UL MU PPDUs arrive
|
||||
for (const auto& [band, power] : rxPower)
|
||||
{
|
||||
auto niIt = m_niChanges.at(freqRange).find(band);
|
||||
NS_ABORT_IF(niIt == m_niChanges.at(freqRange).end());
|
||||
auto niIt = m_niChanges.find(band);
|
||||
NS_ABORT_IF(niIt == m_niChanges.end());
|
||||
auto first = GetPreviousPosition(event->GetStartTime(), niIt);
|
||||
auto last = GetPreviousPosition(event->GetEndTime(), niIt);
|
||||
for (auto i = first; i != last; ++i)
|
||||
@@ -478,17 +443,14 @@ InterferenceHelper::CalculateSnr(double signal,
|
||||
double
|
||||
InterferenceHelper::CalculateNoiseInterferenceW(Ptr<Event> event,
|
||||
NiChangesPerBand* nis,
|
||||
const WifiSpectrumBandInfo& band,
|
||||
const FrequencyRange& freqRange) const
|
||||
const WifiSpectrumBandInfo& band) const
|
||||
{
|
||||
NS_LOG_FUNCTION(this << band << 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());
|
||||
NS_LOG_FUNCTION(this << band);
|
||||
auto firstPower_it = m_firstPowers.find(band);
|
||||
NS_ABORT_IF(firstPower_it == m_firstPowers.end());
|
||||
double noiseInterferenceW = firstPower_it->second;
|
||||
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 niIt = m_niChanges.find(band);
|
||||
NS_ABORT_IF(niIt == m_niChanges.end());
|
||||
auto it = niIt->second.find(event->GetStartTime());
|
||||
for (; it != niIt->second.end() && it->first < Simulator::Now(); ++it)
|
||||
{
|
||||
@@ -561,7 +523,6 @@ InterferenceHelper::CalculatePayloadPer(Ptr<const Event> event,
|
||||
uint16_t channelWidth,
|
||||
NiChangesPerBand* nis,
|
||||
const WifiSpectrumBandInfo& band,
|
||||
const FrequencyRange& freqRange,
|
||||
uint16_t staId,
|
||||
std::pair<Time, Time> window) const
|
||||
{
|
||||
@@ -581,9 +542,8 @@ InterferenceHelper::CalculatePayloadPer(Ptr<const Event> event,
|
||||
}
|
||||
Time windowStart = phyPayloadStart + window.first;
|
||||
Time windowEnd = phyPayloadStart + window.second;
|
||||
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);
|
||||
NS_ABORT_IF(m_firstPowers.count(band) == 0);
|
||||
double noiseInterferenceW = m_firstPowers.at(band);
|
||||
double powerW = event->GetRxPowerW(band);
|
||||
while (++j != niIt.cend())
|
||||
{
|
||||
@@ -634,10 +594,9 @@ InterferenceHelper::CalculatePhyHeaderSectionPsr(
|
||||
NiChangesPerBand* nis,
|
||||
uint16_t channelWidth,
|
||||
const WifiSpectrumBandInfo& band,
|
||||
const FrequencyRange& freqRange,
|
||||
PhyEntity::PhyHeaderSections phyHeaderSections) const
|
||||
{
|
||||
NS_LOG_FUNCTION(this << band << freqRange);
|
||||
NS_LOG_FUNCTION(this << band);
|
||||
double psr = 1.0; /* Packet Success Rate */
|
||||
auto niIt = nis->find(band)->second;
|
||||
auto j = niIt.begin();
|
||||
@@ -650,9 +609,8 @@ InterferenceHelper::CalculatePhyHeaderSectionPsr(
|
||||
}
|
||||
|
||||
Time previous = j->first;
|
||||
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);
|
||||
NS_ABORT_IF(m_firstPowers.count(band) == 0);
|
||||
double noiseInterferenceW = m_firstPowers.at(band);
|
||||
double powerW = event->GetRxPowerW(band);
|
||||
while (++j != niIt.end())
|
||||
{
|
||||
@@ -699,10 +657,9 @@ InterferenceHelper::CalculatePhyHeaderPer(Ptr<const Event> event,
|
||||
NiChangesPerBand* nis,
|
||||
uint16_t channelWidth,
|
||||
const WifiSpectrumBandInfo& band,
|
||||
const FrequencyRange& freqRange,
|
||||
WifiPpduField header) const
|
||||
{
|
||||
NS_LOG_FUNCTION(this << band << freqRange << header);
|
||||
NS_LOG_FUNCTION(this << band << header);
|
||||
auto niIt = nis->find(band)->second;
|
||||
auto phyEntity = WifiPhy::GetStaticPhyEntity(event->GetTxVector().GetModulationClass());
|
||||
|
||||
@@ -719,7 +676,7 @@ InterferenceHelper::CalculatePhyHeaderPer(Ptr<const Event> event,
|
||||
double psr = 1.0;
|
||||
if (!sections.empty())
|
||||
{
|
||||
psr = CalculatePhyHeaderSectionPsr(event, nis, channelWidth, band, freqRange, sections);
|
||||
psr = CalculatePhyHeaderSectionPsr(event, nis, channelWidth, band, sections);
|
||||
}
|
||||
return 1 - psr;
|
||||
}
|
||||
@@ -728,14 +685,13 @@ PhyEntity::SnrPer
|
||||
InterferenceHelper::CalculatePayloadSnrPer(Ptr<Event> event,
|
||||
uint16_t channelWidth,
|
||||
const WifiSpectrumBandInfo& band,
|
||||
const FrequencyRange& freqRange,
|
||||
uint16_t staId,
|
||||
std::pair<Time, Time> relativeMpduStartStop) const
|
||||
{
|
||||
NS_LOG_FUNCTION(this << channelWidth << band << freqRange << staId
|
||||
<< relativeMpduStartStop.first << relativeMpduStartStop.second);
|
||||
NS_LOG_FUNCTION(this << channelWidth << band << staId << relativeMpduStartStop.first
|
||||
<< relativeMpduStartStop.second);
|
||||
NiChangesPerBand ni;
|
||||
double noiseInterferenceW = CalculateNoiseInterferenceW(event, &ni, band, freqRange);
|
||||
double noiseInterferenceW = CalculateNoiseInterferenceW(event, &ni, band);
|
||||
double snr = CalculateSnr(event->GetRxPowerW(band),
|
||||
noiseInterferenceW,
|
||||
channelWidth,
|
||||
@@ -744,13 +700,7 @@ 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,
|
||||
freqRange,
|
||||
staId,
|
||||
relativeMpduStartStop);
|
||||
double per = CalculatePayloadPer(event, channelWidth, &ni, band, staId, relativeMpduStartStop);
|
||||
|
||||
return PhyEntity::SnrPer(snr, per);
|
||||
}
|
||||
@@ -759,11 +709,10 @@ double
|
||||
InterferenceHelper::CalculateSnr(Ptr<Event> event,
|
||||
uint16_t channelWidth,
|
||||
uint8_t nss,
|
||||
const WifiSpectrumBandInfo& band,
|
||||
const FrequencyRange& freqRange) const
|
||||
const WifiSpectrumBandInfo& band) const
|
||||
{
|
||||
NiChangesPerBand ni;
|
||||
double noiseInterferenceW = CalculateNoiseInterferenceW(event, &ni, band, freqRange);
|
||||
double noiseInterferenceW = CalculateNoiseInterferenceW(event, &ni, band);
|
||||
double snr = CalculateSnr(event->GetRxPowerW(band), noiseInterferenceW, channelWidth, nss);
|
||||
return snr;
|
||||
}
|
||||
@@ -772,18 +721,17 @@ PhyEntity::SnrPer
|
||||
InterferenceHelper::CalculatePhyHeaderSnrPer(Ptr<Event> event,
|
||||
uint16_t channelWidth,
|
||||
const WifiSpectrumBandInfo& band,
|
||||
const FrequencyRange& freqRange,
|
||||
WifiPpduField header) const
|
||||
{
|
||||
NS_LOG_FUNCTION(this << band << header);
|
||||
NiChangesPerBand ni;
|
||||
double noiseInterferenceW = CalculateNoiseInterferenceW(event, &ni, band, freqRange);
|
||||
double noiseInterferenceW = CalculateNoiseInterferenceW(event, &ni, band);
|
||||
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, freqRange, header);
|
||||
double per = CalculatePhyHeaderPer(event, &ni, channelWidth, band, header);
|
||||
|
||||
return PhyEntity::SnrPer(snr, per);
|
||||
}
|
||||
@@ -821,18 +769,27 @@ void
|
||||
InterferenceHelper::NotifyRxEnd(Time endTime, const FrequencyRange& freqRange)
|
||||
{
|
||||
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(freqRange).begin(); niIt != m_niChanges.at(freqRange).end();
|
||||
++niIt)
|
||||
for (auto niIt = m_niChanges.begin(); niIt != m_niChanges.end(); ++niIt)
|
||||
{
|
||||
if (!IsBandInFrequencyRange(niIt->first, freqRange))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
NS_ASSERT(niIt->second.size() > 1);
|
||||
auto it = GetPreviousPosition(endTime, niIt);
|
||||
it--;
|
||||
m_firstPowers.at(freqRange).find(niIt->first)->second = it->second.GetPower();
|
||||
m_firstPowers.find(niIt->first)->second = it->second.GetPower();
|
||||
}
|
||||
}
|
||||
|
||||
bool
|
||||
InterferenceHelper::IsBandInFrequencyRange(const WifiSpectrumBandInfo& band,
|
||||
const FrequencyRange& freqRange) const
|
||||
{
|
||||
return ((band.frequencies.second > (freqRange.minFrequency * 1e6)) &&
|
||||
(band.frequencies.first < (freqRange.maxFrequency * 1e6)));
|
||||
}
|
||||
|
||||
} // namespace ns3
|
||||
|
||||
@@ -148,21 +148,19 @@ class InterferenceHelper : public Object
|
||||
* Add a frequency band.
|
||||
*
|
||||
* \param band the band to be added
|
||||
* \param freqRange the frequency range the band to add belongs to
|
||||
*/
|
||||
void AddBand(const WifiSpectrumBandInfo& band, const FrequencyRange& freqRange);
|
||||
void AddBand(const WifiSpectrumBandInfo& band);
|
||||
|
||||
/**
|
||||
* Check whether a given frequency range is already tracked by this interference helper.
|
||||
* Check whether bands are already tracked by this interference helper.
|
||||
*
|
||||
* \param freqRange the frequency range to check
|
||||
* \return true if bands are tracked by this interference helper for a given frequency range,
|
||||
* false otherwise
|
||||
* \return true if bands are tracked by this interference helper, false otherwise
|
||||
*/
|
||||
bool HasBands(const FrequencyRange& freqRange) const;
|
||||
bool HasBands() const;
|
||||
|
||||
/**
|
||||
* Update the frequency bands for a given frequency range when the spectrum model is changed.
|
||||
* Update the frequency bands that belongs to a given frequency range when the spectrum model is
|
||||
* changed.
|
||||
*
|
||||
* \param bands the bands to be added in the new spectrum model
|
||||
* \param freqRange the frequency range the bands belong to
|
||||
@@ -200,15 +198,12 @@ class InterferenceHelper : public Object
|
||||
/**
|
||||
* \param energyW the minimum energy (W) requested
|
||||
* \param band identify the requested band
|
||||
* \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,
|
||||
const WifiSpectrumBandInfo& band,
|
||||
const FrequencyRange& freqRange);
|
||||
Time GetEnergyDuration(double energyW, const WifiSpectrumBandInfo& band);
|
||||
|
||||
/**
|
||||
* Add the PPDU-related signal to interference helper.
|
||||
@@ -217,7 +212,6 @@ class InterferenceHelper : public Object
|
||||
* \param txVector the TXVECTOR
|
||||
* \param duration the PPDU duration
|
||||
* \param rxPower received power per band (W)
|
||||
* \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
|
||||
@@ -228,18 +222,14 @@ class InterferenceHelper : public Object
|
||||
const WifiTxVector& txVector,
|
||||
Time duration,
|
||||
RxPowerWattPerChannelBand& rxPower,
|
||||
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 freqRange the frequency range in which the non-wifi signal has been detected
|
||||
*/
|
||||
void AddForeignSignal(Time duration,
|
||||
RxPowerWattPerChannelBand& rxPower,
|
||||
const FrequencyRange& freqRange);
|
||||
void AddForeignSignal(Time duration, RxPowerWattPerChannelBand& rxPower);
|
||||
/**
|
||||
* 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.
|
||||
@@ -250,7 +240,6 @@ 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 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
|
||||
@@ -260,7 +249,6 @@ class InterferenceHelper : public Object
|
||||
PhyEntity::SnrPer CalculatePayloadSnrPer(Ptr<Event> event,
|
||||
uint16_t channelWidth,
|
||||
const WifiSpectrumBandInfo& band,
|
||||
const FrequencyRange& freqRange,
|
||||
uint16_t staId,
|
||||
std::pair<Time, Time> relativeMpduStartStop) const;
|
||||
/**
|
||||
@@ -270,15 +258,13 @@ 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 freqRange the frequency range the band belongs to
|
||||
*
|
||||
* \return the SNR for the PPDU in linear scale
|
||||
*/
|
||||
double CalculateSnr(Ptr<Event> event,
|
||||
uint16_t channelWidth,
|
||||
uint8_t nss,
|
||||
const WifiSpectrumBandInfo& band,
|
||||
const FrequencyRange& freqRange) const;
|
||||
const WifiSpectrumBandInfo& band) const;
|
||||
/**
|
||||
* Calculate the SNIR at the start of the PHY header and accumulate
|
||||
* all SNIR changes in the SNIR vector.
|
||||
@@ -286,7 +272,6 @@ 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 freqRange the frequency range the band belongs to
|
||||
* \param header the PHY header to consider
|
||||
*
|
||||
* \return struct of SNR and PER
|
||||
@@ -294,7 +279,6 @@ class InterferenceHelper : public Object
|
||||
PhyEntity::SnrPer CalculatePhyHeaderSnrPer(Ptr<Event> event,
|
||||
uint16_t channelWidth,
|
||||
const WifiSpectrumBandInfo& band,
|
||||
const FrequencyRange& freqRange,
|
||||
WifiPpduField header) const;
|
||||
|
||||
/**
|
||||
@@ -305,7 +289,7 @@ class InterferenceHelper : public Object
|
||||
* Notify that RX has ended.
|
||||
*
|
||||
* \param endTime the end time of the signal
|
||||
* \param freqRange the frequency range in which the signal event has been detected
|
||||
* \param freqRange the frequency range in which the received signal event had been detected
|
||||
*/
|
||||
void NotifyRxEnd(Time endTime, const FrequencyRange& freqRange);
|
||||
|
||||
@@ -314,11 +298,8 @@ class InterferenceHelper : public Object
|
||||
*
|
||||
* \param event the event to be updated
|
||||
* \param rxPower the received power (W) per band to be added to the current event
|
||||
* \param freqRange the frequency range in which the signal event has been detected
|
||||
*/
|
||||
void UpdateEvent(Ptr<Event> event,
|
||||
const RxPowerWattPerChannelBand& rxPower,
|
||||
const FrequencyRange& freqRange);
|
||||
void UpdateEvent(Ptr<Event> event, const RxPowerWattPerChannelBand& rxPower);
|
||||
|
||||
protected:
|
||||
void DoDispose() override;
|
||||
@@ -420,39 +401,37 @@ class InterferenceHelper : public Object
|
||||
*/
|
||||
using NiChangesPerBand = std::map<WifiSpectrumBandInfo, NiChanges>;
|
||||
|
||||
/**
|
||||
* Map of NiChanges per band and per range
|
||||
*/
|
||||
using NiChangesPerBandPerRange = std::map<FrequencyRange, NiChangesPerBand>;
|
||||
|
||||
/**
|
||||
* Map of first power per band
|
||||
*/
|
||||
using FirstPowerPerBand = std::map<WifiSpectrumBandInfo, double>;
|
||||
|
||||
/**
|
||||
* Map of first power per band and per range
|
||||
*/
|
||||
using FirstPowerPerBandPerRange = std::map<FrequencyRange, FirstPowerPerBand>;
|
||||
|
||||
/**
|
||||
* Check whether a given band is tracked by this interference helper.
|
||||
*
|
||||
* \param band the band to be checked
|
||||
* \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(const WifiSpectrumBandInfo& band, const FrequencyRange& freqRange) const;
|
||||
bool HasBand(const WifiSpectrumBandInfo& band) const;
|
||||
|
||||
/**
|
||||
* Check whether a given band belongs to a given frequency range.
|
||||
*
|
||||
* \param band the band to be checked
|
||||
* \param freqRange the frequency range to check whether the band belong to
|
||||
* \return true if the band belongs to the frequency range, false otherwise
|
||||
*/
|
||||
bool IsBandInFrequencyRange(const WifiSpectrumBandInfo& band,
|
||||
const FrequencyRange& freqRange) const;
|
||||
|
||||
/**
|
||||
* Append the given Event.
|
||||
*
|
||||
* \param event the event to be appended
|
||||
* \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& freqRange, bool isStartOfdmaRxing);
|
||||
void AppendEvent(Ptr<Event> event, bool isStartOfdmaRxing);
|
||||
|
||||
/**
|
||||
* Calculate noise and interference power in W.
|
||||
@@ -460,14 +439,12 @@ class InterferenceHelper : public Object
|
||||
* \param event the event
|
||||
* \param nis the NiChanges
|
||||
* \param band the band
|
||||
* \param freqRange the frequency range
|
||||
*
|
||||
* \return noise and interference power
|
||||
*/
|
||||
double CalculateNoiseInterferenceW(Ptr<Event> event,
|
||||
NiChangesPerBand* nis,
|
||||
const WifiSpectrumBandInfo& band,
|
||||
const FrequencyRange& freqRange) const;
|
||||
const WifiSpectrumBandInfo& band) 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
|
||||
@@ -477,7 +454,6 @@ 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 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
|
||||
*
|
||||
@@ -487,7 +463,6 @@ class InterferenceHelper : public Object
|
||||
uint16_t channelWidth,
|
||||
NiChangesPerBand* nis,
|
||||
const WifiSpectrumBandInfo& band,
|
||||
const FrequencyRange& freqRange,
|
||||
uint16_t staId,
|
||||
std::pair<Time, Time> window) const;
|
||||
/**
|
||||
@@ -498,7 +473,6 @@ class InterferenceHelper : public Object
|
||||
* \param nis the NiChanges
|
||||
* \param channelWidth the channel width (in MHz) for header measurement
|
||||
* \param band the band
|
||||
* \param freqRange the frequency range
|
||||
* \param header the PHY header to consider
|
||||
*
|
||||
* \return the error rate of the HT PHY header
|
||||
@@ -507,7 +481,6 @@ class InterferenceHelper : public Object
|
||||
NiChangesPerBand* nis,
|
||||
uint16_t channelWidth,
|
||||
const WifiSpectrumBandInfo& band,
|
||||
const FrequencyRange& freqRange,
|
||||
WifiPpduField header) const;
|
||||
/**
|
||||
* Calculate the success rate of the PHY header sections for the provided event.
|
||||
@@ -516,7 +489,6 @@ class InterferenceHelper : public Object
|
||||
* \param nis the NiChanges
|
||||
* \param channelWidth the channel width (in MHz) for header measurement
|
||||
* \param band the band
|
||||
* \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
|
||||
@@ -525,15 +497,14 @@ class InterferenceHelper : public Object
|
||||
NiChangesPerBand* nis,
|
||||
uint16_t channelWidth,
|
||||
const WifiSpectrumBandInfo& band,
|
||||
const FrequencyRange& freqRange,
|
||||
PhyEntity::PhyHeaderSections phyHeaderSections) const;
|
||||
|
||||
double m_noiseFigure; //!< noise figure (linear)
|
||||
Ptr<ErrorRateModel> m_errorRateModel; //!< error rate model
|
||||
uint8_t m_numRxAntennas; //!< the number of RX antennas in the corresponding receiver
|
||||
NiChangesPerBandPerRange m_niChanges; //!< NI Changes for each band in each range
|
||||
FirstPowerPerBandPerRange m_firstPowers; //!< first power of each band in watts
|
||||
bool m_rxing; //!< flag whether it is in receiving state
|
||||
uint8_t m_numRxAntennas; //!< the number of RX antennas in the corresponding receiver
|
||||
NiChangesPerBand m_niChanges; //!< NI Changes for each band
|
||||
FirstPowerPerBand m_firstPowers; //!< first power of each band in watts
|
||||
bool m_rxing; //!< flag whether it is in receiving state
|
||||
|
||||
/**
|
||||
* Returns an iterator to the first NiChange that is later than moment
|
||||
|
||||
@@ -273,7 +273,6 @@ PhyEntity::GetPhyHeaderSnrPer(WifiPpduField field, Ptr<Event> event) const
|
||||
event,
|
||||
measurementChannelWidth,
|
||||
GetPrimaryBand(measurementChannelWidth),
|
||||
m_wifiPhy->GetCurrentFrequencyRange(),
|
||||
field);
|
||||
}
|
||||
|
||||
@@ -711,8 +710,7 @@ PhyEntity::EndReceivePayload(Ptr<Event> event)
|
||||
double snr = m_wifiPhy->m_interference->CalculateSnr(event,
|
||||
channelWidthAndBand.first,
|
||||
txVector.GetNss(staId),
|
||||
channelWidthAndBand.second,
|
||||
m_wifiPhy->GetCurrentFrequencyRange());
|
||||
channelWidthAndBand.second);
|
||||
|
||||
Ptr<const WifiPsdu> psdu = GetAddressedPsduInPpdu(ppdu);
|
||||
m_wifiPhy->NotifyRxEnd(psdu);
|
||||
@@ -793,7 +791,6 @@ PhyEntity::GetReceptionStatus(Ptr<const WifiPsdu> psdu,
|
||||
event,
|
||||
channelWidthAndBand.first,
|
||||
channelWidthAndBand.second,
|
||||
m_wifiPhy->GetCurrentFrequencyRange(),
|
||||
staId,
|
||||
std::make_pair(relativeMpduStart, relativeMpduStart + mpduDuration));
|
||||
|
||||
@@ -896,14 +893,13 @@ PhyEntity::CreateInterferenceEvent(Ptr<const WifiPpdu> ppdu,
|
||||
ppdu->GetTxVector(),
|
||||
duration,
|
||||
rxPower,
|
||||
m_wifiPhy->GetCurrentFrequencyRange(),
|
||||
isStartOfdmaRxing);
|
||||
}
|
||||
|
||||
void
|
||||
PhyEntity::UpdateInterferenceEvent(Ptr<Event> event, const RxPowerWattPerChannelBand& rxPower)
|
||||
{
|
||||
m_wifiPhy->m_interference->UpdateEvent(event, rxPower, m_wifiPhy->GetCurrentFrequencyRange());
|
||||
m_wifiPhy->m_interference->UpdateEvent(event, rxPower);
|
||||
}
|
||||
|
||||
void
|
||||
@@ -997,8 +993,7 @@ PhyEntity::EndPreambleDetectionPeriod(Ptr<Event> event)
|
||||
double snr = m_wifiPhy->m_interference->CalculateSnr(m_wifiPhy->m_currentEvent,
|
||||
measurementChannelWidth,
|
||||
1,
|
||||
measurementBand,
|
||||
m_wifiPhy->GetCurrentFrequencyRange());
|
||||
measurementBand);
|
||||
NS_LOG_DEBUG("SNR(dB)=" << RatioToDb(snr) << " at end of preamble detection period");
|
||||
|
||||
if ((!m_wifiPhy->m_preambleDetectionModel && maxRxPowerW > 0.0) ||
|
||||
@@ -1236,9 +1231,7 @@ PhyEntity::GetCcaThreshold(const Ptr<const WifiPpdu> ppdu,
|
||||
Time
|
||||
PhyEntity::GetDelayUntilCcaEnd(double thresholdDbm, const WifiSpectrumBandInfo& band)
|
||||
{
|
||||
return m_wifiPhy->m_interference->GetEnergyDuration(DbmToW(thresholdDbm),
|
||||
band,
|
||||
m_wifiPhy->GetCurrentFrequencyRange());
|
||||
return m_wifiPhy->m_interference->GetEnergyDuration(DbmToW(thresholdDbm), band);
|
||||
}
|
||||
|
||||
void
|
||||
|
||||
@@ -155,7 +155,7 @@ SpectrumWifiPhy::UpdateInterferenceHelperBands()
|
||||
|
||||
m_currentSpectrumPhyInterface->SetBands(std::move(bands));
|
||||
|
||||
if (m_interference->HasBands(GetCurrentFrequencyRange()))
|
||||
if (m_interference->HasBands())
|
||||
{
|
||||
m_interference->UpdateBands(allBands, GetCurrentFrequencyRange());
|
||||
}
|
||||
@@ -163,7 +163,7 @@ SpectrumWifiPhy::UpdateInterferenceHelperBands()
|
||||
{
|
||||
for (const auto& band : allBands)
|
||||
{
|
||||
m_interference->AddBand(band, GetCurrentFrequencyRange());
|
||||
m_interference->AddBand(band);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -284,8 +284,7 @@ void
|
||||
SpectrumWifiPhy::StartRx(Ptr<SpectrumSignalParameters> rxParams,
|
||||
Ptr<const WifiSpectrumPhyInterface> interface)
|
||||
{
|
||||
const auto freqRange = interface ? interface->GetFrequencyRange() : GetCurrentFrequencyRange();
|
||||
NS_LOG_FUNCTION(this << rxParams << interface << freqRange);
|
||||
NS_LOG_FUNCTION(this << rxParams << interface);
|
||||
Time rxDuration = rxParams->duration;
|
||||
Ptr<SpectrumValue> receivedSignalPsd = rxParams->psd;
|
||||
NS_LOG_DEBUG("Received signal with PSD " << *receivedSignalPsd << " and duration "
|
||||
@@ -365,7 +364,7 @@ SpectrumWifiPhy::StartRx(Ptr<SpectrumSignalParameters> rxParams,
|
||||
if (!wifiRxParams)
|
||||
{
|
||||
NS_LOG_INFO("Received non Wi-Fi signal");
|
||||
m_interference->AddForeignSignal(rxDuration, rxPowerW, freqRange);
|
||||
m_interference->AddForeignSignal(rxDuration, rxPowerW);
|
||||
SwitchMaybeToCcaBusy(nullptr);
|
||||
return;
|
||||
}
|
||||
@@ -373,7 +372,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, freqRange);
|
||||
m_interference->AddForeignSignal(rxDuration, rxPowerW);
|
||||
SwitchMaybeToCcaBusy(nullptr);
|
||||
return;
|
||||
}
|
||||
@@ -382,7 +381,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, freqRange);
|
||||
m_interference->AddForeignSignal(rxDuration, rxPowerW);
|
||||
SwitchMaybeToCcaBusy(nullptr);
|
||||
return;
|
||||
}
|
||||
@@ -396,7 +395,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, freqRange);
|
||||
m_interference->Add(ppdu, txVector, rxDuration, rxPowerW);
|
||||
SwitchMaybeToCcaBusy(nullptr);
|
||||
return;
|
||||
}
|
||||
@@ -406,7 +405,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, freqRange);
|
||||
m_interference->Add(ppdu, txVector, rxDuration, rxPowerW);
|
||||
SwitchMaybeToCcaBusy(ppdu);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1846,11 +1846,7 @@ 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,
|
||||
GetCurrentFrequencyRange());
|
||||
m_interference->Add(ppdu, ppdu->GetTxVector(), rxDuration, rxPowersW);
|
||||
SwitchMaybeToCcaBusy(nullptr);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -53,7 +53,7 @@ YansWifiPhy::SetInterferenceHelper(const Ptr<InterferenceHelper> helper)
|
||||
{
|
||||
WifiPhy::SetInterferenceHelper(helper);
|
||||
// add dummy band for Yans
|
||||
m_interference->AddBand({{0, 0}, {0, 0}}, GetCurrentFrequencyRange());
|
||||
m_interference->AddBand({{0, 0}, {0, 0}});
|
||||
}
|
||||
|
||||
YansWifiPhy::~YansWifiPhy()
|
||||
|
||||
@@ -1045,7 +1045,7 @@ SpectrumWifiPhyMultipleInterfacesTest::DoCheckInterferences(Ptr<ExtSpectrumWifiP
|
||||
auto interferenceHelper = DynamicCast<InterferenceHelper>(ptr.Get<InterferenceHelper>());
|
||||
NS_ASSERT(interferenceHelper);
|
||||
const auto band = phy->GetBandForInterface(channelWidth, 0, freqRange, channelWidth);
|
||||
const auto energyDuration = interferenceHelper->GetEnergyDuration(0, band, freqRange);
|
||||
const auto energyDuration = interferenceHelper->GetEnergyDuration(0, band);
|
||||
NS_TEST_ASSERT_MSG_EQ(energyDuration.IsStrictlyPositive(),
|
||||
interferencesExpected,
|
||||
"Incorrect interferences detection");
|
||||
|
||||
@@ -280,7 +280,7 @@ OfdmaSpectrumWifiPhy::GetCurrentEvent()
|
||||
Time
|
||||
OfdmaSpectrumWifiPhy::GetEnergyDuration(double energyW, WifiSpectrumBandInfo band)
|
||||
{
|
||||
return m_interference->GetEnergyDuration(energyW, band, WHOLE_WIFI_SPECTRUM);
|
||||
return m_interference->GetEnergyDuration(energyW, band);
|
||||
}
|
||||
|
||||
Ptr<const HePhy>
|
||||
|
||||
Reference in New Issue
Block a user