A Discrete-Event Network Simulator
API
lte-simple-spectrum-phy.cc
Go to the documentation of this file.
1 /* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2014 Piotr Gawlowicz
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License version 2 as
7  * published by the Free Software Foundation;
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17  *
18  * Author: Piotr Gawlowicz <gawlowicz.p@gmail.com>
19  *
20  */
21 
22 #include <ns3/log.h>
23 #include <cmath>
24 #include <ns3/simulator.h>
25 #include <ns3/antenna-model.h>
27 #include "ns3/lte-spectrum-signal-parameters.h"
28 #include "ns3/lte-net-device.h"
29 #include "ns3/lte-phy-tag.h"
30 #include <ns3/boolean.h>
31 #include <ns3/double.h>
32 
33 namespace ns3 {
34 
35 NS_LOG_COMPONENT_DEFINE ("LteSimpleSpectrumPhy");
36 
37 NS_OBJECT_ENSURE_REGISTERED (LteSimpleSpectrumPhy);
38 
40  : m_cellId (0)
41 {
42 }
43 
44 
46 {
47  NS_LOG_FUNCTION (this);
48 }
49 
51 {
52  NS_LOG_FUNCTION (this);
53  m_channel = 0;
54  m_mobility = 0;
55  m_device = 0;
57 }
58 
59 
60 TypeId
62 {
63  static TypeId tid = TypeId ("ns3::LteSimpleSpectrumPhy")
65  .AddTraceSource ("RxStart",
66  "Data reception start",
68  "ns3::SpectrumValue::TracedCallback")
69  ;
70  return tid;
71 }
72 
73 
74 
77 {
78  NS_LOG_FUNCTION (this);
79  return m_device;
80 }
81 
82 
85 {
86  NS_LOG_FUNCTION (this);
87  return m_mobility;
88 }
89 
90 
91 void
93 {
94  NS_LOG_FUNCTION (this << d);
95  m_device = d;
96 }
97 
98 
99 void
101 {
102  NS_LOG_FUNCTION (this << m);
103  m_mobility = m;
104 }
105 
106 
107 void
109 {
110  NS_LOG_FUNCTION (this << c);
111  m_channel = c;
112 }
113 
116 {
117  return m_rxSpectrumModel;
118 }
119 
120 
123 {
124  return m_antenna;
125 }
126 
127 void
129 {
130  NS_LOG_DEBUG ("LteSimpleSpectrumPhy::StartRx");
131 
132  NS_LOG_FUNCTION (this << spectrumRxParams);
133  Ptr <const SpectrumValue> rxPsd = spectrumRxParams->psd;
134  Time duration = spectrumRxParams->duration;
135 
136  // the device might start RX only if the signal is of a type
137  // understood by this device - in this case, an LTE signal.
138  Ptr<LteSpectrumSignalParametersDataFrame> lteDataRxParams = DynamicCast<LteSpectrumSignalParametersDataFrame> (spectrumRxParams);
139  if (lteDataRxParams != 0)
140  {
141  if ( m_cellId > 0 )
142  {
143  if (m_cellId == lteDataRxParams->cellId)
144  {
145  m_rxStart (rxPsd);
146  }
147  }
148  else
149  {
150  m_rxStart (rxPsd);
151  }
152  }
153 }
154 
155 void
157 {
158  NS_LOG_FUNCTION (this);
159  m_rxSpectrumModel = model;
160 }
161 
162 void
164 {
165  NS_LOG_FUNCTION (this);
166  m_cellId = cellId;
167 }
168 
169 
170 
171 } // namespace ns3
void SetDevice(Ptr< NetDevice > d)
Set the associated NetDevice instance.
Ptr< const SpectrumModel > GetRxSpectrumModel() const
Ptr< SpectrumChannel > m_channel
the channel
Ptr< MobilityModel > GetMobility() const
Get the associated MobilityModel instance.
void SetChannel(Ptr< SpectrumChannel > c)
Set the channel attached to this device.
void SetRxSpectrumModel(Ptr< const SpectrumModel > model)
Set receive spectrum model.
static TypeId GetTypeId(void)
Get the type ID.
Ptr< NetDevice > GetDevice() const
Get the associated NetDevice instance.
Ptr< AntennaModel > m_antenna
the antenna model
TracedCallback< Ptr< const SpectrumValue > > m_rxStart
receive start trace callback function
Ptr< Object > GetAntenna() const
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
virtual void DoDispose()
Destructor implementation.
void SetMobility(Ptr< MobilityModel > m)
Set the mobility model associated with this device.
Ptr< MobilityModel > m_mobility
the mobility model
void SetCellId(uint16_t cellId)
Set cell ID.
void StartRx(Ptr< SpectrumSignalParameters > params)
Notify the SpectrumPhy instance of an incoming signal.
virtual void DoDispose(void)
Destructor implementation.
Definition: object.cc:346
Abstract base class for Spectrum-aware PHY layers.
Definition: spectrum-phy.h:47
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:103
a unique identifier for an interface.
Definition: type-id.h:59
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition: type-id.cc:922
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:205
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
Definition: log.h:273
#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:45
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.