A Discrete-Event Network Simulator
API
Classes | Public Member Functions | Private Types | Private Member Functions | Private Attributes | List of all members
ns3::InterferenceHelper Class Reference

handles interference calculations More...

#include "interference-helper.h"

Classes

class  NiChange
 Noise and Interference (thus Ni) event. More...
 
struct  SnrPer
 Signal event for a packet. More...
 

Public Member Functions

 InterferenceHelper ()
 
 ~InterferenceHelper ()
 
Ptr< EventAdd (Ptr< const Packet > packet, WifiTxVector txVector, Time duration, double rxPower)
 Add the packet-related signal to interference helper. More...
 
void AddForeignSignal (Time duration, double rxPower)
 Add a non-Wifi signal to interference helper. More...
 
struct InterferenceHelper::SnrPer CalculatePlcpHeaderSnrPer (Ptr< Event > event) const
 Calculate the SNIR at the start of the plcp header and accumulate all SNIR changes in the snir vector. More...
 
struct InterferenceHelper::SnrPer CalculatePlcpPayloadSnrPer (Ptr< Event > event) const
 Calculate the SNIR at the start of the plcp payload and accumulate all SNIR changes in the snir vector. More...
 
void EraseEvents (void)
 Erase all events. More...
 
Time GetEnergyDuration (double energyW) const
 
Ptr< ErrorRateModelGetErrorRateModel (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 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...
 

Private Types

typedef std::multimap< Time, NiChangeNiChanges
 typedef for a multimap of NiChanges More...
 

Private Member Functions

NiChanges::iterator AddNiChangeEvent (Time moment, NiChange change)
 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 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 CalculateNoiseInterferenceW (Ptr< Event > event, NiChanges *ni) const
 Calculate noise and interference power in W. More...
 
double CalculatePlcpHeaderPer (Ptr< const Event > event, NiChanges *ni) const
 Calculate the error rate of the plcp header. More...
 
double CalculatePlcpPayloadPer (Ptr< const Event > event, NiChanges *ni) const
 Calculate the error rate of the given plcp payload. More...
 
double CalculateSnr (double signal, double noiseInterference, uint16_t channelWidth) const
 Calculate SNR (linear ratio) from the given signal power and noise+interference power. More...
 
NiChanges::const_iterator GetNextPosition (Time moment) const
 Returns an iterator to the first nichange that is later than moment. More...
 
NiChanges::const_iterator GetPreviousPosition (Time moment) const
 Returns an iterator to the first nichange that is later than moment. More...
 

Private Attributes

Ptr< ErrorRateModelm_errorRateModel
 error rate model More...
 
double m_firstPower
 first power More...
 
NiChanges m_niChanges
 Experimental: needed for energy duration calculation. 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...
 

Detailed Description

handles interference calculations

Definition at line 101 of file interference-helper.h.

Member Typedef Documentation

◆ NiChanges

typedef std::multimap<Time, NiChange> ns3::InterferenceHelper::NiChanges
private

typedef for a multimap of NiChanges

Definition at line 249 of file interference-helper.h.

Constructor & Destructor Documentation

◆ InterferenceHelper()

ns3::InterferenceHelper::InterferenceHelper ( )

Definition at line 121 of file interference-helper.cc.

References AddNiChangeEvent().

◆ ~InterferenceHelper()

ns3::InterferenceHelper::~InterferenceHelper ( )

Definition at line 131 of file interference-helper.cc.

References EraseEvents(), and m_errorRateModel.

Member Function Documentation

◆ Add()

Ptr< Event > ns3::InterferenceHelper::Add ( Ptr< const Packet packet,
WifiTxVector  txVector,
Time  duration,
double  rxPower 
)

Add the packet-related signal to interference helper.

Parameters
packetthe packet
txVectorTXVECTOR of the packet
durationthe duration of the signal
rxPowerreceive power (W)
Returns
Event

Definition at line 138 of file interference-helper.cc.

References AppendEvent().

Referenced by AddForeignSignal(), and ns3::WifiPhy::StartReceivePreambleAndHeader().

◆ AddForeignSignal()

void ns3::InterferenceHelper::AddForeignSignal ( Time  duration,
double  rxPower 
)

Add a non-Wifi signal to interference helper.

Parameters
durationthe duration of the signal
rxPowerreceive power (W)

Definition at line 146 of file interference-helper.cc.

References Add().

Referenced by ns3::SpectrumWifiPhy::StartRx().

◆ AddNiChangeEvent()

InterferenceHelper::NiChanges::iterator ns3::InterferenceHelper::AddNiChangeEvent ( Time  moment,
NiChange  change 
)
private

Add NiChange to the list at the appropriate position and return the iterator of the new event.

Parameters
moment
change
Returns
the iterator of the new event

Definition at line 806 of file interference-helper.cc.

References GetNextPosition(), and m_niChanges.

Referenced by AppendEvent(), EraseEvents(), and InterferenceHelper().

◆ AppendEvent()

void ns3::InterferenceHelper::AppendEvent ( Ptr< Event event)
private

Append the given Event.

Parameters
event

Definition at line 198 of file interference-helper.cc.

References AddNiChangeEvent(), GetNextPosition(), GetPreviousPosition(), m_firstPower, m_niChanges, m_rxing, and NS_LOG_FUNCTION.

Referenced by Add().

◆ CalculateChunkSuccessRate()

double ns3::InterferenceHelper::CalculateChunkSuccessRate ( double  snir,
Time  duration,
WifiMode  mode,
WifiTxVector  txVector 
) const
private

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.

Parameters
snirSINR
duration
mode
txVector
Returns
the success rate

Definition at line 255 of file interference-helper.cc.

References ns3::WifiTxVector::GetMode(), ns3::WifiMode::GetModulationClass(), ns3::WifiTxVector::GetNss(), ns3::WifiTxVector::GetNTx(), ns3::WifiMode::GetPhyRate(), ns3::Time::GetSeconds(), ns3::Time::IsZero(), m_errorRateModel, m_numRxAntennas, NS_LOG_DEBUG, ns3::WIFI_MOD_CLASS_HE, ns3::WIFI_MOD_CLASS_HT, and ns3::WIFI_MOD_CLASS_VHT.

Referenced by CalculatePlcpHeaderPer(), and CalculatePlcpPayloadPer().

◆ CalculateNoiseInterferenceW()

double ns3::InterferenceHelper::CalculateNoiseInterferenceW ( Ptr< Event event,
NiChanges ni 
) const
private

Calculate noise and interference power in W.

Parameters
event
ni
Returns
noise and interference power

Definition at line 237 of file interference-helper.cc.

References m_firstPower, and m_niChanges.

Referenced by CalculatePlcpHeaderSnrPer(), and CalculatePlcpPayloadSnrPer().

◆ CalculatePlcpHeaderPer()

double ns3::InterferenceHelper::CalculatePlcpHeaderPer ( Ptr< const Event event,
NiChanges ni 
) const
private

◆ CalculatePlcpHeaderSnrPer()

struct InterferenceHelper::SnrPer ns3::InterferenceHelper::CalculatePlcpHeaderSnrPer ( Ptr< Event event) const

Calculate the SNIR at the start of the plcp header and accumulate all SNIR changes in the snir vector.

Parameters
eventthe event corresponding to the first time the corresponding packet arrives
Returns
struct of SNR and PER

Definition at line 760 of file interference-helper.cc.

References CalculateNoiseInterferenceW(), CalculatePlcpHeaderPer(), CalculateSnr(), ns3::InterferenceHelper::SnrPer::per, and ns3::InterferenceHelper::SnrPer::snr.

Referenced by ns3::WifiPhy::StartReceivePacket().

◆ CalculatePlcpPayloadPer()

double ns3::InterferenceHelper::CalculatePlcpPayloadPer ( Ptr< const Event event,
NiChanges ni 
) const
private

◆ CalculatePlcpPayloadSnrPer()

struct InterferenceHelper::SnrPer ns3::InterferenceHelper::CalculatePlcpPayloadSnrPer ( Ptr< Event event) const

Calculate the SNIR at the start of the plcp payload and accumulate all SNIR changes in the snir vector.

Parameters
eventthe event corresponding to the first time the corresponding packet arrives
Returns
struct of SNR and PER

Definition at line 740 of file interference-helper.cc.

References CalculateNoiseInterferenceW(), CalculatePlcpPayloadPer(), CalculateSnr(), ns3::InterferenceHelper::SnrPer::per, and ns3::InterferenceHelper::SnrPer::snr.

Referenced by ns3::WifiPhy::EndReceive().

◆ CalculateSnr()

double ns3::InterferenceHelper::CalculateSnr ( double  signal,
double  noiseInterference,
uint16_t  channelWidth 
) const
private

Calculate SNR (linear ratio) from the given signal power and noise+interference power.

(Mode is not currently used)

Parameters
signal
noiseInterference
channelWidth
Returns
SNR in liear ratio

Definition at line 222 of file interference-helper.cc.

References m_noiseFigure, and NS_LOG_DEBUG.

Referenced by CalculatePlcpHeaderPer(), CalculatePlcpHeaderSnrPer(), CalculatePlcpPayloadPer(), and CalculatePlcpPayloadSnrPer().

◆ EraseEvents()

void ns3::InterferenceHelper::EraseEvents ( void  )

◆ GetEnergyDuration()

Time ns3::InterferenceHelper::GetEnergyDuration ( double  energyW) const
Parameters
energyWthe minimum energy (W) requested
Returns
the expected amount of time the observed energy on the medium will be higher than the requested threshold.

Definition at line 180 of file interference-helper.cc.

References GetPreviousPosition(), m_niChanges, ns3::MicroSeconds(), and ns3::Simulator::Now().

Referenced by ns3::WifiPhy::MaybeCcaBusyDuration(), ns3::WifiPhy::ResumeFromOff(), ns3::WifiPhy::ResumeFromSleep(), and ns3::WifiPhy::SwitchMaybeToCcaBusy().

◆ GetErrorRateModel()

Ptr< ErrorRateModel > ns3::InterferenceHelper::GetErrorRateModel ( void  ) const

Return the error rate model.

Returns
Error rate model

Definition at line 168 of file interference-helper.cc.

References m_errorRateModel.

Referenced by ns3::WifiPhy::CalculateSnr().

◆ GetNextPosition()

InterferenceHelper::NiChanges::const_iterator ns3::InterferenceHelper::GetNextPosition ( Time  moment) const
private

Returns an iterator to the first nichange that is later than moment.

Parameters
momenttime to check from
Returns
an iterator to the list of NiChanges

Definition at line 790 of file interference-helper.cc.

References m_niChanges.

Referenced by AddNiChangeEvent(), AppendEvent(), and GetPreviousPosition().

◆ GetPreviousPosition()

InterferenceHelper::NiChanges::const_iterator ns3::InterferenceHelper::GetPreviousPosition ( Time  moment) const
private

Returns an iterator to the first nichange that is later than moment.

Parameters
momenttime to check from
Returns
an iterator to the list of NiChanges Returns an iterator to the last nichange that is before than moment
Parameters
momenttime to check from
Returns
an iterator to the list of NiChanges

Definition at line 796 of file interference-helper.cc.

References GetNextPosition().

Referenced by AppendEvent(), and GetEnergyDuration().

◆ NotifyRxEnd()

void ns3::InterferenceHelper::NotifyRxEnd ( )

◆ NotifyRxStart()

void ns3::InterferenceHelper::NotifyRxStart ( void  )

Notify that RX has started.

Definition at line 812 of file interference-helper.cc.

References m_rxing, and NS_LOG_FUNCTION.

Referenced by ns3::WifiPhy::StartRx().

◆ SetErrorRateModel()

void ns3::InterferenceHelper::SetErrorRateModel ( const Ptr< ErrorRateModel rate)

Set the error rate model for this interference helper.

Parameters
rateError rate model

Definition at line 162 of file interference-helper.cc.

References m_errorRateModel.

Referenced by ns3::WifiPhy::SetErrorRateModel().

◆ SetNoiseFigure()

void ns3::InterferenceHelper::SetNoiseFigure ( double  value)

Set the noise figure.

Parameters
valuenoise figure

Definition at line 156 of file interference-helper.cc.

References m_noiseFigure.

Referenced by ns3::WifiPhy::SetRxNoiseFigure().

◆ SetNumberOfReceiveAntennas()

void ns3::InterferenceHelper::SetNumberOfReceiveAntennas ( uint8_t  rx)

Set the number of RX antennas in the receiver corresponding to this interference helper.

Parameters
rxthe number of RX antennas

Definition at line 174 of file interference-helper.cc.

References m_numRxAntennas.

Referenced by ns3::WifiPhy::SetErrorRateModel(), ns3::WifiPhy::SetNumberOfAntennas(), and ns3::WifiPhy::SetRxNoiseFigure().

Member Data Documentation

◆ m_errorRateModel

Ptr<ErrorRateModel> ns3::InterferenceHelper::m_errorRateModel
private

error rate model

Definition at line 311 of file interference-helper.h.

Referenced by CalculateChunkSuccessRate(), GetErrorRateModel(), SetErrorRateModel(), and ~InterferenceHelper().

◆ m_firstPower

double ns3::InterferenceHelper::m_firstPower
private

◆ m_niChanges

NiChanges ns3::InterferenceHelper::m_niChanges
private

Experimental: needed for energy duration calculation.

Definition at line 314 of file interference-helper.h.

Referenced by AddNiChangeEvent(), AppendEvent(), CalculateNoiseInterferenceW(), EraseEvents(), GetEnergyDuration(), GetNextPosition(), and NotifyRxEnd().

◆ m_noiseFigure

double ns3::InterferenceHelper::m_noiseFigure
private

noise figure (linear)

Definition at line 310 of file interference-helper.h.

Referenced by CalculateSnr(), and SetNoiseFigure().

◆ m_numRxAntennas

uint8_t ns3::InterferenceHelper::m_numRxAntennas
private

the number of RX antennas in the corresponding receiver

Definition at line 312 of file interference-helper.h.

Referenced by CalculateChunkSuccessRate(), and SetNumberOfReceiveAntennas().

◆ m_rxing

bool ns3::InterferenceHelper::m_rxing
private

flag whether it is in receiving state

Definition at line 316 of file interference-helper.h.

Referenced by AppendEvent(), EraseEvents(), NotifyRxEnd(), and NotifyRxStart().


The documentation for this class was generated from the following files: