A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
rem-spectrum-phy.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 * Modified by: Marco Miozzo <mmiozzo@cttc.es> convert to
8 * LteSpectrumSignalParametersDlCtrlFrame framework
9 */
10
11#include "rem-spectrum-phy.h"
12
14
15#include <ns3/antenna-model.h>
16#include <ns3/double.h>
17#include <ns3/log.h>
18#include <ns3/object-factory.h>
19#include <ns3/simulator.h>
20#include <ns3/trace-source-accessor.h>
21
22namespace ns3
23{
24
25NS_LOG_COMPONENT_DEFINE("RemSpectrumPhy");
26
27NS_OBJECT_ENSURE_REGISTERED(RemSpectrumPhy);
28
30 : m_mobility(nullptr),
31 m_referenceSignalPower(0),
32 m_sumPower(0),
33 m_active(true),
34 m_useDataChannel(false),
35 m_rbId(-1)
36{
37 NS_LOG_FUNCTION(this);
38}
39
44
45void
52
55{
56 static TypeId tid = TypeId("ns3::RemSpectrumPhy")
58 .SetGroupName("Lte")
59 .AddConstructor<RemSpectrumPhy>();
60 return tid;
61}
62
63void
65{
66 // this is a no-op, RemSpectrumPhy does not transmit hence it does not need a reference to the
67 // channel
68}
69
70void
76
77void
79{
80 NS_LOG_FUNCTION(this << d);
81 // this is a no-op, RemSpectrumPhy does not handle any data hence it does not support the use of
82 // a NetDevice
83}
84
87{
88 return m_mobility;
89}
90
93{
94 return nullptr;
95}
96
102
105{
106 return nullptr;
107}
108
109void
111{
112 NS_LOG_FUNCTION(this << params);
113
114 if (m_active)
115 {
117 {
120 if (lteDlDataRxParams)
121 {
122 NS_LOG_DEBUG("StartRx data");
123 double power = 0;
124 if (m_rbId >= 0)
125 {
126 power = (*(params->psd))[m_rbId] * 180000;
127 }
128 else
129 {
130 power = Integral(*(params->psd));
131 }
132
133 m_sumPower += power;
134 if (power > m_referenceSignalPower)
135 {
137 }
138 }
139 }
140 else
141 {
144 if (lteDlCtrlRxParams)
145 {
146 NS_LOG_DEBUG("StartRx control");
147 double power = 0;
148 if (m_rbId >= 0)
149 {
150 power = (*(params->psd))[m_rbId] * 180000;
151 }
152 else
153 {
154 power = Integral(*(params->psd));
155 }
156
157 m_sumPower += power;
158 if (power > m_referenceSignalPower)
159 {
161 }
162 }
163 }
164 }
165}
166
167void
173
174double
175RemSpectrumPhy::GetSinr(double noisePower) const
176{
178}
179
180void
182{
183 m_active = false;
184}
185
186bool
188{
189 return m_active;
190}
191
192void
198
199void
201{
202 m_useDataChannel = value;
203}
204
205void
207{
208 m_rbId = rbId;
209}
210
211} // namespace ns3
virtual void DoDispose()
Destructor implementation.
Definition object.cc:433
Smart pointer class similar to boost::intrusive_ptr.
This minimal SpectrumPhy implementation calculates the SINR with respect to the strongest signal for ...
double m_referenceSignalPower
reference signal power
Ptr< MobilityModel > m_mobility
the mobility model
void DoDispose() override
Destructor implementation.
void Reset()
Reset the SINR calculator.
double GetSinr(double noisePower) const
void Deactivate()
make StartRx a no-op from now on, and mark instance as inactive
Ptr< const SpectrumModel > m_rxSpectrumModel
receive spectrum model
void StartRx(Ptr< SpectrumSignalParameters > params) override
Notify the SpectrumPhy instance of an incoming signal.
Ptr< Object > GetAntenna() const override
Get the AntennaModel used by this SpectrumPhy instance for transmission and/or reception.
void SetRbId(int32_t rbId)
set RB Id
static TypeId GetTypeId()
Get the type ID.
double m_sumPower
sum power
void SetRxSpectrumModel(Ptr< const SpectrumModel > m)
set the RX spectrum model to be used
Ptr< const SpectrumModel > GetRxSpectrumModel() const override
Ptr< NetDevice > GetDevice() const override
Get the associated NetDevice instance.
bool m_active
is active?
void SetMobility(Ptr< MobilityModel > m) override
Set the mobility model associated with this device.
void SetUseDataChannel(bool value)
set usage of DataChannel
Ptr< MobilityModel > GetMobility() const override
Get the associated MobilityModel instance.
void SetChannel(Ptr< SpectrumChannel > c) override
Set the channel attached to this device.
bool m_useDataChannel
use data channel
void SetDevice(Ptr< NetDevice > d) override
Set the associated NetDevice instance.
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
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition log.h:191
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
Definition log.h:257
#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.
double Integral(const SpectrumValue &arg)
Ptr< T1 > DynamicCast(const Ptr< T2 > &p)
Cast a Ptr.
Definition ptr.h:580