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 <<
")");
199 std::vector<uint8_t> channelList;
221 Time rxDuration = rxParams->duration;
223 NS_LOG_DEBUG (
"Received signal with PSD " << *receivedSignalPsd <<
" and duration " << rxDuration.
As (
Time::NS));
224 uint32_t senderNodeId = 0;
227 senderNodeId = rxParams->txPhy->GetDevice ()->GetNode ()->GetId ();
229 NS_LOG_DEBUG (
"Received signal from " << senderNodeId <<
" with unfiltered power " <<
WToDbm (
Integral (*receivedSignalPsd)) <<
" dBm");
235 SpectrumValue filteredSignal = (*filter) * (*receivedSignalPsd);
237 NS_LOG_DEBUG (
"Signal power received (watts) before antenna gain: " <<
Integral (filteredSignal));
239 NS_LOG_DEBUG (
"Signal power received after antenna gain: " << rxPowerW <<
" W (" <<
WToDbm (rxPowerW) <<
" dBm)");
244 m_signalCb (wifiRxParams ?
true :
false, senderNodeId,
WToDbm (rxPowerW), rxDuration);
245 if (wifiRxParams == 0)
254 NS_LOG_INFO (
"Received Wi-Fi signal but blocked from syncing");
261 Ptr<Packet> packet = wifiRxParams->packet->Copy ();
292 switch (modulationClass)
300 NS_ABORT_MSG_IF (channelWidth != 22,
"Invalid channel width for DSSS");
321 uint16_t centerFrequencyForSupportedWidth =
GetFrequency ();
324 if (currentWidth != supportedWidth)
326 uint16_t startingFrequency = centerFrequencyForSupportedWidth - (supportedWidth / 2);
327 return startingFrequency + (currentWidth / 2);
329 return centerFrequencyForSupportedWidth;
339 txParams->duration = txDuration;
340 txParams->psd = txPowerSpectrum;
344 txParams->packet = packet;
346 NS_LOG_DEBUG (
"Starting transmission with integrated spectrum power " <<
WToDbm (
Integral (*txPowerSpectrum)) <<
" dBm; spectrum model Uid: " << txPowerSpectrum->GetSpectrumModel ()->GetUid ());
353 double bandBandwidth = 0;
364 bandBandwidth = 312500;
368 bandBandwidth = 156250;
372 bandBandwidth = 78125;
377 bandBandwidth = 78125;
383 return bandBandwidth;
389 uint16_t guardBandwidth = 0;
390 if (currentChannelWidth == 22)
403 guardBandwidth = currentChannelWidth;
405 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)
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...
#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...
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.
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.
virtual void SetFrequency(uint16_t freq)
void SetAntenna(const Ptr< AntennaModel > antenna)
virtual void SetChannelNumber(uint8_t id)
Set channel number.
Ptr< const SpectrumModel > GetRxSpectrumModel() const
void DoInitialize(void)
Initialize() implementation.
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)
double GetPowerDbm(uint8_t power) const
Get the power of the given power level in dBm.
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)
static Ptr< SpectrumValue > CreateRfFilter(uint32_t centerFrequency, uint16_t channelWidth, double bandBandwidth, uint16_t guardBandwidth)
Create a spectral density corresponding to the RF filter.
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
std::vector< uint8_t > m_operationalChannelList
List of possible channels.
uint16_t GetCenterFrequencyForChannelWidth(WifiTxVector txVector) const
Get the center frequency of the channel corresponding the current TxVector rather than that of the su...
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.
uint8_t GetTxPowerLevel(void) const
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).
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.
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...