A Discrete-Event Network Simulator
API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
interference-helper.h
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 
32 namespace ns3 {
33 
34 class ErrorRateModel;
35 
41 {
42 public:
43  class Event : public SimpleRefCount<InterferenceHelper::Event>
44  {
45 public:
46  Event (uint32_t size, WifiMode payloadMode,
47  enum WifiPreamble preamble,
48  Time duration, double rxPower);
49  ~Event ();
50 
51  Time GetDuration (void) const;
52  Time GetStartTime (void) const;
53  Time GetEndTime (void) const;
54  double GetRxPowerW (void) const;
55  uint32_t GetSize (void) const;
56  WifiMode GetPayloadMode (void) const;
57  enum WifiPreamble GetPreambleType (void) const;
58 private:
59  uint32_t m_size;
60  WifiMode m_payloadMode;
61  enum WifiPreamble m_preamble;
62  Time m_startTime;
63  Time m_endTime;
64  double m_rxPowerW;
65  };
66  struct SnrPer
67  {
68  double snr;
69  double per;
70  };
71 
74 
75  void SetNoiseFigure (double value);
76  void SetErrorRateModel (Ptr<ErrorRateModel> rate);
77 
78  double GetNoiseFigure (void) const;
79  Ptr<ErrorRateModel> GetErrorRateModel (void) const;
80 
81 
88  Time GetEnergyDuration (double energyW);
89 
90 
91  Ptr<InterferenceHelper::Event> Add (uint32_t size, WifiMode payloadMode,
92  enum WifiPreamble preamble,
93  Time duration, double rxPower);
94 
95  struct InterferenceHelper::SnrPer CalculateSnrPer (Ptr<InterferenceHelper::Event> event);
96  void NotifyRxStart ();
97  void NotifyRxEnd ();
98  void EraseEvents (void);
99 private:
100  class NiChange
101  {
102 public:
103  NiChange (Time time, double delta);
104  Time GetTime (void) const;
105  double GetDelta (void) const;
106  bool operator < (const NiChange& o) const;
107 private:
108  Time m_time;
109  double m_delta;
110  };
111  typedef std::vector <NiChange> NiChanges;
112  typedef std::list<Ptr<Event> > Events;
113 
115  InterferenceHelper &operator = (const InterferenceHelper &o);
116  void AppendEvent (Ptr<Event> event);
117  double CalculateNoiseInterferenceW (Ptr<Event> event, NiChanges *ni) const;
118  double CalculateSnr (double signal, double noiseInterference, WifiMode mode) const;
119  double CalculateChunkSuccessRate (double snir, Time delay, WifiMode mode) const;
120  double CalculatePer (Ptr<const Event> event, NiChanges *ni) const;
121 
122  double m_noiseFigure;
123  Ptr<ErrorRateModel> m_errorRateModel;
125  NiChanges m_niChanges;
126  double m_firstPower;
127  bool m_rxing;
129  NiChanges::iterator GetPosition (Time moment);
130  void AddNiChangeEvent (NiChange change);
131 };
132 
133 } // namespace ns3
134 
135 #endif /* INTERFERENCE_HELPER_H */
keep track of time unit.
Definition: nstime.h:149
smart pointer class similar to boost::intrusive_ptr
Definition: ptr.h:59
handles interference calculations
Time GetEnergyDuration(double energyW)
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:88
WifiPreamble
Definition: wifi-preamble.h:29
NiChanges m_niChanges
Experimental: needed for energy duration calculation.
A template-based reference counting class.