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  ;
40 
42  : m_mobility (0),
43  m_referenceSignalPower (0),
44  m_sumPower (0),
45  m_active (true)
46 {
47  NS_LOG_FUNCTION (this);
48 }
49 
50 
51 
53 {
54  NS_LOG_FUNCTION (this);
55 }
56 
57 void
59 {
60  NS_LOG_FUNCTION (this);
61  m_mobility = 0;
63 }
64 
65 TypeId
67 {
68  static TypeId tid = TypeId ("ns3::RemSpectrumPhy")
70  .AddConstructor<RemSpectrumPhy> ()
71  ;
72  return tid;
73 }
74 
75 
76 
77 void
79 {
80  // this is a no-op, RemSpectrumPhy does not transmit hence it does not need a reference to the channel
81 }
82 
83 void
85 {
86  NS_LOG_FUNCTION (this << m);
87  m_mobility = m;
88 }
89 
90 void
92 {
93  NS_LOG_FUNCTION (this << d);
94  // this is a no-op, RemSpectrumPhy does not handle any data hence it does not support the use of a NetDevice
95 }
96 
99 {
100  return m_mobility;
101 }
102 
105 {
106  return 0;
107 }
108 
111 {
112  return m_rxSpectrumModel;
113 }
114 
117 {
118  return 0;
119 }
120 
121 
122 void
124 {
125  NS_LOG_FUNCTION ( this << params);
126 
127  if (m_active)
128  {
129  Ptr<LteSpectrumSignalParametersDlCtrlFrame> lteDlCtrlRxParams = DynamicCast<LteSpectrumSignalParametersDlCtrlFrame> (params);
130  if (lteDlCtrlRxParams!=0)
131  {
132  double power = Integral (*(params->psd));
133 
134  m_sumPower += power;
135  if (power > m_referenceSignalPower)
136  {
137  m_referenceSignalPower = power;
138  }
139  }
140  }
141 }
142 
143 void
145 {
146  NS_LOG_FUNCTION (this << m);
147  m_rxSpectrumModel = m;
148 }
149 
150 double
151 RemSpectrumPhy::GetSinr (double noisePower)
152 {
153  return m_referenceSignalPower / (m_sumPower - m_referenceSignalPower + noisePower);
154 }
155 
156 void
158 {
159  m_active = false;
160 }
161 
162 bool
164 {
165  return m_active;
166 }
167 
168 void
170 {
172  m_sumPower = 0;
173 }
174 
175 
176 } // 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:59
#define NS_LOG_FUNCTION(parameters)
Definition: log.h:345
Abstract base class for Spectrum-aware PHY layers.
Definition: spectrum-phy.h:45
double Integral(const SpectrumValue &arg)
void SetRxSpectrumModel(Ptr< const SpectrumModel > m)
set the RX spectrum model to be used
NS_OBJECT_ENSURE_REGISTERED(NullMessageSimulatorImpl)
virtual void DoDispose(void)
This method is called by Object::Dispose or by the object's destructor, whichever comes first...
Definition: object.cc:336
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)
NS_LOG_COMPONENT_DEFINE("RemSpectrumPhy")
a unique identifier for an interface.
Definition: type-id.h:49
TypeId SetParent(TypeId tid)
Definition: type-id.cc:611
Ptr< const SpectrumModel > GetRxSpectrumModel() const
void SetDevice(Ptr< NetDevice > d)
set the associated NetDevice instance