A Discrete-Event Network Simulator
API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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 NS_LOG_COMPONENT_DEFINE ("LteSimpleSpectrumPhy");
34 
35 namespace ns3 {
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  ;
69  return tid;
70 }
71 
72 
73 
76 {
77  NS_LOG_FUNCTION (this);
78  return m_device;
79 }
80 
81 
84 {
85  NS_LOG_FUNCTION (this);
86  return m_mobility;
87 }
88 
89 
90 void
92 {
93  NS_LOG_FUNCTION (this << d);
94  m_device = d;
95 }
96 
97 
98 void
100 {
101  NS_LOG_FUNCTION (this << m);
102  m_mobility = m;
103 }
104 
105 
106 void
108 {
109  NS_LOG_FUNCTION (this << c);
110  m_channel = c;
111 }
112 
115 {
116  return m_rxSpectrumModel;
117 }
118 
119 
122 {
123  return m_antenna;
124 }
125 
126 void
128 {
129  NS_LOG_DEBUG ("LteSimpleSpectrumPhy::StartRx");
130 
131  NS_LOG_FUNCTION (this << spectrumRxParams);
132  Ptr <const SpectrumValue> rxPsd = spectrumRxParams->psd;
133  Time duration = spectrumRxParams->duration;
134 
135  // the device might start RX only if the signal is of a type
136  // understood by this device - in this case, an LTE signal.
137  Ptr<LteSpectrumSignalParametersDataFrame> lteDataRxParams = DynamicCast<LteSpectrumSignalParametersDataFrame> (spectrumRxParams);
138  if (lteDataRxParams != 0)
139  {
140  if ( m_cellId > 0 )
141  {
142  if (m_cellId == lteDataRxParams->cellId)
143  {
144  m_rxStart (rxPsd);
145  }
146  }
147  else
148  {
149  m_rxStart (rxPsd);
150  }
151  }
152 }
153 
154 void
156 {
157  NS_LOG_FUNCTION (this);
158  m_rxSpectrumModel = model;
159 }
160 
161 void
163 {
164  NS_LOG_FUNCTION (this);
165  m_cellId = cellId;
166 }
167 
168 
169 
170 } // namespace ns3
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:95
smart pointer class similar to boost::intrusive_ptr
Definition: ptr.h:60
#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 the class in the ns-3 factory.
Definition: object-base.h:38
void SetChannel(Ptr< SpectrumChannel > c)
Set the channel attached to this device.
void SetRxSpectrumModel(Ptr< const SpectrumModel > model)
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:170
virtual void DoDispose()
This method is called by Object::Dispose or by the object's destructor, whichever comes first...
virtual void DoDispose(void)
This method is called by Object::Dispose or by the object's destructor, whichever comes first...
Definition: object.cc:335
Ptr< const SpectrumModel > GetRxSpectrumModel() const
Ptr< AntennaModel > GetRxAntenna()
get the AntennaModel used by the NetDevice for reception
Ptr< SpectrumChannel > m_channel
void SetMobility(Ptr< MobilityModel > m)
Set the mobility model associated with this device.
TracedCallback< Ptr< const SpectrumValue > > m_rxStart
Ptr< const TraceSourceAccessor > MakeTraceSourceAccessor(T a)
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
Definition: log.h:213
Ptr< MobilityModel > GetMobility()
get the associated MobilityModel instance
Ptr< NetDevice > GetDevice()
get the associated NetDevice instance
Ptr< const SpectrumModel > m_rxSpectrumModel
a unique identifier for an interface.
Definition: type-id.h:49
TypeId SetParent(TypeId tid)
Definition: type-id.cc:610
void StartRx(Ptr< SpectrumSignalParameters > params)
Notify the SpectrumPhy instance of an incoming signal.
void SetDevice(Ptr< NetDevice > d)
set the associated NetDevice instance