27 #include "ns3/wifi-spectrum-value-helper.h"
28 #include "ns3/abort.h"
30 #include "ns3/boolean.h"
45 .SetGroupName (
"Wifi")
47 .AddAttribute (
"DisableWifiReception",
"Prevent Wi-Fi frame sync from ever happening",
51 .AddTraceSource (
"SignalArrival",
54 "ns3::SpectrumWifiPhy::SignalArrivalCallback")
90 NS_FATAL_ERROR (
"SpectrumWifiPhy misses channel and WifiSpectrumPhyInterface objects at initialization time");
112 NS_LOG_DEBUG (
"Creating spectrum model from frequency/width pair of (" <<
GetFrequency () <<
", " << +channelWidth <<
")");
137 NS_LOG_DEBUG (
"Run-time change of spectrum model from frequency/width pair of (" <<
GetFrequency () <<
", " << +channelWidth <<
")");
197 std::vector<uint8_t> channelList;
219 Time rxDuration = rxParams->duration;
221 NS_LOG_DEBUG (
"Received signal with PSD " << *receivedSignalPsd <<
" and duration " << rxDuration.
As (
Time::NS));
222 uint32_t senderNodeId = 0;
225 senderNodeId = rxParams->txPhy->GetDevice ()->GetNode ()->GetId ();
227 NS_LOG_DEBUG (
"Received signal from " << senderNodeId <<
" with unfiltered power " <<
WToDbm (
Integral (*receivedSignalPsd)) <<
" dBm");
233 SpectrumValue filteredSignal = (*filter) * (*receivedSignalPsd);
235 NS_LOG_DEBUG (
"Signal power received (watts) before antenna gain: " <<
Integral (filteredSignal));
237 NS_LOG_DEBUG (
"Signal power received after antenna gain: " << rxPowerW <<
" W (" <<
WToDbm (rxPowerW) <<
" dBm)");
242 m_signalCb (wifiRxParams ?
true :
false, senderNodeId,
WToDbm (rxPowerW), rxDuration);
243 if (wifiRxParams == 0)
252 NS_LOG_INFO (
"Received Wi-Fi signal but blocked from syncing");
259 Ptr<Packet> packet = wifiRxParams->packet->Copy ();
296 switch (modulationClass)
304 NS_ABORT_MSG_IF (channelWidth != 22,
"Invalid channel width for DSSS");
325 uint32_t centerFrequencyForSupportedWidth =
GetFrequency ();
328 if (currentWidth != supportedWidth)
330 uint32_t startingFrequency = centerFrequencyForSupportedWidth -
static_cast<uint32_t
> (supportedWidth / 2);
331 return startingFrequency +
static_cast<uint32_t
> (currentWidth / 2);
333 return centerFrequencyForSupportedWidth;
343 txParams->duration = txDuration;
344 txParams->psd = txPowerSpectrum;
348 txParams->packet = packet;
350 NS_LOG_DEBUG (
"Starting transmission with integrated spectrum power " <<
WToDbm (
Integral (*txPowerSpectrum)) <<
" dBm; spectrum model Uid: " << txPowerSpectrum->GetSpectrumModel ()->GetUid ());
357 double bandBandwidth = 0;
368 bandBandwidth = 312500;
372 bandBandwidth = 156250;
376 bandBandwidth = 78125;
381 bandBandwidth = 78125;
387 return bandBandwidth;
393 uint8_t guardBandwidth = 0;
394 if (currentChannelWidth == 22)
407 guardBandwidth = currentChannelWidth;
409 return guardBandwidth;
ERP-OFDM PHY (Clause 19, Section 19.5)
uint8_t GetChannelNumber(void) const
Return current channel number.
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.
double GetTxGain(void) const
Return the transmission gain (dB).
AttributeValue implementation for Boolean.
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.
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< Channel > GetChannel(void) const
Return the Channel this WifiPhy is connected to.
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.
void StartTx(Ptr< Packet > packet, WifiTxVector txVector, Time txDuration)
static Ptr< SpectrumValue > CreateDsssTxPowerSpectralDensity(uint32_t centerFrequency, double txPowerW, uint8_t guardBandwidth)
Create a transmit power spectral density corresponding to DSSS.
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
HE PHY for the 2.4 GHz band (clause 26)
void StartReceivePreambleAndHeader(Ptr< Packet > packet, double rxPowerW, Time rxDuration)
Starting receiving the plcp of a packet (i.e.
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.
uint8_t GetGuardBandwidth(uint8_t currentChannelWidth) const
HT PHY for the 2.4 GHz band (clause 20)
Ptr< const SpectrumModel > GetRxSpectrumModel() const
uint32_t GetCenterFrequencyForChannelWidth(WifiTxVector txVector) const
Get the center frequency of the channel corresponding the current TxVector rather than that of the su...
static Ptr< SpectrumValue > CreateRfFilter(uint32_t centerFrequency, uint8_t channelWidth, double bandBandwidth, uint8_t guardBandwidth)
Create a spectral density corresponding to the RF filter.
Ptr< WifiSpectrumPhyInterface > GetSpectrumPhy(void) const
virtual void SetFrequency(uint16_t freq)
uint16_t GetFrequency(void) const
void SetAntenna(const Ptr< AntennaModel > antenna)
double GetBandBandwidth(void) const
virtual void SetChannelNumber(uint8_t id)
Set channel number.
static Ptr< SpectrumValue > CreateHeOfdmTxPowerSpectralDensity(uint32_t centerFrequency, uint8_t channelWidth, double txPowerW, uint8_t guardBandwidth)
Create a transmit power spectral density corresponding to OFDM High Efficiency (HE) (802...
uint8_t GetTxPowerLevel(void) const
void DoInitialize(void)
Initialize() implementation.
Ptr< const TraceSourceAccessor > MakeTraceSourceAccessor(T a)
Create a TraceSourceAccessor which will control access to the underlying trace source.
uint8_t GetChannelWidth(void) const
Ptr< SpectrumChannel > m_channel
SpectrumChannel that this SpectrumWifiPhy is connected to.
double GetPowerDbm(uint8_t power) const
Get the power of the given power level in dBm.
std::vector< uint8_t > GetOperationalChannelList(void) const
Return a list of channels to which it may be possible to roam By default, this method will return the...
WifiPhyStandard
Identifies the PHY specification that a Wifi device is configured to use.
static Ptr< SpectrumValue > CreateHtOfdmTxPowerSpectralDensity(uint32_t centerFrequency, uint8_t channelWidth, double txPowerW, uint8_t guardBandwidth)
Create a transmit power spectral density corresponding to OFDM High Throughput (HT) (802...
HE PHY for the 5 GHz band (clause 26)
NS_ASSERT_MSG(false,"Ipv4AddressGenerator::MaskToIndex(): Impossible")
Ptr< AntennaModel > GetRxAntenna(void) const
Get the antenna model used for reception.
virtual void ConfigureStandard(WifiPhyStandard standard)
Configure the PHY-level parameters for different Wi-Fi standard.
static Ptr< SpectrumModel > GetSpectrumModel(uint32_t centerFrequency, uint8_t channelWidth, double bandBandwidth, uint8_t guardBandwidth)
Return a SpectrumModel instance corresponding to the center frequency and channel width...
Ptr< SpectrumValue > GetTxPowerSpectralDensity(uint16_t centerFrequency, uint8_t channelWidth, double txPowerW, WifiModulationClass modulationClass) 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
virtual void SetFrequency(uint16_t freq)
This is intended to be the configuration used in this paper: Gavin Holland, Nitin Vaidya and Paramvir...
OFDM PHY for the 5 GHz band (Clause 17)
Every class exported by the ns3 library is enclosed in the ns3 namespace.
virtual void SetChannelWidth(uint8_t channelwidth)
Ptr< const AttributeChecker > MakeBooleanChecker(void)
DSSS PHY (Clause 15) and HR/DSSS PHY (Clause 18)
bool IsInitialized(void) const
Check if the object has been initialized.
virtual void SetChannelNumber(uint8_t id)
Set channel number.
virtual void DoInitialize(void)
Initialize() implementation.
double WToDbm(double w)
Convert from Watts to dBm.
double DbToRatio(double dB)
Convert from dB to ratio.
uint8_t GetChannelWidth(void) const
WifiModulationClass
This enumeration defines the modulation classes per (Table 9-4 "Modulation classes"; IEEE 802...
TimeWithUnit As(const enum Unit unit) const
Attach a unit to a Time, to facilitate output in a specific unit.
#define NS_ABORT_MSG_IF(cond, msg)
Abnormal program termination if a condition is true, with a message.
InterferenceHelper m_interference
Pointer to InterferenceHelper.
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
Ptr< AntennaModel > m_antenna
antenna model
std::vector< uint8_t > m_operationalChannelList
List of possible channels.
virtual void SetChannelWidth(uint8_t channelwidth)
void ClearOperationalChannelList(void)
Clear the list of operational channels.
Ptr< WifiSpectrumPhyInterface > m_wifiSpectrumPhyInterface
Spectrum phy interface.
void ResetSpectrumModel(void)
Perform run-time spectrum model change.
static Ptr< SpectrumValue > CreateOfdmTxPowerSpectralDensity(uint32_t centerFrequency, uint8_t channelWidth, double txPowerW, uint8_t guardBandwidth)
Create a transmit power spectral density corresponding to OFDM (802.11a/g).
void AddOperationalChannel(uint8_t channelNumber)
Add a channel number to the list of operational channels.
virtual ~SpectrumWifiPhy()
virtual void ConfigureStandard(WifiPhyStandard standard)
Configure the PHY-level parameters for different Wi-Fi standard.
WifiModulationClass GetModulationClass() const
WifiMode GetMode(void) const
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.
void SwitchMaybeToCcaBusy(void)
Check if Phy state should move to CCA busy state based on current state of interference tracker...
WifiPhyStandard GetStandard(void) const
Get the configured Wi-Fi standard.
double GetRxGain(void) const
Return the reception gain (dB).
void CreateWifiSpectrumPhyInterface(Ptr< NetDevice > device)
Method to encapsulate the creation of the WifiSpectrumPhyInterface object (used to bind the WifiSpect...