A Discrete-Event Network Simulator
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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
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  */
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"
33 namespace ns3 {
35 class ErrorRateModel;
42 {
43 public:
47  class Event : public SimpleRefCount<InterferenceHelper::Event>
48  {
49 public:
60  Event (uint32_t size, WifiMode payloadMode,
61  enum WifiPreamble preamble,
62  Time duration, double rxPower, WifiTxVector txvector);
63  ~Event ();
70  Time GetDuration (void) const;
76  Time GetStartTime (void) const;
82  Time GetEndTime (void) const;
88  double GetRxPowerW (void) const;
94  uint32_t GetSize (void) const;
100  WifiMode GetPayloadMode (void) const;
106  enum WifiPreamble GetPreambleType (void) const;
112  WifiTxVector GetTxVector (void) const;
113 private:
114  uint32_t m_size;
119  double m_rxPowerW;
121  };
125  struct SnrPer
126  {
127  double snr;
128  double per;
129  };
139  void SetNoiseFigure (double value);
152  double GetNoiseFigure (void) const;
167  Time GetEnergyDuration (double energyW);
180  Ptr<InterferenceHelper::Event> Add (uint32_t size, WifiMode payloadMode,
181  enum WifiPreamble preamble,
182  Time duration, double rxPower, WifiTxVector txvector);
195  void NotifyRxStart ();
199  void NotifyRxEnd ();
203  void EraseEvents (void);
204 private:
208  class NiChange
209  {
210 public:
217  NiChange (Time time, double delta);
223  Time GetTime (void) const;
229  double GetDelta (void) const;
236  bool operator < (const NiChange& o) const;
237 private:
239  double m_delta;
240  };
244  typedef std::vector <NiChange> NiChanges;
248  typedef std::list<Ptr<Event> > Events;
250  //InterferenceHelper (const InterferenceHelper &o);
251  //InterferenceHelper &operator = (const InterferenceHelper &o);
257  void AppendEvent (Ptr<Event> event);
265  double CalculateNoiseInterferenceW (Ptr<Event> event, NiChanges *ni) const;
275  double CalculateSnr (double signal, double noiseInterference, WifiMode mode) const;
285  double CalculateChunkSuccessRate (double snir, Time duration, WifiMode mode) const;
294  double CalculatePer (Ptr<const Event> event, NiChanges *ni) const;
296  double m_noiseFigure;
300  double m_firstPower;
301  bool m_rxing;
303  NiChanges::iterator GetPosition (Time moment);
309  void AddNiChangeEvent (NiChange change);
310 };
312 } // namespace ns3
314 #endif /* INTERFERENCE_HELPER_H */
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:79
A struct for both SNR and PER.
smart pointer class similar to boost::intrusive_ptr
Definition: ptr.h:60
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.
double CalculatePer(Ptr< const Event > event, NiChanges *ni) const
Calculate the error rate of the given packet.
std::vector< NiChange > NiChanges
typedef for a vector of NiChanges
handles interference calculations
Time GetEnergyDuration(double energyW)
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:91
uint32_t GetSize(void) const
Return the size of the packet (bytes).
double CalculateChunkSuccessRate(double snir, Time duration, WifiMode mode) const
Calculate the success rate of the chunk given the SINR, duration, and Wi-Fi mode. ...
The type of preamble to be used by an IEEE 802.11 transmission.
Definition: wifi-preamble.h:29
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.
Ptr< InterferenceHelper::Event > Add(uint32_t size, WifiMode payloadMode, enum WifiPreamble preamble, Time duration, double rxPower, WifiTxVector txvector)
Add the packet-related signal to interference helper.
bool operator<(const int64x64_t &lhs, const int64x64_t &rhs)
Less than operator.
Definition: int64x64-128.h:327
struct InterferenceHelper::SnrPer CalculateSnrPer(Ptr< InterferenceHelper::Event > event)
Calculate the SNIR at the start of the packet and accumulate all SNIR changes in the snir vector...
std::list< Ptr< Event > > Events
typedef for a list of Events
double m_noiseFigure
noise figure (linear)
void NotifyRxStart()
Notify that RX has started.
Noise and Interference (thus Ni) event.
void EraseEvents(void)
Erase all events.
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.
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.
Event(uint32_t size, WifiMode payloadMode, enum WifiPreamble preamble, Time duration, double rxPower, WifiTxVector txvector)
Create an Event with the given parameters.
double CalculateSnr(double signal, double noiseInterference, WifiMode mode) const
Calculate SNR (linear ratio) from the given signal power and noise+interference power.
void AppendEvent(Ptr< Event > event)
Append the given Event.
double GetNoiseFigure(void) const
Return the noise figure.
A template-based reference counting class.