A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
lte-ue-power-control.cc
Go to the documentation of this file.
1/*
2 * Copyright (c) 2014 Piotr Gawlowicz
3 *
4 * SPDX-License-Identifier: GPL-2.0-only
5 *
6 * Author: Piotr Gawlowicz <gawlowicz.p@gmail.com>
7 *
8 */
9
11
12#include <ns3/boolean.h>
13#include <ns3/double.h>
14#include <ns3/integer.h>
15#include <ns3/log.h>
16#include <ns3/math.h>
17
18namespace ns3
19{
20
21NS_LOG_COMPONENT_DEFINE("LteUePowerControl");
22
23NS_OBJECT_ENSURE_REGISTERED(LteUePowerControl);
24
26{
27 NS_LOG_FUNCTION(this);
28 m_deltaTF = 0;
29 m_fc = 0;
30 m_pathLoss = 100; // initial value
33 m_curSrsTxPower = 10;
34 m_txPower = 10;
35
36 m_cellId = 0;
37 m_rnti = 0;
38
39 m_M_Pusch = 0;
40 m_rsrpSet = false;
41 m_pcRsrpFilterCoefficient = 4; // Default value similar to the eNB (see lte-enb-rrc.cc)
42}
43
48
49void
54
55void
60
63{
64 static TypeId tid =
65 TypeId("ns3::LteUePowerControl")
67 .SetGroupName("Lte")
68 .AddConstructor<LteUePowerControl>()
69 .AddAttribute("ClosedLoop",
70 "If true Closed Loop mode will be active, otherwise Open Loop",
71 BooleanValue(true),
74 .AddAttribute("AccumulationEnabled",
75 "If true TCP accumulation mode will be active, otherwise absolute mode "
76 "will be active",
77 BooleanValue(true),
80 .AddAttribute("Alpha",
81 "Value of Alpha parameter",
82 DoubleValue(1.0),
85 .AddAttribute("Pcmax",
86 "Max Transmission power in dBm, Default value 23 dBm"
87 "TS36.101 section 6.2.3",
88 DoubleValue(23.0),
91 .AddAttribute("Pcmin",
92 "Min Transmission power in dBm, Default value -40 dBm"
93 "TS36.101 section 6.2.3",
94 DoubleValue(-40),
97 .AddAttribute("PoNominalPusch",
98 "P_O_NOMINAL_PUSCH INT (-126 ... 24), Default value -80",
99 IntegerValue(-80),
102 .AddAttribute("PoUePusch",
103 "P_O_UE_PUSCH INT(-8...7), Default value 0",
104 IntegerValue(0),
107 .AddAttribute("PsrsOffset",
108 "P_SRS_OFFSET INT(0...15), Default value 7",
109 IntegerValue(7),
112 .AddTraceSource("ReportPuschTxPower",
113 "Report PUSCH TxPower in dBm",
115 "ns3::LteUePowerControl::TxPowerTracedCallback")
116 .AddTraceSource("ReportPucchTxPower",
117 "Report PUCCH TxPower in dBm",
119 "ns3::LteUePowerControl::TxPowerTracedCallback")
120 .AddTraceSource("ReportSrsTxPower",
121 "Report SRS TxPower in dBm",
123 "ns3::LteUePowerControl::TxPowerTracedCallback");
124 return tid;
125}
126
127void
129{
130 NS_LOG_FUNCTION(this);
131 m_Pcmax = value;
132}
133
134double
136{
137 NS_LOG_FUNCTION(this);
138 return m_Pcmax;
139}
140
141void
143{
144 NS_LOG_FUNCTION(this);
145 m_txPower = value;
146 m_curPuschTxPower = value;
147 m_curPucchTxPower = value;
148 m_curSrsTxPower = value;
149}
150
151void
153{
154 NS_LOG_FUNCTION(this);
155 m_referenceSignalPower = referenceSignalPower;
156}
157
158void
160{
161 NS_LOG_FUNCTION(this);
162 m_cellId = cellId;
163}
164
165void
167{
168 NS_LOG_FUNCTION(this);
169 m_rnti = rnti;
170}
171
172void
174{
175 NS_LOG_FUNCTION(this);
176
177 if (m_PoNominalPusch.empty())
178 {
179 m_PoNominalPusch.push_back(value);
180 m_PoNominalPusch.push_back(value);
181 m_PoNominalPusch.push_back(value);
182 }
183 else
184 {
185 m_PoNominalPusch[0] = value;
186 m_PoNominalPusch[1] = value;
187 m_PoNominalPusch[2] = value;
188 }
189}
190
191void
193{
194 NS_LOG_FUNCTION(this);
195 if (m_PoUePusch.empty())
196 {
197 m_PoUePusch.push_back(value);
198 m_PoUePusch.push_back(value);
199 m_PoUePusch.push_back(0);
200 }
201 else
202 {
203 m_PoUePusch[0] = value;
204 m_PoUePusch[1] = value;
205 m_PoUePusch[2] = 0;
206 }
207}
208
209void
211{
212 NS_LOG_FUNCTION(this);
213
214 uint32_t temp = value * 10;
215 switch (temp)
216 {
217 case 0:
218 case 4:
219 case 5:
220 case 6:
221 case 7:
222 case 8:
223 case 9:
224 case 10:
225 break;
226 default:
227 NS_FATAL_ERROR("Unexpected Alpha value");
228 }
229
230 if (m_alpha.empty())
231 {
232 m_alpha.push_back(value);
233 m_alpha.push_back(value);
234 m_alpha.push_back(0);
235 }
236 else
237 {
238 m_alpha[0] = value;
239 m_alpha[1] = value;
240 m_alpha[2] = 1;
241 }
242}
243
244void
246{
247 NS_LOG_FUNCTION(this);
248
249 if (!m_rsrpSet)
250 {
251 m_rsrp = value;
252 m_rsrpSet = true;
253 return;
254 }
255
256 double alphaRsrp = std::pow(0.5, m_pcRsrpFilterCoefficient / 4.0);
257 m_rsrp = (1 - alphaRsrp) * m_rsrp + alphaRsrp * value;
258
260}
261
262void
264{
265 NS_LOG_FUNCTION(this);
266 m_pcRsrpFilterCoefficient = rsrpFilterCoefficient;
267}
268
269void
271{
272 NS_LOG_FUNCTION(this);
273
274 int delta = 0;
276 {
277 switch (tpc)
278 {
279 case 0:
280 delta = -1;
281 break;
282 case 1:
283 delta = 0;
284 break;
285 case 2:
286 delta = 1;
287 break;
288 case 3:
289 delta = 3;
290 break;
291 default:
292 NS_FATAL_ERROR("Unexpected TPC value");
293 }
294 }
295 else
296 {
297 switch (tpc)
298 {
299 case 0:
300 delta = -4;
301 break;
302 case 1:
303 delta = -1;
304 break;
305 case 2:
306 delta = 1;
307 break;
308 case 3:
309 delta = 4;
310 break;
311 default:
312 NS_FATAL_ERROR("Unexpected TPC value");
313 }
314 }
315
316 m_deltaPusch.push_back(delta);
317
318 if (m_closedLoop)
319 {
321 {
322 if (m_deltaPusch.size() == 4)
323 {
324 if ((m_curPuschTxPower <= m_Pcmin && m_deltaPusch.at(0) < 0) ||
325 (m_curPuschTxPower >= m_Pcmax && m_deltaPusch.at(0) > 0))
326 {
327 // TPC commands for serving cell shall not be accumulated
328 m_deltaPusch.erase(m_deltaPusch.begin());
329 }
330 else
331 {
332 m_fc = m_fc + m_deltaPusch.at(0);
333 m_deltaPusch.erase(m_deltaPusch.begin());
334 }
335 }
336 else
337 {
338 m_fc = 0;
339 }
340 }
341 else
342 {
343 m_fc = m_deltaPusch.at(0);
344 m_deltaPusch.erase(m_deltaPusch.begin());
345 }
346 }
347 else
348 {
349 m_fc = 0;
350 }
351
352 NS_LOG_INFO("ReportTpc: " << (int)tpc << " delta: " << delta << " Fc: " << m_fc);
353}
354
355void
357{
358 NS_LOG_FUNCTION(this);
359 m_M_Pusch = mask.size();
360}
361
362void
364{
365 NS_LOG_FUNCTION(this);
366 int32_t j = 1;
367 int32_t PoPusch = m_PoNominalPusch[j] + m_PoUePusch[j];
368
369 NS_LOG_INFO("RB: " << m_M_Pusch << " m_PoPusch: " << PoPusch << " Alpha: " << m_alpha[j]
370 << " PathLoss: " << m_pathLoss << " deltaTF: " << m_deltaTF
371 << " fc: " << m_fc);
372
373 if (m_M_Pusch > 0)
374 {
376 10 * log10(1.0 * m_M_Pusch) + PoPusch + m_alpha[j] * m_pathLoss + m_deltaTF + m_fc;
377 m_M_Pusch = 0;
378 }
379 else
380 {
381 m_curPuschTxPower = PoPusch + m_alpha[j] * m_pathLoss + m_fc;
382 }
383
384 NS_LOG_INFO("CalcPower: " << m_curPuschTxPower << " MinPower: " << m_Pcmin
385 << " MaxPower:" << m_Pcmax);
386
389 NS_LOG_INFO("PuschTxPower: " << m_curPuschTxPower);
390}
391
392void
399
400void
402{
403 NS_LOG_FUNCTION(this);
404 int32_t j = 1;
405 int32_t PoPusch = m_PoNominalPusch[j] + m_PoUePusch[j];
406
407 NS_LOG_INFO("RB: " << m_M_Pusch << " m_PoPusch: " << PoPusch << " Alpha: " << m_alpha[j]
408 << " PathLoss: " << m_pathLoss << " deltaTF: " << m_deltaTF
409 << " fc: " << m_fc);
410
411 double pSrsOffsetValue = -10.5 + m_PsrsOffset * 1.5;
412
414 pSrsOffsetValue + 10 * log10(m_srsBandwidth) + PoPusch + m_alpha[j] * m_pathLoss + m_fc;
415
416 NS_LOG_INFO("CalcPower: " << m_curSrsTxPower << " MinPower: " << m_Pcmin
417 << " MaxPower:" << m_Pcmax);
418
421 NS_LOG_INFO("SrsTxPower: " << m_curSrsTxPower);
422}
423
424double
426{
427 NS_LOG_FUNCTION(this);
428
429 m_M_Pusch = dlRb.size();
431
433
434 return m_curPuschTxPower;
435}
436
437double
448
449double
451{
452 NS_LOG_FUNCTION(this);
453
454 m_srsBandwidth = dlRb.size();
456
458
459 return m_curSrsTxPower;
460}
461
462} // namespace ns3
This class can be used to hold variables of floating point type such as 'double' or 'float'.
Definition double.h:31
Hold a signed integer type.
Definition integer.h:34
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.
void DoDispose() override
Destructor implementation.
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.
void DoInitialize() override
Initialize() 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.
static TypeId GetTypeId()
Get the type ID.
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.
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.
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:78
a unique identifier for an interface.
Definition type-id.h:48
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition type-id.cc:1001
#define NS_FATAL_ERROR(msg)
Report a fatal error with a message and terminate.
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition log.h:191
#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:264
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Definition object-base.h:35
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.
Ptr< const AttributeChecker > MakeBooleanChecker()
Definition boolean.cc:113
Ptr< const AttributeChecker > MakeIntegerChecker()
Definition integer.h:99
Ptr< const AttributeAccessor > MakeIntegerAccessor(T1 a1)
Definition integer.h:35
Ptr< const AttributeChecker > MakeDoubleChecker()
Definition double.h:82
Ptr< const AttributeAccessor > MakeBooleanAccessor(T1 a1)
Definition boolean.h:70
Ptr< const AttributeAccessor > MakeDoubleAccessor(T1 a1)
Definition double.h:32