23 #include "ns3/simulator.h" 
   37                                   Time duration, 
double rxPower)
 
   39     m_txVector (txVector),
 
   40     m_preamble (preamble),
 
   42     m_endTime (m_startTime + duration),
 
   53   return m_endTime - m_startTime;
 
   83   return m_txVector.GetMode();
 
  115   return (m_time < o.
m_time);
 
  137                          Time duration, 
double rxPowerW)
 
  141   event = Create<InterferenceHelper::Event> (size,
 
  179   double noiseInterferenceW = 0.0;
 
  184       noiseInterferenceW += i->GetDelta ();
 
  190       if (noiseInterferenceW < energyW)
 
  204       NiChanges::iterator nowIterator = 
GetPosition (now);
 
  205       for (NiChanges::iterator i = 
m_niChanges.begin (); i != nowIterator; i++)
 
  225   static const double BOLTZMANN = 1.3803e-23;
 
  230   double noise = noiseFloor + noiseInterference;
 
  231   double snr = signal / noise;
 
  242       if ((event->GetEndTime () == i->GetTime ()) && event->GetRxPowerW () == -i->GetDelta ())
 
  248   ni->insert (ni->begin (), 
NiChange (event->GetStartTime (), noiseInterference));
 
  249   ni->push_back (
NiChange (event->GetEndTime (), 0));
 
  250   return noiseInterference;
 
  261   uint64_t nbits = (uint64_t)(rate * duration.
GetSeconds ());
 
  262   double csr = 
m_errorRateModel->GetChunkSuccessRate (mode, snir, (uint32_t)nbits);
 
  270   NiChanges::iterator j = ni->begin ();
 
  271   Time previous = (*j).GetTime ();
 
  272   WifiMode payloadMode = 
event->GetPayloadMode ();
 
  278   double noiseInterferenceW = (*j).GetDelta ();
 
  279   double powerW = 
event->GetRxPowerW ();
 
  281   while (ni->end () != j)
 
  283       Time current = (*j).GetTime ();
 
  286       if (previous >= plcpPayloadStart)
 
  295       else if (previous >= plcpHtTrainingSymbolsStart)
 
  298           if (current >= plcpPayloadStart)
 
  304                                                  current - plcpPayloadStart,
 
  310       else if (previous >= plcpHsigHeaderStart)
 
  313           if (current >= plcpPayloadStart)
 
  318                                                      current - plcpPayloadStart,
 
  325       else if (previous >= plcpHeaderStart)
 
  328           if (current >= plcpPayloadStart)
 
  333                                                      current - plcpPayloadStart,
 
  341           if (current >= plcpPayloadStart)
 
  347                                                 current - plcpPayloadStart,
 
  353       noiseInterferenceW += (*j).GetDelta ();
 
  354       previous = (*j).GetTime ();
 
  358   double per = 1 - psr;
 
  366   NiChanges::iterator j = ni->begin ();
 
  367   Time previous = (*j).GetTime ();
 
  368   WifiMode payloadMode = 
event->GetPayloadMode ();
 
  380   double noiseInterferenceW = (*j).GetDelta ();
 
  381   double powerW = 
event->GetRxPowerW ();
 
  383   while (ni->end () != j)
 
  385       Time current = (*j).GetTime ();
 
  388       if (previous >= plcpHsigHeaderStart)
 
  391           if (current >= plcpPayloadStart)
 
  398                                                       plcpHtTrainingSymbolsStart - previous,
 
  402           else if (current >=plcpHtTrainingSymbolsStart)
 
  407                                                   plcpHtTrainingSymbolsStart - previous,
 
  423       else if (previous >= plcpHeaderStart)
 
  426           if (current >= plcpPayloadStart)
 
  434                                                       plcpPayloadStart - previous,
 
  442                                                       plcpHtTrainingSymbolsStart - plcpHsigHeaderStart,
 
  447                                                       plcpHsigHeaderStart - previous,
 
  452           else if (current >= plcpHtTrainingSymbolsStart)
 
  457                                                   plcpHtTrainingSymbolsStart - plcpHsigHeaderStart,
 
  462                                                    plcpHsigHeaderStart - previous,
 
  466           else if (current >= plcpHsigHeaderStart)
 
  471                                                   current - plcpHsigHeaderStart,
 
  476                                                    plcpHsigHeaderStart - previous,
 
  505           if (current >= plcpPayloadStart)
 
  512                                                    plcpPayloadStart - plcpHeaderStart,
 
  519                                                   plcpHtTrainingSymbolsStart - plcpHsigHeaderStart,
 
  525                                                    plcpHsigHeaderStart-plcpHeaderStart,
 
  528           else if (current >= plcpHtTrainingSymbolsStart )
 
  535                                                 plcpHtTrainingSymbolsStart - plcpHsigHeaderStart,
 
  543                                                       plcpHsigHeaderStart-plcpHeaderStart,
 
  548           else if (current >= plcpHsigHeaderStart)
 
  553                                                   current- plcpHsigHeaderStart,
 
  560                                                      plcpHsigHeaderStart-plcpHeaderStart,
 
  565           else if (current >= plcpHeaderStart)
 
  572                                                    current - plcpHeaderStart,
 
  580                                                 current - plcpHeaderStart,
 
  586       noiseInterferenceW += (*j).GetDelta ();
 
  587       previous = (*j).GetTime ();
 
  591   double per = 1 - psr;
 
  602                              event->GetPayloadMode ());
 
  642 InterferenceHelper::NiChanges::iterator
 
Simulation virtual time values and global simulation resolution. 
 
A struct for both SNR and PER. 
 
Smart pointer class similar to boost::intrusive_ptr. 
 
Control the scheduling of simulation events. 
 
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...
 
bool operator<(const NiChange &o) const 
Compare the event time of two NiChange objects (a < o). 
 
std::vector< NiChange > NiChanges
typedef for a vector of NiChanges 
 
handles interference calculations 
 
static Time GetPlcpHtSigHeaderDuration(WifiPreamble preamble)
 
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file...
 
Time GetEnergyDuration(double energyW)
 
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name. 
 
static WifiMode GetMFPlcpHeaderMode(WifiMode payloadMode, WifiPreamble preamble)
 
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...
 
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. ...
 
WifiPreamble
The type of preamble to be used by an IEEE 802.11 transmission. 
 
void SetErrorRateModel(Ptr< ErrorRateModel > rate)
Set the error rate model for this interference helper. 
 
double GetSeconds(void) const 
Get an approximation of the time stored in this instance in the indicated unit. 
 
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. 
 
Time NanoSeconds(uint64_t value)
Construct a Time in the indicated unit. 
 
NiChanges m_niChanges
Experimental: needed for energy duration calculation. 
 
void AddNiChangeEvent(NiChange change)
Add NiChange to the list at the appropriate position. 
 
static WifiMode GetPlcpHeaderMode(WifiMode payloadMode, WifiPreamble preamble)
 
Time GetTime(void) const 
Return the event time. 
 
double CalculatePlcpPayloadPer(Ptr< const Event > event, NiChanges *ni) const 
Calculate the error rate of the given plcp payload. 
 
uint32_t GetBandwidth(void) const 
 
static Time GetPlcpHeaderDuration(WifiMode payloadMode, WifiPreamble preamble)
 
double m_noiseFigure
noise figure (linear) 
 
static Time GetPlcpHtTrainingSymbolDuration(WifiPreamble preamble, WifiTxVector txvector)
 
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. 
 
Ptr< InterferenceHelper::Event > Add(uint32_t size, WifiTxVector txvector, enum WifiPreamble preamble, Time duration, double rxPower)
Add the packet-related signal to interference helper. 
 
uint64_t GetPhyRate(void) const 
 
double CalculatePlcpHeaderPer(Ptr< const Event > event, NiChanges *ni) const 
Calculate the error rate of the plcp header. 
 
double GetDelta(void) const 
Return the power. 
 
static Time Now(void)
Return the current simulation virtual time. 
 
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. 
 
NiChange(Time time, double delta)
Create a NiChange at the given time and the amount of NI change. 
 
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. 
 
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. 
 
Time MicroSeconds(uint64_t value)
Construct a Time in the indicated unit. 
 
Time Now(void)
create an ns3::Time instance which contains the current simulation time. 
 
double GetNoiseFigure(void) const 
Return the noise figure. 
 
Event(uint32_t size, WifiTxVector txvector, enum WifiPreamble preamble, Time duration, double rxPower)
Create an Event with the given parameters. 
 
static Time GetPlcpPreambleDuration(WifiMode payloadMode, WifiPreamble preamble)