A Discrete-Event Network Simulator
API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
lte-sinr-chunk-processor.cc
Go to the documentation of this file.
1 /* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2010 Centre Tecnologic de Telecomunicacions de Catalunya (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>
20  * (move from CQI to Ctrl and Data SINR Chunk processors
21  */
22 
23 
24 #include <ns3/log.h>
25 
27 
28 NS_LOG_COMPONENT_DEFINE ("LteSinrChunkProcessor");
29 
30 namespace ns3 {
31 
33 {
34  NS_LOG_FUNCTION (this);
35 }
36 
37 
38 // ------------- LteCtrlSinrChunkProcessor ------------------------------
39 
41  : m_phy (p),
42  m_spectrumPhy (0)
43 {
44  NS_LOG_FUNCTION (this << p);
45  NS_ASSERT (m_phy);
46 }
47 
49 : m_phy (p),
50  m_spectrumPhy (s)
51 {
52  NS_LOG_FUNCTION (this << p);
53  NS_ASSERT (m_phy);
55 }
56 
57 
59 {
60  NS_LOG_FUNCTION (this);
61 }
62 
63 
64 void
66 {
67  NS_LOG_FUNCTION (this);
68  m_sumSinr = 0;
69  m_totDuration = MicroSeconds (0);
70 }
71 
72 
73 void
75 {
76  NS_LOG_FUNCTION (this << sinr << duration);
77  if (m_sumSinr == 0)
78  {
79  m_sumSinr = Create<SpectrumValue> (sinr.GetSpectrumModel ());
80  }
81  (*m_sumSinr) += sinr * duration.GetSeconds ();
82  m_totDuration += duration;
83 }
84 
85 void
87 {
88  NS_LOG_FUNCTION (this);
89  if (m_totDuration.GetSeconds () > 0)
90  {
91  m_phy->GenerateCtrlCqiReport ((*m_sumSinr) / m_totDuration.GetSeconds ());
92  if (m_spectrumPhy)
93  {
94  m_spectrumPhy->UpdateSinrPerceived ((*m_sumSinr) / m_totDuration.GetSeconds ());
95  }
96  }
97  else
98  {
99  NS_LOG_WARN ("m_numSinr == 0");
100  }
101 }
102 
103 
104 // ------------- LteDataSinrChunkProcessor ------------------------------
105 
107 : m_spectrumPhy (s),
108  m_phy (p)
109 {
110  NS_LOG_FUNCTION (this << p);
112  NS_ASSERT (m_phy);
113 }
114 
116 : m_spectrumPhy (p),
117  m_phy (0)
118 {
119  NS_LOG_FUNCTION (this << p);
121 
122 }
123 
124 
125 
127 {
128  NS_LOG_FUNCTION (this);
129 }
130 
131 
132 void
134 {
135  NS_LOG_FUNCTION (this);
136  m_sumSinr = 0;
137  m_totDuration = MicroSeconds (0);
138 }
139 
140 
141 void
143 {
144  NS_LOG_FUNCTION (this << sinr << duration);
145  if (m_sumSinr == 0)
146  {
147  m_sumSinr = Create<SpectrumValue> (sinr.GetSpectrumModel ());
148  }
149  (*m_sumSinr) += sinr * duration.GetSeconds ();
150  m_totDuration += duration;
151 }
152 
153 void
155 {
156  NS_LOG_FUNCTION (this);
157  if (m_totDuration.GetSeconds () > 0)
158  {
159  m_spectrumPhy->UpdateSinrPerceived ((*m_sumSinr) / m_totDuration.GetSeconds ());
160  if (m_phy)
161  {
162  m_phy->GenerateDataCqiReport ((*m_sumSinr) / m_totDuration.GetSeconds ());
163  }
164  }
165  else
166  {
167  NS_LOG_WARN ("m_numSinr == 0");
168  }
169 }
170 
171 
172 
173 
174 // ------------- LteRsReceivedPowerChunkProcessor ------------------------------
175 
177 : m_phy (p)
178 {
179  NS_LOG_FUNCTION (this << p);
180  NS_ASSERT (m_phy);
181 }
182 
184 {
185  NS_LOG_FUNCTION (this);
186 }
187 
188 
189 void
191 {
192  NS_LOG_FUNCTION (this);
193  m_sumSinr = 0;
194  m_totDuration = MicroSeconds (0);
195 }
196 
197 
198 void
200 {
201  NS_LOG_FUNCTION (this << sinr << duration);
202  if (m_sumSinr == 0)
203  {
204  m_sumSinr = Create<SpectrumValue> (sinr.GetSpectrumModel ());
205  }
206  (*m_sumSinr) += sinr * duration.GetSeconds ();
207  m_totDuration += duration;
208 }
209 
210 void
212 {
213  NS_LOG_FUNCTION (this);
214  if (m_totDuration.GetSeconds () > 0)
215  {
216  m_phy->ReportRsReceivedPower ((*m_sumSinr) / m_totDuration.GetSeconds ());
217  }
218  else
219  {
220  NS_LOG_WARN ("m_numSinr == 0");
221  }
222 }
223 
224 
225 
226 
227 
228 // ------------- LteInterferencePowerChunkProcessor ------------------------------
229 
231 : m_phy (p)
232 {
233  NS_LOG_FUNCTION (this << p);
234  NS_ASSERT (m_phy);
235 }
236 
238 {
239  NS_LOG_FUNCTION (this);
240 }
241 
242 
243 void
245 {
246  NS_LOG_FUNCTION (this);
247  m_sumSinr = 0;
248  m_totDuration = MicroSeconds (0);
249 }
250 
251 
252 void
254 {
255  NS_LOG_FUNCTION (this << sinr << duration);
256  if (m_sumSinr == 0)
257  {
258  m_sumSinr = Create<SpectrumValue> (sinr.GetSpectrumModel ());
259  }
260  (*m_sumSinr) += sinr * duration.GetSeconds ();
261  m_totDuration += duration;
262 }
263 
264 void
266 {
267  NS_LOG_FUNCTION (this);
268  if (m_totDuration.GetSeconds () > 0)
269  {
270  m_phy->ReportInterference ((*m_sumSinr) / m_totDuration.GetSeconds ());
271  }
272  else
273  {
274  NS_LOG_WARN ("m_numSinr == 0");
275  }
276 }
277 
278 
279 } // namespace ns3
keep track of time values and allow control of global simulation resolution
Definition: nstime.h:81
smart pointer class similar to boost::intrusive_ptr
Definition: ptr.h:59
#define NS_LOG_FUNCTION(parameters)
Definition: log.h:345
NS_LOG_COMPONENT_DEFINE("LteSinrChunkProcessor")
virtual void EvaluateSinrChunk(const SpectrumValue &sinr, Time duration)
#define NS_ASSERT(condition)
Definition: assert.h:64
virtual void EvaluateSinrChunk(const SpectrumValue &sinr, Time duration)
double GetSeconds(void) const
Definition: nstime.h:274
Ptr< const SpectrumModel > GetSpectrumModel() const
Ptr< SampleEmitter > s
#define NS_LOG_WARN(msg)
Definition: log.h:280
virtual void EvaluateSinrChunk(const SpectrumValue &sinr, Time duration)
LteDataSinrChunkProcessor(Ptr< LteSpectrumPhy > p)
virtual void EvaluateSinrChunk(const SpectrumValue &sinr, Time duration)
Set of values corresponding to a given SpectrumModel.