A Discrete-Event Network Simulator
API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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 #ifndef INTERFERENCE_HELPER_H
21 #define INTERFERENCE_HELPER_H
22 
23 #include <stdint.h>
24 #include <vector>
25 #include <list>
26 #include "wifi-mode.h"
27 #include "wifi-preamble.h"
28 #include "wifi-phy-standard.h"
29 #include "ns3/nstime.h"
30 #include "ns3/simple-ref-count.h"
31 #include "ns3/wifi-tx-vector.h"
32 
33 namespace ns3 {
34 
35 class ErrorRateModel;
36 
42 {
43 public:
44  class Event : public SimpleRefCount<InterferenceHelper::Event>
45  {
46 public:
47  Event (uint32_t size, WifiMode payloadMode,
48  enum WifiPreamble preamble,
49  Time duration, double rxPower, WifiTxVector txvector);
50  ~Event ();
51 
52  Time GetDuration (void) const;
53  Time GetStartTime (void) const;
54  Time GetEndTime (void) const;
55  double GetRxPowerW (void) const;
56  uint32_t GetSize (void) const;
57  WifiMode GetPayloadMode (void) const;
58  enum WifiPreamble GetPreambleType (void) const;
59  WifiTxVector GetTxVector (void) const;
60 private:
61  uint32_t m_size;
66  double m_rxPowerW;
68  };
69  struct SnrPer
70  {
71  double snr;
72  double per;
73  };
74 
77 
78  void SetNoiseFigure (double value);
80 
81  double GetNoiseFigure (void) const;
83 
84 
91  Time GetEnergyDuration (double energyW);
92 
93 
94  Ptr<InterferenceHelper::Event> Add (uint32_t size, WifiMode payloadMode,
95  enum WifiPreamble preamble,
96  Time duration, double rxPower, WifiTxVector txvector);
97 
99  void NotifyRxStart ();
100  void NotifyRxEnd ();
101  void EraseEvents (void);
102 private:
103  class NiChange
104  {
105 public:
106  NiChange (Time time, double delta);
107  Time GetTime (void) const;
108  double GetDelta (void) const;
109  bool operator < (const NiChange& o) const;
110 private:
112  double m_delta;
113  };
114  typedef std::vector <NiChange> NiChanges;
115  typedef std::list<Ptr<Event> > Events;
116 
119  void AppendEvent (Ptr<Event> event);
120  double CalculateNoiseInterferenceW (Ptr<Event> event, NiChanges *ni) const;
121  double CalculateSnr (double signal, double noiseInterference, WifiMode mode) const;
122  double CalculateChunkSuccessRate (double snir, Time delay, WifiMode mode) const;
123  double CalculatePer (Ptr<const Event> event, NiChanges *ni) const;
124 
125  double m_noiseFigure;
129  double m_firstPower;
130  bool m_rxing;
132  NiChanges::iterator GetPosition (Time moment);
133  void AddNiChangeEvent (NiChange change);
134 };
135 
136 } // namespace ns3
137 
138 #endif /* INTERFERENCE_HELPER_H */
keep track of time values and allow control of global simulation resolution
Definition: nstime.h:81
smart pointer class similar to boost::intrusive_ptr
Definition: ptr.h:59
Ptr< ErrorRateModel > GetErrorRateModel(void) const
double CalculatePer(Ptr< const Event > event, NiChanges *ni) const
std::vector< NiChange > NiChanges
handles interference calculations
Time GetEnergyDuration(double energyW)
bool operator<(const Room &a, const Room &b)
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:91
WifiPreamble
Definition: wifi-preamble.h:29
void SetErrorRateModel(Ptr< ErrorRateModel > rate)
double CalculateNoiseInterferenceW(Ptr< Event > event, NiChanges *ni) const
WifiTxVector GetTxVector(void) const
NiChanges m_niChanges
Experimental: needed for energy duration calculation.
void AddNiChangeEvent(NiChange change)
Ptr< InterferenceHelper::Event > Add(uint32_t size, WifiMode payloadMode, enum WifiPreamble preamble, Time duration, double rxPower, WifiTxVector txvector)
struct InterferenceHelper::SnrPer CalculateSnrPer(Ptr< InterferenceHelper::Event > event)
std::list< Ptr< Event > > Events
double CalculateChunkSuccessRate(double snir, Time delay, WifiMode mode) const
enum WifiPreamble GetPreambleType(void) const
void SetNoiseFigure(double value)
WifiMode GetPayloadMode(void) const
Event(uint32_t size, WifiMode payloadMode, enum WifiPreamble preamble, Time duration, double rxPower, WifiTxVector txvector)
double CalculateSnr(double signal, double noiseInterference, WifiMode mode) const
void AppendEvent(Ptr< Event > event)
double GetNoiseFigure(void) const
A template-based reference counting class.
InterferenceHelper & operator=(const InterferenceHelper &o)