A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
interference-helper.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2005,2006 INRIA
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation;
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program; if not, write to the Free Software
15 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16 *
17 * Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
18 */
19
20#ifndef INTERFERENCE_HELPER_H
21#define INTERFERENCE_HELPER_H
22
23#include "phy-entity.h"
24
25#include "ns3/object.h"
26
27namespace ns3
28{
29
30class WifiPpdu;
31class WifiPsdu;
32class ErrorRateModel;
33
39class Event : public SimpleRefCount<Event>
40{
41 public:
52 const WifiTxVector& txVector,
53 Time duration,
55 ~Event();
56
68 Time GetStartTime() const;
74 Time GetEndTime() const;
80 Time GetDuration() const;
86 double GetRxPowerW() const;
93 double GetRxPowerW(const WifiSpectrumBandInfo& band) const;
105 const WifiTxVector& GetTxVector() const;
112 void UpdateRxPowerW(const RxPowerWattPerChannelBand& rxPower);
113
114 private:
120};
121
129std::ostream& operator<<(std::ostream& os, const Event& event);
130
136{
137 public:
139 ~InterferenceHelper() override;
140
145 static TypeId GetTypeId();
146
152 void AddBand(const WifiSpectrumBandInfo& band);
153
159 bool HasBands() const;
160
168 void UpdateBands(const std::vector<WifiSpectrumBandInfo>& bands,
169 const FrequencyRange& freqRange);
170
176 void SetNoiseFigure(double value);
182 void SetErrorRateModel(const Ptr<ErrorRateModel> rate);
183
196 void SetNumberOfReceiveAntennas(uint8_t rx);
197
206 Time GetEnergyDuration(double energyW, const WifiSpectrumBandInfo& band);
207
222 const WifiTxVector& txVector,
223 Time duration,
225 bool isStartOfdmaRxing = false);
226
232 void AddForeignSignal(Time duration, RxPowerWattPerChannelBand& rxPower);
250 uint16_t channelWidth,
251 const WifiSpectrumBandInfo& band,
252 uint16_t staId,
253 std::pair<Time, Time> relativeMpduStartStop) const;
264 double CalculateSnr(Ptr<Event> event,
265 uint16_t channelWidth,
266 uint8_t nss,
267 const WifiSpectrumBandInfo& band) const;
280 uint16_t channelWidth,
281 const WifiSpectrumBandInfo& band,
282 WifiPpduField header) const;
283
287 void NotifyRxStart();
294 void NotifyRxEnd(Time endTime, const FrequencyRange& freqRange);
295
302 void UpdateEvent(Ptr<Event> event, const RxPowerWattPerChannelBand& rxPower);
303
304 protected:
305 void DoDispose() override;
306
317 double CalculateSnr(double signal,
318 double noiseInterference,
319 uint16_t channelWidth,
320 uint8_t nss) const;
333 double CalculateChunkSuccessRate(double snir,
334 Time duration,
335 WifiMode mode,
336 const WifiTxVector& txVector,
337 WifiPpduField field) const;
350 double CalculatePayloadChunkSuccessRate(double snir,
351 Time duration,
352 const WifiTxVector& txVector,
353 uint16_t staId = SU_STA_ID) const;
354
355 private:
360 {
361 public:
368 NiChange(double power, Ptr<Event> event);
369 ~NiChange();
375 double GetPower() const;
381 void AddPower(double power);
387 Ptr<Event> GetEvent() const;
388
389 private:
390 double m_power;
392 };
393
397 using NiChanges = std::multimap<Time, NiChange>;
398
402 using NiChangesPerBand = std::map<WifiSpectrumBandInfo, NiChanges>;
403
407 using FirstPowerPerBand = std::map<WifiSpectrumBandInfo, double>;
408
415 bool HasBand(const WifiSpectrumBandInfo& band) const;
416
425 const FrequencyRange& freqRange) const;
426
434 void AppendEvent(Ptr<Event> event, bool isStartOfdmaRxing);
435
446 NiChangesPerBand* nis,
447 const WifiSpectrumBandInfo& band) const;
463 uint16_t channelWidth,
464 NiChangesPerBand* nis,
465 const WifiSpectrumBandInfo& band,
466 uint16_t staId,
467 std::pair<Time, Time> window) const;
481 NiChangesPerBand* nis,
482 uint16_t channelWidth,
483 const WifiSpectrumBandInfo& band,
484 WifiPpduField header) const;
497 NiChangesPerBand* nis,
498 uint16_t channelWidth,
499 const WifiSpectrumBandInfo& band,
500 PhyEntity::PhyHeaderSections phyHeaderSections) const;
501
507 bool m_rxing;
508
516 NiChanges::iterator GetNextPosition(Time moment, NiChangesPerBand::iterator niIt);
524 NiChanges::iterator GetPreviousPosition(Time moment, NiChangesPerBand::iterator niIt);
525
535 NiChanges::iterator AddNiChangeEvent(Time moment,
536 NiChange change,
537 NiChangesPerBand::iterator niIt);
538};
539
540} // namespace ns3
541
542#endif /* INTERFERENCE_HELPER_H */
handles interference calculations
Time m_endTime
end time
WifiTxVector m_txVector
TXVECTOR.
Time m_startTime
start time
Ptr< const WifiPpdu > GetPpdu() const
Return the PPDU.
Ptr< const WifiPpdu > m_ppdu
PPDU.
void UpdateRxPowerW(const RxPowerWattPerChannelBand &rxPower)
Update the received power (W) for all bands, i.e.
Time GetEndTime() const
Return the end time of the signal.
Time GetDuration() const
Return the duration of the signal.
double GetRxPowerW() const
Return the total received power (W).
const WifiTxVector & GetTxVector() const
Return the TXVECTOR of the PPDU.
RxPowerWattPerChannelBand m_rxPowerW
received power in watts per band
const RxPowerWattPerChannelBand & GetRxPowerWPerBand() const
Return the received power (W) for all bands.
Time GetStartTime() const
Return the start time of the signal.
Noise and Interference (thus Ni) event.
void AddPower(double power)
Add a given amount of power.
double GetPower() const
Return the power.
Ptr< Event > GetEvent() const
Return the event causes the corresponding NI change.
handles interference calculations
void SetNoiseFigure(double value)
Set the noise figure.
double m_noiseFigure
noise figure (linear)
Ptr< ErrorRateModel > GetErrorRateModel() const
Return the error rate model.
void AddForeignSignal(Time duration, RxPowerWattPerChannelBand &rxPower)
Add a non-Wifi signal to interference helper.
bool m_rxing
flag whether it is in receiving state
NiChanges::iterator AddNiChangeEvent(Time moment, NiChange change, NiChangesPerBand::iterator niIt)
Add NiChange to the list at the appropriate position and return the iterator of the new event.
std::map< WifiSpectrumBandInfo, NiChanges > NiChangesPerBand
Map of NiChanges per band.
uint8_t m_numRxAntennas
the number of RX antennas in the corresponding receiver
bool IsBandInFrequencyRange(const WifiSpectrumBandInfo &band, const FrequencyRange &freqRange) const
Check whether a given band belongs to a given frequency range.
void DoDispose() override
Destructor implementation.
std::multimap< Time, NiChange > NiChanges
typedef for a multimap of NiChange
NiChangesPerBand m_niChanges
NI Changes for each band.
void UpdateBands(const std::vector< WifiSpectrumBandInfo > &bands, const FrequencyRange &freqRange)
Update the frequency bands that belongs to a given frequency range when the spectrum model is changed...
void SetErrorRateModel(const Ptr< ErrorRateModel > rate)
Set the error rate model for this interference helper.
bool HasBands() const
Check whether bands are already tracked by this interference helper.
double CalculatePayloadChunkSuccessRate(double snir, Time duration, const WifiTxVector &txVector, uint16_t staId=SU_STA_ID) const
Calculate the success rate of the payload chunk given the SINR, duration, and TXVECTOR.
Ptr< ErrorRateModel > m_errorRateModel
error rate model
void AppendEvent(Ptr< Event > event, bool isStartOfdmaRxing)
Append the given Event.
void NotifyRxStart()
Notify that RX has started.
NiChanges::iterator GetNextPosition(Time moment, NiChangesPerBand::iterator niIt)
Returns an iterator to the first NiChange that is later than moment.
FirstPowerPerBand m_firstPowers
first power of each band in watts
Time GetEnergyDuration(double energyW, const WifiSpectrumBandInfo &band)
double CalculateNoiseInterferenceW(Ptr< Event > event, NiChangesPerBand *nis, const WifiSpectrumBandInfo &band) const
Calculate noise and interference power in W.
double CalculateChunkSuccessRate(double snir, Time duration, WifiMode mode, const WifiTxVector &txVector, WifiPpduField field) const
Calculate the success rate of the chunk given the SINR, duration, and TXVECTOR.
double CalculatePayloadPer(Ptr< const Event > event, uint16_t channelWidth, NiChangesPerBand *nis, const WifiSpectrumBandInfo &band, uint16_t staId, std::pair< Time, Time > window) const
Calculate the error rate of the given PHY payload only in the provided time window (thus enabling per...
bool HasBand(const WifiSpectrumBandInfo &band) const
Check whether a given band is tracked by this interference helper.
void AddBand(const WifiSpectrumBandInfo &band)
Add a frequency band.
double CalculatePhyHeaderPer(Ptr< const Event > event, NiChangesPerBand *nis, uint16_t channelWidth, const WifiSpectrumBandInfo &band, WifiPpduField header) const
Calculate the error rate of the PHY header.
NiChanges::iterator GetPreviousPosition(Time moment, NiChangesPerBand::iterator niIt)
Returns an iterator to the last NiChange that is before than moment.
double CalculateSnr(Ptr< Event > event, uint16_t channelWidth, uint8_t nss, const WifiSpectrumBandInfo &band) const
Calculate the SNIR for the event (starting from now until the event end).
std::map< WifiSpectrumBandInfo, double > FirstPowerPerBand
Map of first power per band.
PhyEntity::SnrPer CalculatePhyHeaderSnrPer(Ptr< Event > event, uint16_t channelWidth, const WifiSpectrumBandInfo &band, WifiPpduField header) const
Calculate the SNIR at the start of the PHY header and accumulate all SNIR changes in the SNIR vector.
Ptr< Event > Add(Ptr< const WifiPpdu > ppdu, const WifiTxVector &txVector, Time duration, RxPowerWattPerChannelBand &rxPower, bool isStartOfdmaRxing=false)
Add the PPDU-related signal to interference helper.
static TypeId GetTypeId()
Get the type ID.
void UpdateEvent(Ptr< Event > event, const RxPowerWattPerChannelBand &rxPower)
Update event to scale its received power (W) per band.
void NotifyRxEnd(Time endTime, const FrequencyRange &freqRange)
Notify that RX has ended.
double CalculatePhyHeaderSectionPsr(Ptr< const Event > event, NiChangesPerBand *nis, uint16_t channelWidth, const WifiSpectrumBandInfo &band, PhyEntity::PhyHeaderSections phyHeaderSections) const
Calculate the success rate of the PHY header sections for the provided event.
void SetNumberOfReceiveAntennas(uint8_t rx)
Set the number of RX antennas in the receiver corresponding to this interference helper.
PhyEntity::SnrPer CalculatePayloadSnrPer(Ptr< Event > event, uint16_t channelWidth, const WifiSpectrumBandInfo &band, uint16_t staId, std::pair< Time, Time > relativeMpduStartStop) const
Calculate the SNIR at the start of the payload and accumulate all SNIR changes in the SNIR vector for...
A base class which provides memory management and object aggregation.
Definition: object.h:89
std::map< WifiPpduField, PhyHeaderChunkInfo > PhyHeaderSections
A map of PhyHeaderChunkInfo elements per PPDU field.
Definition: phy-entity.h:327
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:78
A template-based reference counting class.
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:105
a unique identifier for an interface.
Definition: type-id.h:59
represent a single transmission mode
Definition: wifi-mode.h:51
This class mimics the TXVECTOR which is to be passed to the PHY in order to define the parameters whi...
WifiPpduField
The type of PPDU field (grouped for convenience)
Every class exported by the ns3 library is enclosed in the ns3 namespace.
std::ostream & operator<<(std::ostream &os, const Angles &a)
Definition: angles.cc:129
std::map< WifiSpectrumBandInfo, double > RxPowerWattPerChannelBand
A map of the received power (Watts) for each band.
Definition: phy-entity.h:78
static constexpr uint16_t SU_STA_ID
STA_ID to identify a single user (SU)
Definition: wifi-mode.h:35
Declaration of:
Struct defining a frequency range between minFrequency (MHz) and maxFrequency (MHz).
A struct for both SNR and PER.
Definition: phy-entity.h:148
WifiSpectrumBandInfo structure containing info about a spectrum band.