A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
lte-simple-spectrum-phy.cc
Go to the documentation of this file.
1/*
2 * Copyright (c) 2014 Piotr Gawlowicz
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: Piotr Gawlowicz <gawlowicz.p@gmail.com>
18 *
19 */
20
22
23#include "ns3/lte-net-device.h"
24#include "ns3/lte-phy-tag.h"
25#include "ns3/lte-spectrum-signal-parameters.h"
26#include <ns3/antenna-model.h>
27#include <ns3/boolean.h>
28#include <ns3/double.h>
29#include <ns3/log.h>
30#include <ns3/simulator.h>
31
32#include <cmath>
33
34namespace ns3
35{
36
37NS_LOG_COMPONENT_DEFINE("LteSimpleSpectrumPhy");
38
39NS_OBJECT_ENSURE_REGISTERED(LteSimpleSpectrumPhy);
40
42 : m_cellId(0)
43{
44}
45
47{
48 NS_LOG_FUNCTION(this);
49}
50
51void
53{
54 NS_LOG_FUNCTION(this);
55 m_channel = nullptr;
56 m_mobility = nullptr;
57 m_device = nullptr;
59}
60
63{
64 static TypeId tid =
65 TypeId("ns3::LteSimpleSpectrumPhy")
67 .AddTraceSource("RxStart",
68 "Data reception start",
70 "ns3::SpectrumValue::TracedCallback");
71 return tid;
72}
73
76{
77 NS_LOG_FUNCTION(this);
78 return m_device;
79}
80
83{
84 NS_LOG_FUNCTION(this);
85 return m_mobility;
86}
87
88void
90{
91 NS_LOG_FUNCTION(this << d);
92 m_device = d;
93}
94
95void
97{
98 NS_LOG_FUNCTION(this << m);
99 m_mobility = m;
100}
101
102void
104{
105 NS_LOG_FUNCTION(this << c);
106 m_channel = c;
107}
108
111{
112 return m_rxSpectrumModel;
113}
114
117{
118 return m_antenna;
119}
120
121void
123{
124 NS_LOG_DEBUG("LteSimpleSpectrumPhy::StartRx");
125
126 NS_LOG_FUNCTION(this << spectrumRxParams);
127 Ptr<const SpectrumValue> rxPsd = spectrumRxParams->psd;
128 Time duration = spectrumRxParams->duration;
129
130 // the device might start RX only if the signal is of a type
131 // understood by this device - in this case, an LTE signal.
133 DynamicCast<LteSpectrumSignalParametersDataFrame>(spectrumRxParams);
134 if (lteDataRxParams)
135 {
136 if (m_cellId > 0)
137 {
138 if (m_cellId == lteDataRxParams->cellId)
139 {
140 m_rxStart(rxPsd);
141 }
142 }
143 else
144 {
145 m_rxStart(rxPsd);
146 }
147 }
148}
149
150void
152{
153 NS_LOG_FUNCTION(this);
154 m_rxSpectrumModel = model;
155}
156
157void
159{
160 NS_LOG_FUNCTION(this);
161 m_cellId = cellId;
162}
163
164} // namespace ns3
void SetMobility(Ptr< MobilityModel > m) override
Set the mobility model associated with this device.
Ptr< NetDevice > GetDevice() const override
Get the associated NetDevice instance.
Ptr< SpectrumChannel > m_channel
the channel
void SetRxSpectrumModel(Ptr< const SpectrumModel > model)
Set receive spectrum model.
void DoDispose() override
Destructor implementation.
Ptr< MobilityModel > GetMobility() const override
Get the associated MobilityModel instance.
Ptr< const SpectrumModel > GetRxSpectrumModel() const override
Ptr< AntennaModel > m_antenna
the antenna model
void SetDevice(Ptr< NetDevice > d) override
Set the associated NetDevice instance.
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.
Ptr< NetDevice > m_device
the device
Ptr< const SpectrumModel > m_rxSpectrumModel
the spectrum model
TracedCallback< Ptr< const SpectrumValue > > m_rxStart
receive start trace callback function
static TypeId GetTypeId()
Get the type ID.
Ptr< MobilityModel > m_mobility
the mobility model
void SetCellId(uint16_t cellId)
Set cell ID.
void SetChannel(Ptr< SpectrumChannel > c) override
Set the channel attached to this device.
virtual void DoDispose()
Destructor implementation.
Definition: object.cc:444
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:77
Abstract base class for Spectrum-aware PHY layers.
Definition: spectrum-phy.h:46
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:105
a unique identifier for an interface.
Definition: type-id.h:59
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition: type-id.cc:932
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:202
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
Definition: log.h:268
#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
Ptr< const TraceSourceAccessor > MakeTraceSourceAccessor(T a)
Create a TraceSourceAccessor which will control access to the underlying trace source.
Every class exported by the ns3 library is enclosed in the ns3 namespace.