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 "ns3/nstime.h"
25 #include "ns3/wifi-spectrum-value-helper.h"
26 #include "wifi-tx-vector.h"
27 #include <map>
28 
29 namespace ns3 {
30 
31 class WifiPpdu;
32 class WifiPsdu;
34 
38 typedef std::map <WifiSpectrumBand, double> RxPowerWattPerChannelBand;
39 
45 class Event : public SimpleRefCount<Event>
46 {
47 public:
56  Event (Ptr<const WifiPpdu> ppdu, WifiTxVector txVector, Time duration, RxPowerWattPerChannelBand rxPower);
57  ~Event ();
58 
64  Ptr<const WifiPpdu> GetPpdu (void) const;
70  Time GetStartTime (void) const;
76  Time GetEndTime (void) const;
82  Time GetDuration (void) const;
88  double GetRxPowerW (void) const;
95  double GetRxPowerW (WifiSpectrumBand band) const;
107  WifiTxVector GetTxVector (void) const;
108 
109 
110 private:
116 };
117 
125 std::ostream& operator<< (std::ostream& os, const Event &event);
126 
127 
133 {
134 public:
142  struct SnrPer
143  {
144  double snr;
145  double per;
146  };
147 
150 
156  void AddBand (WifiSpectrumBand band);
157 
161  void RemoveBands (void);
162 
168  void SetNoiseFigure (double value);
174  void SetErrorRateModel (const Ptr<ErrorRateModel> rate);
175 
188  void SetNumberOfReceiveAntennas (uint8_t rx);
189 
198  Time GetEnergyDuration (double energyW, WifiSpectrumBand band) const;
199 
210  Ptr<Event> Add (Ptr<const WifiPpdu> ppdu, WifiTxVector txVector, Time duration, RxPowerWattPerChannelBand rxPower);
211 
217  void AddForeignSignal (Time duration, RxPowerWattPerChannelBand rxPower);
233  struct InterferenceHelper::SnrPer CalculatePayloadSnrPer (Ptr<Event> event, uint16_t channelWidth, WifiSpectrumBand band,
234  uint16_t staId, std::pair<Time, Time> relativeMpduStartStop) const;
245  double CalculateSnr (Ptr<Event> event, uint16_t channelWidth, uint8_t nss, WifiSpectrumBand band) const;
255  struct InterferenceHelper::SnrPer CalculateNonHtPhyHeaderSnrPer (Ptr<Event> event, WifiSpectrumBand band) const;
265  struct InterferenceHelper::SnrPer CalculateHtPhyHeaderSnrPer (Ptr<Event> event, WifiSpectrumBand band) const;
266 
270  void NotifyRxStart ();
274  void NotifyRxEnd ();
278  void EraseEvents (void);
279 
280 
281 protected:
292  double CalculateSnr (double signal, double noiseInterference, uint16_t channelWidth, uint8_t nss) const;
304  double CalculateChunkSuccessRate (double snir, Time duration, WifiMode mode, WifiTxVector txVector) const;
305 
306 
307 private:
311  class NiChange
312  {
313 public:
320  NiChange (double power, Ptr<Event> event);
326  double GetPower (void) const;
332  void AddPower (double power);
338  Ptr<Event> GetEvent (void) const;
339 
340 
341 private:
342  double m_power;
344  };
345 
349  typedef std::multimap<Time, NiChange> NiChanges;
350 
354  typedef std::map <WifiSpectrumBand, NiChanges> NiChangesPerBand;
355 
361  void AppendEvent (Ptr<Event> event);
383  double CalculatePayloadChunkSuccessRate (double snir, Time duration, WifiTxVector txVector, uint16_t staId) const;
398  double CalculatePayloadPer (Ptr<const Event> event, uint16_t channelWidth, NiChangesPerBand *nis, WifiSpectrumBand band,
399  uint16_t staId, std::pair<Time, Time> window) const;
422 
423  double m_noiseFigure;
425  uint8_t m_numRxAntennas;
427  std::map <WifiSpectrumBand, double> m_firstPowerPerBand;
428  bool m_rxing;
429 
437  NiChanges::const_iterator GetNextPosition (Time moment, WifiSpectrumBand band) const;
445  NiChanges::const_iterator GetPreviousPosition (Time moment, WifiSpectrumBand band) const;
446 
456  NiChanges::iterator AddNiChangeEvent (Time moment, NiChange change, WifiSpectrumBand band);
457 };
458 
459 } //namespace ns3
460 
461 #endif /* INTERFERENCE_HELPER_H */
double GetRxPowerW(void) const
Return the total received power (W).
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...
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:103
NiChanges::const_iterator GetNextPosition(Time moment, WifiSpectrumBand band) const
Returns an iterator to the first NiChange that is later than moment.
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:73
Time GetEnergyDuration(double energyW, WifiSpectrumBand band) const
void SetNumberOfReceiveAntennas(uint8_t rx)
Set the number of RX antennas in the receiver corresponding to this interference helper.
Ptr< ErrorRateModel > GetErrorRateModel(void) const
Return the error rate model.
This class mimics the TXVECTOR which is to be passed to the PHY in order to define the parameters whi...
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 ...
Time GetEndTime(void) const
Return the end time of the signal.
void RemoveBands(void)
Remove the frequency bands.
handles interference calculations
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...
void SetErrorRateModel(const Ptr< ErrorRateModel > rate)
Set the error rate model for this interference helper.
NiChangesPerBand m_niChangesPerBand
NI Changes for each band.
Time GetStartTime(void) const
Return the start time of the signal.
Ptr< const WifiPpdu > GetPpdu(void) const
Return the PPDU.
Event(Ptr< const WifiPpdu > ppdu, WifiTxVector txVector, Time duration, RxPowerWattPerChannelBand rxPower)
Create an Event with the given parameters.
STL namespace.
Ptr< ErrorRateModel > m_errorRateModel
error rate model
Ptr< Event > Add(Ptr< const WifiPpdu > ppdu, WifiTxVector txVector, Time duration, RxPowerWattPerChannelBand rxPower)
Add the PPDU-related signal to interference helper.
double snr
SNR in linear scale.
Ptr< const WifiPpdu > m_ppdu
PPDU.
the interface for Wifi&#39;s error models
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...
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. ...
std::map< WifiSpectrumBand, double > m_firstPowerPerBand
first power of each band in watts
Time GetDuration(void) const
Return the duration of the signal.
std::map< WifiSpectrumBand, NiChanges > NiChangesPerBand
Map of NiChanges per band.
std::pair< uint32_t, uint32_t > WifiSpectrumBand
typedef for a pair of start and stop sub-band indexes
WifiTxVector GetTxVector(void) const
Return the TXVECTOR of the PPDU.
std::ostream & operator<<(std::ostream &os, const Angles &a)
print a struct Angles to output
Definition: angles.cc:42
double m_noiseFigure
noise figure (linear)
double CalculateNonHtPhyHeaderPer(Ptr< const Event > event, NiChangesPerBand *nis, WifiSpectrumBand band) const
Calculate the error rate of the non-HT PHY header.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
void NotifyRxStart()
Notify that RX has started.
Noise and Interference (thus Ni) event.
void EraseEvents(void)
Erase all events.
uint8_t m_numRxAntennas
the number of RX antennas in the corresponding receiver
void AddBand(WifiSpectrumBand band)
Add a frequency band.
double CalculateNoiseInterferenceW(Ptr< Event > event, NiChangesPerBand *nis, WifiSpectrumBand band) const
Calculate noise and interference power in W.
NiChanges::const_iterator GetPreviousPosition(Time moment, WifiSpectrumBand band) const
Returns an iterator to the last NiChange that is before than moment.
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 vect...
void NotifyRxEnd()
Notify that RX has ended.
void AddForeignSignal(Time duration, RxPowerWattPerChannelBand rxPower)
Add a non-Wifi signal to interference helper.
double CalculateHtPhyHeaderPer(Ptr< const Event > event, NiChangesPerBand *nis, WifiSpectrumBand band) const
Calculate the error rate of the HT PHY header.
void SetNoiseFigure(double value)
Set the noise figure.
RxPowerWattPerChannelBand m_rxPowerW
received power in watts per band
WifiTxVector m_txVector
TXVECTOR.
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...
void AppendEvent(Ptr< Event > event)
Append the given Event.
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).
Time m_endTime
end time
handles interference calculations
RxPowerWattPerChannelBand GetRxPowerWPerBand(void) const
Return the received power (W) for all bands.
A template-based reference counting class.
std::map< WifiSpectrumBand, double > RxPowerWattPerChannelBand
A map of the received power (Watts) for each band.
std::multimap< Time, NiChange > NiChanges
typedef for a multimap of NiChange
bool m_rxing
flag whether it is in receiving state
Time m_startTime
start time