A Discrete-Event Network Simulator
API
interference-helper.h
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2005,2006 INRIA
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License version 2 as
7  * published by the Free Software Foundation;
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17  *
18  * Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
19  */
20 
21 #ifndef INTERFERENCE_HELPER_H
22 #define INTERFERENCE_HELPER_H
23 
24 #include "phy-entity.h"
25 
26 namespace ns3 {
27 
28 class WifiPpdu;
29 class WifiPsdu;
30 class ErrorRateModel;
31 
37 class Event : public SimpleRefCount<Event>
38 {
39 public:
49  Event (Ptr<const WifiPpdu> ppdu, const WifiTxVector& txVector, Time duration, RxPowerWattPerChannelBand&& rxPower);
50  ~Event ();
51 
57  Ptr<const WifiPpdu> GetPpdu (void) const;
63  Time GetStartTime (void) const;
69  Time GetEndTime (void) const;
75  Time GetDuration (void) const;
81  double GetRxPowerW (void) const;
88  double GetRxPowerW (WifiSpectrumBand band) const;
100  const WifiTxVector& GetTxVector (void) const;
107  void UpdateRxPowerW (const RxPowerWattPerChannelBand& rxPower);
108 
109 
110 private:
116 };
117 
125 std::ostream& operator<< (std::ostream& os, const Event &event);
126 
127 
133 {
134 public:
137 
143  void AddBand (WifiSpectrumBand band);
144 
148  void RemoveBands (void);
149 
155  void SetNoiseFigure (double value);
161  void SetErrorRateModel (const Ptr<ErrorRateModel> rate);
162 
175  void SetNumberOfReceiveAntennas (uint8_t rx);
176 
185  Time GetEnergyDuration (double energyW, WifiSpectrumBand band);
186 
198  Ptr<Event> Add (Ptr<const WifiPpdu> ppdu, const WifiTxVector& txVector, Time duration, RxPowerWattPerChannelBand& rxPower, bool isStartOfdmaRxing = false);
199 
205  void AddForeignSignal (Time duration, RxPowerWattPerChannelBand& rxPower);
221  struct PhyEntity::SnrPer CalculatePayloadSnrPer (Ptr<Event> event, uint16_t channelWidth, WifiSpectrumBand band,
222  uint16_t staId, std::pair<Time, Time> relativeMpduStartStop) const;
233  double CalculateSnr (Ptr<Event> event, uint16_t channelWidth, uint8_t nss, WifiSpectrumBand band) const;
245  struct PhyEntity::SnrPer CalculatePhyHeaderSnrPer (Ptr<Event> event, uint16_t channelWidth, WifiSpectrumBand band,
246  WifiPpduField header) const;
247 
251  void NotifyRxStart ();
257  void NotifyRxEnd (Time endTime);
261  void EraseEvents (void);
262 
269  void UpdateEvent (Ptr<Event> event, const RxPowerWattPerChannelBand& rxPower);
270 
271 
272 protected:
283  double CalculateSnr (double signal, double noiseInterference, uint16_t channelWidth, uint8_t nss) const;
296  double CalculateChunkSuccessRate (double snir, Time duration, WifiMode mode, const WifiTxVector& txVector, WifiPpduField field) const;
308  double CalculatePayloadChunkSuccessRate (double snir, Time duration, const WifiTxVector& txVector, uint16_t staId = SU_STA_ID) const;
309 
310 private:
314  class NiChange
315  {
316 public:
323  NiChange (double power, Ptr<Event> event);
324  ~NiChange ();
330  double GetPower (void) const;
336  void AddPower (double power);
342  Ptr<Event> GetEvent (void) const;
343 
344 
345 private:
346  double m_power;
348  };
349 
353  typedef std::multimap<Time, NiChange> NiChanges;
354 
358  typedef std::map <WifiSpectrumBand, NiChanges> NiChangesPerBand;
359 
366  void AppendEvent (Ptr<Event> event, bool isStartOfdmaRxing);
367 
392  double CalculatePayloadPer (Ptr<const Event> event, uint16_t channelWidth, NiChangesPerBand *nis, WifiSpectrumBand band,
393  uint16_t staId, std::pair<Time, Time> window) const;
407  uint16_t channelWidth, WifiSpectrumBand band,
408  WifiPpduField header) const;
421  uint16_t channelWidth, WifiSpectrumBand band,
422  PhyEntity::PhyHeaderSections phyHeaderSections) const;
423 
424  double m_noiseFigure;
426  uint8_t m_numRxAntennas;
428  std::map <WifiSpectrumBand, double> m_firstPowerPerBand;
429  bool m_rxing;
430 
438  NiChanges::iterator GetNextPosition (Time moment, NiChangesPerBand::iterator niIt);
446  NiChanges::iterator GetPreviousPosition (Time moment, NiChangesPerBand::iterator niIt);
447 
457  NiChanges::iterator AddNiChangeEvent (Time moment, NiChange change, NiChangesPerBand::iterator niIt);
458 };
459 
460 } //namespace ns3
461 
462 #endif /* INTERFERENCE_HELPER_H */
ns3::Event::m_endTime
Time m_endTime
end time
Definition: interference-helper.h:114
ns3::InterferenceHelper::NotifyRxStart
void NotifyRxStart()
Notify that RX has started.
Definition: interference-helper.cc:635
ns3::InterferenceHelper::m_firstPowerPerBand
std::map< WifiSpectrumBand, double > m_firstPowerPerBand
first power of each band in watts
Definition: interference-helper.h:428
ns3::InterferenceHelper::m_noiseFigure
double m_noiseFigure
noise figure (linear)
Definition: interference-helper.h:424
ns3::InterferenceHelper::CalculateNoiseInterferenceW
double CalculateNoiseInterferenceW(Ptr< Event > event, NiChangesPerBand *nis, WifiSpectrumBand band) const
Calculate noise and interference power in W.
Definition: interference-helper.cc:362
ns3::InterferenceHelper::NiChange
Noise and Interference (thus Ni) event.
Definition: interference-helper.h:315
ns3::WifiSpectrumBand
std::pair< uint32_t, uint32_t > WifiSpectrumBand
typedef for a pair of start and stop sub-band indexes
Definition: wifi-spectrum-value-helper.h:34
ns3
Every class exported by the ns3 library is enclosed in the ns3 namespace.
ns3::Event::GetRxPowerW
double GetRxPowerW(void) const
Return the total received power (W).
Definition: interference-helper.cc:81
ns3::Event::m_txVector
WifiTxVector m_txVector
TXVECTOR.
Definition: interference-helper.h:112
ns3::InterferenceHelper::GetEnergyDuration
Time GetEnergyDuration(double energyW, WifiSpectrumBand band)
Definition: interference-helper.cc:260
ns3::InterferenceHelper::CalculatePhyHeaderPer
double CalculatePhyHeaderPer(Ptr< const Event > event, NiChangesPerBand *nis, uint16_t channelWidth, WifiSpectrumBand band, WifiPpduField header) const
Calculate the error rate of the PHY header.
Definition: interference-helper.cc:522
ns3::InterferenceHelper::GetErrorRateModel
Ptr< ErrorRateModel > GetErrorRateModel(void) const
Return the error rate model.
Definition: interference-helper.cc:248
ns3::InterferenceHelper::SetErrorRateModel
void SetErrorRateModel(const Ptr< ErrorRateModel > rate)
Set the error rate model for this interference helper.
Definition: interference-helper.cc:242
ns3::InterferenceHelper::CalculatePhyHeaderSectionPsr
double CalculatePhyHeaderSectionPsr(Ptr< const Event > event, NiChangesPerBand *nis, uint16_t channelWidth, WifiSpectrumBand band, PhyEntity::PhyHeaderSections phyHeaderSections) const
Calculate the success rate of the PHY header sections for the provided event.
Definition: interference-helper.cc:469
ns3::InterferenceHelper::m_niChangesPerBand
NiChangesPerBand m_niChangesPerBand
NI Changes for each band.
Definition: interference-helper.h:427
ns3::InterferenceHelper::SetNumberOfReceiveAntennas
void SetNumberOfReceiveAntennas(uint8_t rx)
Set the number of RX antennas in the receiver corresponding to this interference helper.
Definition: interference-helper.cc:254
ns3::SimpleRefCount
A template-based reference counting class.
Definition: simple-ref-count.h:74
ns3::Event::m_ppdu
Ptr< const WifiPpdu > m_ppdu
PPDU.
Definition: interference-helper.h:111
ns3::InterferenceHelper::m_errorRateModel
Ptr< ErrorRateModel > m_errorRateModel
error rate model
Definition: interference-helper.h:425
ns3::InterferenceHelper::AddNiChangeEvent
NiChanges::iterator AddNiChangeEvent(Time moment, NiChange change, NiChangesPerBand::iterator niIt)
Add NiChange to the list at the appropriate position and return the iterator of the new event.
Definition: interference-helper.cc:629
ns3::Event
handles interference calculations
Definition: interference-helper.h:38
ns3::InterferenceHelper::AddForeignSignal
void AddForeignSignal(Time duration, RxPowerWattPerChannelBand &rxPower)
Add a non-Wifi signal to interference helper.
Definition: interference-helper.cc:198
ns3::WifiTxVector
This class mimics the TXVECTOR which is to be passed to the PHY in order to define the parameters whi...
Definition: wifi-tx-vector.h:71
ns3::Event::GetStartTime
Time GetStartTime(void) const
Return the start time of the signal.
Definition: interference-helper.cc:63
ns3::InterferenceHelper::NiChangesPerBand
std::map< WifiSpectrumBand, NiChanges > NiChangesPerBand
Map of NiChanges per band.
Definition: interference-helper.h:358
ns3::Event::Event
Event(Ptr< const WifiPpdu > ppdu, const WifiTxVector &txVector, Time duration, RxPowerWattPerChannelBand &&rxPower)
Create an Event with the given parameters.
Definition: interference-helper.cc:41
ns3::InterferenceHelper::EraseEvents
void EraseEvents(void)
Erase all events.
Definition: interference-helper.cc:600
ns3::PhyEntity::PhyHeaderSections
std::map< WifiPpduField, PhyHeaderChunkInfo > PhyHeaderSections
A map of PhyHeaderChunkInfo elements per PPDU field.
Definition: phy-entity.h:301
ns3::InterferenceHelper::CalculatePayloadPer
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...
Definition: interference-helper.cc:419
ns3::InterferenceHelper::CalculateChunkSuccessRate
double CalculateChunkSuccessRate(double snir, Time duration, WifiMode mode, const WifiTxVector &txVector, WifiPpduField field) const
Calculate the success rate of the chunk given the SINR, duration, and TXVECTOR.
Definition: interference-helper.cc:391
phy-entity.h
Declaration of:
ns3::InterferenceHelper::InterferenceHelper
InterferenceHelper()
Definition: interference-helper.cc:176
ns3::Event::GetPpdu
Ptr< const WifiPpdu > GetPpdu(void) const
Return the PPDU.
Definition: interference-helper.cc:57
ns3::Ptr
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:74
ns3::InterferenceHelper::GetPreviousPosition
NiChanges::iterator GetPreviousPosition(Time moment, NiChangesPerBand::iterator niIt)
Returns an iterator to the last NiChange that is before than moment.
Definition: interference-helper.cc:619
ns3::InterferenceHelper::AppendEvent
void AppendEvent(Ptr< Event > event, bool isStartOfdmaRxing)
Append the given Event.
Definition: interference-helper.cc:280
ns3::Event::m_rxPowerW
RxPowerWattPerChannelBand m_rxPowerW
received power in watts per band
Definition: interference-helper.h:115
ns3::Event::~Event
~Event()
Definition: interference-helper.cc:50
ns3::Event::GetEndTime
Time GetEndTime(void) const
Return the end time of the signal.
Definition: interference-helper.cc:69
ns3::InterferenceHelper::NiChange::m_power
double m_power
power in watts
Definition: interference-helper.h:346
ns3::Time
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:104
visualizer.ipython_view.window
window
GTK Window.
Definition: ipython_view.py:660
ns3::WifiPpduField
WifiPpduField
The type of PPDU field (grouped for convenience)
Definition: wifi-phy-common.h:166
ns3::Event::UpdateRxPowerW
void UpdateRxPowerW(const RxPowerWattPerChannelBand &rxPower)
Update the received power (W) for all bands, i.e.
Definition: interference-helper.cc:113
ns3::InterferenceHelper::m_rxing
bool m_rxing
flag whether it is in receiving state
Definition: interference-helper.h:429
ns3::Event::GetRxPowerWPerBand
const RxPowerWattPerChannelBand & GetRxPowerWPerBand(void) const
Return the received power (W) for all bands.
Definition: interference-helper.cc:101
ns3::InterferenceHelper::m_numRxAntennas
uint8_t m_numRxAntennas
the number of RX antennas in the corresponding receiver
Definition: interference-helper.h:426
ns3::InterferenceHelper::UpdateEvent
void UpdateEvent(Ptr< Event > event, const RxPowerWattPerChannelBand &rxPower)
Update event to scale its received power (W) per band.
Definition: interference-helper.cc:316
ns3::Event::m_startTime
Time m_startTime
start time
Definition: interference-helper.h:113
ns3::InterferenceHelper::NiChanges
std::multimap< Time, NiChange > NiChanges
typedef for a multimap of NiChange
Definition: interference-helper.h:353
ns3::InterferenceHelper::CalculateSnr
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).
Definition: interference-helper.cc:568
ns3::InterferenceHelper::AddBand
void AddBand(WifiSpectrumBand band)
Add a frequency band.
Definition: interference-helper.cc:223
ns3::InterferenceHelper::CalculatePhyHeaderSnrPer
struct PhyEntity::SnrPer CalculatePhyHeaderSnrPer(Ptr< Event > event, uint16_t channelWidth, WifiSpectrumBand band, WifiPpduField header) const
Calculate the SNIR at the start of the PHY header and accumulate all SNIR changes in the SNIR vector.
Definition: interference-helper.cc:580
ns3::InterferenceHelper::NiChange::m_event
Ptr< Event > m_event
event
Definition: interference-helper.h:347
ns3::InterferenceHelper::Add
Ptr< Event > Add(Ptr< const WifiPpdu > ppdu, const WifiTxVector &txVector, Time duration, RxPowerWattPerChannelBand &rxPower, bool isStartOfdmaRxing=false)
Add the PPDU-related signal to interference helper.
Definition: interference-helper.cc:190
ns3::InterferenceHelper::RemoveBands
void RemoveBands(void)
Remove the frequency bands.
Definition: interference-helper.cc:211
ns3::InterferenceHelper::CalculatePayloadChunkSuccessRate
double CalculatePayloadChunkSuccessRate(double snir, Time duration, const WifiTxVector &txVector, uint16_t staId=SU_STA_ID) const
Calculate the success rate of the payload chunk given the SINR, duration, and TXVECTOR.
Definition: interference-helper.cc:404
ns3::InterferenceHelper::SetNoiseFigure
void SetNoiseFigure(double value)
Set the noise figure.
Definition: interference-helper.cc:236
ns3::PhyEntity::SnrPer
A struct for both SNR and PER.
Definition: phy-entity.h:137
ns3::RxPowerWattPerChannelBand
std::map< WifiSpectrumBand, double > RxPowerWattPerChannelBand
A map of the received power (Watts) for each band.
Definition: phy-entity.h:75
ns3::InterferenceHelper::~InterferenceHelper
~InterferenceHelper()
Definition: interference-helper.cc:183
ns3::operator<<
std::ostream & operator<<(std::ostream &os, const Angles &a)
Definition: angles.cc:137
ns3::Event::GetDuration
Time GetDuration(void) const
Return the duration of the signal.
Definition: interference-helper.cc:75
ns3::InterferenceHelper::GetNextPosition
NiChanges::iterator GetNextPosition(Time moment, NiChangesPerBand::iterator niIt)
Returns an iterator to the first NiChange that is later than moment.
Definition: interference-helper.cc:613
ns3::Event::GetTxVector
const WifiTxVector & GetTxVector(void) const
Return the TXVECTOR of the PPDU.
Definition: interference-helper.cc:107
ns3::InterferenceHelper::CalculatePayloadSnrPer
struct PhyEntity::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...
Definition: interference-helper.cc:548
ns3::InterferenceHelper
handles interference calculations
Definition: interference-helper.h:133
ns3::InterferenceHelper::NotifyRxEnd
void NotifyRxEnd(Time endTime)
Notify that RX has ended.
Definition: interference-helper.cc:642