A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
spectrum-wifi-phy.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2005,2006 INRIA
3 *
4 * SPDX-License-Identifier: GPL-2.0-only
5 *
6 * Authors: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
7 * Ghada Badawy <gbadawy@gmail.com>
8 * Sébastien Deronne <sebastien.deronne@gmail.com>
9 *
10 * Ported from yans-wifi-phy.h by several contributors starting
11 * with Nicola Baldo and Dean Armstrong
12 */
13
14#ifndef SPECTRUM_WIFI_PHY_H
15#define SPECTRUM_WIFI_PHY_H
16
17#include "wifi-phy.h"
18
19#include "ns3/antenna-model.h"
20#include "ns3/wifi-export.h"
21
22#include <map>
23#include <optional>
24#include <set>
25#include <vector>
26
28
29namespace ns3
30{
31
32class SpectrumChannel;
36
37/// Set of RU bands
38using RuBands = std::set<WifiSpectrumBandInfo>;
39
40/**
41 * @brief 802.11 PHY layer model
42 * @ingroup wifi
43 *
44 * This PHY implements a spectrum-aware enhancement of the 802.11 SpectrumWifiPhy
45 * model.
46 *
47 * This PHY model depends on a channel loss and delay
48 * model as provided by the ns3::SpectrumPropagationLossModel
49 * and ns3::PropagationDelayModel classes.
50 *
51 */
52class WIFI_EXPORT SpectrumWifiPhy : public WifiPhy
53{
54 public:
55 /// allow SpectrumWifiPhyFilterTest class access
56 friend class ::SpectrumWifiPhyFilterTest;
57
58 /**
59 * @brief Get the type ID.
60 * @return the object TypeId
61 */
62 static TypeId GetTypeId();
63
65 ~SpectrumWifiPhy() override;
66
67 // Implementation of pure virtual method.
68 void SetDevice(const Ptr<WifiNetDevice> device) override;
69 void StartTx(Ptr<const WifiPpdu> ppdu) override;
70 Ptr<Channel> GetChannel() const override;
71 MHz_u GetGuardBandwidth(MHz_u currentChannelWidth) const override;
72 std::tuple<dBr_u, dBr_u, dBr_u> GetTxMaskRejectionParams() const override;
73 WifiSpectrumBandInfo GetBand(MHz_u bandWidth, uint8_t bandIndex = 0) override;
76 const WifiSpectrumBandIndices& indices) const override;
77
78 /**
79 * Attach a SpectrumChannel to use for a given frequency range.
80 *
81 * @param channel the SpectrumChannel to attach
82 * @param freqRange the frequency range, bounded by a minFrequency and a maxFrequency in MHz
83 */
84 void AddChannel(const Ptr<SpectrumChannel> channel,
85 const FrequencyRange& freqRange = WHOLE_WIFI_SPECTRUM);
86
87 /**
88 * Input method for delivering a signal from the spectrum channel
89 * and low-level PHY interface to this SpectrumWifiPhy instance.
90 *
91 * @param rxParams Input signal parameters
92 * @param interface the Spectrum PHY interface for which the signal has been detected
93 */
96
97 /**
98 * @param antenna an AntennaModel to include in the transmitted
99 * SpectrumSignalParameters (in case any objects downstream of the
100 * SpectrumWifiPhy wish to adjust signal properties based on the
101 * transmitted antenna model. This antenna is also used when
102 * the underlying WifiSpectrumPhyInterface::GetAntenna() method
103 * is called.
104 *
105 * Note: this method may be split into separate SetTx and SetRx
106 * methods in the future if the modeling need for this arises
107 */
108 void SetAntenna(const Ptr<AntennaModel> antenna);
109 /**
110 * Get the antenna model used for reception
111 *
112 * @return the AntennaModel used for reception
113 */
115
116 /**
117 * Callback invoked when the PHY model starts to process a signal
118 *
119 * @param senderNodeId Node Id of the sender of the signal
120 * @param rxPower received signal power (dBm)
121 * @param duration Signal duration
122 */
124 uint32_t senderNodeId,
125 double rxPower,
126 Time duration);
127
128 /**
129 * Configure a non-active spectrum PHY interface to operate on a given frequency (or several
130 * frequencies for non-contiguous) with a given total width. The function searches for the
131 * non-active PHY interface that operates on the frequency range corresponding to the spectrum
132 * portion specified by the caller. It takes care to configure the RX spectrum model of the PHY
133 * interface and to update the bands tracked in interference helper.
134 *
135 * @param frequencies the center frequency of each segment the PHY interface should use
136 * @param width the total channel width the PHY interface should use
137 */
138 void ConfigureInterface(const std::vector<MHz_u>& frequencies, MHz_u width);
139
140 /**
141 * This function is sending the signal to the Spectrum channel
142 * after finishing the configuration of the transmit parameters.
143 *
144 * @param txParams the parameters to be provided to the Spectrum channel
145 */
147
148 /**
149 * Determine the WifiPpdu to be used by the RX PHY based on the WifiPpdu sent by the TX PHY.
150 *
151 * @param ppdu the WifiPpdu transmitted by the TX PHY
152 * @return the WifiPpdu to be used by the RX PHY
153 */
155
156 /**
157 * Get the currently active spectrum PHY interface
158 *
159 * @return the current spectrum PHY interface
160 */
162
163 /**
164 * Get the map of interfaces attached to this spectrum PHY
165 *
166 * @return the map of interfaces attached to this spectrum PHY
167 */
168 const std::map<FrequencyRange, Ptr<WifiSpectrumPhyInterface>>& GetSpectrumPhyInterfaces() const;
169
170 /**
171 * Determine the number of bands between the two segments if the operating channel is made of
172 * non-contiguous segments, otherwise the function returns zero.
173 *
174 * @param centerFrequencies the center frequency of each segment
175 * @param totalWidth the width of the operating channel
176 * @param subcarrierSpacing the subcarrier spacing
177 * @return the number of bands between the two segments if the operating channel is made of
178 * non-contiguous segments, zero otherwise
179 */
180 static uint32_t GetNumBandsBetweenSegments(const std::vector<MHz_u>& centerFrequencies,
181 MHz_u totalWidth,
182 Hz_u subcarrierSpacing);
183
184 /**
185 * @param callback the callback to invoke when operating channel has switched.
186 */
188
189 protected:
190 void DoDispose() override;
191 void DoInitialize() override;
192
193 // The following method calls the base WifiPhy class method
194 // but also generates a new SpectrumModel if called during runtime
195 void DoChannelSwitch() override;
196
197 std::map<FrequencyRange, Ptr<WifiSpectrumPhyInterface>>
198 m_spectrumPhyInterfaces; //!< Spectrum PHY interfaces
199
201 m_currentSpectrumPhyInterface; //!< The current Spectrum PHY interface (held for performance
202 //!< reasons)
203
204 private:
205 void FinalizeChannelSwitch() override;
206
207 /**
208 * Perform run-time spectrum model change
209 * @param spectrumPhyInterface the spectrum PHY interface for which the spectrum model should be
210 * changed
211 * @param centerFrequencies the center frequency of each segment the PHY interface should use
212 * @param channelWidth the total channel width the PHY interface should use
213 */
214 void ResetSpectrumModel(Ptr<WifiSpectrumPhyInterface> spectrumPhyInterface,
215 const std::vector<MHz_u>& centerFrequencies,
216 MHz_u channelWidth);
217
218 /**
219 * This function is called to update the bands handled by the InterferenceHelper.
220 * @param spectrumPhyInterface the spectrum PHY interface for which the bands should be updated
221 */
223
224 /**
225 * This function computes the RU bands that belong to a given spectrum PHY interface.
226 *
227 * @param spectrumPhyInterface the spectrum PHY interface to consider to compute the RU bands
228 * @param guardBandwidth width of the guard band
229 * @returns the computed RU bands for the spectrum PHY interface
230 */
231 RuBands GetRuBands(Ptr<WifiSpectrumPhyInterface> spectrumPhyInterface, MHz_u guardBandwidth);
232
233 /**
234 * This function computes the bands that belong to a given spectrum PHY interface.
235 *
236 * @param spectrumPhyInterface the spectrum PHY interface to consider to compute the bands
237 * @returns the computed bands for the spectrum PHY interface
238 */
240
241 /**
242 * Get the info of a given band that belongs to a given spectrum PHY interface
243 *
244 * @param spectrumPhyInterface the spectrum PHY interface
245 * @param bandWidth the width of the band to be returned
246 * @param bandIndex the index of the band to be returned
247 *
248 * @return the info that defines the band
249 */
251 MHz_u bandWidth,
252 uint8_t bandIndex = 0);
253
254 /**
255 * This is a helper function to convert start and stop indices to start and stop frequencies.
256 *
257 * @param spectrumPhyInterface the spectrum PHY interface to consider for the calculations
258 * @param indices the start/stop indices to convert
259 * @return the converted frequencies
260 */
262 Ptr<WifiSpectrumPhyInterface> spectrumPhyInterface,
263 const WifiSpectrumBandIndices& indices) const;
264
265 /**
266 * Determine whether the PHY shall issue a PHY-RXSTART.indication primitive in response to a
267 * given PPDU.
268 *
269 * @param ppdu the PPDU
270 * @return true if the PHY shall issue a PHY-RXSTART.indication primitive in response to a PPDU,
271 * false otherwise
272 */
273 bool CanStartRx(Ptr<const WifiPpdu> ppdu) const;
274
275 /**
276 * Get the spectrum PHY interface that covers a band portion of the RF channel
277 *
278 * @param frequency the center frequency of the RF channel band
279 * @param width the width of the RF channel band
280 * @return the spectrum PHY interface that covers the indicated band of the RF channel
281 */
283 MHz_u width) const;
284
285 /**
286 * Notify the spectrum channel has switched
287 */
289
290 Ptr<AntennaModel> m_antenna; //!< antenna model
291
292 bool m_disableWifiReception; //!< forces this PHY to fail to sync on any signal
293 bool m_trackSignalsInactiveInterfaces; //!< flag whether signals coming from inactive spectrum
294 //!< PHY interfaces are tracked
295 std::vector<MHz_u> m_frequenciesBeforeSwitch; //!< center frequency before channel switch
296 std::vector<MHz_u> m_widthsBeforeSwitch; //!< channel width before channel switch
297
299 m_signalCb; //!< Signal callback
300
301 dBr_u m_txMaskInnerBandMinimumRejection; //!< The minimum rejection for the inner band of the
302 //!< transmit spectrum mask
303 dBr_u m_txMaskOuterBandMinimumRejection; //!< The minimum rejection for the outer band of the
304 //!< transmit spectrum mask
305 dBr_u m_txMaskOuterBandMaximumRejection; //!< The maximum rejection for the outer band of the
306 //!< transmit spectrum mask
307
308 Callback<void> m_channelSwitchedCallback; //!< Callback when channel switched
309};
310
311} // namespace ns3
312
313#endif /* SPECTRUM_WIFI_PHY_H */
Spectrum Wifi Phy Filter Test.
Callback template class.
Definition callback.h:428
Smart pointer class similar to boost::intrusive_ptr.
Definition ptr.h:70
Defines the interface for spectrum-aware channel implementations.
std::vector< MHz_u > m_frequenciesBeforeSwitch
center frequency before channel switch
WifiSpectrumBandInfo GetBand(MHz_u bandWidth, uint8_t bandIndex=0) override
Get the info of a given band.
void(* SignalArrivalCallback)(Ptr< const SpectrumSignalParameters > signal, uint32_t senderNodeId, double rxPower, Time duration)
Callback invoked when the PHY model starts to process a signal.
void SetDevice(const Ptr< WifiNetDevice > device) override
Sets the device this PHY is associated with.
void Transmit(Ptr< WifiSpectrumSignalParameters > txParams)
This function is sending the signal to the Spectrum channel after finishing the configuration of the ...
dBr_u m_txMaskInnerBandMinimumRejection
The minimum rejection for the inner band of the transmit spectrum mask.
std::vector< MHz_u > m_widthsBeforeSwitch
channel width before channel switch
WifiSpectrumBands ComputeBands(Ptr< WifiSpectrumPhyInterface > spectrumPhyInterface)
This function computes the bands that belong to a given spectrum PHY interface.
void StartRx(Ptr< SpectrumSignalParameters > rxParams, Ptr< const WifiSpectrumPhyInterface > interface)
Input method for delivering a signal from the spectrum channel and low-level PHY interface to this Sp...
void DoInitialize() override
Initialize() implementation.
void FinalizeChannelSwitch() override
Method that can be overridden by subclasses to perform operations after the channel is actually switc...
dBr_u m_txMaskOuterBandMinimumRejection
The minimum rejection for the outer band of the transmit spectrum mask.
std::map< FrequencyRange, Ptr< WifiSpectrumPhyInterface > > m_spectrumPhyInterfaces
Spectrum PHY interfaces.
WifiSpectrumBandFrequencies ConvertIndicesToFrequenciesForInterface(Ptr< WifiSpectrumPhyInterface > spectrumPhyInterface, const WifiSpectrumBandIndices &indices) const
This is a helper function to convert start and stop indices to start and stop frequencies.
Ptr< AntennaModel > m_antenna
antenna model
FrequencyRange GetCurrentFrequencyRange() const override
Get the frequency range of the current RF interface.
Ptr< const WifiPpdu > GetRxPpduFromTxPpdu(Ptr< const WifiPpdu > ppdu)
Determine the WifiPpdu to be used by the RX PHY based on the WifiPpdu sent by the TX PHY.
MHz_u GetGuardBandwidth(MHz_u currentChannelWidth) const override
Ptr< WifiSpectrumPhyInterface > GetInterfaceCoveringChannelBand(MHz_u frequency, MHz_u width) const
Get the spectrum PHY interface that covers a band portion of the RF channel.
Ptr< AntennaModel > GetAntenna() const
Get the antenna model used for reception.
std::tuple< dBr_u, dBr_u, dBr_u > GetTxMaskRejectionParams() const override
Ptr< Channel > GetChannel() const override
Return the Channel this WifiPhy is connected to.
void AddChannel(const Ptr< SpectrumChannel > channel, const FrequencyRange &freqRange=WHOLE_WIFI_SPECTRUM)
Attach a SpectrumChannel to use for a given frequency range.
void SetChannelSwitchedCallback(Callback< void > callback)
Ptr< WifiSpectrumPhyInterface > m_currentSpectrumPhyInterface
The current Spectrum PHY interface (held for performance reasons).
Ptr< WifiSpectrumPhyInterface > GetCurrentInterface() const
Get the currently active spectrum PHY interface.
bool m_trackSignalsInactiveInterfaces
flag whether signals coming from inactive spectrum PHY interfaces are tracked
void DoDispose() override
Destructor implementation.
const std::map< FrequencyRange, Ptr< WifiSpectrumPhyInterface > > & GetSpectrumPhyInterfaces() const
Get the map of interfaces attached to this spectrum PHY.
static TypeId GetTypeId()
Get the type ID.
TracedCallback< Ptr< const SpectrumSignalParameters >, uint32_t, double, Time > m_signalCb
Signal callback.
Callback< void > m_channelSwitchedCallback
Callback when channel switched.
void SetAntenna(const Ptr< AntennaModel > antenna)
void ResetSpectrumModel(Ptr< WifiSpectrumPhyInterface > spectrumPhyInterface, const std::vector< MHz_u > &centerFrequencies, MHz_u channelWidth)
Perform run-time spectrum model change.
void ConfigureInterface(const std::vector< MHz_u > &frequencies, MHz_u width)
Configure a non-active spectrum PHY interface to operate on a given frequency (or several frequencies...
bool m_disableWifiReception
forces this PHY to fail to sync on any signal
bool CanStartRx(Ptr< const WifiPpdu > ppdu) const
Determine whether the PHY shall issue a PHY-RXSTART.indication primitive in response to a given PPDU.
void UpdateInterferenceHelperBands(Ptr< WifiSpectrumPhyInterface > spectrumPhyInterface)
This function is called to update the bands handled by the InterferenceHelper.
void StartTx(Ptr< const WifiPpdu > ppdu) override
dBr_u m_txMaskOuterBandMaximumRejection
The maximum rejection for the outer band of the transmit spectrum mask.
void NotifyChannelSwitched()
Notify the spectrum channel has switched.
void DoChannelSwitch() override
Actually switch channel based on the stored channel settings.
static uint32_t GetNumBandsBetweenSegments(const std::vector< MHz_u > &centerFrequencies, MHz_u totalWidth, Hz_u subcarrierSpacing)
Determine the number of bands between the two segments if the operating channel is made of non-contig...
WifiSpectrumBandFrequencies ConvertIndicesToFrequencies(const WifiSpectrumBandIndices &indices) const override
This is a helper function to convert start and stop indices to start and stop frequencies.
RuBands GetRuBands(Ptr< WifiSpectrumPhyInterface > spectrumPhyInterface, MHz_u guardBandwidth)
This function computes the RU bands that belong to a given spectrum PHY interface.
WifiSpectrumBandInfo GetBandForInterface(Ptr< WifiSpectrumPhyInterface > spectrumPhyInterface, MHz_u bandWidth, uint8_t bandIndex=0)
Get the info of a given band that belongs to a given spectrum PHY interface.
Simulation virtual time values and global simulation resolution.
Definition nstime.h:95
Forward calls to a chain of Callback.
a unique identifier for an interface.
Definition type-id.h:50
This class is an adaptor between class SpectrumWifiPhy (which inherits from WifiPhy) and class Spectr...
Every class exported by the ns3 library is enclosed in the ns3 namespace.
constexpr FrequencyRange WHOLE_WIFI_SPECTRUM
Identifier for the frequency range covering the whole wifi spectrum.
Definition wifi-types.h:124
double Hz_u
Hz weak type.
Definition wifi-units.h:30
std::vector< WifiSpectrumBandInfo > WifiSpectrumBands
vector of spectrum bands
double MHz_u
MHz weak type.
Definition wifi-units.h:31
dB_u dBr_u
dBr weak type
Definition wifi-units.h:29
std::pair< Hz_u, Hz_u > WifiSpectrumBandFrequencies
typedef for a pair of start and stop frequencies to represent a band
std::set< WifiSpectrumBandInfo > RuBands
Set of RU bands.
std::pair< uint32_t, uint32_t > WifiSpectrumBandIndices
typedef for a pair of start and stop sub-band indices
Struct defining a frequency range between minFrequency (MHz) and maxFrequency (MHz).
Definition wifi-types.h:94
This struct provides the generic signal representation to be used by all wireless technologies.
WifiSpectrumBandInfo structure containing info about a spectrum band.