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  */
20 
21 
22 #include <ns3/object-factory.h>
23 #include <ns3/log.h>
24 #include <ns3/double.h>
25 #include <ns3/simulator.h>
26 #include <ns3/trace-source-accessor.h>
27 #include <ns3/antenna-model.h>
28 
29 #include "rem-spectrum-phy.h"
30 
31 NS_LOG_COMPONENT_DEFINE ("RemSpectrumPhy");
32 
33 namespace ns3 {
34 
35 NS_OBJECT_ENSURE_REGISTERED (RemSpectrumPhy);
36 
38  : m_mobility (0),
39  m_referenceSignalPower (0),
40  m_sumPower (0),
41  m_active (true)
42 {
43  NS_LOG_FUNCTION (this);
44 }
45 
46 
47 
49 {
50  NS_LOG_FUNCTION (this);
51 }
52 
53 void
55 {
56  NS_LOG_FUNCTION (this);
57  m_mobility = 0;
59 }
60 
61 TypeId
63 {
64  static TypeId tid = TypeId ("ns3::RemSpectrumPhy")
66  .AddConstructor<RemSpectrumPhy> ()
67  ;
68  return tid;
69 }
70 
71 
72 
73 void
75 {
76  // this is a no-op, RemSpectrumPhy does not transmit hence it does not need a reference to the channel
77 }
78 
79 void
81 {
82  NS_LOG_FUNCTION (this << m);
83  m_mobility = m;
84 }
85 
86 void
88 {
89  NS_LOG_FUNCTION (this << d);
90  // this is a no-op, RemSpectrumPhy does not handle any data hence it does not support the use of a NetDevice
91 }
92 
95 {
96  return m_mobility;
97 }
98 
101 {
102  return 0;
103 }
104 
107 {
108  return m_rxSpectrumModel;
109 }
110 
113 {
114  return 0;
115 }
116 
117 
118 void
120 {
121  NS_LOG_FUNCTION ( this << params);
122  if (m_active)
123  {
124  double power = Integral (*(params->psd));
125  NS_ASSERT_MSG (params->duration.GetMilliSeconds () == 1,
126  "RemSpectrumPhy works only for LTE signals with duration of 1 ms");
127  m_sumPower += power;
128  if (power > m_referenceSignalPower)
129  {
130  m_referenceSignalPower = power;
131  }
132  }
133 }
134 
135 void
137 {
138  NS_LOG_FUNCTION (this << m);
139  m_rxSpectrumModel = m;
140 }
141 
142 double
143 RemSpectrumPhy::GetSinr (double noisePower)
144 {
145  return m_referenceSignalPower / (m_sumPower - m_referenceSignalPower + noisePower);
146 }
147 
148 void
150 {
151  m_active = false;
152 }
153 
154 bool
156 {
157  return m_active;
158 }
159 
160 void
162 {
164  m_sumPower = 0;
165 }
166 
167 
168 } // namespace ns3