A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
wifi-spectrum-phy-interface.cc
Go to the documentation of this file.
1/*
2 * Copyright (c) 2009 CTTC
3 *
4 * SPDX-License-Identifier: GPL-2.0-only
5 *
6 * Author: Nicola Baldo <nbaldo@cttc.es>
7 */
8
10
11#include "ns3/log.h"
12#include "ns3/mobility-model.h"
13#include "ns3/net-device.h"
14#include "ns3/spectrum-channel.h"
15#include "ns3/spectrum-value.h"
16
17#include <sstream>
18
19NS_LOG_COMPONENT_DEFINE("WifiSpectrumPhyInterface");
20
21namespace ns3
22{
23
24NS_OBJECT_ENSURE_REGISTERED(WifiSpectrumPhyInterface);
25
26TypeId
28{
29 static TypeId tid =
30 TypeId("ns3::WifiSpectrumPhyInterface").SetParent<SpectrumPhy>().SetGroupName("Wifi");
31 return tid;
32}
33
35 : m_frequencyRange{freqRange},
36 m_centerFrequencies{},
37 m_channelWidth{0},
38 m_bands{},
39 m_heRuBands{}
40{
41 NS_LOG_FUNCTION(this << freqRange);
42}
43
44void
46{
47 NS_LOG_FUNCTION(this);
48 m_rxSpectrumModel = nullptr;
49 m_spectrumWifiPhy = nullptr;
50 m_netDevice = nullptr;
51 m_channel = nullptr;
52 m_bands.clear();
53 m_heRuBands.clear();
54}
55
56void
58{
59 m_spectrumWifiPhy = spectrumWifiPhy;
60}
61
67
73
76{
77 return m_spectrumWifiPhy->GetMobility();
78}
79
80void
85
86void
91
92void
94{
95 NS_LOG_FUNCTION(this << c);
96 NS_ASSERT_MSG(!m_rxSpectrumModel, "Spectrum channel shall be set before RX spectrum model");
97 m_channel = c;
98}
99
100void
101WifiSpectrumPhyInterface::SetRxSpectrumModel(const std::vector<MHz_u>& centerFrequencies,
102 MHz_u channelWidth,
103 Hz_u bandBandwidth,
104 MHz_u guardBandwidth)
105{
106 std::stringstream ss;
107 for (const auto& centerFrequency : centerFrequencies)
108 {
109 ss << centerFrequency << " ";
110 }
111 NS_LOG_FUNCTION(this << ss.str() << channelWidth << bandBandwidth << guardBandwidth);
112 m_centerFrequencies = centerFrequencies;
113 m_channelWidth = channelWidth;
115 channelWidth,
116 bandBandwidth,
117 guardBandwidth);
118}
119
125
131
134{
135 return m_spectrumWifiPhy->GetAntenna();
136}
137
138const FrequencyRange&
143
144const std::vector<MHz_u>&
149
150MHz_u
155
156void
158{
159 m_bands = std::move(bands);
160}
161
164{
165 return m_bands;
166}
167
168void
170{
171 m_heRuBands = std::move(heRuBands);
172}
173
174const HeRuBands&
179
180void
185
186void
188{
189 params->txPhy = Ptr<SpectrumPhy>(this);
190 params->txAntenna = m_spectrumWifiPhy->GetAntenna();
191 m_channel->StartTx(params);
192}
193
194} // namespace ns3
Smart pointer class similar to boost::intrusive_ptr.
Abstract base class for Spectrum-aware PHY layers.
a unique identifier for an interface.
Definition type-id.h:48
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition type-id.cc:1001
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
void SetRxSpectrumModel(const std::vector< MHz_u > &centerFrequencies, MHz_u channelWidth, Hz_u bandBandwidth, MHz_u guardBandwidth)
Set the RX spectrum model.
HeRuBands m_heRuBands
Store all the distinct spectrum bands associated with every RU.
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 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.
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.
MHz_u GetChannelWidth() const
Get the channel width covered by the spectrum channel this interface is attached to.
const std::vector< MHz_u > & GetCenterFrequencies() const
Get the center frequency for each segment of the the spectrum channel this interface is attached to.
void SetBands(WifiSpectrumBands &&bands)
Set the vector of spectrum bands handled by this interface.
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.
std::vector< MHz_u > m_centerFrequencies
center frequency per segment
Ptr< SpectrumWifiPhy > m_spectrumWifiPhy
spectrum PHY
Ptr< const SpectrumWifiPhy > GetSpectrumWifiPhy() const
Get SpectrumWifiPhy object.
static Ptr< SpectrumModel > GetSpectrumModel(const std::vector< MHz_u > &centerFrequencies, MHz_u channelWidth, Hz_u carrierSpacing, MHz_u 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:75
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition log.h:191
#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:35
Every class exported by the ns3 library is enclosed in the ns3 namespace.
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
double MHz_u
MHz weak type.
Definition wifi-units.h:31
Struct defining a frequency range between minFrequency and maxFrequency.