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
Ptr< MobilityModel > m_mobility
the mobility model
void SetCellId(uint16_t cellId)
Set cell ID.
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:102
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:73
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by "...
Abstract base class for Spectrum-aware PHY layers.
Definition: spectrum-phy.h:45
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Definition: object-base.h:45
void SetChannel(Ptr< SpectrumChannel > c)
Set the channel attached to this device.
Ptr< NetDevice > GetDevice() const
Get the associated NetDevice instance.
void SetRxSpectrumModel(Ptr< const SpectrumModel > model)
Set receive spectrum model.
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:204
virtual void DoDispose()
Destructor implementation.
virtual void DoDispose(void)
Destructor implementation.
Definition: object.cc:346
Ptr< AntennaModel > GetRxAntenna()
Get the AntennaModel used by the NetDevice for reception.
Ptr< const TraceSourceAccessor > MakeTraceSourceAccessor(T a)
Create a TraceSourceAccessor which will control access to the underlying trace source.
Ptr< SpectrumChannel > m_channel
the channel
Ptr< AntennaModel > m_antenna
the antenna model
static TypeId GetTypeId(void)
Get the type ID.
Ptr< const SpectrumModel > GetRxSpectrumModel() const
void SetMobility(Ptr< MobilityModel > m)
Set the mobility model associated with this device.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
TracedCallback< Ptr< const SpectrumValue > > m_rxStart
receive start trace callback function
Ptr< NetDevice > m_device
the device
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
Definition: log.h:272
Ptr< MobilityModel > GetMobility()
Get the associated MobilityModel instance.
Ptr< const SpectrumModel > m_rxSpectrumModel
the spectrum model
a unique identifier for an interface.
Definition: type-id.h:58
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition: type-id.cc:915
void StartRx(Ptr< SpectrumSignalParameters > params)
Notify the SpectrumPhy instance of an incoming signal.
void SetDevice(Ptr< NetDevice > d)
Set the associated NetDevice instance.