A Discrete-Event Network Simulator
API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
rem-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) 2009 CTTC
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: Nicola Baldo <nbaldo@cttc.es>
19  * Modified by: Marco Miozzo <mmiozzo@cttc.es> convert to
20  * LteSpectrumSignalParametersDlCtrlFrame framework
21  */
22 
23 
24 #include <ns3/object-factory.h>
25 #include <ns3/log.h>
26 #include <ns3/double.h>
27 #include <ns3/simulator.h>
28 #include <ns3/trace-source-accessor.h>
29 #include <ns3/lte-spectrum-signal-parameters.h>
30 #include <ns3/antenna-model.h>
31 
32 #include "rem-spectrum-phy.h"
33 
34 NS_LOG_COMPONENT_DEFINE ("RemSpectrumPhy");
35 
36 namespace ns3 {
37 
38 NS_OBJECT_ENSURE_REGISTERED (RemSpectrumPhy);
39 
41  : m_mobility (0),
42  m_referenceSignalPower (0),
43  m_sumPower (0),
44  m_active (true)
45 {
46  NS_LOG_FUNCTION (this);
47 }
48 
49 
50 
52 {
53  NS_LOG_FUNCTION (this);
54 }
55 
56 void
58 {
59  NS_LOG_FUNCTION (this);
60  m_mobility = 0;
62 }
63 
64 TypeId
66 {
67  static TypeId tid = TypeId ("ns3::RemSpectrumPhy")
69  .AddConstructor<RemSpectrumPhy> ()
70  ;
71  return tid;
72 }
73 
74 
75 
76 void
78 {
79  // this is a no-op, RemSpectrumPhy does not transmit hence it does not need a reference to the channel
80 }
81 
82 void
84 {
85  NS_LOG_FUNCTION (this << m);
86  m_mobility = m;
87 }
88 
89 void
91 {
92  NS_LOG_FUNCTION (this << d);
93  // this is a no-op, RemSpectrumPhy does not handle any data hence it does not support the use of a NetDevice
94 }
95 
98 {
99  return m_mobility;
100 }
101 
104 {
105  return 0;
106 }
107 
110 {
111  return m_rxSpectrumModel;
112 }
113 
116 {
117  return 0;
118 }
119 
120 
121 void
123 {
124  NS_LOG_FUNCTION ( this << params);
125 
126  if (m_active)
127  {
128  Ptr<LteSpectrumSignalParametersDlCtrlFrame> lteDlCtrlRxParams = DynamicCast<LteSpectrumSignalParametersDlCtrlFrame> (params);
129  if (lteDlCtrlRxParams!=0)
130  {
131  double power = Integral (*(params->psd));
132 
133  m_sumPower += power;
134  if (power > m_referenceSignalPower)
135  {
136  m_referenceSignalPower = power;
137  }
138  }
139  }
140 }
141 
142 void
144 {
145  NS_LOG_FUNCTION (this << m);
146  m_rxSpectrumModel = m;
147 }
148 
149 double
150 RemSpectrumPhy::GetSinr (double noisePower)
151 {
152  return m_referenceSignalPower / (m_sumPower - m_referenceSignalPower + noisePower);
153 }
154 
155 void
157 {
158  m_active = false;
159 }
160 
161 bool
163 {
164  return m_active;
165 }
166 
167 void
169 {
171  m_sumPower = 0;
172 }
173 
174 
175 } // namespace ns3
Ptr< MobilityModel > GetMobility()
get the associated MobilityModel instance
double GetSinr(double noisePower)
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
double Integral(const SpectrumValue &arg)
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register the class in the ns-3 factory.
Definition: object-base.h:38
void SetRxSpectrumModel(Ptr< const SpectrumModel > m)
set the RX spectrum model to be used
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:170
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< AntennaModel > GetRxAntenna()
get the AntennaModel used by the NetDevice for reception
Ptr< NetDevice > GetDevice()
get the associated NetDevice instance
void Reset()
Reset the SINR calculator.
void Deactivate()
make StartRx a no-op from now on, and mark instance as inactive
void StartRx(Ptr< SpectrumSignalParameters > params)
Notify the SpectrumPhy instance of an incoming signal.
Ptr< const SpectrumModel > m_rxSpectrumModel
Ptr< MobilityModel > m_mobility
void SetChannel(Ptr< SpectrumChannel > c)
Set the channel attached to this device.
void SetMobility(Ptr< MobilityModel > m)
Set the mobility model associated with this device.
void DoDispose()
This method is called by Object::Dispose or by the object's destructor, whichever comes first...
static TypeId GetTypeId(void)
a unique identifier for an interface.
Definition: type-id.h:49
TypeId SetParent(TypeId tid)
Definition: type-id.cc:610
Ptr< const SpectrumModel > GetRxSpectrumModel() const
void SetDevice(Ptr< NetDevice > d)
set the associated NetDevice instance