26 #include "ns3/wifi-spectrum-value-helper.h" 28 #include "ns3/boolean.h" 29 #include "ns3/net-device.h" 47 .SetGroupName (
"Wifi")
49 .AddAttribute (
"DisableWifiReception",
"Prevent Wi-Fi frame sync from ever happening",
53 .AddTraceSource (
"SignalArrival",
56 "ns3::SpectrumWifiPhy::SignalArrivalCallback")
92 NS_FATAL_ERROR (
"SpectrumWifiPhy misses channel and WifiSpectrumPhyInterface objects at initialization time");
114 NS_LOG_DEBUG (
"Creating spectrum model from frequency/width pair of (" <<
GetFrequency () <<
", " << channelWidth <<
")");
139 NS_LOG_DEBUG (
"Run-time change of spectrum model from frequency/width pair of (" <<
GetFrequency () <<
", " << channelWidth <<
")");
194 Time rxDuration = rxParams->duration;
196 NS_LOG_DEBUG (
"Received signal with PSD " << *receivedSignalPsd <<
" and duration " << rxDuration.
As (
Time::NS));
197 uint32_t senderNodeId = 0;
200 senderNodeId = rxParams->txPhy->GetDevice ()->GetNode ()->GetId ();
202 NS_LOG_DEBUG (
"Received signal from " << senderNodeId <<
" with unfiltered power " <<
WToDbm (
Integral (*receivedSignalPsd)) <<
" dBm");
208 SpectrumValue filteredSignal = (*filter) * (*receivedSignalPsd);
210 NS_LOG_DEBUG (
"Signal power received (watts) before antenna gain: " <<
Integral (filteredSignal));
212 NS_LOG_DEBUG (
"Signal power received after antenna gain: " << rxPowerW <<
" W (" <<
WToDbm (rxPowerW) <<
" dBm)");
217 m_signalCb (wifiRxParams ?
true :
false, senderNodeId,
WToDbm (rxPowerW), rxDuration);
223 NS_LOG_INFO (
"Received signal too weak to process: " <<
WToDbm (rxPowerW) <<
" dBm");
226 if (wifiRxParams == 0)
235 NS_LOG_INFO (
"Received Wi-Fi signal but blocked from syncing");
242 Ptr<Packet> packet = wifiRxParams->packet->Copy ();
273 switch (modulationClass)
281 NS_ABORT_MSG_IF (channelWidth != 22,
"Invalid channel width for DSSS");
302 uint16_t centerFrequencyForSupportedWidth =
GetFrequency ();
305 if (currentWidth != supportedWidth)
307 uint16_t startingFrequency = centerFrequencyForSupportedWidth - (supportedWidth / 2);
308 return startingFrequency + (currentWidth / 2);
310 return centerFrequencyForSupportedWidth;
317 NS_LOG_DEBUG (
"Start transmission: signal power before antenna gain=" << txPowerDbm <<
"dBm");
318 double txPowerWatts =
DbmToW (txPowerDbm);
321 txParams->duration = txDuration;
322 txParams->psd = txPowerSpectrum;
326 txParams->packet = packet;
335 double bandBandwidth = 0;
346 bandBandwidth = 312500;
350 bandBandwidth = 156250;
354 bandBandwidth = 78125;
359 bandBandwidth = 78125;
365 return bandBandwidth;
371 uint16_t guardBandwidth = 0;
372 if (currentChannelWidth == 22)
385 guardBandwidth = currentChannelWidth;
387 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.
void StartTx(Ptr< Packet > packet, WifiTxVector txVector, Time txDuration)
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 Ptr< SpectrumModel > GetSpectrumModel(uint32_t centerFrequency, uint16_t channelWidth, double bandBandwidth, uint16_t guardBandwidth)
Return a SpectrumModel instance corresponding to the center frequency and channel width...
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.
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.
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.
double GetBandBandwidth(void) const
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...
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
Ptr< const AttributeChecker > MakeBooleanChecker(void)
virtual void SetChannelWidth(uint16_t channelwidth)
DSSS PHY (Clause 15) and HR/DSSS PHY (Clause 18)
void StartReceivePreamble(Ptr< Packet > packet, double rxPowerW, Time rxDuration)
Start receiving the PHY preamble of a packet (i.e.
static Ptr< SpectrumValue > CreateRfFilter(uint32_t centerFrequency, uint16_t channelWidth, double bandBandwidth, uint16_t guardBandwidth)
Create a spectral density corresponding to the RF filter.
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.
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
Ptr< AntennaModel > m_antenna
antenna model
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.
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...