replace RefCountBase with SimpleRefCount<> to avoid duplicate refcounting implementations.
1 /* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
3 * Copyright (c) 2005,2006 INRIA
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;
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.
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
18 * Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
20 #ifndef INTERFERENCE_HELPER_H
21 #define INTERFERENCE_HELPER_H
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"
36 class InterferenceHelper
39 class Event : public SimpleRefCount<InterferenceHelper::Event>
42 Event (uint32_t size, WifiMode payloadMode,
43 enum WifiPreamble preamble,
44 Time duration, double rxPower);
47 Time GetDuration (void) const;
48 Time GetStartTime (void) const;
49 Time GetEndTime (void) const;
50 bool Overlaps (Time time) const;
51 double GetRxPowerW (void) const;
52 uint32_t GetSize (void) const;
53 WifiMode GetPayloadMode (void) const;
54 enum WifiPreamble GetPreambleType (void) const;
57 WifiMode m_payloadMode;
58 enum WifiPreamble m_preamble;
69 InterferenceHelper ();
70 ~InterferenceHelper ();
72 void SetNoiseFigure (double value);
73 void SetErrorRateModel (Ptr<ErrorRateModel> rate);
75 double GetNoiseFigure (void) const;
76 Ptr<ErrorRateModel> GetErrorRateModel (void) const;
80 * \param energyW the minimum energy (W) requested
81 * \returns the expected amount of time the observed
82 * energy on the medium will be higher than
83 * the requested threshold.
85 Time GetEnergyDuration (double energyW);
88 static WifiMode GetPlcpHeaderMode (WifiMode payloadMode, WifiPreamble preamble);
89 static uint32_t GetPlcpHeaderDurationMicroSeconds (WifiMode payloadMode, WifiPreamble preamble);
90 static uint32_t GetPlcpPreambleDurationMicroSeconds (WifiMode mode, WifiPreamble preamble);
91 static uint32_t GetPayloadDurationMicroSeconds (uint32_t size, WifiMode payloadMode);
92 static Time CalculateTxDuration (uint32_t size, WifiMode payloadMode, WifiPreamble preamble);
93 Ptr<InterferenceHelper::Event> Add (uint32_t size, WifiMode payloadMode,
94 enum WifiPreamble preamble,
95 Time duration, double rxPower);
97 struct InterferenceHelper::SnrPer CalculateSnrPer (Ptr<InterferenceHelper::Event> event);
98 void EraseEvents (void);
102 NiChange (Time time, double delta);
103 Time GetTime (void) const;
104 double GetDelta (void) const;
105 bool operator < (NiChange const &o) const;
110 typedef std::vector <NiChange> NiChanges;
111 typedef std::list<Ptr<Event> > Events;
113 void EraseEvents (Events::iterator start, Events::iterator end);
115 InterferenceHelper (const InterferenceHelper &o);
116 InterferenceHelper &operator = (const InterferenceHelper &o);
117 void AppendEvent (Ptr<Event> event);
118 double CalculateNoiseInterferenceW (Ptr<Event> event, NiChanges *ni) const;
119 double CalculateSnr (double signal, double noiseInterference, WifiMode mode) const;
120 double CalculateChunkSuccessRate (double snir, Time delay, WifiMode mode) const;
121 double CalculatePer (Ptr<const Event> event, NiChanges *ni) const;
122 Time GetMaxPacketDuration (void) const;
124 Time m_maxPacketDuration;
125 double m_noiseFigure; /**< noise figure (linear) */
127 Ptr<ErrorRateModel> m_errorRateModel;
132 #endif /* INTERFERENCE_HELPER_H */