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 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation;
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program; if not, write to the Free Software
15 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16 *
17 * Authors: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
18 * Ghada Badawy <gbadawy@gmail.com>
19 * Sébastien Deronne <sebastien.deronne@gmail.com>
20 *
21 * Ported from yans-wifi-phy.h by several contributors starting
22 * with Nicola Baldo and Dean Armstrong
23 */
24
25#ifndef SPECTRUM_WIFI_PHY_H
26#define SPECTRUM_WIFI_PHY_H
27
28#include "wifi-phy.h"
29
30#include "ns3/antenna-model.h"
31
32#include <map>
33#include <optional>
34
36
37namespace ns3
38{
39
40class SpectrumChannel;
41struct SpectrumSignalParameters;
42class WifiSpectrumPhyInterface;
43struct WifiSpectrumSignalParameters;
44
45/// Map a spectrum band associated with an RU to the RU specification
46using HeRuBands = std::map<WifiSpectrumBandInfo, HeRu::RuSpec>;
47
48/**
49 * \brief 802.11 PHY layer model
50 * \ingroup wifi
51 *
52 * This PHY implements a spectrum-aware enhancement of the 802.11 SpectrumWifiPhy
53 * model.
54 *
55 * This PHY model depends on a channel loss and delay
56 * model as provided by the ns3::SpectrumPropagationLossModel
57 * and ns3::PropagationDelayModel classes.
58 *
59 */
61{
62 public:
63 /// allow SpectrumWifiPhyFilterTest class access
64 friend class ::SpectrumWifiPhyFilterTest;
65
66 /**
67 * \brief Get the type ID.
68 * \return the object TypeId
69 */
70 static TypeId GetTypeId();
71
73 ~SpectrumWifiPhy() override;
74
75 // Implementation of pure virtual method.
76 void SetDevice(const Ptr<WifiNetDevice> device) override;
77 void StartTx(Ptr<const WifiPpdu> ppdu) override;
78 Ptr<Channel> GetChannel() const override;
79 uint16_t GetGuardBandwidth(uint16_t currentChannelWidth) const override;
80 std::tuple<double, double, double> GetTxMaskRejectionParams() const override;
81 WifiSpectrumBandInfo GetBand(uint16_t bandWidth, uint8_t bandIndex = 0) override;
84 const WifiSpectrumBandIndices& indices) const override;
85
86 /**
87 * Attach a SpectrumChannel to use for a given frequency range.
88 *
89 * \param channel the SpectrumChannel to attach
90 * \param freqRange the frequency range, bounded by a minFrequency and a maxFrequency in MHz
91 */
92 void AddChannel(const Ptr<SpectrumChannel> channel,
93 const FrequencyRange& freqRange = WHOLE_WIFI_SPECTRUM);
94
95 /**
96 * Input method for delivering a signal from the spectrum channel
97 * and low-level PHY interface to this SpectrumWifiPhy instance.
98 *
99 * \param rxParams Input signal parameters
100 * \param interface the Spectrum PHY interface for which the signal has been detected
101 */
104
105 /**
106 * \param antenna an AntennaModel to include in the transmitted
107 * SpectrumSignalParameters (in case any objects downstream of the
108 * SpectrumWifiPhy wish to adjust signal properties based on the
109 * transmitted antenna model. This antenna is also used when
110 * the underlying WifiSpectrumPhyInterface::GetAntenna() method
111 * is called.
112 *
113 * Note: this method may be split into separate SetTx and SetRx
114 * methods in the future if the modeling need for this arises
115 */
116 void SetAntenna(const Ptr<AntennaModel> antenna);
117 /**
118 * Get the antenna model used for reception
119 *
120 * \return the AntennaModel used for reception
121 */
123
124 /**
125 * Callback invoked when the PHY model starts to process a signal
126 *
127 * \param signalType Whether signal is WiFi (true) or foreign (false)
128 * \param senderNodeId Node Id of the sender of the signal
129 * \param rxPower received signal power (dBm)
130 * \param duration Signal duration
131 */
132 typedef void (*SignalArrivalCallback)(bool signalType,
133 uint32_t senderNodeId,
134 double rxPower,
135 Time duration);
136
137 /**
138 * Configure a non-active spectrum PHY interface to operate on a given frequency with a given
139 * width. The function searches for the non-active PHY interface that operates on the frequency
140 * range corresponding to the spectrum portion specified by the caller. It takes care to
141 * configure the RX spectrum model of the PHY interface and to update the bands tracked in
142 * interference helper.
143 *
144 * \param frequency the center frequency in MHz the PHY interface should use
145 * \param width the channel width in MHz the PHY interface should use
146 */
147 void ConfigureInterface(uint16_t frequency, uint16_t width);
148
149 /**
150 * This function is sending the signal to the Spectrum channel
151 * after finishing the configuration of the transmit parameters.
152 *
153 * \param txParams the parameters to be provided to the Spectrum channel
154 */
156
157 /**
158 * Determine the WifiPpdu to be used by the RX PHY based on the WifiPpdu sent by the TX PHY.
159 *
160 * \param ppdu the WifiPpdu transmitted by the TX PHY
161 * \return the WifiPpdu to be used by the RX PHY
162 */
164
165 /**
166 * Get the currently active spectrum PHY interface
167 *
168 * \return the current spectrum PHY interface
169 */
171
172 /**
173 * Get the map of interfaces attached to this spectrum PHY
174 *
175 * \return the map of interfaces attached to this spectrum PHY
176 */
177 const std::map<FrequencyRange, Ptr<WifiSpectrumPhyInterface>>& GetSpectrumPhyInterfaces() const;
178
179 /**
180 * \param callback the callback to invoke when operating channel has switched.
181 */
183
184 protected:
185 void DoDispose() override;
186 void DoInitialize() override;
187
188 // The following method calls the base WifiPhy class method
189 // but also generates a new SpectrumModel if called during runtime
190 void DoChannelSwitch() override;
191
192 std::map<FrequencyRange, Ptr<WifiSpectrumPhyInterface>>
193 m_spectrumPhyInterfaces; //!< Spectrum PHY interfaces
194
196 m_currentSpectrumPhyInterface; //!< The current Spectrum PHY interface (held for performance
197 //!< reasons)
198
199 private:
200 /**
201 * Perform run-time spectrum model change
202 * \param spectrumPhyInterface the spectrum PHY interface for which the spectrum model should be
203 * changed \param centerFrequency the center frequency in MHz the PHY interface should use
204 * \param channelWidth the channel width in MHz the PHY interface should use
205 */
206 void ResetSpectrumModel(Ptr<WifiSpectrumPhyInterface> spectrumPhyInterface,
207 uint16_t centerFrequency,
208 uint16_t channelWidth);
209
210 /**
211 * This function is called to update the bands handled by the InterferenceHelper.
212 * \param spectrumPhyInterface the spectrum PHY interface for which the bands should be updated
213 */
215
216 /**
217 * This function computes the RU bands that belong to a given spectrum PHY interface.
218 *
219 * \param spectrumPhyInterface the spectrum PHY interface to consider to compute the RU bands
220 * \param guardBandwidth width of the guard band in MHz
221 * \returns the computed RU bands for the spectrum PHY interface
222 */
224 uint16_t guardBandwidth);
225
226 /**
227 * This function computes the bands that belong to a given spectrum PHY interface.
228 *
229 * \param spectrumPhyInterface the spectrum PHY interface to consider to compute the bands
230 * \returns the computed bands for the spectrum PHY interface
231 */
233
234 /**
235 * Get the info of a given band that belongs to a given spectrum PHY interface
236 *
237 * \param spectrumPhyInterface the spectrum PHY interface
238 * \param bandWidth the width of the band to be returned (MHz)
239 * \param bandIndex the index of the band to be returned
240 *
241 * \return the info that defines the band
242 */
244 uint16_t bandWidth,
245 uint8_t bandIndex = 0);
246
247 /**
248 * This is a helper function to convert start and stop indices to start and stop frequencies.
249 *
250 * \param spectrumPhyInterface the spectrum PHY interface to consider for the calculations
251 * \param indices the start/stop indices to convert
252 * \return the converted frequencies
253 */
255 Ptr<WifiSpectrumPhyInterface> spectrumPhyInterface,
256 const WifiSpectrumBandIndices& indices) const;
257
258 /**
259 * Determine whether the PHY shall issue a PHY-RXSTART.indication primitive in response to a
260 * given PPDU.
261 *
262 * \param ppdu the PPDU
263 * \return true if the PHY shall issue a PHY-RXSTART.indication primitive in response to a PPDU,
264 * false otherwise
265 */
266 bool CanStartRx(Ptr<const WifiPpdu> ppdu) const;
267
268 /**
269 * Get the spectrum PHY interface that covers a band portion of the RF channel
270 *
271 * \param frequency the center frequency in MHz of the RF channel band
272 * \param width the width in MHz of the RF channel band
273 * \return the spectrum PHY interface that covers the indicated band of the RF channel
274 */
276 uint16_t width) const;
277
278 /**
279 * Notify the spectrum channel has switched
280 */
282
283 Ptr<AntennaModel> m_antenna; //!< antenna model
284
285 bool m_disableWifiReception; //!< forces this PHY to fail to sync on any signal
286 bool m_trackSignalsInactiveInterfaces; //!< flag whether signals coming from inactive spectrum
287 //!< PHY interfaces are tracked
288
290
291 double m_txMaskInnerBandMinimumRejection; //!< The minimum rejection (in dBr) for the inner band
292 //!< of the transmit spectrum mask
293 double m_txMaskOuterBandMinimumRejection; //!< The minimum rejection (in dBr) for the outer band
294 //!< of the transmit spectrum mask
295 double m_txMaskOuterBandMaximumRejection; //!< The maximum rejection (in dBr) for the outer band
296 //!< of the transmit spectrum mask
297
298 Callback<void> m_channelSwitchedCallback; //!< Callback when channel switched
299};
300
301} // namespace ns3
302
303#endif /* SPECTRUM_WIFI_PHY_H */
Spectrum Wifi Phy Filter Test.
Callback template class.
Definition: callback.h:438
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:77
802.11 PHY layer model
TracedCallback< bool, uint32_t, double, Time > m_signalCb
Signal callback.
std::tuple< double, double, double > GetTxMaskRejectionParams() const override
void ResetSpectrumModel(Ptr< WifiSpectrumPhyInterface > spectrumPhyInterface, uint16_t centerFrequency, uint16_t channelWidth)
Perform run-time spectrum model change.
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 ...
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.
HeRuBands GetHeRuBands(Ptr< WifiSpectrumPhyInterface > spectrumPhyInterface, uint16_t guardBandwidth)
This function computes the RU bands that belong to a given spectrum PHY interface.
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.
void ConfigureInterface(uint16_t frequency, uint16_t width)
Configure a non-active spectrum PHY interface to operate on a given frequency with a given width.
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.
Ptr< WifiSpectrumPhyInterface > GetInterfaceCoveringChannelBand(uint16_t frequency, uint16_t 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.
void(* SignalArrivalCallback)(bool signalType, uint32_t senderNodeId, double rxPower, Time duration)
Callback invoked when the PHY model starts to process a signal.
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.
double m_txMaskInnerBandMinimumRejection
The minimum rejection (in dBr) for the inner band of the transmit spectrum mask.
bool m_trackSignalsInactiveInterfaces
flag whether signals coming from inactive spectrum PHY interfaces are tracked
double m_txMaskOuterBandMinimumRejection
The minimum rejection (in dBr) for the outer band of the transmit spectrum mask.
void DoDispose() override
Destructor implementation.
uint16_t GetGuardBandwidth(uint16_t currentChannelWidth) const override
WifiSpectrumBandInfo GetBandForInterface(Ptr< WifiSpectrumPhyInterface > spectrumPhyInterface, uint16_t bandWidth, uint8_t bandIndex=0)
Get the info of a given band that belongs to a given spectrum PHY interface.
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.
Callback< void > m_channelSwitchedCallback
Callback when channel switched.
void SetAntenna(const Ptr< AntennaModel > antenna)
double m_txMaskOuterBandMaximumRejection
The maximum rejection (in dBr) for the outer band of the transmit spectrum mask.
WifiSpectrumBandInfo GetBand(uint16_t bandWidth, uint8_t bandIndex=0) override
Get the info of a given band.
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
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.
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:105
Forward calls to a chain of Callback.
a unique identifier for an interface.
Definition: type-id.h:59
802.11 PHY layer model
Definition: wifi-phy.h:65
Every class exported by the ns3 library is enclosed in the ns3 namespace.
std::pair< uint64_t, uint64_t > WifiSpectrumBandFrequencies
typedef for a pair of start and stop frequencies in Hz to represent a band
constexpr FrequencyRange WHOLE_WIFI_SPECTRUM
Identifier for the frequency range covering the whole wifi spectrum.
std::vector< WifiSpectrumBandInfo > WifiSpectrumBands
vector of spectrum bands
std::pair< uint32_t, uint32_t > WifiSpectrumBandIndices
typedef for a pair of start and stop sub-band indices
std::map< WifiSpectrumBandInfo, HeRu::RuSpec > HeRuBands
Map a spectrum band associated with an RU to the RU specification.
Struct defining a frequency range between minFrequency (MHz) and maxFrequency (MHz).
WifiSpectrumBandInfo structure containing info about a spectrum band.