A Discrete-Event Network Simulator
API
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 
37 namespace ns3
38 {
39 
40 class SpectrumChannel;
41 struct SpectrumSignalParameters;
42 class WifiSpectrumPhyInterface;
43 struct WifiSpectrumSignalParameters;
44 
46 using HeRuBands = std::map<WifiSpectrumBandInfo, HeRu::RuSpec>;
47 
60 class SpectrumWifiPhy : public WifiPhy
61 {
62  public:
64  friend class ::SpectrumWifiPhyFilterTest;
65 
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 
93  const FrequencyRange& freqRange = WHOLE_WIFI_SPECTRUM);
94 
104 
116  void SetAntenna(const Ptr<AntennaModel> antenna);
123 
132  typedef void (*SignalArrivalCallback)(bool signalType,
133  uint32_t senderNodeId,
134  double rxPower,
135  Time duration);
136 
147  void ConfigureInterface(uint16_t frequency, uint16_t width);
148 
156 
164 
171 
177  const std::map<FrequencyRange, Ptr<WifiSpectrumPhyInterface>>& GetSpectrumPhyInterfaces() const;
178 
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>>
194 
198 
199  private:
206  void ResetSpectrumModel(Ptr<WifiSpectrumPhyInterface> spectrumPhyInterface,
207  uint16_t centerFrequency,
208  uint16_t channelWidth);
209 
215 
224  uint16_t guardBandwidth);
225 
233 
244  uint16_t bandWidth,
245  uint8_t bandIndex = 0);
246 
255  Ptr<WifiSpectrumPhyInterface> spectrumPhyInterface,
256  const WifiSpectrumBandIndices& indices) const;
257 
266  bool CanStartRx(Ptr<const WifiPpdu> ppdu) const;
267 
276  uint16_t width) const;
277 
281  void NotifyChannelSwitched();
282 
284 
288 
290 
297 
299 };
300 
301 } // namespace ns3
302 
303 #endif /* SPECTRUM_WIFI_PHY_H */
Spectrum Wifi Phy Filter Test.
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:53
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.
channel
Definition: third.py:88
Struct defining a frequency range between minFrequency (MHz) and maxFrequency (MHz).
WifiSpectrumBandInfo structure containing info about a spectrum band.