26 #include "ns3/wifi-spectrum-value-helper.h" 28 #include "ns3/boolean.h" 29 #include "ns3/net-device.h" 49 .SetGroupName (
"Wifi")
51 .AddAttribute (
"DisableWifiReception",
"Prevent Wi-Fi frame sync from ever happening",
55 .AddTraceSource (
"SignalArrival",
58 "ns3::SpectrumWifiPhy::SignalArrivalCallback")
94 NS_FATAL_ERROR (
"SpectrumWifiPhy misses channel and WifiSpectrumPhyInterface objects at initialization time");
116 NS_LOG_DEBUG (
"Creating spectrum model from frequency/width pair of (" <<
GetFrequency () <<
", " << channelWidth <<
")");
141 NS_LOG_DEBUG (
"Run-time change of spectrum model from frequency/width pair of (" <<
GetFrequency () <<
", " << channelWidth <<
")");
196 Time rxDuration = rxParams->duration;
198 NS_LOG_DEBUG (
"Received signal with PSD " << *receivedSignalPsd <<
" and duration " << rxDuration.
As (
Time::NS));
199 uint32_t senderNodeId = 0;
202 senderNodeId = rxParams->txPhy->GetDevice ()->GetNode ()->GetId ();
204 NS_LOG_DEBUG (
"Received signal from " << senderNodeId <<
" with unfiltered power " <<
WToDbm (
Integral (*receivedSignalPsd)) <<
" dBm");
210 SpectrumValue filteredSignal = (*filter) * (*receivedSignalPsd);
212 NS_LOG_DEBUG (
"Signal power received (watts) before antenna gain: " <<
Integral (filteredSignal));
214 NS_LOG_DEBUG (
"Signal power received after antenna gain: " << rxPowerW <<
" W (" <<
WToDbm (rxPowerW) <<
" dBm)");
219 m_signalCb (wifiRxParams ?
true :
false, senderNodeId,
WToDbm (rxPowerW), rxDuration);
225 NS_LOG_INFO (
"Received signal too weak to process: " <<
WToDbm (rxPowerW) <<
" dBm");
228 if (wifiRxParams == 0)
237 NS_LOG_INFO (
"Received Wi-Fi signal but blocked from syncing");
275 switch (modulationClass)
283 NS_ABORT_MSG_IF (channelWidth != 22,
"Invalid channel width for DSSS");
304 uint16_t centerFrequencyForSupportedWidth =
GetFrequency ();
307 if (currentWidth != supportedWidth)
309 uint16_t startingFrequency = centerFrequencyForSupportedWidth - (supportedWidth / 2);
310 return startingFrequency + (currentWidth / 2);
312 return centerFrequencyForSupportedWidth;
321 NS_LOG_DEBUG (
"Start transmission: signal power before antenna gain=" << txPowerDbm <<
"dBm");
322 double txPowerWatts =
DbmToW (txPowerDbm);
325 txParams->duration = ppdu->GetTxDuration ();
326 txParams->psd = txPowerSpectrum;
330 txParams->ppdu = ppdu;
339 uint32_t bandBandwidth = 0;
350 bandBandwidth = 312500;
354 bandBandwidth = 156250;
358 bandBandwidth = 78125;
363 bandBandwidth = 78125;
369 return bandBandwidth;
375 uint16_t guardBandwidth = 0;
376 if (currentChannelWidth == 22)
389 guardBandwidth = currentChannelWidth;
391 return guardBandwidth;
ERP-OFDM PHY (Clause 19, Section 19.5)
uint16_t GetGuardBandwidth(uint16_t currentChannelWidth) const
Simulation virtual time values and global simulation resolution.
TracedCallback< bool, uint32_t, double, Time > m_signalCb
Signal callback.
void AddForeignSignal(Time duration, double rxPower)
Add a non-Wifi signal to interference helper.
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by "...
OFDM PHY for the 5 GHz band (Clause 17 with 5 MHz channel bandwidth)
Abstract base class for Spectrum-aware PHY layers.
AttributeValue implementation for Boolean.
double GetRxGain(void) const
Return the reception gain (dB).
HT PHY for the 5 GHz band (clause 20)
This class mimics the TXVECTOR which is to be passed to the PHY in order to define the parameters whi...
double Integral(const SpectrumValue &arg)
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
WifiPhyStandard GetStandard(void) const
Get the configured Wi-Fi standard.
NS_ASSERT_MSG(false, "Ipv4AddressGenerator::MaskToIndex(): Impossible")
static Ptr< SpectrumValue > CreateHtOfdmTxPowerSpectralDensity(uint32_t centerFrequency, uint16_t channelWidth, double txPowerW, uint16_t guardBandwidth)
Create a transmit power spectral density corresponding to OFDM High Throughput (HT) (802...
void StartRx(Ptr< SpectrumSignalParameters > rxParams)
Input method for delivering a signal from the spectrum channel and low-level PHY interface to this Sp...
double DbmToW(double dBm)
Convert from dBm to Watts.
Ptr< const AttributeAccessor > MakeBooleanAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method...
virtual void DoDispose(void)
Destructor implementation.
bool IsInitialized(void) const
Check if the object has been initialized.
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
HE PHY for the 2.4 GHz band (clause 26)
static TypeId GetTypeId(void)
Get the type ID.
OFDM PHY for the 5 GHz band (Clause 17 with 10 MHz channel bandwidth)
bool m_disableWifiReception
forces this PHY to fail to sync on any signal
#define NS_LOG_INFO(msg)
Use NS_LOG to output a message of level LOG_INFO.
#define NS_FATAL_ERROR(msg)
Report a fatal error with a message and terminate.
static Ptr< SpectrumValue > CreateRfFilter(uint32_t centerFrequency, uint16_t channelWidth, uint32_t bandBandwidth, uint16_t guardBandwidth)
Create a spectral density corresponding to the RF filter.
HT PHY for the 2.4 GHz band (clause 20)
TimeWithUnit As(const enum Unit unit) const
Attach a unit to a Time, to facilitate output in a specific unit.
static Ptr< SpectrumValue > CreateDsssTxPowerSpectralDensity(uint32_t centerFrequency, double txPowerW, uint16_t guardBandwidth)
Create a transmit power spectral density corresponding to DSSS.
void StartTx(Ptr< WifiPpdu > ppdu)
double GetTxPowerForTransmission(WifiTxVector txVector) const
Compute the transmit power (in dBm) for the next transmission.
virtual void SetFrequency(uint16_t freq)
void SetAntenna(const Ptr< AntennaModel > antenna)
virtual void SetChannelNumber(uint8_t id)
Set channel number.
SpectrumModelUid_t GetUid() const
Ptr< const SpectrumModel > GetRxSpectrumModel() const
void DoInitialize(void)
Initialize() implementation.
double GetRxSensitivity(void) const
Return the receive sensitivity threshold (dBm).
Ptr< const TraceSourceAccessor > MakeTraceSourceAccessor(T a)
Create a TraceSourceAccessor which will control access to the underlying trace source.
Ptr< SpectrumChannel > m_channel
SpectrumChannel that this SpectrumWifiPhy is connected to.
uint16_t GetChannelWidth(void) const
Ptr< SpectrumValue > GetTxPowerSpectralDensity(uint16_t centerFrequency, uint16_t channelWidth, double txPowerW, WifiModulationClass modulationClass) const
WifiPhyStandard
Identifies the PHY specification that a Wifi device is configured to use.
HE PHY for the 5 GHz band (clause 26)
virtual void ConfigureStandard(WifiPhyStandard standard)
Configure the PHY-level parameters for different Wi-Fi standard.
WifiMode GetMode(void) const
void DoDispose(void)
Destructor implementation.
802.11 PHY layer modelThis PHY implements a spectrum-aware enhancement of the 802.11 SpectrumWifiPhy model.
Ptr< const SpectrumModel > m_rxSpectrumModel
receive spectrum model
WifiModulationClass GetModulationClass() const
static Ptr< SpectrumValue > CreateHeOfdmTxPowerSpectralDensity(uint32_t centerFrequency, uint16_t channelWidth, double txPowerW, uint16_t guardBandwidth)
Create a transmit power spectral density corresponding to OFDM High Efficiency (HE) (802...
virtual void SetFrequency(uint16_t freq)
This is intended to be the configuration used in this paper: Gavin Holland, Nitin Vaidya and Paramvir...
void StartReceivePreamble(Ptr< WifiPpdu > ppdu, double rxPowerW)
Start receiving the PHY preamble of a PPDU (i.e.
static Ptr< SpectrumModel > GetSpectrumModel(uint32_t centerFrequency, uint16_t channelWidth, uint32_t bandBandwidth, uint16_t guardBandwidth)
Return a SpectrumModel instance corresponding to the center frequency and channel width...
OFDM PHY for the 5 GHz band (Clause 17)
Every class exported by the ns3 library is enclosed in the ns3 namespace.
uint16_t GetFrequency(void) const
DSSS PHY (Clause 15) and HR/DSSS PHY (Clause 18)
uint32_t GetBandBandwidth(void) const
Ptr< const SpectrumModel > GetSpectrumModel() const
virtual void SetChannelNumber(uint8_t id)
Set channel number.
virtual void DoInitialize(void)
Initialize() implementation.
double WToDbm(double w)
Convert from Watts to dBm.
uint8_t GetChannelNumber(void) const
Return current channel number.
double DbToRatio(double dB)
Convert from dB to ratio.
virtual void SetChannelWidth(uint16_t channelwidth)
WifiModulationClass
This enumeration defines the modulation classes per (Table 9-4 "Modulation classes"; IEEE 802...
#define NS_ABORT_MSG_IF(cond, msg)
Abnormal program termination if a condition is true, with a message.
Ptr< AntennaModel > GetRxAntenna(void) const
Get the antenna model used for reception.
InterferenceHelper m_interference
Pointer to InterferenceHelper.
virtual void SetChannelWidth(uint16_t channelWidth)
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
Ptr< AntennaModel > m_antenna
antenna model
Ptr< const AttributeChecker > MakeBooleanChecker(void)
uint16_t GetCenterFrequencyForChannelWidth(WifiTxVector txVector) const
Get the center frequency of the channel corresponding the current TxVector rather than that of the su...
Ptr< WifiSpectrumPhyInterface > m_wifiSpectrumPhyInterface
Spectrum PHY interface.
void ResetSpectrumModel(void)
Perform run-time spectrum model change.
double GetTxGain(void) const
Return the transmission gain (dB).
uint16_t GetChannelWidth(void) const
static Ptr< SpectrumValue > CreateOfdmTxPowerSpectralDensity(uint32_t centerFrequency, uint16_t channelWidth, double txPowerW, uint16_t guardBandwidth)
Create a transmit power spectral density corresponding to OFDM (802.11a/g).
virtual ~SpectrumWifiPhy()
virtual void ConfigureStandard(WifiPhyStandard standard)
Configure the PHY-level parameters for different Wi-Fi standard.
Ptr< Channel > GetChannel(void) const
Return the Channel this WifiPhy is connected to.
void SetChannel(const Ptr< SpectrumChannel > channel)
Set the SpectrumChannel this SpectrumWifiPhy is to be connected to.
Set of values corresponding to a given SpectrumModel.
a unique identifier for an interface.
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Ptr< T > Copy(Ptr< T > object)
Return a deep copy of a Ptr.
void SwitchMaybeToCcaBusy(void)
Check if PHY state should move to CCA busy state based on current state of interference tracker...
void CreateWifiSpectrumPhyInterface(Ptr< NetDevice > device)
Method to encapsulate the creation of the WifiSpectrumPhyInterface object (used to bind the WifiSpect...