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 <stdint.h>
25 #include <vector>
26 #include <list>
27 #include "wifi-mode.h"
28 #include "wifi-preamble.h"
29 #include "wifi-phy-standard.h"
30 #include "ns3/nstime.h"
31 #include "ns3/simple-ref-count.h"
32 #include "ns3/wifi-tx-vector.h"
33 #include "error-rate-model.h"
34 
35 namespace ns3 {
36 
42 {
43 public:
47  class Event : public SimpleRefCount<InterferenceHelper::Event>
48  {
49 public:
59  Event (uint32_t size, WifiTxVector txVector,
60  enum WifiPreamble preamble,
61  Time duration, double rxPower);
62  ~Event ();
63 
69  Time GetDuration (void) const;
75  Time GetStartTime (void) const;
81  Time GetEndTime (void) const;
87  double GetRxPowerW (void) const;
93  uint32_t GetSize (void) const;
99  WifiTxVector GetTxVector (void) const;
105  WifiMode GetPayloadMode (void) const;
111  enum WifiPreamble GetPreambleType (void) const;
112 
113 
114 private:
115  uint32_t m_size;
120  double m_rxPowerW;
121  };
122 
126  struct SnrPer
127  {
128  double snr;
129  double per;
130  };
131 
134 
140  void SetNoiseFigure (double value);
147 
153  double GetNoiseFigure (void) const;
160 
168  Time GetEnergyDuration (double energyW);
169 
181  Ptr<InterferenceHelper::Event> Add (uint32_t size, WifiTxVector txVector,
182  enum WifiPreamble preamble,
183  Time duration, double rxPower);
184 
190  void AddForeignSignal (Time duration, double rxPower);
208  struct InterferenceHelper::SnrPer CalculatePlcpHeaderSnrPer (Ptr<InterferenceHelper::Event> event);
209 
213  void NotifyRxStart ();
217  void NotifyRxEnd ();
221  void EraseEvents (void);
222 
223 
224 private:
228  class NiChange
229  {
230 public:
237  NiChange (Time time, double delta);
243  Time GetTime (void) const;
249  double GetDelta (void) const;
256  bool operator < (const NiChange& o) const;
257 
258 
259 private:
261  double m_delta;
262  };
266  typedef std::vector <NiChange> NiChanges;
270  typedef std::list<Ptr<Event> > Events;
271 
277  void AppendEvent (Ptr<Event> event);
286  double CalculateNoiseInterferenceW (Ptr<Event> event, NiChanges *ni) const;
297  double CalculateSnr (double signal, double noiseInterference, uint32_t channelWidth) const;
309  double CalculateChunkSuccessRate (double snir, Time duration, WifiMode mode, WifiTxVector txVector) const;
319  double CalculatePlcpPayloadPer (Ptr<const Event> event, NiChanges *ni) const;
329  double CalculatePlcpHeaderPer (Ptr<const Event> event, NiChanges *ni) const;
330 
331  double m_noiseFigure;
334  NiChanges m_niChanges;
335  double m_firstPower;
336  bool m_rxing;
338  NiChanges::iterator GetPosition (Time moment);
344  void AddNiChangeEvent (NiChange change);
345 };
346 
347 } //namespace ns3
348 
349 #endif /* INTERFERENCE_HELPER_H */
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.
A struct for both SNR and PER.
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:73
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...
Signal event for a packet.
std::vector< NiChange > NiChanges
typedef for a vector of NiChanges
handles interference calculations
Time GetEnergyDuration(double energyW)
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. ...
double GetRxPowerW(void) const
Return the receive power (w).
Ptr< ErrorRateModel > m_errorRateModel
NiChanges::iterator GetPosition(Time moment)
Returns an iterator to the first nichange, which is later than moment.
represent a single transmission modeA WifiMode is implemented by a single integer which is used to lo...
Definition: wifi-mode.h:99
uint32_t GetSize(void) const
Return the size of the packet (bytes).
WifiPreamble
The type of preamble to be used by an IEEE 802.11 transmission.
Definition: wifi-preamble.h:30
void SetErrorRateModel(Ptr< ErrorRateModel > rate)
Set the error rate model for this interference helper.
double CalculateNoiseInterferenceW(Ptr< Event > event, NiChanges *ni) const
Calculate noise and interference power in W.
Time GetStartTime(void) const
Return the start time of the signal.
WifiTxVector GetTxVector(void) const
Return the TXVECTOR of the packet.
NiChanges m_niChanges
Experimental: needed for energy duration calculation.
void AddNiChangeEvent(NiChange change)
Add NiChange to the list at the appropriate position.
struct InterferenceHelper::SnrPer CalculatePlcpHeaderSnrPer(Ptr< InterferenceHelper::Event > event)
Calculate the SNIR at the start of the plcp header and accumulate all SNIR changes in the snir vector...
double CalculatePlcpPayloadPer(Ptr< const Event > event, NiChanges *ni) const
Calculate the error rate of the given plcp payload.
bool operator<(const int64x64_t &lhs, const int64x64_t &rhs)
Less than operator.
Definition: int64x64-128.h:356
std::list< Ptr< Event > > Events
typedef for a list of Events
double m_noiseFigure
noise figure (linear)
struct InterferenceHelper::SnrPer CalculatePlcpPayloadSnrPer(Ptr< InterferenceHelper::Event > event)
Calculate the SNIR at the start of the plcp payload and accumulate all SNIR changes in the snir vecto...
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.
Ptr< InterferenceHelper::Event > Add(uint32_t size, WifiTxVector txVector, enum WifiPreamble preamble, Time duration, double rxPower)
Add the packet-related signal to interference helper.
Event(uint32_t size, WifiTxVector txVector, enum WifiPreamble preamble, Time duration, double rxPower)
Create an Event with the given parameters.
double CalculatePlcpHeaderPer(Ptr< const Event > event, NiChanges *ni) const
Calculate the error rate of the plcp header.
Time GetEndTime(void) const
Return the end time of the signal.
enum WifiPreamble GetPreambleType(void) const
Return the preamble type of the packet.
void NotifyRxEnd()
Notify that RX has ended.
double CalculateSnr(double signal, double noiseInterference, uint32_t channelWidth) const
Calculate SNR (linear ratio) from the given signal power and noise+interference power.
Time GetDuration(void) const
Return the duration of the signal.
void SetNoiseFigure(double value)
Set the noise figure.
WifiMode GetPayloadMode(void) const
Return the Wi-Fi mode used for the payload.
void AppendEvent(Ptr< Event > event)
Append the given Event.
double GetNoiseFigure(void) const
Return the noise figure.
A template-based reference counting class.