A Discrete-Event Network Simulator
API
wifi-spectrum-phy-interface.cc
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2009 CTTC
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  * Author: Nicola Baldo <nbaldo@cttc.es>
18  */
19 
21 
22 #include "ns3/log.h"
23 #include "ns3/mobility-model.h"
24 #include "ns3/net-device.h"
25 #include "ns3/spectrum-channel.h"
26 #include "ns3/spectrum-value.h"
27 
28 NS_LOG_COMPONENT_DEFINE("WifiSpectrumPhyInterface");
29 
30 namespace ns3
31 {
32 
33 NS_OBJECT_ENSURE_REGISTERED(WifiSpectrumPhyInterface);
34 
35 TypeId
37 {
38  static TypeId tid =
39  TypeId("ns3::WifiSpectrumPhyInterface").SetParent<SpectrumPhy>().SetGroupName("Wifi");
40  return tid;
41 }
42 
44  : m_frequencyRange{freqRange},
45  m_centerFrequency{0},
46  m_channelWidth{0},
47  m_bands{},
48  m_heRuBands{}
49 {
50  NS_LOG_FUNCTION(this << freqRange);
51 }
52 
53 void
55 {
56  NS_LOG_FUNCTION(this);
57  m_rxSpectrumModel = nullptr;
58  m_spectrumWifiPhy = nullptr;
59  m_netDevice = nullptr;
60  m_channel = nullptr;
61  m_bands.clear();
62  m_heRuBands.clear();
63 }
64 
65 void
67 {
68  m_spectrumWifiPhy = spectrumWifiPhy;
69 }
70 
73 {
74  return m_spectrumWifiPhy;
75 }
76 
79 {
80  return m_netDevice;
81 }
82 
85 {
87 }
88 
89 void
91 {
92  m_netDevice = d;
93 }
94 
95 void
97 {
99 }
100 
101 void
103 {
104  NS_LOG_FUNCTION(this << c);
105  NS_ASSERT_MSG(!m_rxSpectrumModel, "Spectrum channel shall be set before RX spectrum model");
106  m_channel = c;
107 }
108 
109 void
111  uint16_t channelWidth,
112  uint32_t bandBandwidth,
113  uint16_t guardBandwidth)
114 {
115  NS_LOG_FUNCTION(this << centerFrequency << channelWidth << bandBandwidth << guardBandwidth);
116  m_centerFrequency = centerFrequency;
117  m_channelWidth = channelWidth;
119  channelWidth,
120  bandBandwidth,
121  guardBandwidth);
122 }
123 
126 {
127  return m_channel;
128 }
129 
132 {
133  return m_rxSpectrumModel;
134 }
135 
138 {
139  return m_spectrumWifiPhy->GetAntenna();
140 }
141 
142 const FrequencyRange&
144 {
145  return m_frequencyRange;
146 }
147 
148 uint16_t
150 {
151  return m_centerFrequency;
152 }
153 
154 uint16_t
156 {
157  return m_channelWidth;
158 }
159 
160 void
162 {
163  m_bands = std::move(bands);
164 }
165 
166 const WifiSpectrumBands&
168 {
169  return m_bands;
170 }
171 
172 void
174 {
175  m_heRuBands = std::move(heRuBands);
176 }
177 
178 const HeRuBands&
180 {
181  return m_heRuBands;
182 }
183 
184 void
186 {
188 }
189 
190 void
192 {
193  params->txPhy = Ptr<SpectrumPhy>(this);
194  params->txAntenna = m_spectrumWifiPhy->GetAntenna();
195  m_channel->StartTx(params);
196 }
197 
198 } // namespace ns3
Abstract base class for Spectrum-aware PHY layers.
Definition: spectrum-phy.h:46
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...
Ptr< AntennaModel > GetAntenna() const
Get the antenna model used for reception.
a unique identifier for an interface.
Definition: type-id.h:59
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition: type-id.cc:931
Ptr< MobilityModel > GetMobility() const
Return the mobility model this PHY is associated with.
Definition: wifi-phy.cc:625
void SetMobility(const Ptr< MobilityModel > mobility)
assign a mobility model to this device
Definition: wifi-phy.cc:619
void SetDevice(const Ptr< NetDevice > d) override
Set the associated NetDevice instance.
const HeRuBands & GetHeRuBands() const
Get the HE RU spectrum bands handled by this interface.
void StartTx(Ptr< SpectrumSignalParameters > params)
Start transmission over the spectrum channel.
const FrequencyRange & GetFrequencyRange() const
Get the frequency range covered by the spectrum channel this interface is attached to.
Ptr< const SpectrumModel > m_rxSpectrumModel
receive spectrum model
uint16_t m_centerFrequency
center frequency in MHz
HeRuBands m_heRuBands
Store all the distinct spectrum bands associated with every RU.
uint16_t m_channelWidth
channel width in MHz
Ptr< Object > GetAntenna() const override
Get the AntennaModel used by this SpectrumPhy instance for transmission and/or reception.
FrequencyRange m_frequencyRange
frequency range
void SetSpectrumWifiPhy(const Ptr< SpectrumWifiPhy > phy)
Connect SpectrumWifiPhy object.
const WifiSpectrumBands & GetBands() const
Get the vector of spectrum bands handled by this interface.
void SetRxSpectrumModel(uint32_t centerFrequency, uint16_t channelWidth, uint32_t bandBandwidth, uint16_t guardBandwidth)
Set the RX spectrum model.
Ptr< NetDevice > m_netDevice
the device
void SetChannel(const Ptr< SpectrumChannel > c) override
Set the channel attached to this device.
void DoDispose() override
Destructor implementation.
void StartRx(Ptr< SpectrumSignalParameters > params) override
Notify the SpectrumPhy instance of an incoming signal.
uint16_t GetCenterFrequency() const
Get the center frequency in MHz of the the spectrum channel this interface is attached to.
Ptr< const SpectrumModel > GetRxSpectrumModel() const override
void SetHeRuBands(HeRuBands &&heRuBands)
Set the HE RU spectrum bands handled by this interface (if any)
void SetMobility(const Ptr< MobilityModel > m) override
Set the mobility model associated with this device.
Ptr< NetDevice > GetDevice() const override
Get the associated NetDevice instance.
WifiSpectrumBands m_bands
Store all the distinct spectrum bands associated with every channels widths.
WifiSpectrumPhyInterface(FrequencyRange freqRange)
Constructor.
Ptr< MobilityModel > GetMobility() const override
Get the associated MobilityModel instance.
void SetBands(WifiSpectrumBands &&bands)
Set the vector of spectrum bands handled by this interface.
uint16_t GetChannelWidth() const
Get the channel width in MHz covered by the spectrum channel this interface is attached to.
static TypeId GetTypeId()
Get the type ID.
Ptr< SpectrumChannel > m_channel
spectrum channel
Ptr< SpectrumChannel > GetChannel() const
Get the spectrum channel this interface is attached to.
Ptr< SpectrumWifiPhy > m_spectrumWifiPhy
spectrum PHY
Ptr< const SpectrumWifiPhy > GetSpectrumWifiPhy() const
Get SpectrumWifiPhy object.
static Ptr< SpectrumModel > GetSpectrumModel(uint32_t centerFrequency, uint16_t channelWidth, uint32_t carrierSpacing, uint16_t guardBandwidth)
Return a SpectrumModel instance corresponding to the center frequency and channel width.
#define NS_ASSERT_MSG(condition, message)
At runtime, in debugging builds, if this condition is not true, the program prints the message to out...
Definition: assert.h:86
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:202
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by ",...
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Definition: object-base.h:46
Every class exported by the ns3 library is enclosed in the ns3 namespace.
std::vector< WifiSpectrumBandInfo > WifiSpectrumBands
vector of spectrum bands
std::map< WifiSpectrumBandInfo, HeRu::RuSpec > HeRuBands
Map a spectrum band associated with an RU to the RU specification.
params
Fit Fluctuating Two Ray model to the 3GPP TR 38.901 using the Anderson-Darling goodness-of-fit ##.
Struct defining a frequency range between minFrequency (MHz) and maxFrequency (MHz).