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 "wifi-tx-vector.h"
26 #include <map>
27 
28 namespace ns3 {
29 
30 class WifiPpdu;
31 class WifiPsdu;
32 class ErrorRateModel;
33 
39 class Event : public SimpleRefCount<Event>
40 {
41 public:
50  Event (Ptr<const WifiPpdu> ppdu, WifiTxVector txVector, Time duration, double rxPower);
51  ~Event ();
52 
58  Ptr<const WifiPsdu> GetPsdu (void) const;
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;
94  WifiTxVector GetTxVector (void) const;
95 
96 
97 private:
102  double m_rxPowerW;
103 };
104 
112 std::ostream& operator<< (std::ostream& os, const Event &event);
113 
114 
120 {
121 public:
129  struct SnrPer
130  {
131  double snr;
132  double per;
133  };
134 
137 
143  void SetNoiseFigure (double value);
149  void SetErrorRateModel (const Ptr<ErrorRateModel> rate);
150 
163  void SetNumberOfReceiveAntennas (uint8_t rx);
164 
172  Time GetEnergyDuration (double energyW) const;
173 
183  Ptr<Event> Add (Ptr<const WifiPpdu> ppdu, WifiTxVector txVector, Time duration, double rxPower);
184 
190  void AddForeignSignal (Time duration, double rxPower);
203  struct InterferenceHelper::SnrPer CalculatePayloadSnrPer (Ptr<Event> event, std::pair<Time, Time> relativeMpduStartStop) const;
211  double CalculateSnr (Ptr<Event> event) const;
220  struct InterferenceHelper::SnrPer CalculateNonHtPhyHeaderSnrPer (Ptr<Event> event) const;
229  struct InterferenceHelper::SnrPer CalculateHtPhyHeaderSnrPer (Ptr<Event> event) const;
230 
234  void NotifyRxStart ();
238  void NotifyRxEnd ();
242  void EraseEvents (void);
243 
244 
245 private:
249  class NiChange
250  {
251 public:
258  NiChange (double power, Ptr<Event> event);
264  double GetPower (void) const;
270  void AddPower (double power);
276  Ptr<Event> GetEvent (void) const;
277 
278 
279 private:
280  double m_power;
282  };
283 
287  typedef std::multimap<Time, NiChange> NiChanges;
288 
294  void AppendEvent (Ptr<Event> event);
303  double CalculateNoiseInterferenceW (Ptr<Event> event, NiChanges *ni) const;
313  double CalculateSnr (double signal, double noiseInterference, uint16_t channelWidth) const;
325  double CalculateChunkSuccessRate (double snir, Time duration, WifiMode mode, WifiTxVector txVector) const;
336  double CalculatePayloadChunkSuccessRate (double snir, Time duration, WifiTxVector txVector) const;
348  double CalculatePayloadPer (Ptr<const Event> event, NiChanges *ni, std::pair<Time, Time> window) const;
358  double CalculateNonHtPhyHeaderPer (Ptr<const Event> event, NiChanges *ni) const;
368  double CalculateHtPhyHeaderPer (Ptr<const Event> event, NiChanges *ni) const;
369 
370  double m_noiseFigure;
372  uint8_t m_numRxAntennas;
375  double m_firstPower;
376  bool m_rxing;
377 
384  NiChanges::const_iterator GetNextPosition (Time moment) const;
391  //NiChanges::iterator GetNextPosition (Time moment);
398  NiChanges::const_iterator GetPreviousPosition (Time moment) const;
399 
408  NiChanges::iterator AddNiChangeEvent (Time moment, NiChange change);
409 };
410 
411 } //namespace ns3
412 
413 #endif /* INTERFERENCE_HELPER_H */
double GetRxPowerW(void) const
Return the received power (w).
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:102
void AddForeignSignal(Time duration, double rxPower)
Add a non-Wifi signal to interference helper.
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:73
NiChanges::iterator AddNiChangeEvent(Time moment, NiChange change)
Add NiChange to the list at the appropriate position and return the iterator of the new event...
void SetNumberOfReceiveAntennas(uint8_t rx)
Set the number of RX antennas in the receiver corresponding to this interference helper.
double m_rxPowerW
received power in watts
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...
Time GetEndTime(void) const
Return the end time of the signal.
handles interference calculations
double CalculateNonHtPhyHeaderPer(Ptr< const Event > event, NiChanges *ni) const
Calculate the error rate of the non-HT PHY header.
void SetErrorRateModel(const Ptr< ErrorRateModel > rate)
Set the error rate model for this interference helper.
Time GetStartTime(void) const
Return the start time of the signal.
Ptr< const WifiPpdu > GetPpdu(void) const
Return the PPDU.
STL namespace.
Ptr< ErrorRateModel > m_errorRateModel
error rate model
represent a single transmission modeA WifiMode is implemented by a single integer which is used to lo...
Definition: wifi-mode.h:97
double snr
SNR in linear scale.
Ptr< const WifiPpdu > m_ppdu
PPDU.
struct InterferenceHelper::SnrPer CalculateNonHtPhyHeaderSnrPer(Ptr< Event > event) const
Calculate the SNIR at the start of the non-HT PHY header and accumulate all SNIR changes in the SNIR ...
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. ...
Time GetEnergyDuration(double energyW) const
NiChanges m_niChanges
Experimental: needed for energy duration calculation.
double CalculatePayloadChunkSuccessRate(double snir, Time duration, WifiTxVector txVector) const
Calculate the success rate of the payload chunk given the SINR, duration, and Wi-Fi mode...
Time GetDuration(void) const
Return the duration of the signal.
double CalculateNoiseInterferenceW(Ptr< Event > event, NiChanges *ni) const
Calculate noise and interference power in W.
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)
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.
struct InterferenceHelper::SnrPer CalculateHtPhyHeaderSnrPer(Ptr< Event > event) const
Calculate the SNIR at the start of the HT PHY header and accumulate all SNIR changes in the SNIR vect...
double CalculateSnr(Ptr< Event > event) const
Calculate the SNIR for the event (starting from now until the event end).
uint8_t m_numRxAntennas
the number of RX antennas in the corresponding receiver
double CalculateHtPhyHeaderPer(Ptr< const Event > event, NiChanges *ni) const
Calculate the error rate of the HT PHY header.
Ptr< Event > Add(Ptr< const WifiPpdu > ppdu, WifiTxVector txVector, Time duration, double rxPower)
Add the PPDU-related signal to interference helper.
struct InterferenceHelper::SnrPer CalculatePayloadSnrPer(Ptr< Event > event, 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...
Event(Ptr< const WifiPpdu > ppdu, WifiTxVector txVector, Time duration, double rxPower)
Create an Event with the given parameters.
void NotifyRxEnd()
Notify that RX has ended.
void SetNoiseFigure(double value)
Set the noise figure.
double m_firstPower
first power in watts
double CalculatePayloadPer(Ptr< const Event > event, NiChanges *ni, std::pair< Time, Time > window) const
Calculate the error rate of the given PHY payload only in the provided time window (thus enabling per...
WifiTxVector m_txVector
TXVECTOR.
void AppendEvent(Ptr< Event > event)
Append the given Event.
Time m_endTime
end time
NiChanges::const_iterator GetNextPosition(Time moment) const
Returns an iterator to the first NiChange that is later than moment.
handles interference calculations
Ptr< const WifiPsdu > GetPsdu(void) const
Return the PSDU in the PPDU.
A template-based reference counting class.
NiChanges::const_iterator GetPreviousPosition(Time moment) const
Returns an iterator to the first NiChange that is later than moment.
std::multimap< Time, NiChange > NiChanges
typedef for a multimap of NiChanges
bool m_rxing
flag whether it is in receiving state
Time m_startTime
start time