A Discrete-Event Network Simulator
API
interference-helper.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2005,2006 INRIA
3  *
4  * This program is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License version 2 as
6  * published by the Free Software Foundation;
7  *
8  * This program is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  * GNU General Public License for more details.
12  *
13  * You should have received a copy of the GNU General Public License
14  * along with this program; if not, write to the Free Software
15  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16  *
17  * Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
18  */
19 
20 #ifndef INTERFERENCE_HELPER_H
21 #define INTERFERENCE_HELPER_H
22 
23 #include "phy-entity.h"
24 
25 #include "ns3/object.h"
26 
27 namespace ns3
28 {
29 
30 class WifiPpdu;
31 class WifiPsdu;
32 class ErrorRateModel;
33 
39 class Event : public SimpleRefCount<Event>
40 {
41  public:
52  const WifiTxVector& txVector,
53  Time duration,
54  RxPowerWattPerChannelBand&& rxPower);
55  ~Event();
56 
68  Time GetStartTime() const;
74  Time GetEndTime() const;
80  Time GetDuration() const;
86  double GetRxPowerW() const;
93  double GetRxPowerW(WifiSpectrumBand band) const;
105  const WifiTxVector& GetTxVector() const;
112  void UpdateRxPowerW(const RxPowerWattPerChannelBand& rxPower);
113 
114  private:
120 };
121 
129 std::ostream& operator<<(std::ostream& os, const Event& event);
130 
136 {
137  public:
139  ~InterferenceHelper() override;
140 
145  static TypeId GetTypeId();
146 
152  void AddBand(WifiSpectrumBand band);
153 
157  void RemoveBands();
158 
164  void SetNoiseFigure(double value);
170  void SetErrorRateModel(const Ptr<ErrorRateModel> rate);
171 
184  void SetNumberOfReceiveAntennas(uint8_t rx);
185 
194  Time GetEnergyDuration(double energyW, WifiSpectrumBand band);
195 
210  const WifiTxVector& txVector,
211  Time duration,
212  RxPowerWattPerChannelBand& rxPower,
213  bool isStartOfdmaRxing = false);
214 
220  void AddForeignSignal(Time duration, RxPowerWattPerChannelBand& rxPower);
238  Ptr<Event> event,
239  uint16_t channelWidth,
240  WifiSpectrumBand band,
241  uint16_t staId,
242  std::pair<Time, Time> relativeMpduStartStop) const;
253  double CalculateSnr(Ptr<Event> event,
254  uint16_t channelWidth,
255  uint8_t nss,
256  WifiSpectrumBand band) const;
268  struct PhyEntity::SnrPer CalculatePhyHeaderSnrPer(Ptr<Event> event,
269  uint16_t channelWidth,
270  WifiSpectrumBand band,
271  WifiPpduField header) const;
272 
276  void NotifyRxStart();
282  void NotifyRxEnd(Time endTime);
286  void EraseEvents();
287 
294  void UpdateEvent(Ptr<Event> event, const RxPowerWattPerChannelBand& rxPower);
295 
296  protected:
297  void DoDispose() override;
298 
309  double CalculateSnr(double signal,
310  double noiseInterference,
311  uint16_t channelWidth,
312  uint8_t nss) const;
325  double CalculateChunkSuccessRate(double snir,
326  Time duration,
327  WifiMode mode,
328  const WifiTxVector& txVector,
329  WifiPpduField field) const;
342  double CalculatePayloadChunkSuccessRate(double snir,
343  Time duration,
344  const WifiTxVector& txVector,
345  uint16_t staId = SU_STA_ID) const;
346 
347  private:
351  class NiChange
352  {
353  public:
360  NiChange(double power, Ptr<Event> event);
361  ~NiChange();
367  double GetPower() const;
373  void AddPower(double power);
379  Ptr<Event> GetEvent() const;
380 
381  private:
382  double m_power;
384  };
385 
389  typedef std::multimap<Time, NiChange> NiChanges;
390 
394  typedef std::map<WifiSpectrumBand, NiChanges> NiChangesPerBand;
395 
403  void AppendEvent(Ptr<Event> event, bool isStartOfdmaRxing);
404 
415  NiChangesPerBand* nis,
416  WifiSpectrumBand band) const;
432  uint16_t channelWidth,
433  NiChangesPerBand* nis,
434  WifiSpectrumBand band,
435  uint16_t staId,
436  std::pair<Time, Time> window) const;
450  NiChangesPerBand* nis,
451  uint16_t channelWidth,
452  WifiSpectrumBand band,
453  WifiPpduField header) const;
466  NiChangesPerBand* nis,
467  uint16_t channelWidth,
468  WifiSpectrumBand band,
469  PhyEntity::PhyHeaderSections phyHeaderSections) const;
470 
471  double m_noiseFigure;
473  uint8_t m_numRxAntennas;
475  std::map<WifiSpectrumBand, double> m_firstPowerPerBand;
476  bool m_rxing;
477 
485  NiChanges::iterator GetNextPosition(Time moment, NiChangesPerBand::iterator niIt);
493  NiChanges::iterator GetPreviousPosition(Time moment, NiChangesPerBand::iterator niIt);
494 
504  NiChanges::iterator AddNiChangeEvent(Time moment,
505  NiChange change,
506  NiChangesPerBand::iterator niIt);
507 };
508 
509 } // namespace ns3
510 
511 #endif /* INTERFERENCE_HELPER_H */
handles interference calculations
Time m_endTime
end time
WifiTxVector m_txVector
TXVECTOR.
Time m_startTime
start time
Ptr< const WifiPpdu > GetPpdu() const
Return the PPDU.
Ptr< const WifiPpdu > m_ppdu
PPDU.
void UpdateRxPowerW(const RxPowerWattPerChannelBand &rxPower)
Update the received power (W) for all bands, i.e.
Event(Ptr< const WifiPpdu > ppdu, const WifiTxVector &txVector, Time duration, RxPowerWattPerChannelBand &&rxPower)
Create an Event with the given parameters.
Time GetEndTime() const
Return the end time of the signal.
Time GetDuration() const
Return the duration of the signal.
double GetRxPowerW() const
Return the total received power (W).
const WifiTxVector & GetTxVector() const
Return the TXVECTOR of the PPDU.
RxPowerWattPerChannelBand m_rxPowerW
received power in watts per band
const RxPowerWattPerChannelBand & GetRxPowerWPerBand() const
Return the received power (W) for all bands.
Time GetStartTime() const
Return the start time of the signal.
Noise and Interference (thus Ni) event.
handles interference calculations
void SetNoiseFigure(double value)
Set the noise figure.
double m_noiseFigure
noise figure (linear)
Ptr< ErrorRateModel > GetErrorRateModel() const
Return the error rate model.
void AddForeignSignal(Time duration, RxPowerWattPerChannelBand &rxPower)
Add a non-Wifi signal to interference helper.
bool m_rxing
flag whether it is in receiving state
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.
std::map< WifiSpectrumBand, NiChanges > NiChangesPerBand
Map of NiChanges per band.
uint8_t m_numRxAntennas
the number of RX antennas in the corresponding receiver
void DoDispose() override
Destructor implementation.
void RemoveBands()
Remove the frequency bands.
void NotifyRxEnd(Time endTime)
Notify that RX has ended.
double CalculateNoiseInterferenceW(Ptr< Event > event, NiChangesPerBand *nis, WifiSpectrumBand band) const
Calculate noise and interference power in W.
void SetErrorRateModel(const Ptr< ErrorRateModel > rate)
Set the error rate model for this interference helper.
std::multimap< Time, NiChange > NiChanges
typedef for a multimap of NiChange
Time GetEnergyDuration(double energyW, WifiSpectrumBand band)
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.
void EraseEvents()
Erase all events.
Ptr< ErrorRateModel > m_errorRateModel
error rate model
void AppendEvent(Ptr< Event > event, bool isStartOfdmaRxing)
Append the given Event.
void NotifyRxStart()
Notify that RX has started.
NiChanges::iterator GetNextPosition(Time moment, NiChangesPerBand::iterator niIt)
Returns an iterator to the first NiChange that is later than moment.
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).
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.
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.
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...
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...
NiChanges::iterator GetPreviousPosition(Time moment, NiChangesPerBand::iterator niIt)
Returns an iterator to the last NiChange that is before than moment.
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.
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.
static TypeId GetTypeId()
Get the type ID.
void UpdateEvent(Ptr< Event > event, const RxPowerWattPerChannelBand &rxPower)
Update event to scale its received power (W) per band.
void SetNumberOfReceiveAntennas(uint8_t rx)
Set the number of RX antennas in the receiver corresponding to this interference helper.
void AddBand(WifiSpectrumBand band)
Add a frequency band.
double CalculatePhyHeaderPer(Ptr< const Event > event, NiChangesPerBand *nis, uint16_t channelWidth, WifiSpectrumBand band, WifiPpduField header) const
Calculate the error rate of the PHY header.
NiChangesPerBand m_niChangesPerBand
NI Changes for each band.
std::map< WifiSpectrumBand, double > m_firstPowerPerBand
first power of each band in watts
A base class which provides memory management and object aggregation.
Definition: object.h:89
std::map< WifiPpduField, PhyHeaderChunkInfo > PhyHeaderSections
A map of PhyHeaderChunkInfo elements per PPDU field.
Definition: phy-entity.h:327
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:78
A template-based reference counting class.
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:105
a unique identifier for an interface.
Definition: type-id.h:60
This class mimics the TXVECTOR which is to be passed to the PHY in order to define the parameters whi...
WifiPpduField
The type of PPDU field (grouped for convenience)
Every class exported by the ns3 library is enclosed in the ns3 namespace.
std::pair< uint32_t, uint32_t > WifiSpectrumBand
typedef for a pair of start and stop sub-band indexes
std::map< WifiSpectrumBand, double > RxPowerWattPerChannelBand
A map of the received power (Watts) for each band.
Definition: phy-entity.h:78
std::ostream & operator<<(std::ostream &os, const Angles &a)
Definition: angles.cc:129
value
Definition: second.py:41
Declaration of:
A struct for both SNR and PER.
Definition: phy-entity.h:148