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 "ns3/nstime.h"
25 #include "wifi-tx-vector.h"
26 #include <map>
27 
28 namespace ns3 {
29 
30 class Packet;
31 class ErrorRateModel;
32 
38 class Event : public SimpleRefCount<Event>
39 {
40 public:
49  Event (Ptr<const Packet> packet, WifiTxVector txVector, Time duration, double rxPower);
50  ~Event ();
51 
56  Ptr<const Packet> GetPacket (void) const;
62  Time GetStartTime (void) const;
68  Time GetEndTime (void) const;
74  double GetRxPowerW (void) const;
80  WifiTxVector GetTxVector (void) const;
86  WifiMode GetPayloadMode (void) const;
87 
88 
89 private:
94  double m_rxPowerW;
95 };
96 
102 {
103 public:
111  struct SnrPer
112  {
113  double snr;
114  double per;
115  };
116 
119 
125  void SetNoiseFigure (double value);
131  void SetErrorRateModel (const Ptr<ErrorRateModel> rate);
132 
145  void SetNumberOfReceiveAntennas (uint8_t rx);
146 
154  Time GetEnergyDuration (double energyW) const;
155 
166  Ptr<Event> Add (Ptr<const Packet> packet, WifiTxVector txVector, Time duration, double rxPower);
167 
173  void AddForeignSignal (Time duration, double rxPower);
192 
196  void NotifyRxStart ();
200  void NotifyRxEnd ();
204  void EraseEvents (void);
205 
206 
207 private:
211  class NiChange
212  {
213 public:
220  NiChange (double power, Ptr<Event> event);
226  double GetPower (void) const;
232  void AddPower (double power);
238  Ptr<Event> GetEvent (void) const;
239 
240 
241 private:
242  double m_power;
244  };
245 
249  typedef std::multimap<Time, NiChange> NiChanges;
250 
256  void AppendEvent (Ptr<Event> event);
265  double CalculateNoiseInterferenceW (Ptr<Event> event, NiChanges *ni) const;
276  double CalculateSnr (double signal, double noiseInterference, uint16_t channelWidth) const;
288  double CalculateChunkSuccessRate (double snir, Time duration, WifiMode mode, WifiTxVector txVector) const;
298  double CalculatePlcpPayloadPer (Ptr<const Event> event, NiChanges *ni) const;
308  double CalculatePlcpHeaderPer (Ptr<const Event> event, NiChanges *ni) const;
309 
310  double m_noiseFigure;
312  uint8_t m_numRxAntennas;
315  double m_firstPower;
316  bool m_rxing;
317 
324  NiChanges::const_iterator GetNextPosition (Time moment) const;
331  //NiChanges::iterator GetNextPosition (Time moment);
338  NiChanges::const_iterator GetPreviousPosition (Time moment) const;
339 
348  NiChanges::iterator AddNiChangeEvent (Time moment, NiChange change);
349 };
350 
351 } //namespace ns3
352 
353 #endif /* INTERFERENCE_HELPER_H */
double GetRxPowerW(void) const
Return the receive power (w).
void AddPower(double power)
Add a given amount of power.
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.
Signal event for a packet.
NiChanges::iterator AddNiChangeEvent(Time moment, NiChange change)
Add NiChange to the list at the appropriate position and return the iterator of the new event...
void SetNumberOfReceiveAntennas(uint8_t rx)
Set the number of RX antennas in the receiver corresponding to this interference helper.
double m_rxPowerW
receive power in watts
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...
Time GetEndTime(void) const
Return the end time of the signal.
double CalculatePlcpPayloadPer(Ptr< const Event > event, NiChanges *ni) const
Calculate the error rate of the given plcp payload.
handles interference calculations
void SetErrorRateModel(const Ptr< ErrorRateModel > rate)
Set the error rate model for this interference helper.
Time GetStartTime(void) const
Return the start time of the signal.
Ptr< Event > GetEvent(void) const
Return the event causes the corresponding NI change.
Ptr< ErrorRateModel > m_errorRateModel
error rate model
represent a single transmission modeA WifiMode is implemented by a single integer which is used to lo...
Definition: wifi-mode.h:97
Event(Ptr< const Packet > packet, WifiTxVector txVector, Time duration, double rxPower)
Create an Event with the given parameters.
struct InterferenceHelper::SnrPer CalculatePlcpHeaderSnrPer(Ptr< Event > event) const
Calculate the SNIR at the start of the plcp header and accumulate all SNIR changes in the snir vector...
WifiMode GetPayloadMode(void) const
Return the Wi-Fi mode used for the payload.
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 CalculateSnr(double signal, double noiseInterference, uint16_t channelWidth) const
Calculate SNR (linear ratio) from the given signal power and noise+interference power.
Time GetEnergyDuration(double energyW) const
Ptr< Event > Add(Ptr< const Packet > packet, WifiTxVector txVector, Time duration, double rxPower)
Add the packet-related signal to interference helper.
NiChanges m_niChanges
Experimental: needed for energy duration calculation.
Ptr< const Packet > GetPacket(void) const
Return the packet.
double CalculateNoiseInterferenceW(Ptr< Event > event, NiChanges *ni) const
Calculate noise and interference power in W.
WifiTxVector GetTxVector(void) const
Return the TXVECTOR of the packet.
double m_noiseFigure
noise figure (linear)
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.
struct InterferenceHelper::SnrPer CalculatePlcpPayloadSnrPer(Ptr< Event > event) const
Calculate the SNIR at the start of the plcp payload and accumulate all SNIR changes in the snir vecto...
uint8_t m_numRxAntennas
the number of RX antennas in the corresponding receiver
void NotifyRxEnd()
Notify that RX has ended.
void SetNoiseFigure(double value)
Set the noise figure.
double m_firstPower
first power
NiChange(double power, Ptr< Event > event)
Create a NiChange at the given time and the amount of NI change.
WifiTxVector m_txVector
TXVECTOR.
void AppendEvent(Ptr< Event > event)
Append the given Event.
Time m_endTime
end time
NiChanges::const_iterator GetNextPosition(Time moment) const
Returns an iterator to the first nichange that is later than moment.
double GetPower(void) const
Return the power.
double CalculatePlcpHeaderPer(Ptr< const Event > event, NiChanges *ni) const
Calculate the error rate of the plcp header.
handles interference calculations
Ptr< const Packet > m_packet
packet
A template-based reference counting class.
NiChanges::const_iterator GetPreviousPosition(Time moment) const
Returns an iterator to the first nichange that is later than moment.
std::multimap< Time, NiChange > NiChanges
typedef for a multimap of NiChanges
bool m_rxing
flag whether it is in receiving state
Time m_startTime
start time