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
21#include <map>
22#include <optional>
23#include <vector>
24
26
27namespace ns3
28{
29
30class SpectrumChannel;
31struct SpectrumSignalParameters;
32class WifiSpectrumPhyInterface;
33struct WifiSpectrumSignalParameters;
34
35/// Map a spectrum band associated with an RU to the RU specification
36using HeRuBands = std::map<WifiSpectrumBandInfo, HeRu::RuSpec>;
37
38/**
39 * @brief 802.11 PHY layer model
40 * @ingroup wifi
41 *
42 * This PHY implements a spectrum-aware enhancement of the 802.11 SpectrumWifiPhy
43 * model.
44 *
45 * This PHY model depends on a channel loss and delay
46 * model as provided by the ns3::SpectrumPropagationLossModel
47 * and ns3::PropagationDelayModel classes.
48 *
49 */
51{
52 public:
53 /// allow SpectrumWifiPhyFilterTest class access
54 friend class ::SpectrumWifiPhyFilterTest;
55
56 /**
57 * @brief Get the type ID.
58 * @return the object TypeId
59 */
60 static TypeId GetTypeId();
61
63 ~SpectrumWifiPhy() override;
64
65 // Implementation of pure virtual method.
66 void SetDevice(const Ptr<WifiNetDevice> device) override;
67 void StartTx(Ptr<const WifiPpdu> ppdu) override;
68 Ptr<Channel> GetChannel() const override;
69 MHz_u GetGuardBandwidth(MHz_u currentChannelWidth) const override;
70 std::tuple<dBr_u, dBr_u, dBr_u> GetTxMaskRejectionParams() const override;
71 WifiSpectrumBandInfo GetBand(MHz_u bandWidth, uint8_t bandIndex = 0) override;
74 const WifiSpectrumBandIndices& indices) const override;
75
76 /**
77 * Attach a SpectrumChannel to use for a given frequency range.
78 *
79 * @param channel the SpectrumChannel to attach
80 * @param freqRange the frequency range, bounded by a minFrequency and a maxFrequency in MHz
81 */
82 void AddChannel(const Ptr<SpectrumChannel> channel,
83 const FrequencyRange& freqRange = WHOLE_WIFI_SPECTRUM);
84
85 /**
86 * Input method for delivering a signal from the spectrum channel
87 * and low-level PHY interface to this SpectrumWifiPhy instance.
88 *
89 * @param rxParams Input signal parameters
90 * @param interface the Spectrum PHY interface for which the signal has been detected
91 */
94
95 /**
96 * @param antenna an AntennaModel to include in the transmitted
97 * SpectrumSignalParameters (in case any objects downstream of the
98 * SpectrumWifiPhy wish to adjust signal properties based on the
99 * transmitted antenna model. This antenna is also used when
100 * the underlying WifiSpectrumPhyInterface::GetAntenna() method
101 * is called.
102 *
103 * Note: this method may be split into separate SetTx and SetRx
104 * methods in the future if the modeling need for this arises
105 */
106 void SetAntenna(const Ptr<AntennaModel> antenna);
107 /**
108 * Get the antenna model used for reception
109 *
110 * @return the AntennaModel used for reception
111 */
113
114 /**
115 * Callback invoked when the PHY model starts to process a signal
116 *
117 * @param senderNodeId Node Id of the sender of the signal
118 * @param rxPower received signal power (dBm)
119 * @param duration Signal duration
120 */
122 uint32_t senderNodeId,
123 double rxPower,
124 Time duration);
125
126 /**
127 * Configure a non-active spectrum PHY interface to operate on a given frequency (or several
128 * frequencies for non-contiguous) with a given total width. The function searches for the
129 * non-active PHY interface that operates on the frequency range corresponding to the spectrum
130 * portion specified by the caller. It takes care to configure the RX spectrum model of the PHY
131 * interface and to update the bands tracked in interference helper.
132 *
133 * @param frequencies the center frequency of each segment the PHY interface should use
134 * @param width the total channel width the PHY interface should use
135 */
136 void ConfigureInterface(const std::vector<MHz_u>& frequencies, MHz_u width);
137
138 /**
139 * This function is sending the signal to the Spectrum channel
140 * after finishing the configuration of the transmit parameters.
141 *
142 * @param txParams the parameters to be provided to the Spectrum channel
143 */
145
146 /**
147 * Determine the WifiPpdu to be used by the RX PHY based on the WifiPpdu sent by the TX PHY.
148 *
149 * @param ppdu the WifiPpdu transmitted by the TX PHY
150 * @return the WifiPpdu to be used by the RX PHY
151 */
153
154 /**
155 * Get the currently active spectrum PHY interface
156 *
157 * @return the current spectrum PHY interface
158 */
160
161 /**
162 * Get the map of interfaces attached to this spectrum PHY
163 *
164 * @return the map of interfaces attached to this spectrum PHY
165 */
166 const std::map<FrequencyRange, Ptr<WifiSpectrumPhyInterface>>& GetSpectrumPhyInterfaces() const;
167
168 /**
169 * Determine the number of bands between the two segments if the operating channel is made of
170 * non-contiguous segments, otherwise the function returns zero.
171 *
172 * @param centerFrequencies the center frequency of each segment
173 * @param totalWidth the width of the operating channel
174 * @param subcarrierSpacing the subcarrier spacing
175 * @return the number of bands between the two segments if the operating channel is made of
176 * non-contiguous segments, zero otherwise
177 */
178 static uint32_t GetNumBandsBetweenSegments(const std::vector<MHz_u>& centerFrequencies,
179 MHz_u totalWidth,
180 uint32_t subcarrierSpacing);
181
182 /**
183 * @param callback the callback to invoke when operating channel has switched.
184 */
186
187 protected:
188 void DoDispose() override;
189 void DoInitialize() override;
190
191 // The following method calls the base WifiPhy class method
192 // but also generates a new SpectrumModel if called during runtime
193 void DoChannelSwitch() override;
194
195 std::map<FrequencyRange, Ptr<WifiSpectrumPhyInterface>>
196 m_spectrumPhyInterfaces; //!< Spectrum PHY interfaces
197
199 m_currentSpectrumPhyInterface; //!< The current Spectrum PHY interface (held for performance
200 //!< reasons)
201
202 private:
203 void FinalizeChannelSwitch() override;
204
205 /**
206 * Perform run-time spectrum model change
207 * @param spectrumPhyInterface the spectrum PHY interface for which the spectrum model should be
208 * changed
209 * @param centerFrequencies the center frequency of each segment the PHY interface should use
210 * @param channelWidth the total channel width the PHY interface should use
211 */
212 void ResetSpectrumModel(Ptr<WifiSpectrumPhyInterface> spectrumPhyInterface,
213 const std::vector<MHz_u>& centerFrequencies,
214 MHz_u channelWidth);
215
216 /**
217 * This function is called to update the bands handled by the InterferenceHelper.
218 * @param spectrumPhyInterface the spectrum PHY interface for which the bands should be updated
219 */
221
222 /**
223 * This function computes the RU bands that belong to a given spectrum PHY interface.
224 *
225 * @param spectrumPhyInterface the spectrum PHY interface to consider to compute the RU bands
226 * @param guardBandwidth width of the guard band
227 * @returns the computed RU bands for the spectrum PHY interface
228 */
230 MHz_u guardBandwidth);
231
232 /**
233 * This function computes the bands that belong to a given spectrum PHY interface.
234 *
235 * @param spectrumPhyInterface the spectrum PHY interface to consider to compute the bands
236 * @returns the computed bands for the spectrum PHY interface
237 */
239
240 /**
241 * Get the info of a given band that belongs to a given spectrum PHY interface
242 *
243 * @param spectrumPhyInterface the spectrum PHY interface
244 * @param bandWidth the width of the band to be returned
245 * @param bandIndex the index of the band to be returned
246 *
247 * @return the info that defines the band
248 */
250 MHz_u bandWidth,
251 uint8_t bandIndex = 0);
252
253 /**
254 * This is a helper function to convert start and stop indices to start and stop frequencies.
255 *
256 * @param spectrumPhyInterface the spectrum PHY interface to consider for the calculations
257 * @param indices the start/stop indices to convert
258 * @return the converted frequencies
259 */
261 Ptr<WifiSpectrumPhyInterface> spectrumPhyInterface,
262 const WifiSpectrumBandIndices& indices) const;
263
264 /**
265 * Determine whether the PHY shall issue a PHY-RXSTART.indication primitive in response to a
266 * given PPDU.
267 *
268 * @param ppdu the PPDU
269 * @return true if the PHY shall issue a PHY-RXSTART.indication primitive in response to a PPDU,
270 * false otherwise
271 */
272 bool CanStartRx(Ptr<const WifiPpdu> ppdu) const;
273
274 /**
275 * Get the spectrum PHY interface that covers a band portion of the RF channel
276 *
277 * @param frequency the center frequency of the RF channel band
278 * @param width the width of the RF channel band
279 * @return the spectrum PHY interface that covers the indicated band of the RF channel
280 */
282 MHz_u width) const;
283
284 /**
285 * Notify the spectrum channel has switched
286 */
288
289 Ptr<AntennaModel> m_antenna; //!< antenna model
290
291 bool m_disableWifiReception; //!< forces this PHY to fail to sync on any signal
292 bool m_trackSignalsInactiveInterfaces; //!< flag whether signals coming from inactive spectrum
293 //!< PHY interfaces are tracked
294 std::vector<MHz_u> m_frequenciesBeforeSwitch; //!< center frequency before channel switch
295 std::vector<MHz_u> m_widthsBeforeSwitch; //!< channel width before channel switch
296
298 m_signalCb; //!< Signal callback
299
300 dBr_u m_txMaskInnerBandMinimumRejection; //!< The minimum rejection for the inner band of the
301 //!< transmit spectrum mask
302 dBr_u m_txMaskOuterBandMinimumRejection; //!< The minimum rejection for the outer band of the
303 //!< transmit spectrum mask
304 dBr_u m_txMaskOuterBandMaximumRejection; //!< The maximum rejection for the outer band of the
305 //!< transmit spectrum mask
306
307 Callback<void> m_channelSwitchedCallback; //!< Callback when channel switched
308};
309
310} // namespace ns3
311
312#endif /* SPECTRUM_WIFI_PHY_H */
Spectrum Wifi Phy Filter Test.
Callback template class.
Definition callback.h:422
Smart pointer class similar to boost::intrusive_ptr.
802.11 PHY layer model
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.
HeRuBands GetHeRuBands(Ptr< WifiSpectrumPhyInterface > spectrumPhyInterface, MHz_u guardBandwidth)
This function computes the RU bands that belong to a given spectrum PHY interface.
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)
static uint32_t GetNumBandsBetweenSegments(const std::vector< MHz_u > &centerFrequencies, MHz_u totalWidth, uint32_t subcarrierSpacing)
Determine the number of bands between the two segments if the operating channel is made of non-contig...
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.
WifiSpectrumBandFrequencies ConvertIndicesToFrequencies(const WifiSpectrumBandIndices &indices) const override
This is a helper function to convert start and stop indices to start and stop frequencies.
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:94
Forward calls to a chain of Callback.
a unique identifier for an interface.
Definition type-id.h:48
802.11 PHY layer model
Definition wifi-phy.h:55
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.
std::map< WifiSpectrumBandInfo, HeRu::RuSpec > HeRuBands
Map a spectrum band associated with an RU to the RU specification.
std::vector< WifiSpectrumBandInfo > WifiSpectrumBands
vector of spectrum bands
std::pair< Hz_u, Hz_u > WifiSpectrumBandFrequencies
typedef for a pair of start and stop frequencies to represent a band
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 and maxFrequency.
WifiSpectrumBandInfo structure containing info about a spectrum band.