A Discrete-Event Network Simulator
API
lte-ue-power-control.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
23#include <ns3/log.h>
24#include <ns3/boolean.h>
25#include <ns3/double.h>
26#include <ns3/integer.h>
27#include <ns3/math.h>
28
29namespace ns3 {
30
31NS_LOG_COMPONENT_DEFINE ("LteUePowerControl");
32
33NS_OBJECT_ENSURE_REGISTERED (LteUePowerControl);
34
36{
37 NS_LOG_FUNCTION (this);
38 m_deltaTF = 0;
39 m_fc = 0;
40 m_pathLoss = 100; //initial value
43 m_curSrsTxPower = 10;
44 m_txPower = 10;
45
46 m_cellId = 0;
47 m_rnti = 0;
48
49 m_M_Pusch = 0;
50 m_rsrpSet = false;
51 m_pcRsrpFilterCoefficient = 4; //Default value similar to the eNB (see lte-enb-rrc.cc)
52}
53
55{
56 NS_LOG_FUNCTION (this);
57}
58
59void
61{
62 NS_LOG_FUNCTION (this);
63}
64
65void
67{
68 NS_LOG_FUNCTION (this);
69}
70
73{
74 static TypeId tid = TypeId ("ns3::LteUePowerControl")
75 .SetParent<Object> ()
76 .SetGroupName("Lte")
77 .AddConstructor<LteUePowerControl> ()
78 .AddAttribute ("ClosedLoop",
79 "If true Closed Loop mode will be active, otherwise Open Loop",
80 BooleanValue (true),
83 .AddAttribute ("AccumulationEnabled",
84 "If true TCP accumulation mode will be active, otherwise absolute mode will be active",
85 BooleanValue (true),
88 .AddAttribute ("Alpha",
89 "Value of Alpha parameter",
90 DoubleValue (1.0),
92 MakeDoubleChecker<double> ())
93 .AddAttribute ("Pcmax",
94 "Max Transmission power in dBm, Default value 23 dBm"
95 "TS36.101 section 6.2.3",
96 DoubleValue (23.0),
98 MakeDoubleChecker<double> ())
99 .AddAttribute ("Pcmin",
100 "Min Transmission power in dBm, Default value -40 dBm"
101 "TS36.101 section 6.2.3",
102 DoubleValue (-40),
104 MakeDoubleChecker<double> ())
105 .AddAttribute ("PoNominalPusch",
106 "P_O_NOMINAL_PUSCH INT (-126 ... 24), Default value -80",
107 IntegerValue (-80),
109 MakeIntegerChecker<int16_t> ())
110 .AddAttribute ("PoUePusch",
111 "P_O_UE_PUSCH INT(-8...7), Default value 0",
112 IntegerValue (0),
114 MakeIntegerChecker<int16_t> ())
115 .AddAttribute ("PsrsOffset",
116 "P_SRS_OFFSET INT(0...15), Default value 7",
117 IntegerValue (7),
119 MakeIntegerChecker<int16_t> ())
120 .AddTraceSource ("ReportPuschTxPower",
121 "Report PUSCH TxPower in dBm",
123 "ns3::LteUePowerControl::TxPowerTracedCallback")
124 .AddTraceSource ("ReportPucchTxPower",
125 "Report PUCCH TxPower in dBm",
127 "ns3::LteUePowerControl::TxPowerTracedCallback")
128 .AddTraceSource ("ReportSrsTxPower",
129 "Report SRS TxPower in dBm",
131 "ns3::LteUePowerControl::TxPowerTracedCallback")
132 ;
133 return tid;
134}
135
136void
138{
139 NS_LOG_FUNCTION (this);
140 m_Pcmax = value;
141}
142
143double
145{
146 NS_LOG_FUNCTION (this);
147 return m_Pcmax;
148}
149
150void
152{
153 NS_LOG_FUNCTION (this);
154 m_txPower = value;
155 m_curPuschTxPower = value;
156 m_curPucchTxPower = value;
157 m_curSrsTxPower = value;
158}
159
160void
162{
163 NS_LOG_FUNCTION (this);
164 m_referenceSignalPower = referenceSignalPower;
165}
166
167void
169{
170 NS_LOG_FUNCTION (this);
171 m_cellId = cellId;
172}
173void
175{
176 NS_LOG_FUNCTION (this);
177 m_rnti = rnti;
178}
179
180void
182{
183 NS_LOG_FUNCTION (this);
184
185 if (m_PoNominalPusch.empty ())
186 {
187 m_PoNominalPusch.push_back (value);
188 m_PoNominalPusch.push_back (value);
189 m_PoNominalPusch.push_back (value);
190 }
191 else
192 {
193 m_PoNominalPusch[0] = value;
194 m_PoNominalPusch[1] = value;
195 m_PoNominalPusch[2] = value;
196 }
197
198}
199void
201{
202 NS_LOG_FUNCTION (this);
203 if (m_PoUePusch.empty ())
204 {
205 m_PoUePusch.push_back (value);
206 m_PoUePusch.push_back (value);
207 m_PoUePusch.push_back (0);
208 }
209 else
210 {
211 m_PoUePusch[0] = value;
212 m_PoUePusch[1] = value;
213 m_PoUePusch[2] = 0;
214 }
215}
216void
218{
219 NS_LOG_FUNCTION (this);
220
221 uint32_t temp = value * 10;
222 switch (temp)
223 {
224 case 0:
225 case 4:
226 case 5:
227 case 6:
228 case 7:
229 case 8:
230 case 9:
231 case 10:
232 break;
233 default:
234 NS_FATAL_ERROR ("Unexpected Alpha value");
235 }
236
237 if (m_alpha.empty ())
238 {
239 m_alpha.push_back (value);
240 m_alpha.push_back (value);
241 m_alpha.push_back (0);
242 }
243 else
244 {
245 m_alpha[0] = value;
246 m_alpha[1] = value;
247 m_alpha[2] = 1;
248 }
249
250}
251
252void
254{
255 NS_LOG_FUNCTION (this);
256
257 if (!m_rsrpSet)
258 {
259 m_rsrp = value;
260 m_rsrpSet = true;
261 return;
262 }
263
264 double alphaRsrp = std::pow (0.5, m_pcRsrpFilterCoefficient / 4.0);
265 m_rsrp = (1 - alphaRsrp) * m_rsrp + alphaRsrp * value;
266
268}
269
270void
271LteUePowerControl::SetRsrpFilterCoefficient (uint8_t rsrpFilterCoefficient)
272{
273 NS_LOG_FUNCTION (this);
274 m_pcRsrpFilterCoefficient = rsrpFilterCoefficient;
275}
276
277void
279{
280 NS_LOG_FUNCTION (this);
281
282 int delta = 0;
284 {
285 switch (tpc)
286 {
287 case 0:
288 delta = -1;
289 break;
290 case 1:
291 delta = 0;
292 break;
293 case 2:
294 delta = 1;
295 break;
296 case 3:
297 delta = 3;
298 break;
299 default:
300 NS_FATAL_ERROR ("Unexpected TPC value");
301 }
302 }
303 else
304 {
305 switch (tpc)
306 {
307 case 0:
308 delta = -4;
309 break;
310 case 1:
311 delta = -1;
312 break;
313 case 2:
314 delta = 1;
315 break;
316 case 3:
317 delta = 4;
318 break;
319 default:
320 NS_FATAL_ERROR ("Unexpected TPC value");
321 }
322 }
323
324 m_deltaPusch.push_back (delta);
325
326 if (m_closedLoop)
327 {
329 {
330 if (m_deltaPusch.size () == 4)
331 {
332 if ((m_curPuschTxPower <= m_Pcmin && m_deltaPusch.at (0) < 0)
333 || (m_curPuschTxPower >= m_Pcmax && m_deltaPusch.at (0) > 0))
334 {
335 //TPC commands for serving cell shall not be accumulated
336 m_deltaPusch.erase (m_deltaPusch.begin ());
337 }
338 else
339 {
340 m_fc = m_fc + m_deltaPusch.at (0);
341 m_deltaPusch.erase (m_deltaPusch.begin ());
342 }
343 }
344 else
345 {
346 m_fc = 0;
347 }
348 }
349 else
350 {
351 m_fc = m_deltaPusch.at (0);
352 m_deltaPusch.erase (m_deltaPusch.begin ());
353 }
354 }
355 else
356 {
357 m_fc = 0;
358 }
359
360 NS_LOG_INFO ("ReportTpc: " << (int)tpc << " delta: " << delta << " Fc: " << m_fc);
361}
362
363void
365{
366 NS_LOG_FUNCTION (this);
367 m_M_Pusch = mask.size ();
368}
369
370void
372{
373 NS_LOG_FUNCTION (this);
374 int32_t j = 1;
375 int32_t PoPusch = m_PoNominalPusch[j] + m_PoUePusch[j];
376
377 NS_LOG_INFO ("RB: " << m_M_Pusch << " m_PoPusch: " << PoPusch
378 << " Alpha: " << m_alpha[j] << " PathLoss: " << m_pathLoss
379 << " deltaTF: " << m_deltaTF << " fc: " << m_fc);
380
381 if ( m_M_Pusch > 0 )
382 {
383 m_curPuschTxPower = 10 * log10 (1.0 * m_M_Pusch) + PoPusch + m_alpha[j] * m_pathLoss + m_deltaTF + m_fc;
384 m_M_Pusch = 0;
385 }
386 else
387 {
388 m_curPuschTxPower = PoPusch + m_alpha[j] * m_pathLoss + m_fc;
389 }
390
391 NS_LOG_INFO ("CalcPower: " << m_curPuschTxPower << " MinPower: " << m_Pcmin << " MaxPower:" << m_Pcmax);
392
395 NS_LOG_INFO ("PuschTxPower: " << m_curPuschTxPower);
396}
397
398void
400{
401 NS_LOG_FUNCTION (this);
403 NS_LOG_INFO ("PucchTxPower: " << m_curPucchTxPower);
404}
405
406void
408{
409 NS_LOG_FUNCTION (this);
410 int32_t j = 1;
411 int32_t PoPusch = m_PoNominalPusch[j] + m_PoUePusch[j];
412
413 NS_LOG_INFO ("RB: " << m_M_Pusch << " m_PoPusch: " << PoPusch
414 << " Alpha: " << m_alpha[j] << " PathLoss: " << m_pathLoss
415 << " deltaTF: " << m_deltaTF << " fc: " << m_fc);
416
417
418 double pSrsOffsetValue = -10.5 + m_PsrsOffset * 1.5;
419
420 m_curSrsTxPower = pSrsOffsetValue + 10 * log10 (m_srsBandwidth) + PoPusch + m_alpha[j] * m_pathLoss + m_fc;
421
422 NS_LOG_INFO ("CalcPower: " << m_curSrsTxPower << " MinPower: " << m_Pcmin << " MaxPower:" << m_Pcmax);
423
426 NS_LOG_INFO ("SrsTxPower: " << m_curSrsTxPower);
427}
428
429
430double
432{
433 NS_LOG_FUNCTION (this);
434
435 m_M_Pusch = dlRb.size ();
437
439
440 return m_curPuschTxPower;
441}
442
443double
445{
446 NS_LOG_FUNCTION (this);
447
449
451
452 return m_curPucchTxPower;
453}
454
455double
456LteUePowerControl::GetSrsTxPower (std::vector <int> dlRb)
457{
458 NS_LOG_FUNCTION (this);
459
460 m_srsBandwidth = dlRb.size ();
462
464
465 return m_curSrsTxPower;
466}
467
468} // namespace ns3
AttributeValue implementation for Boolean.
Definition: boolean.h:37
This class can be used to hold variables of floating point type such as 'double' or 'float'.
Definition: double.h:41
Hold a signed integer type.
Definition: integer.h:44
This class realizes Uplink Power Control functionality.
void SetPoNominalPusch(int16_t value)
Set PO nominal PUSCH function.
bool m_closedLoop
is closed loop
double m_referenceSignalPower
reference signal power in dBm
TracedCallback< uint16_t, uint16_t, double > m_reportSrsTxPower
Trace information regarding Uplink TxPower uint16_t cellId, uint16_t rnti, double txPower.
TracedCallback< uint16_t, uint16_t, double > m_reportPucchTxPower
Trace information regarding Uplink TxPower uint16_t cellId, uint16_t rnti, double txPower.
void SetCellId(uint16_t cellId)
Set the cell ID function.
double m_txPower
transmit power
double m_curPucchTxPower
current PUCCH transmit power
void SetPoUePusch(int16_t value)
Set PO UE PUSCH function.
std::vector< double > m_alpha
alpha values
std::vector< int16_t > m_PoUePusch
PO US PUSCH.
void SetRsrp(double value)
Set RSRP function.
void SetPcmax(double value)
Set PC maximum function.
double m_pathLoss
path loss value in dB
void ConfigureReferenceSignalPower(int8_t referenceSignalPower)
Configure reference signal power (dBm) function.
virtual void DoDispose(void)
Destructor implementation.
std::vector< int16_t > m_PoNominalPusch
PO nominal PUSCH.
void SetRnti(uint16_t rnti)
Set the RNTI function.
double GetPucchTxPower(std::vector< int > rb)
Get PUCCH transmit power function.
int16_t m_PsrsOffset
PSRS offset.
double m_curPuschTxPower
current PUSCH transmit power
void SetTxPower(double value)
Set transmit power function.
std::vector< int8_t > m_deltaPusch
delta PUSCH
void CalculatePuschTxPower()
Calculate PUSCH transmit power function.
double GetPcmax()
Get PC maximum function.
void SetSubChannelMask(std::vector< int > mask)
Set subchannel mask function.
void SetRsrpFilterCoefficient(uint8_t rsrpFilterCoefficient)
Set RSRP function.
uint16_t m_srsBandwidth
SRS bandwidth.
uint8_t m_pcRsrpFilterCoefficient
The RsrpFilterCoefficient attribute.
void CalculatePucchTxPower()
Calculate PUCCH transmit power function.
double GetPuschTxPower(std::vector< int > rb)
Get PUSCH transmit power function.
uint16_t m_M_Pusch
size of DL RB list
void ReportTpc(uint8_t tpc)
Set RSRP function.
virtual void DoInitialize(void)
Initialize() implementation.
double GetSrsTxPower(std::vector< int > rb)
Get SRS transmit power function.
void SetAlpha(double value)
Set alpha function.
double m_rsrp
RSRP value in dBm.
void CalculateSrsTxPower()
Calculate SRS transmit power function.
static TypeId GetTypeId(void)
Get the type ID.
double m_curSrsTxPower
current SRS transmit power
TracedCallback< uint16_t, uint16_t, double > m_reportPuschTxPower
Trace information regarding Uplink TxPower uint16_t cellId, uint16_t rnti, double txPower.
bool m_accumulationEnabled
accumulation enabled
A base class which provides memory management and object aggregation.
Definition: object.h:88
a unique identifier for an interface.
Definition: type-id.h:59
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition: type-id.cc:922
Ptr< const AttributeChecker > MakeBooleanChecker(void)
Definition: boolean.cc:121
Ptr< const AttributeAccessor > MakeBooleanAccessor(T1 a1)
Definition: boolean.h:85
Ptr< const AttributeAccessor > MakeDoubleAccessor(T1 a1)
Definition: double.h:42
Ptr< const AttributeAccessor > MakeIntegerAccessor(T1 a1)
Definition: integer.h:45
#define NS_FATAL_ERROR(msg)
Report a fatal error with a message and terminate.
Definition: fatal-error.h:165
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:205
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by ",...
#define NS_LOG_INFO(msg)
Use NS_LOG to output a message of level LOG_INFO.
Definition: log.h:281
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Definition: object-base.h:45
Ptr< const TraceSourceAccessor > MakeTraceSourceAccessor(T a)
Create a TraceSourceAccessor which will control access to the underlying trace source.
Every class exported by the ns3 library is enclosed in the ns3 namespace.