handles interference calculations More...
#include "interference-helper.h"
Classes | |
class | NiChange |
Noise and Interference (thus Ni) event. More... | |
struct | SnrPer |
Signal event for a PPDU. More... | |
Public Member Functions | |
InterferenceHelper () | |
~InterferenceHelper () | |
Ptr< Event > | Add (Ptr< const WifiPpdu > ppdu, WifiTxVector txVector, Time duration, RxPowerWattPerChannelBand rxPower) |
Add the PPDU-related signal to interference helper. More... | |
void | AddBand (WifiSpectrumBand band) |
Add a frequency band. More... | |
void | AddForeignSignal (Time duration, RxPowerWattPerChannelBand rxPower) |
Add a non-Wifi signal to interference helper. More... | |
struct InterferenceHelper::SnrPer | CalculateHtPhyHeaderSnrPer (Ptr< Event > event, WifiSpectrumBand band) const |
Calculate the SNIR at the start of the HT PHY header and accumulate all SNIR changes in the SNIR vector. More... | |
struct InterferenceHelper::SnrPer | CalculateNonHtPhyHeaderSnrPer (Ptr< Event > event, WifiSpectrumBand band) const |
Calculate the SNIR at the start of the non-HT PHY header and accumulate all SNIR changes in the SNIR vector. More... | |
struct InterferenceHelper::SnrPer | CalculatePayloadSnrPer (Ptr< Event > event, uint16_t channelWidth, WifiSpectrumBand band, uint16_t staId, std::pair< Time, Time > relativeMpduStartStop) const |
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. More... | |
double | CalculateSnr (Ptr< Event > event, uint16_t channelWidth, uint8_t nss, WifiSpectrumBand band) const |
Calculate the SNIR for the event (starting from now until the event end). More... | |
void | EraseEvents (void) |
Erase all events. More... | |
Time | GetEnergyDuration (double energyW, WifiSpectrumBand band) const |
Ptr< ErrorRateModel > | GetErrorRateModel (void) const |
Return the error rate model. More... | |
void | NotifyRxEnd () |
Notify that RX has ended. More... | |
void | NotifyRxStart () |
Notify that RX has started. More... | |
void | RemoveBands (void) |
Remove the frequency bands. More... | |
void | SetErrorRateModel (const Ptr< ErrorRateModel > rate) |
Set the error rate model for this interference helper. More... | |
void | SetNoiseFigure (double value) |
Set the noise figure. More... | |
void | SetNumberOfReceiveAntennas (uint8_t rx) |
Set the number of RX antennas in the receiver corresponding to this interference helper. More... | |
Protected Member Functions | |
double | CalculateChunkSuccessRate (double snir, Time duration, WifiMode mode, WifiTxVector txVector) const |
Calculate the success rate of the chunk given the SINR, duration, and Wi-Fi mode. More... | |
double | CalculateSnr (double signal, double noiseInterference, uint16_t channelWidth, uint8_t nss) const |
Calculate SNR (linear ratio) from the given signal power and noise+interference power. More... | |
Private Types | |
typedef std::multimap< Time, NiChange > | NiChanges |
typedef for a multimap of NiChange More... | |
typedef std::map< WifiSpectrumBand, NiChanges > | NiChangesPerBand |
Map of NiChanges per band. More... | |
Private Member Functions | |
NiChanges::iterator | AddNiChangeEvent (Time moment, NiChange change, WifiSpectrumBand band) |
Add NiChange to the list at the appropriate position and return the iterator of the new event. More... | |
void | AppendEvent (Ptr< Event > event) |
Append the given Event. More... | |
double | CalculateHtPhyHeaderPer (Ptr< const Event > event, NiChangesPerBand *nis, WifiSpectrumBand band) const |
Calculate the error rate of the HT PHY header. More... | |
double | CalculateNoiseInterferenceW (Ptr< Event > event, NiChangesPerBand *nis, WifiSpectrumBand band) const |
Calculate noise and interference power in W. More... | |
double | CalculateNonHtPhyHeaderPer (Ptr< const Event > event, NiChangesPerBand *nis, WifiSpectrumBand band) const |
Calculate the error rate of the non-HT PHY header. More... | |
double | CalculatePayloadChunkSuccessRate (double snir, Time duration, WifiTxVector txVector, uint16_t staId) const |
Calculate the success rate of the payload chunk given the SINR, duration, and Wi-Fi mode. More... | |
double | CalculatePayloadPer (Ptr< const Event > event, uint16_t channelWidth, NiChangesPerBand *nis, WifiSpectrumBand band, uint16_t staId, std::pair< Time, Time > window) const |
Calculate the error rate of the given PHY payload only in the provided time window (thus enabling per MPDU PER information). More... | |
NiChanges::const_iterator | GetNextPosition (Time moment, WifiSpectrumBand band) const |
Returns an iterator to the first NiChange that is later than moment. More... | |
NiChanges::const_iterator | GetPreviousPosition (Time moment, WifiSpectrumBand band) const |
Returns an iterator to the last NiChange that is before than moment. More... | |
Private Attributes | |
Ptr< ErrorRateModel > | m_errorRateModel |
error rate model More... | |
std::map< WifiSpectrumBand, double > | m_firstPowerPerBand |
first power of each band in watts More... | |
NiChangesPerBand | m_niChangesPerBand |
NI Changes for each band. More... | |
double | m_noiseFigure |
noise figure (linear) More... | |
uint8_t | m_numRxAntennas |
the number of RX antennas in the corresponding receiver More... | |
bool | m_rxing |
flag whether it is in receiving state More... | |
handles interference calculations
Definition at line 132 of file interference-helper.h.
|
private |
typedef for a multimap of NiChange
Definition at line 349 of file interference-helper.h.
|
private |
Map of NiChanges per band.
Definition at line 354 of file interference-helper.h.
ns3::InterferenceHelper::InterferenceHelper | ( | ) |
Definition at line 154 of file interference-helper.cc.
ns3::InterferenceHelper::~InterferenceHelper | ( | ) |
Definition at line 161 of file interference-helper.cc.
References EraseEvents(), and m_errorRateModel.
Ptr< Event > ns3::InterferenceHelper::Add | ( | Ptr< const WifiPpdu > | ppdu, |
WifiTxVector | txVector, | ||
Time | duration, | ||
RxPowerWattPerChannelBand | rxPower | ||
) |
Add the PPDU-related signal to interference helper.
ppdu | the PPDU |
txVector | the TXVECTOR |
duration | the PPDU duration |
rxPower | received power per band (W) |
Definition at line 168 of file interference-helper.cc.
References AppendEvent().
Referenced by AddForeignSignal(), and ns3::WifiPhy::StartReceivePreamble().
void ns3::InterferenceHelper::AddBand | ( | WifiSpectrumBand | band | ) |
Add a frequency band.
band | the band to be created |
Definition at line 196 of file interference-helper.cc.
References AddNiChangeEvent(), m_firstPowerPerBand, m_niChangesPerBand, NS_ASSERT, and NS_LOG_FUNCTION.
Referenced by ns3::SpectrumWifiPhy::UpdateInterferenceHelperBands(), and ns3::YansWifiPhy::YansWifiPhy().
void ns3::InterferenceHelper::AddForeignSignal | ( | Time | duration, |
RxPowerWattPerChannelBand | rxPower | ||
) |
Add a non-Wifi signal to interference helper.
duration | the duration of the signal |
rxPower | received power per band (W) |
Definition at line 176 of file interference-helper.cc.
References Add(), ns3::WifiMacHeader::SetType(), ns3::WIFI_MAC_QOSDATA, and ns3::WIFI_PHY_BAND_UNSPECIFIED.
Referenced by ns3::SpectrumWifiPhy::StartRx().
|
private |
Add NiChange to the list at the appropriate position and return the iterator of the new event.
moment | time to check from |
change | the NiChange to add |
band | identify the band to check |
Definition at line 923 of file interference-helper.cc.
References GetNextPosition(), m_niChangesPerBand, and NS_ASSERT.
Referenced by AddBand(), AppendEvent(), and EraseEvents().
Append the given Event.
event |
Definition at line 252 of file interference-helper.cc.
References AddNiChangeEvent(), GetNextPosition(), GetPreviousPosition(), m_firstPowerPerBand, m_niChangesPerBand, m_rxing, NS_ASSERT, and NS_LOG_FUNCTION.
Referenced by Add().
|
protected |
Calculate the success rate of the chunk given the SINR, duration, and Wi-Fi mode.
The duration and mode are used to calculate how many bits are present in the chunk.
snir | the SINR |
duration | the duration of the chunk |
mode | the WifiMode |
txVector | the TXVECTOR |
Definition at line 333 of file interference-helper.cc.
References ns3::WifiTxVector::GetChannelWidth(), ns3::WifiMode::GetDataRate(), ns3::Time::GetSeconds(), ns3::Time::IsZero(), and m_errorRateModel.
Referenced by CalculateHtPhyHeaderPer(), CalculateNonHtPhyHeaderPer(), and WifiErrorRateModelsTestCaseMimo::DoRun().
|
private |
Calculate the error rate of the HT PHY header.
TheHT PHY header can be divided into multiple chunks (e.g. due to interference from other transmissions).
event | the event |
nis | the NiChanges |
band | the band |
Definition at line 527 of file interference-helper.cc.
References CalculateChunkSuccessRate(), CalculateSnr(), ns3::WifiTxVector::GetChannelWidth(), ns3::WifiPhy::GetHePhyHeaderMode(), ns3::WifiPhy::GetHtPhyHeaderMode(), ns3::WifiPhy::GetPhyHeaderDuration(), ns3::WifiPhy::GetPhyHeaderMode(), ns3::WifiPhy::GetPhyHtSigHeaderDuration(), ns3::WifiPhy::GetPhyPreambleDuration(), ns3::WifiPhy::GetPhySigA1Duration(), ns3::WifiPhy::GetPhySigA2Duration(), ns3::WifiPhy::GetPhySigBDuration(), ns3::WifiPhy::GetPhyTrainingSymbolDuration(), ns3::WifiTxVector::GetPreambleType(), ns3::WifiPhy::GetVhtPhyHeaderMode(), ns3::IsHe(), ns3::IsHt(), ns3::IsVht(), m_firstPowerPerBand, NS_ASSERT, NS_LOG_DEBUG, NS_LOG_FUNCTION, ns3::WIFI_PREAMBLE_HT_GF, ns3::WIFI_PREAMBLE_LONG, and ns3::WIFI_PREAMBLE_SHORT.
Referenced by CalculateHtPhyHeaderSnrPer().
struct InterferenceHelper::SnrPer ns3::InterferenceHelper::CalculateHtPhyHeaderSnrPer | ( | Ptr< Event > | event, |
WifiSpectrumBand | band | ||
) | const |
Calculate the SNIR at the start of the HT PHY header and accumulate all SNIR changes in the SNIR vector.
event | the event corresponding to the first time the corresponding PPDU arrives |
band | identify the band used by the PSDU |
Definition at line 861 of file interference-helper.cc.
References CalculateHtPhyHeaderPer(), CalculateNoiseInterferenceW(), CalculateSnr(), NS_LOG_FUNCTION, ns3::InterferenceHelper::SnrPer::per, and ns3::InterferenceHelper::SnrPer::snr.
Referenced by ns3::WifiPhy::StartReceivePayload().
|
private |
Calculate noise and interference power in W.
event | the event |
nis | the NiChanges |
band | the band |
Definition at line 304 of file interference-helper.cc.
References m_firstPowerPerBand, m_niChangesPerBand, ns3::Simulator::Now(), NS_ASSERT, NS_ASSERT_MSG, and NS_LOG_FUNCTION.
Referenced by CalculateHtPhyHeaderSnrPer(), CalculateNonHtPhyHeaderSnrPer(), CalculatePayloadSnrPer(), and CalculateSnr().
|
private |
Calculate the error rate of the non-HT PHY header.
The non-HT PHY header can be divided into multiple chunks (e.g. due to interference from other transmissions).
event | the event |
nis | the NiChanges |
band | the band |
Definition at line 412 of file interference-helper.cc.
References CalculateChunkSuccessRate(), CalculateSnr(), ns3::WifiTxVector::GetChannelWidth(), ns3::WifiPhy::GetPhyHeaderDuration(), ns3::WifiPhy::GetPhyHeaderMode(), ns3::WifiPhy::GetPhyHtSigHeaderDuration(), ns3::WifiPhy::GetPhyPreambleDuration(), ns3::WifiPhy::GetPhySigA1Duration(), ns3::WifiPhy::GetPhySigA2Duration(), ns3::WifiPhy::GetPhySigBDuration(), ns3::WifiPhy::GetPhyTrainingSymbolDuration(), ns3::WifiTxVector::GetPreambleType(), m_firstPowerPerBand, NS_ASSERT, NS_LOG_DEBUG, NS_LOG_FUNCTION, ns3::WIFI_PREAMBLE_HT_GF, ns3::WIFI_PREAMBLE_LONG, and ns3::WIFI_PREAMBLE_SHORT.
Referenced by CalculateNonHtPhyHeaderSnrPer().
struct InterferenceHelper::SnrPer ns3::InterferenceHelper::CalculateNonHtPhyHeaderSnrPer | ( | Ptr< Event > | event, |
WifiSpectrumBand | band | ||
) | const |
Calculate the SNIR at the start of the non-HT PHY header and accumulate all SNIR changes in the SNIR vector.
event | the event corresponding to the first time the corresponding PPDU arrives |
band | identify the band used by the PSDU |
Definition at line 830 of file interference-helper.cc.
References CalculateNoiseInterferenceW(), CalculateNonHtPhyHeaderPer(), CalculateSnr(), NS_LOG_FUNCTION, ns3::InterferenceHelper::SnrPer::per, and ns3::InterferenceHelper::SnrPer::snr.
Referenced by ns3::WifiPhy::ContinueReceiveHeader(), and ns3::WifiPhy::StartReceiveHeader().
|
private |
Calculate the success rate of the payload chunk given the SINR, duration, and Wi-Fi mode.
The duration and mode are used to calculate how many bits are present in the chunk.
snir | the SINR |
duration | the duration of the chunk |
txVector | the TXVECTOR |
staId | the station ID of the PSDU (only used for MU) |
Definition at line 346 of file interference-helper.cc.
References ns3::WifiMode::GetDataRate(), ns3::WifiTxVector::GetMode(), ns3::WifiTxVector::GetNss(), ns3::Time::GetSeconds(), ns3::Time::IsZero(), and m_errorRateModel.
Referenced by CalculatePayloadPer().
|
private |
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 multiple chunks (e.g. due to interference from other transmissions).
event | the event |
channelWidth | the channel width used to transmit the PSDU (in MHz) |
nis | the NiChanges |
band | identify the band used by the PSDU |
staId | the station ID of the PSDU (only used for MU) |
window | time window (pair of start and end times) of PHY payload to focus on |
Definition at line 361 of file interference-helper.cc.
References CalculatePayloadChunkSuccessRate(), CalculateSnr(), ns3::WifiTxVector::GetMode(), ns3::WifiTxVector::GetNss(), ns3::WifiPhy::GetPhyHeaderDuration(), ns3::WifiPhy::GetPhyHtSigHeaderDuration(), ns3::WifiPhy::GetPhyPreambleDuration(), ns3::WifiPhy::GetPhySigA1Duration(), ns3::WifiPhy::GetPhySigA2Duration(), ns3::WifiPhy::GetPhySigBDuration(), ns3::WifiPhy::GetPhyTrainingSymbolDuration(), ns3::WifiTxVector::GetPreambleType(), m_firstPowerPerBand, ns3::Min(), NS_ASSERT, NS_LOG_DEBUG, NS_LOG_FUNCTION, and visualizer.ipython_view::window.
Referenced by CalculatePayloadSnrPer().
struct InterferenceHelper::SnrPer ns3::InterferenceHelper::CalculatePayloadSnrPer | ( | Ptr< Event > | event, |
uint16_t | channelWidth, | ||
WifiSpectrumBand | band, | ||
uint16_t | staId, | ||
std::pair< Time, Time > | relativeMpduStartStop | ||
) | const |
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.
This workaround is required in order to provide one PER per MPDU, for reception success/failure evaluation, while hiding aggregation details from this class.
event | the event corresponding to the first time the corresponding PPDU arrives |
channelWidth | the channel width used to transmit the PSDU (in MHz) |
band | identify the band used by the PSDU |
staId | the station ID of the PSDU (only used for MU) |
relativeMpduStartStop | the time window (pair of start and end times) of PHY payload to focus on |
Definition at line 795 of file interference-helper.cc.
References CalculateNoiseInterferenceW(), CalculatePayloadPer(), CalculateSnr(), NS_LOG_FUNCTION, ns3::InterferenceHelper::SnrPer::per, and ns3::InterferenceHelper::SnrPer::snr.
Referenced by ns3::WifiPhy::GetReceptionStatus().
double ns3::InterferenceHelper::CalculateSnr | ( | Ptr< Event > | event, |
uint16_t | channelWidth, | ||
uint8_t | nss, | ||
WifiSpectrumBand | band | ||
) | const |
Calculate the SNIR for the event (starting from now until the event end).
event | the event corresponding to the first time the corresponding PPDU arrives |
channelWidth | the channel width (in MHz) |
nss | the number of spatial streams |
band | identify the band used by the PSDU |
Definition at line 818 of file interference-helper.cc.
References CalculateNoiseInterferenceW().
Referenced by CalculateHtPhyHeaderPer(), CalculateHtPhyHeaderSnrPer(), CalculateNonHtPhyHeaderPer(), CalculateNonHtPhyHeaderSnrPer(), CalculatePayloadPer(), CalculatePayloadSnrPer(), WifiErrorRateModelsTestCaseMimo::DoRun(), ns3::WifiPhy::EndOfMpdu(), and ns3::WifiPhy::EndReceive().
|
protected |
Calculate SNR (linear ratio) from the given signal power and noise+interference power.
signal | signal power, W |
noiseInterference | noise and interference power, W |
channelWidth | signal width (MHz) |
nss | the number of spatial streams |
Definition at line 281 of file interference-helper.cc.
References m_noiseFigure, m_numRxAntennas, NS_LOG_DEBUG, NS_LOG_FUNCTION, and ns3::RatioToDb().
void ns3::InterferenceHelper::EraseEvents | ( | void | ) |
Erase all events.
Definition at line 892 of file interference-helper.cc.
References AddNiChangeEvent(), m_firstPowerPerBand, m_niChangesPerBand, and m_rxing.
Referenced by ns3::WifiPhy::DoChannelSwitch(), ns3::WifiPhy::DoFrequencySwitch(), and ~InterferenceHelper().
Time ns3::InterferenceHelper::GetEnergyDuration | ( | double | energyW, |
WifiSpectrumBand | band | ||
) | const |
energyW | the minimum energy (W) requested |
band | identify the requested band |
Definition at line 232 of file interference-helper.cc.
References GetPreviousPosition(), m_niChangesPerBand, ns3::MicroSeconds(), ns3::Simulator::Now(), and NS_ASSERT.
Referenced by ns3::WifiPhy::MaybeCcaBusyDuration(), ns3::WifiPhy::ResumeFromOff(), ns3::WifiPhy::ResumeFromSleep(), and ns3::WifiPhy::SwitchMaybeToCcaBusy().
Ptr< ErrorRateModel > ns3::InterferenceHelper::GetErrorRateModel | ( | void | ) | const |
Return the error rate model.
Definition at line 220 of file interference-helper.cc.
References m_errorRateModel.
Referenced by ns3::WifiPhy::CalculateSnr().
|
private |
Returns an iterator to the first NiChange that is later than moment.
moment | time to check from |
band | identify the band to check |
Definition at line 905 of file interference-helper.cc.
References m_niChangesPerBand, and NS_ASSERT.
Referenced by AddNiChangeEvent(), AppendEvent(), and GetPreviousPosition().
|
private |
Returns an iterator to the last NiChange that is before than moment.
moment | time to check from |
band | identify the band to check |
Definition at line 913 of file interference-helper.cc.
References GetNextPosition().
Referenced by AppendEvent(), GetEnergyDuration(), and NotifyRxEnd().
void ns3::InterferenceHelper::NotifyRxEnd | ( | ) |
Notify that RX has ended.
Definition at line 938 of file interference-helper.cc.
References GetPreviousPosition(), m_firstPowerPerBand, m_niChangesPerBand, m_rxing, ns3::Simulator::Now(), NS_ASSERT, and NS_LOG_FUNCTION.
Referenced by ns3::WifiPhy::AbortCurrentReception(), ns3::WifiPhy::EndReceive(), ns3::WifiPhy::ResetReceive(), ns3::WifiPhy::StartReceiveHeader(), and ns3::WifiPhy::StartRx().
void ns3::InterferenceHelper::NotifyRxStart | ( | void | ) |
Notify that RX has started.
Definition at line 931 of file interference-helper.cc.
References m_rxing, and NS_LOG_FUNCTION.
Referenced by ns3::WifiPhy::StartRx().
void ns3::InterferenceHelper::RemoveBands | ( | void | ) |
Remove the frequency bands.
Definition at line 188 of file interference-helper.cc.
References m_firstPowerPerBand, m_niChangesPerBand, and NS_LOG_FUNCTION.
Referenced by ns3::SpectrumWifiPhy::UpdateInterferenceHelperBands().
void ns3::InterferenceHelper::SetErrorRateModel | ( | const Ptr< ErrorRateModel > | rate | ) |
Set the error rate model for this interference helper.
rate | Error rate model |
Definition at line 214 of file interference-helper.cc.
References m_errorRateModel.
Referenced by WifiErrorRateModelsTestCaseMimo::DoRun(), and ns3::WifiPhy::SetErrorRateModel().
void ns3::InterferenceHelper::SetNoiseFigure | ( | double | value | ) |
Set the noise figure.
value | noise figure in linear scale |
Definition at line 208 of file interference-helper.cc.
References m_noiseFigure.
Referenced by WifiErrorRateModelsTestCaseMimo::DoRun(), and ns3::WifiPhy::SetRxNoiseFigure().
void ns3::InterferenceHelper::SetNumberOfReceiveAntennas | ( | uint8_t | rx | ) |
Set the number of RX antennas in the receiver corresponding to this interference helper.
rx | the number of RX antennas |
Definition at line 226 of file interference-helper.cc.
References m_numRxAntennas.
Referenced by WifiErrorRateModelsTestCaseMimo::DoRun(), ns3::WifiPhy::SetErrorRateModel(), ns3::WifiPhy::SetNumberOfAntennas(), and ns3::WifiPhy::SetRxNoiseFigure().
|
private |
error rate model
Definition at line 424 of file interference-helper.h.
Referenced by CalculateChunkSuccessRate(), CalculatePayloadChunkSuccessRate(), GetErrorRateModel(), SetErrorRateModel(), and ~InterferenceHelper().
|
private |
first power of each band in watts
Definition at line 427 of file interference-helper.h.
Referenced by AddBand(), AppendEvent(), CalculateHtPhyHeaderPer(), CalculateNoiseInterferenceW(), CalculateNonHtPhyHeaderPer(), CalculatePayloadPer(), EraseEvents(), NotifyRxEnd(), and RemoveBands().
|
private |
NI Changes for each band.
Definition at line 426 of file interference-helper.h.
Referenced by AddBand(), AddNiChangeEvent(), AppendEvent(), CalculateNoiseInterferenceW(), EraseEvents(), GetEnergyDuration(), GetNextPosition(), NotifyRxEnd(), and RemoveBands().
|
private |
noise figure (linear)
Definition at line 423 of file interference-helper.h.
Referenced by CalculateSnr(), and SetNoiseFigure().
|
private |
the number of RX antennas in the corresponding receiver
Definition at line 425 of file interference-helper.h.
Referenced by CalculateSnr(), and SetNumberOfReceiveAntennas().
|
private |
flag whether it is in receiving state
Definition at line 428 of file interference-helper.h.
Referenced by AppendEvent(), EraseEvents(), NotifyRxEnd(), and NotifyRxStart().