12#include "ns3/error-rate-model.h"
13#include "ns3/frame-capture-model.h"
14#include "ns3/interference-helper.h"
16#include "ns3/mobility-model.h"
18#include "ns3/preamble-detection-model.h"
19#include "ns3/spectrum-channel.h"
20#include "ns3/spectrum-transmit-filter.h"
21#include "ns3/spectrum-wifi-phy.h"
22#include "ns3/wifi-bandwidth-filter.h"
23#include "ns3/wifi-net-device.h"
24#include "ns3/wifi-spectrum-value-helper.h"
37 phy.SetTypeId(
"ns3::SpectrumWifiPhy");
79 NS_LOG_DEBUG(
"Found existing WifiBandwidthFilter for channel " << channel);
84 NS_LOG_DEBUG(
"Found different SpectrumTransmitFilter for channel " << channel);
91 channel->AddSpectrumTransmitFilter(pWifi);
92 NS_LOG_DEBUG(
"Adding WifiBandwidthFilter to channel " << channel);
105 it->second.emplace(freqRange);
115std::vector<Ptr<WifiPhy>>
118 std::vector<Ptr<WifiPhy>> ret;
120 for (std::size_t i = 0; i <
m_phys.size(); i++)
124 phy->SetInterferenceHelper(interference);
126 phy->SetErrorRateModel(error);
130 phy->SetFrameCaptureModel(frameCapture);
134 auto preambleDetection =
136 phy->SetPreambleDetectionModel(preambleDetection);
139 phy->SetChannelSwitchedCallback(
141 phy->SetDevice(device);
143 ret.emplace_back(phy);
155 for (
const auto& [freqRange, channel] :
m_channels)
157 phy->AddChannel(channel, freqRange);
164 phy->AddChannel(
m_channels.at(freqRange), freqRange);
172 for (
const auto& otherPhy : phy->GetDevice()->GetPhys())
176 if (spectrumPhy == phy)
181 if (spectrumPhy->GetCurrentFrequencyRange() == phy->GetCurrentFrequencyRange())
186 if (
const auto& interfaces = spectrumPhy->GetSpectrumPhyInterfaces();
187 !interfaces.contains(phy->GetCurrentFrequencyRange()))
192 spectrumPhy->ConfigureInterface(phy->GetOperatingChannel().GetFrequencies(),
193 phy->GetChannelWidth());
the interface for Wifi's error models
the interface for Wifi's frame capture models
handles interference calculations
Keep track of the current position and velocity of an object.
static Ptr< T > Find(std::string path)
Given a name path string, look to see if there's an object in the system with that associated to it.
Ptr< Object > Create() const
Create an Object instance of the configured TypeId.
the interface for Wifi's preamble detection models
Smart pointer class similar to boost::intrusive_ptr.
std::vector< Ptr< WifiPhy > > Create(Ptr< Node > node, Ptr< WifiNetDevice > device) const override
void ResetPhyToFreqRangeMapping()
Reset mapping of the spectrum PHY interfaces added to the PHY instances.
SpectrumWifiPhyHelper(uint8_t nLinks=1)
Create a PHY helper.
std::map< uint8_t, std::set< FrequencyRange > > m_interfacesMap
map of the spectrum PHY interfaces to be added to the PHY instance corresponding to a given link ID
void AddChannel(const Ptr< SpectrumChannel > channel, const FrequencyRange &freqRange=WHOLE_WIFI_SPECTRUM)
void InstallPhyInterfaces(uint8_t linkId, Ptr< SpectrumWifiPhy > phy) const
Install PHY interfaces to the PHY instance of a given link based on the currently configured mapping ...
void SetChannel(const Ptr< SpectrumChannel > channel)
static void SpectrumChannelSwitched(Ptr< SpectrumWifiPhy > phy)
Function that is notified when a spectrum channel switched.
void AddPhyToFreqRangeMapping(uint8_t linkId, const FrequencyRange &freqRange)
Add a given spectrum PHY interface to the PHY instance corresponding of a given link.
void AddWifiBandwidthFilter(Ptr< SpectrumChannel > channel)
std::map< FrequencyRange, Ptr< SpectrumChannel > > m_channels
the spectrum channels
void SetErrorRateModel(std::string type, Args &&... args)
Helper function used to set the error rate model.
void SetInterferenceHelper(std::string type, Args &&... args)
Helper function used to set the interference helper.
std::vector< ObjectFactory > m_frameCaptureModel
frame capture model
std::vector< ObjectFactory > m_preambleDetectionModel
preamble detection model
std::vector< ObjectFactory > m_phys
PHY objects.
std::vector< ObjectFactory > m_errorRateModel
error rate model
ObjectFactory m_interferenceHelper
interference helper
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file,...
#define NS_ABORT_IF(cond)
Abnormal program termination if a condition is true.
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
Ptr< T > CreateObject(Args &&... args)
Create an object by type, with varying number of constructor parameters.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Callback< R, Args... > MakeCallback(R(T::*memPtr)(Args...), OBJ objPtr)
Build Callbacks for class method members which take varying numbers of arguments and potentially retu...
Ptr< T1 > DynamicCast(const Ptr< T2 > &p)
Cast a Ptr.
Struct defining a frequency range between minFrequency and maxFrequency.