wifi: WifiPhy holds a Ptr to InterferenceHelper

This commit is contained in:
Sebastien Deronne
2022-04-19 07:58:23 +02:00
committed by Stefano Avallone
parent 679ce12636
commit 3622965747
13 changed files with 52 additions and 39 deletions

View File

@@ -28,6 +28,7 @@
#include "ns3/sta-wifi-mac.h"
#include "ns3/ap-wifi-mac.h"
#include "ns3/wifi-utils.h"
#include "ns3/interference-helper.h"
#include "ns3/simulator.h"
#include "ns3/log.h"
#include "ns3/assert.h"

View File

@@ -24,6 +24,7 @@
#include "ns3/wifi-psdu.h"
#include "ns3/wifi-phy.h"
#include "ns3/wifi-utils.h"
#include "ns3/interference-helper.h"
#include "ns3/log.h"
#include "ns3/assert.h"

View File

@@ -26,6 +26,7 @@
#include "ns3/wifi-psdu.h"
#include "ns3/wifi-phy.h" //only used for static mode constructor
#include "ns3/wifi-utils.h"
#include "ns3/interference-helper.h"
#include "ns3/simulator.h"
#include "ns3/log.h"

View File

@@ -25,6 +25,7 @@
#include "ns3/wifi-psdu.h"
#include "ns3/wifi-phy.h"
#include "ns3/wifi-utils.h"
#include "ns3/interference-helper.h"
#include "ns3/simulator.h"
#include "ns3/log.h"
#include <array>

View File

@@ -27,6 +27,7 @@
#include "frame-capture-model.h"
#include "wifi-utils.h"
#include "wifi-spectrum-signal-parameters.h"
#include "interference-helper.h"
#include "ns3/packet.h"
#include "ns3/simulator.h"
#include "ns3/log.h"
@@ -250,7 +251,7 @@ PhyEntity::SnrPer
PhyEntity::GetPhyHeaderSnrPer (WifiPpduField field, Ptr<Event> event) const
{
uint16_t measurementChannelWidth = GetMeasurementChannelWidth (event->GetPpdu ());
return m_wifiPhy->m_interference.CalculatePhyHeaderSnrPer (event, measurementChannelWidth, m_wifiPhy->GetPrimaryBand (measurementChannelWidth),
return m_wifiPhy->m_interference->CalculatePhyHeaderSnrPer (event, measurementChannelWidth, m_wifiPhy->GetPrimaryBand (measurementChannelWidth),
field);
}
@@ -638,7 +639,7 @@ PhyEntity::EndReceivePayload (Ptr<Event> event)
NS_ASSERT (event->GetEndTime () == Simulator::Now ());
uint16_t staId = GetStaId (ppdu);
const auto & channelWidthAndBand = GetChannelWidthAndBand (event->GetTxVector (), staId);
double snr = m_wifiPhy->m_interference.CalculateSnr (event, channelWidthAndBand.first, txVector.GetNss (staId), channelWidthAndBand.second);
double snr = m_wifiPhy->m_interference->CalculateSnr (event, channelWidthAndBand.first, txVector.GetNss (staId), channelWidthAndBand.second);
Ptr<const WifiPsdu> psdu = GetAddressedPsduInPpdu (ppdu);
m_wifiPhy->NotifyRxEnd (psdu);
@@ -685,7 +686,7 @@ PhyEntity::GetReceptionStatus (Ptr<const WifiPsdu> psdu, Ptr<Event> event, uint1
{
NS_LOG_FUNCTION (this << *psdu << *event << staId << relativeMpduStart << mpduDuration);
const auto & channelWidthAndBand = GetChannelWidthAndBand (event->GetTxVector (), staId);
SnrPer snrPer = m_wifiPhy->m_interference.CalculatePayloadSnrPer (event, channelWidthAndBand.first, channelWidthAndBand.second, staId,
SnrPer snrPer = m_wifiPhy->m_interference->CalculatePayloadSnrPer (event, channelWidthAndBand.first, channelWidthAndBand.second, staId,
std::make_pair (relativeMpduStart, relativeMpduStart + mpduDuration));
WifiMode mode = event->GetTxVector ().GetMode (staId);
@@ -749,19 +750,19 @@ PhyEntity::DoGetEvent (Ptr<const WifiPpdu> ppdu, RxPowerWattPerChannelBand& rxPo
Ptr<Event>
PhyEntity::CreateInterferenceEvent (Ptr<const WifiPpdu> ppdu, const WifiTxVector& txVector, Time duration, RxPowerWattPerChannelBand& rxPower, bool isStartOfdmaRxing /* = false */)
{
return m_wifiPhy->m_interference.Add (ppdu, txVector, duration, rxPower, isStartOfdmaRxing);
return m_wifiPhy->m_interference->Add (ppdu, txVector, duration, rxPower, isStartOfdmaRxing);
}
void
PhyEntity::UpdateInterferenceEvent (Ptr<Event> event, const RxPowerWattPerChannelBand& rxPower)
{
m_wifiPhy->m_interference.UpdateEvent (event, rxPower);
m_wifiPhy->m_interference->UpdateEvent (event, rxPower);
}
void
PhyEntity::NotifyInterferenceRxEndAndClear (bool reset)
{
m_wifiPhy->m_interference.NotifyRxEnd (Simulator::Now ());
m_wifiPhy->m_interference->NotifyRxEnd (Simulator::Now ());
m_signalNoiseMap.clear ();
m_statusPerMpduMap.clear ();
for (const auto & endOfMpduEvent : m_endOfMpduEvents)
@@ -788,7 +789,7 @@ PhyEntity::StartPreambleDetectionPeriod (Ptr<Event> event)
{
NS_LOG_FUNCTION (this << *event);
NS_LOG_DEBUG ("Sync to signal (power=" << WToDbm (GetRxPowerWForPpdu (event)) << "dBm)");
m_wifiPhy->m_interference.NotifyRxStart (); //We need to notify it now so that it starts recording events
m_wifiPhy->m_interference->NotifyRxStart (); //We need to notify it now so that it starts recording events
m_endPreambleDetectionEvents.push_back (Simulator::Schedule (m_wifiPhy->GetPreambleDetectionDuration (), &PhyEntity::EndPreambleDetectionPeriod, this, event));
}
@@ -823,15 +824,15 @@ PhyEntity::EndPreambleDetectionPeriod (Ptr<Event> event)
auto it = m_wifiPhy->m_currentPreambleEvents.find (std::make_pair (event->GetPpdu ()->GetUid (), event->GetPpdu ()->GetPreamble ()));
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 ());
m_wifiPhy->m_interference->NotifyRxEnd (maxEvent->GetStartTime ());
//Make sure InterferenceHelper keeps recording events
m_wifiPhy->m_interference.NotifyRxStart ();
m_wifiPhy->m_interference->NotifyRxStart ();
return;
}
m_wifiPhy->m_currentEvent = event;
double snr = m_wifiPhy->m_interference.CalculateSnr (m_wifiPhy->m_currentEvent, measurementChannelWidth, 1, measurementBand);
double snr = m_wifiPhy->m_interference->CalculateSnr (m_wifiPhy->m_currentEvent, measurementChannelWidth, 1, measurementBand);
NS_LOG_DEBUG ("SNR(dB)=" << RatioToDb (snr) << " at end of preamble detection period");
if ((!m_wifiPhy->m_preambleDetectionModel && maxRxPowerW > 0.0)
@@ -853,7 +854,7 @@ PhyEntity::EndPreambleDetectionPeriod (Ptr<Event> event)
{
reason = PREAMBLE_DETECTION_PACKET_SWITCH;
//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 (m_wifiPhy->m_currentEvent->GetStartTime ());
m_wifiPhy->m_interference->NotifyRxEnd (m_wifiPhy->m_currentEvent->GetStartTime ());
}
else
{
@@ -869,7 +870,7 @@ PhyEntity::EndPreambleDetectionPeriod (Ptr<Event> event)
}
//Make sure InterferenceHelper keeps recording events
m_wifiPhy->m_interference.NotifyRxStart ();
m_wifiPhy->m_interference->NotifyRxStart ();
m_wifiPhy->NotifyRxBegin (GetAddressedPsduInPpdu (m_wifiPhy->m_currentEvent->GetPpdu ()), m_wifiPhy->m_currentEvent->GetRxPowerWPerBand ());
m_wifiPhy->m_timeLastPreambleDetected = Simulator::Now ();
@@ -888,7 +889,7 @@ 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 ());
m_wifiPhy->m_interference->NotifyRxEnd (Simulator::Now ());
}
m_wifiPhy->m_currentEvent = 0;
//Cancel preamble reception

View File

@@ -23,7 +23,7 @@
#include "ns3/double.h"
#include "simple-frame-capture-model.h"
#include "wifi-utils.h"
#include "wifi-phy.h"
#include "interference-helper.h"
namespace ns3 {

View File

@@ -32,6 +32,7 @@
#include "spectrum-wifi-phy.h"
#include "wifi-spectrum-phy-interface.h"
#include "wifi-spectrum-signal-parameters.h"
#include "interference-helper.h"
#include "wifi-utils.h"
#include "wifi-psdu.h"
@@ -145,11 +146,11 @@ SpectrumWifiPhy::UpdateInterferenceHelperBands (void)
{
NS_LOG_FUNCTION (this);
uint16_t channelWidth = GetChannelWidth ();
m_interference.RemoveBands ();
m_interference->RemoveBands ();
if (channelWidth < 20)
{
WifiSpectrumBand band = GetBand (channelWidth);
m_interference.AddBand (band);
m_interference->AddBand (band);
}
else
{
@@ -157,7 +158,7 @@ SpectrumWifiPhy::UpdateInterferenceHelperBands (void)
{
for (uint8_t i = 0; i < (channelWidth / bw); ++i)
{
m_interference.AddBand (GetBand (bw, i));
m_interference->AddBand (GetBand (bw, i));
}
}
}
@@ -204,7 +205,7 @@ SpectrumWifiPhy::UpdateInterferenceHelperBands (void)
}
for (const auto& bandRuPair : m_ruBands[channelWidth])
{
m_interference.AddBand (bandRuPair.first);
m_interference->AddBand (bandRuPair.first);
}
}
}
@@ -328,14 +329,14 @@ SpectrumWifiPhy::StartRx (Ptr<SpectrumSignalParameters> rxParams)
if (wifiRxParams == 0)
{
NS_LOG_INFO ("Received non Wi-Fi signal");
m_interference.AddForeignSignal (rxDuration, rxPowerW);
m_interference->AddForeignSignal (rxDuration, rxPowerW);
SwitchMaybeToCcaBusy (GetMeasurementChannelWidth (nullptr));
return;
}
if (wifiRxParams && m_disableWifiReception)
{
NS_LOG_INFO ("Received Wi-Fi signal but blocked from syncing");
m_interference.AddForeignSignal (rxDuration, rxPowerW);
m_interference->AddForeignSignal (rxDuration, rxPowerW);
SwitchMaybeToCcaBusy (GetMeasurementChannelWidth (nullptr));
return;
}
@@ -346,7 +347,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 (wifiRxParams->ppdu, wifiRxParams->ppdu->GetTxVector (), rxDuration,
m_interference->Add (wifiRxParams->ppdu, wifiRxParams->ppdu->GetTxVector (), rxDuration,
rxPowerW);
SwitchMaybeToCcaBusy (GetMeasurementChannelWidth (wifiRxParams->ppdu));
return;
@@ -366,7 +367,7 @@ SpectrumWifiPhy::StartRx (Ptr<SpectrumSignalParameters> rxParams)
if (!wifiRxParams->ppdu->CanBeReceived (wifiRxParams->txCenterFreq, p20MinFreq, p20MaxFreq))
{
NS_LOG_INFO ("Cannot receive the PPDU, consider it as interference");
m_interference.Add (wifiRxParams->ppdu, wifiRxParams->ppdu->GetTxVector (),
m_interference->Add (wifiRxParams->ppdu, wifiRxParams->ppdu->GetTxVector (),
rxDuration, rxPowerW);
SwitchMaybeToCcaBusy (GetMeasurementChannelWidth (wifiRxParams->ppdu));
return;

View File

@@ -24,6 +24,7 @@
#include "ns3/wifi-psdu.h"
#include "ns3/wifi-phy.h" //only used for static mode constructor
#include "ns3/wifi-utils.h"
#include "ns3/interference-helper.h"
#include "ns3/log.h"
#include "ns3/assert.h"

View File

@@ -31,6 +31,7 @@
#include "wifi-net-device.h"
#include "wifi-phy.h"
#include "wifi-utils.h"
#include "interference-helper.h"
#include "frame-capture-model.h"
#include "preamble-detection-model.h"
#include "wifi-radio-energy-model.h"
@@ -325,6 +326,7 @@ WifiPhy::WifiPhy ()
m_timeLastPreambleDetected (Seconds (0))
{
NS_LOG_FUNCTION (this);
m_interference = CreateObject<InterferenceHelper> ();
m_random = CreateObject<UniformRandomVariable> ();
m_state = CreateObject<WifiPhyStateHelper> ();
}
@@ -440,8 +442,8 @@ void
WifiPhy::SetRxNoiseFigure (double noiseFigureDb)
{
NS_LOG_FUNCTION (this << noiseFigureDb);
m_interference.SetNoiseFigure (DbToRatio (noiseFigureDb));
m_interference.SetNumberOfReceiveAntennas (GetNumberOfAntennas ());
m_interference->SetNoiseFigure (DbToRatio (noiseFigureDb));
m_interference->SetNumberOfReceiveAntennas (GetNumberOfAntennas ());
}
void
@@ -556,8 +558,8 @@ WifiPhy::GetMobility (void) const
void
WifiPhy::SetErrorRateModel (const Ptr<ErrorRateModel> rate)
{
m_interference.SetErrorRateModel (rate);
m_interference.SetNumberOfReceiveAntennas (GetNumberOfAntennas ());
m_interference->SetErrorRateModel (rate);
m_interference->SetNumberOfReceiveAntennas (GetNumberOfAntennas ());
}
void
@@ -612,7 +614,7 @@ WifiPhy::GetChannelSwitchDelay (void) const
double
WifiPhy::CalculateSnr (const WifiTxVector& txVector, double ber) const
{
return m_interference.GetErrorRateModel ()->CalculateSnr (txVector, ber);
return m_interference->GetErrorRateModel ()->CalculateSnr (txVector, ber);
}
const Ptr<const PhyEntity>
@@ -1045,7 +1047,7 @@ WifiPhy::DoChannelSwitch (void)
{
// notify channel switching
m_state->SwitchToChannelSwitching (GetChannelSwitchDelay ());
m_interference.EraseEvents ();
m_interference->EraseEvents ();
/*
* Needed here to be able to correctly sensed the medium for the first
* time after the switching. The actual switching is not performed until
@@ -1061,7 +1063,7 @@ WifiPhy::SetNumberOfAntennas (uint8_t antennas)
{
NS_ASSERT_MSG (antennas > 0 && antennas <= 4, "unsupported number of antennas");
m_numberOfAntennas = antennas;
m_interference.SetNumberOfReceiveAntennas (antennas);
m_interference->SetNumberOfReceiveAntennas (antennas);
}
uint8_t
@@ -1223,7 +1225,6 @@ WifiPhy::ResumeFromSleep (void)
case WifiPhyState::SLEEP:
{
NS_LOG_DEBUG ("resuming from sleep mode");
m_state->SwitchFromSleep ();
SwitchMaybeToCcaBusy (GetMeasurementChannelWidth (nullptr));
break;
@@ -1613,7 +1614,7 @@ WifiPhy::StartReceivePreamble (Ptr<WifiPpdu> ppdu, RxPowerWattPerChannelBand& rx
{
//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);
m_interference->Add (ppdu, ppdu->GetTxVector (), rxDuration, rxPowersW);
SwitchMaybeToCcaBusy (GetMeasurementChannelWidth (nullptr));
}
}
@@ -1642,7 +1643,7 @@ WifiPhy::ResetReceive (Ptr<Event> event)
{
NS_LOG_FUNCTION (this << *event);
NS_ASSERT (!IsStateRx ());
m_interference.NotifyRxEnd (Simulator::Now ());
m_interference->NotifyRxEnd (Simulator::Now ());
m_currentEvent = 0;
m_currentPreambleEvents.clear ();
SwitchMaybeToCcaBusy (GetMeasurementChannelWidth (event->GetPpdu ()));
@@ -1853,7 +1854,7 @@ WifiPhy::SwitchMaybeToCcaBusy (uint16_t channelWidth)
//not going to be able to synchronize on it
//In this model, CCA becomes busy when the aggregation of all signals as
//tracked by the InterferenceHelper class is higher than the CcaBusyThreshold
Time delayUntilCcaEnd = m_interference.GetEnergyDuration (m_ccaEdThresholdW, GetPrimaryBand (channelWidth));
Time delayUntilCcaEnd = m_interference->GetEnergyDuration (m_ccaEdThresholdW, GetPrimaryBand (channelWidth));
if (!delayUntilCcaEnd.IsZero ())
{
NS_LOG_DEBUG ("Calling SwitchMaybeToCcaBusy for " << delayUntilCcaEnd.As (Time::S));
@@ -1875,7 +1876,7 @@ WifiPhy::AbortCurrentReception (WifiPhyRxfailureReason reason)
{
m_endPhyRxEvent.Cancel ();
}
m_interference.NotifyRxEnd (Simulator::Now ());
m_interference->NotifyRxEnd (Simulator::Now ());
if (!m_currentEvent)
{
return;
@@ -1994,7 +1995,7 @@ WifiPhy::AssignStreams (int64_t stream)
NS_LOG_FUNCTION (this << stream);
int64_t currentStream = stream;
m_random->SetStream (currentStream++);
currentStream += m_interference.GetErrorRateModel ()->AssignStreams (currentStream);
currentStream += m_interference->GetErrorRateModel ()->AssignStreams (currentStream);
return (currentStream - stream);
}

View File

@@ -24,7 +24,6 @@
#include "ns3/error-model.h"
#include "wifi-standards.h"
#include "interference-helper.h"
#include "wifi-phy-state-helper.h"
#include "phy-entity.h"
#include "wifi-phy-operating-channel.h"
@@ -39,6 +38,8 @@ class FrameCaptureModel;
class PreambleDetectionModel;
class WifiRadioEnergyModel;
class UniformRandomVariable;
class InterferenceHelper;
class ErrorRateModel;
/**
* \brief 802.11 PHY layer model
@@ -1131,7 +1132,8 @@ protected:
*/
void AddPhyEntity (WifiModulationClass modulation, Ptr<PhyEntity> phyEntity);
InterferenceHelper m_interference; //!< the class handling interference computations
Ptr<InterferenceHelper> m_interference; //!< Pointer to a helper responsible for interference computations
Ptr<UniformRandomVariable> m_random; //!< Provides uniform random variables.
Ptr<WifiPhyStateHelper> m_state; //!< Pointer to WifiPhyStateHelper

View File

@@ -23,6 +23,7 @@
#include "ns3/log.h"
#include "yans-wifi-phy.h"
#include "yans-wifi-channel.h"
#include "interference-helper.h"
namespace ns3 {
@@ -48,7 +49,7 @@ YansWifiPhy::YansWifiPhy ()
WifiSpectrumBand band;
band.first = 0;
band.second = 0;
m_interference.AddBand (band);
m_interference->AddBand (band);
}
YansWifiPhy::~YansWifiPhy ()

View File

@@ -28,6 +28,7 @@
#include "ns3/wifi-utils.h"
#include "ns3/table-based-error-rate-model.h"
#include "ns3/he-phy.h" //includes HT and VHT
#include "ns3/interference-helper.h"
using namespace ns3;

View File

@@ -33,6 +33,7 @@
#include "ns3/multi-model-spectrum-channel.h"
#include "ns3/spectrum-wifi-phy.h"
#include "ns3/nist-error-rate-model.h"
#include "ns3/interference-helper.h"
#include "ns3/wifi-mac-header.h"
#include "ns3/wifi-net-device.h"
#include "ns3/wifi-psdu.h"
@@ -289,7 +290,7 @@ OfdmaSpectrumWifiPhy::GetCurrentEvent (void)
Time
OfdmaSpectrumWifiPhy::GetEnergyDuration (double energyW, WifiSpectrumBand band)
{
return m_interference.GetEnergyDuration (energyW, band);
return m_interference->GetEnergyDuration (energyW, band);
}
Ptr<const HePhy>