A Discrete-Event Network Simulator
API
lte-test-downlink-power-control.cc
Go to the documentation of this file.
1/*
2 * Copyright (c) 2014 Piotr Gawlowicz
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation;
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program; if not, write to the Free Software
15 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16 *
17 * Author: Piotr Gawlowicz <gawlowicz.p@gmail.com>
18 *
19 */
20
22
23#include "lte-ffr-simple.h"
24
25#include "ns3/lte-helper.h"
26#include "ns3/mobility-helper.h"
27#include <ns3/boolean.h>
28#include <ns3/callback.h>
29#include <ns3/config.h>
30#include <ns3/double.h>
31#include <ns3/enum.h>
32#include <ns3/ff-mac-scheduler.h>
33#include <ns3/log.h>
34#include <ns3/lte-chunk-processor.h>
35#include <ns3/lte-common.h>
36#include <ns3/lte-enb-net-device.h>
37#include <ns3/lte-enb-phy.h>
38#include <ns3/lte-enb-rrc.h>
39#include <ns3/lte-rrc-sap.h>
40#include <ns3/lte-ue-net-device.h>
41#include <ns3/lte-ue-phy.h>
42#include <ns3/lte-ue-rrc.h>
43#include <ns3/pointer.h>
44#include <ns3/simulator.h>
45#include <ns3/string.h>
46
47using namespace ns3;
48
49NS_LOG_COMPONENT_DEFINE("LteDownlinkPowerControlTest");
50
56 : TestSuite("lte-downlink-power-control", SYSTEM)
57{
58 // LogLevel logLevel = (LogLevel)(LOG_PREFIX_FUNC | LOG_PREFIX_TIME | LOG_LEVEL_DEBUG);
59 // LogComponentEnable ("LteDownlinkPowerControlTest", logLevel);
60 NS_LOG_INFO("Creating LteDownlinkPowerControlTestSuite");
61
62 // Spectrum helper test
63 {
64 std::vector<int> activeRbs_txpowdB30nrb6run1earfcn500(4);
65 activeRbs_txpowdB30nrb6run1earfcn500[0] = 0;
66 activeRbs_txpowdB30nrb6run1earfcn500[1] = 2;
67 activeRbs_txpowdB30nrb6run1earfcn500[2] = 3;
68 activeRbs_txpowdB30nrb6run1earfcn500[3] = 5;
69
70 uint16_t earfcn = 500;
71 uint8_t bw = 6;
72 double powerTx = 30;
73
74 std::map<int, double> powerTxMap;
75 double rbTxPower = powerTx;
76
77 rbTxPower = CalculateRbTxPower(powerTx, LteRrcSap::PdschConfigDedicated::dB_6);
78 powerTxMap.insert(std::pair<int, double>(0, rbTxPower));
79
80 rbTxPower = CalculateRbTxPower(powerTx, LteRrcSap::PdschConfigDedicated::dB_3);
81 powerTxMap.insert(std::pair<int, double>(2, rbTxPower));
82
83 rbTxPower = CalculateRbTxPower(powerTx, LteRrcSap::PdschConfigDedicated::dB0);
84 powerTxMap.insert(std::pair<int, double>(3, rbTxPower));
85
86 rbTxPower = CalculateRbTxPower(powerTx, LteRrcSap::PdschConfigDedicated::dB2);
87 powerTxMap.insert(std::pair<int, double>(5, rbTxPower));
88
89 SpectrumValue spectrumValue_txpowdB30nrb6run1earfcn500(
90 LteSpectrumValueHelper::GetSpectrumModel(500, 6));
91 spectrumValue_txpowdB30nrb6run1earfcn500[0] = 2.325820769916e-07;
92 spectrumValue_txpowdB30nrb6run1earfcn500[1] = 0.000000000000e+00;
93 spectrumValue_txpowdB30nrb6run1earfcn500[2] = 4.640622533585e-07;
94 spectrumValue_txpowdB30nrb6run1earfcn500[3] = 9.259259259259e-07;
95 spectrumValue_txpowdB30nrb6run1earfcn500[4] = 0.000000000000e+00;
96 spectrumValue_txpowdB30nrb6run1earfcn500[5] = 1.467493696723e-06;
97
99 "txpowdB30nrb6run1earfcn500_allRbPower",
100 earfcn,
101 bw,
102 powerTx,
103 powerTxMap,
104 activeRbs_txpowdB30nrb6run1earfcn500,
105 spectrumValue_txpowdB30nrb6run1earfcn500),
106 TestCase::QUICK);
107 }
108 {
109 // if power for RB not present, but RB is active, use powerTx
110 std::vector<int> activeRbs_txpowdB30nrb6run1earfcn500(4);
111 activeRbs_txpowdB30nrb6run1earfcn500[0] = 0;
112 activeRbs_txpowdB30nrb6run1earfcn500[1] = 2;
113 activeRbs_txpowdB30nrb6run1earfcn500[2] = 3;
114 activeRbs_txpowdB30nrb6run1earfcn500[3] = 5;
115
116 uint16_t earfcn = 500;
117 uint8_t bw = 6;
118 double powerTx = 30;
119
120 std::map<int, double> powerTxMap;
121 double rbTxPower = powerTx;
122
123 rbTxPower = CalculateRbTxPower(powerTx, LteRrcSap::PdschConfigDedicated::dB_3);
124 powerTxMap.insert(std::pair<int, double>(2, rbTxPower));
125
126 rbTxPower = CalculateRbTxPower(powerTx, LteRrcSap::PdschConfigDedicated::dB0);
127 powerTxMap.insert(std::pair<int, double>(3, rbTxPower));
128
129 rbTxPower = CalculateRbTxPower(powerTx, LteRrcSap::PdschConfigDedicated::dB2);
130 powerTxMap.insert(std::pair<int, double>(5, rbTxPower));
131
132 SpectrumValue spectrumValue_txpowdB30nrb6run1earfcn500(
133 LteSpectrumValueHelper::GetSpectrumModel(500, 6));
134 spectrumValue_txpowdB30nrb6run1earfcn500[0] = 9.259259259259e-07;
135 spectrumValue_txpowdB30nrb6run1earfcn500[1] = 0.000000000000e+00;
136 spectrumValue_txpowdB30nrb6run1earfcn500[2] = 4.640622533585e-07;
137 spectrumValue_txpowdB30nrb6run1earfcn500[3] = 9.259259259259e-07;
138 spectrumValue_txpowdB30nrb6run1earfcn500[4] = 0.000000000000e+00;
139 spectrumValue_txpowdB30nrb6run1earfcn500[5] = 1.467493696723e-06;
140
142 "txpowdB30nrb6run1earfcn500",
143 earfcn,
144 bw,
145 powerTx,
146 powerTxMap,
147 activeRbs_txpowdB30nrb6run1earfcn500,
148 spectrumValue_txpowdB30nrb6run1earfcn500),
149 TestCase::QUICK);
150 }
151 {
152 std::vector<int> activeRbs_txpowdB30nrb25run1earfcn500(15);
153 activeRbs_txpowdB30nrb25run1earfcn500[0] = 0;
154 activeRbs_txpowdB30nrb25run1earfcn500[1] = 1;
155 activeRbs_txpowdB30nrb25run1earfcn500[2] = 2;
156 activeRbs_txpowdB30nrb25run1earfcn500[3] = 3;
157 activeRbs_txpowdB30nrb25run1earfcn500[4] = 7;
158 activeRbs_txpowdB30nrb25run1earfcn500[5] = 8;
159 activeRbs_txpowdB30nrb25run1earfcn500[6] = 9;
160 activeRbs_txpowdB30nrb25run1earfcn500[7] = 11;
161 activeRbs_txpowdB30nrb25run1earfcn500[8] = 13;
162 activeRbs_txpowdB30nrb25run1earfcn500[9] = 14;
163 activeRbs_txpowdB30nrb25run1earfcn500[10] = 18;
164 activeRbs_txpowdB30nrb25run1earfcn500[11] = 19;
165 activeRbs_txpowdB30nrb25run1earfcn500[12] = 20;
166 activeRbs_txpowdB30nrb25run1earfcn500[13] = 21;
167 activeRbs_txpowdB30nrb25run1earfcn500[14] = 24;
168
169 uint16_t earfcn = 500;
170 uint8_t bw = 25;
171 double powerTx = 30;
172
173 std::map<int, double> powerTxMap;
174 double rbTxPower = powerTx;
175 rbTxPower = CalculateRbTxPower(powerTx, LteRrcSap::PdschConfigDedicated::dB_3);
176 powerTxMap.insert(std::pair<int, double>(0, rbTxPower));
177 rbTxPower = CalculateRbTxPower(powerTx, LteRrcSap::PdschConfigDedicated::dB_4dot77);
178 powerTxMap.insert(std::pair<int, double>(1, rbTxPower));
179 rbTxPower = CalculateRbTxPower(powerTx, LteRrcSap::PdschConfigDedicated::dB_6);
180 powerTxMap.insert(std::pair<int, double>(2, rbTxPower));
181 rbTxPower = CalculateRbTxPower(powerTx, LteRrcSap::PdschConfigDedicated::dB1);
182 powerTxMap.insert(std::pair<int, double>(3, rbTxPower));
183 rbTxPower = CalculateRbTxPower(powerTx, LteRrcSap::PdschConfigDedicated::dB2);
184 powerTxMap.insert(std::pair<int, double>(7, rbTxPower));
185 rbTxPower = CalculateRbTxPower(powerTx, LteRrcSap::PdschConfigDedicated::dB2);
186 powerTxMap.insert(std::pair<int, double>(8, rbTxPower));
187 rbTxPower = CalculateRbTxPower(powerTx, LteRrcSap::PdschConfigDedicated::dB2);
188 powerTxMap.insert(std::pair<int, double>(9, rbTxPower));
189 rbTxPower = CalculateRbTxPower(powerTx, LteRrcSap::PdschConfigDedicated::dB_1dot77);
190 powerTxMap.insert(std::pair<int, double>(11, rbTxPower));
191 rbTxPower = CalculateRbTxPower(powerTx, LteRrcSap::PdschConfigDedicated::dB2);
192 powerTxMap.insert(std::pair<int, double>(13, rbTxPower));
193 rbTxPower = CalculateRbTxPower(powerTx, LteRrcSap::PdschConfigDedicated::dB_3);
194 powerTxMap.insert(std::pair<int, double>(14, rbTxPower));
195 rbTxPower = CalculateRbTxPower(powerTx, LteRrcSap::PdschConfigDedicated::dB0);
196 powerTxMap.insert(std::pair<int, double>(18, rbTxPower));
197 rbTxPower = CalculateRbTxPower(powerTx, LteRrcSap::PdschConfigDedicated::dB_3);
198 powerTxMap.insert(std::pair<int, double>(19, rbTxPower));
199 rbTxPower = CalculateRbTxPower(powerTx, LteRrcSap::PdschConfigDedicated::dB_3);
200 powerTxMap.insert(std::pair<int, double>(20, rbTxPower));
201 rbTxPower = CalculateRbTxPower(powerTx, LteRrcSap::PdschConfigDedicated::dB_4dot77);
202 powerTxMap.insert(std::pair<int, double>(21, rbTxPower));
203 rbTxPower = CalculateRbTxPower(powerTx, LteRrcSap::PdschConfigDedicated::dB3);
204 powerTxMap.insert(std::pair<int, double>(24, rbTxPower));
205
206 SpectrumValue spectrumValue_txpowdB30nrb25run1earfcn500(
207 LteSpectrumValueHelper::GetSpectrumModel(500, bw));
208 spectrumValue_txpowdB30nrb25run1earfcn500[0] = 1.113749408060e-07;
209 spectrumValue_txpowdB30nrb25run1earfcn500[1] = 7.409475839182e-08;
210 spectrumValue_txpowdB30nrb25run1earfcn500[2] = 5.581969847799e-08;
211 spectrumValue_txpowdB30nrb25run1earfcn500[3] = 2.797612026209e-07;
212 spectrumValue_txpowdB30nrb25run1earfcn500[4] = 0.000000000000e+00;
213 spectrumValue_txpowdB30nrb25run1earfcn500[5] = 0.000000000000e+00;
214 spectrumValue_txpowdB30nrb25run1earfcn500[6] = 0.000000000000e+00;
215 spectrumValue_txpowdB30nrb25run1earfcn500[7] = 3.521984872135e-07;
216 spectrumValue_txpowdB30nrb25run1earfcn500[8] = 3.521984872135e-07;
217 spectrumValue_txpowdB30nrb25run1earfcn500[9] = 3.521984872135e-07;
218 spectrumValue_txpowdB30nrb25run1earfcn500[10] = 0.000000000000e+00;
219 spectrumValue_txpowdB30nrb25run1earfcn500[11] = 1.478384791559e-07;
220 spectrumValue_txpowdB30nrb25run1earfcn500[12] = 0.000000000000e+00;
221 spectrumValue_txpowdB30nrb25run1earfcn500[13] = 3.521984872135e-07;
222 spectrumValue_txpowdB30nrb25run1earfcn500[14] = 1.113749408060e-07;
223 spectrumValue_txpowdB30nrb25run1earfcn500[15] = 0.000000000000e+00;
224 spectrumValue_txpowdB30nrb25run1earfcn500[16] = 0.000000000000e+00;
225 spectrumValue_txpowdB30nrb25run1earfcn500[17] = 0.000000000000e+00;
226 spectrumValue_txpowdB30nrb25run1earfcn500[18] = 2.222222222222e-07;
227 spectrumValue_txpowdB30nrb25run1earfcn500[19] = 1.113749408060e-07;
228 spectrumValue_txpowdB30nrb25run1earfcn500[20] = 1.113749408060e-07;
229 spectrumValue_txpowdB30nrb25run1earfcn500[21] = 7.409475839182e-08;
230 spectrumValue_txpowdB30nrb25run1earfcn500[22] = 0.000000000000e+00;
231 spectrumValue_txpowdB30nrb25run1earfcn500[23] = 0.000000000000e+00;
232 spectrumValue_txpowdB30nrb25run1earfcn500[24] = 4.433916255486e-07;
233
235 "txpowdB30nrb25run1earfcn500_allRbPower",
236 earfcn,
237 bw,
238 powerTx,
239 powerTxMap,
240 activeRbs_txpowdB30nrb25run1earfcn500,
241 spectrumValue_txpowdB30nrb25run1earfcn500),
242 TestCase::QUICK);
243 }
244 {
245 // if power for RB not present, but RB is active, use powerTx
246 std::vector<int> activeRbs_txpowdB30nrb25run1earfcn500(15);
247 activeRbs_txpowdB30nrb25run1earfcn500[0] = 0;
248 activeRbs_txpowdB30nrb25run1earfcn500[1] = 1;
249 activeRbs_txpowdB30nrb25run1earfcn500[2] = 2;
250 activeRbs_txpowdB30nrb25run1earfcn500[3] = 3;
251 activeRbs_txpowdB30nrb25run1earfcn500[4] = 7;
252 activeRbs_txpowdB30nrb25run1earfcn500[5] = 8;
253 activeRbs_txpowdB30nrb25run1earfcn500[6] = 9;
254 activeRbs_txpowdB30nrb25run1earfcn500[7] = 11;
255 activeRbs_txpowdB30nrb25run1earfcn500[8] = 13;
256 activeRbs_txpowdB30nrb25run1earfcn500[9] = 14;
257 activeRbs_txpowdB30nrb25run1earfcn500[10] = 18;
258 activeRbs_txpowdB30nrb25run1earfcn500[11] = 19;
259 activeRbs_txpowdB30nrb25run1earfcn500[12] = 20;
260 activeRbs_txpowdB30nrb25run1earfcn500[13] = 21;
261 activeRbs_txpowdB30nrb25run1earfcn500[14] = 24;
262
263 uint16_t earfcn = 500;
264 uint8_t bw = 25;
265 double powerTx = 30;
266
267 std::map<int, double> powerTxMap;
268 double rbTxPower = powerTx;
269 rbTxPower = CalculateRbTxPower(powerTx, LteRrcSap::PdschConfigDedicated::dB_3);
270 powerTxMap.insert(std::pair<int, double>(0, rbTxPower));
271 rbTxPower = CalculateRbTxPower(powerTx, LteRrcSap::PdschConfigDedicated::dB_6);
272 powerTxMap.insert(std::pair<int, double>(2, rbTxPower));
273 rbTxPower = CalculateRbTxPower(powerTx, LteRrcSap::PdschConfigDedicated::dB1);
274 powerTxMap.insert(std::pair<int, double>(3, rbTxPower));
275 rbTxPower = CalculateRbTxPower(powerTx, LteRrcSap::PdschConfigDedicated::dB2);
276 powerTxMap.insert(std::pair<int, double>(7, rbTxPower));
277 rbTxPower = CalculateRbTxPower(powerTx, LteRrcSap::PdschConfigDedicated::dB2);
278 powerTxMap.insert(std::pair<int, double>(8, rbTxPower));
279 rbTxPower = CalculateRbTxPower(powerTx, LteRrcSap::PdschConfigDedicated::dB2);
280 powerTxMap.insert(std::pair<int, double>(13, rbTxPower));
281 rbTxPower = CalculateRbTxPower(powerTx, LteRrcSap::PdschConfigDedicated::dB_3);
282 powerTxMap.insert(std::pair<int, double>(14, rbTxPower));
283 rbTxPower = CalculateRbTxPower(powerTx, LteRrcSap::PdschConfigDedicated::dB0);
284 powerTxMap.insert(std::pair<int, double>(18, rbTxPower));
285 rbTxPower = CalculateRbTxPower(powerTx, LteRrcSap::PdschConfigDedicated::dB_3);
286 powerTxMap.insert(std::pair<int, double>(19, rbTxPower));
287 rbTxPower = CalculateRbTxPower(powerTx, LteRrcSap::PdschConfigDedicated::dB3);
288 powerTxMap.insert(std::pair<int, double>(24, rbTxPower));
289
290 SpectrumValue spectrumValue_txpowdB30nrb25run1earfcn500(
291 LteSpectrumValueHelper::GetSpectrumModel(500, bw));
292 spectrumValue_txpowdB30nrb25run1earfcn500[0] = 1.113749408060e-07;
293 spectrumValue_txpowdB30nrb25run1earfcn500[1] = 2.222222222222e-07;
294 spectrumValue_txpowdB30nrb25run1earfcn500[2] = 5.581969847799e-08;
295 spectrumValue_txpowdB30nrb25run1earfcn500[3] = 2.797612026209e-07;
296 spectrumValue_txpowdB30nrb25run1earfcn500[4] = 0.000000000000e+00;
297 spectrumValue_txpowdB30nrb25run1earfcn500[5] = 0.000000000000e+00;
298 spectrumValue_txpowdB30nrb25run1earfcn500[6] = 0.000000000000e+00;
299 spectrumValue_txpowdB30nrb25run1earfcn500[7] = 3.521984872135e-07;
300 spectrumValue_txpowdB30nrb25run1earfcn500[8] = 3.521984872135e-07;
301 spectrumValue_txpowdB30nrb25run1earfcn500[9] = 2.222222222222e-07;
302 spectrumValue_txpowdB30nrb25run1earfcn500[10] = 0.000000000000e+00;
303 spectrumValue_txpowdB30nrb25run1earfcn500[11] = 2.222222222222e-07;
304 spectrumValue_txpowdB30nrb25run1earfcn500[12] = 0.000000000000e+00;
305 spectrumValue_txpowdB30nrb25run1earfcn500[13] = 3.521984872135e-07;
306 spectrumValue_txpowdB30nrb25run1earfcn500[14] = 1.113749408060e-07;
307 spectrumValue_txpowdB30nrb25run1earfcn500[15] = 0.000000000000e+00;
308 spectrumValue_txpowdB30nrb25run1earfcn500[16] = 0.000000000000e+00;
309 spectrumValue_txpowdB30nrb25run1earfcn500[17] = 0.000000000000e+00;
310 spectrumValue_txpowdB30nrb25run1earfcn500[18] = 2.222222222222e-07;
311 spectrumValue_txpowdB30nrb25run1earfcn500[19] = 1.113749408060e-07;
312 spectrumValue_txpowdB30nrb25run1earfcn500[20] = 2.222222222222e-07;
313 spectrumValue_txpowdB30nrb25run1earfcn500[21] = 2.222222222222e-07;
314 spectrumValue_txpowdB30nrb25run1earfcn500[22] = 0.000000000000e+00;
315 spectrumValue_txpowdB30nrb25run1earfcn500[23] = 0.000000000000e+00;
316 spectrumValue_txpowdB30nrb25run1earfcn500[24] = 4.433916255486e-07;
317
319 "txpowdB30nrb25run1earfcn500",
320 earfcn,
321 bw,
322 powerTx,
323 powerTxMap,
324 activeRbs_txpowdB30nrb25run1earfcn500,
325 spectrumValue_txpowdB30nrb25run1earfcn500),
326 TestCase::QUICK);
327 }
328
329 // Downlink DATA and CONTROL channels power comparison
331 LteRrcSap::PdschConfigDedicated::dB0,
332 "DataCtrlPowerDifference_noChange"),
333 TestCase::QUICK);
335 LteRrcSap::PdschConfigDedicated::dB_6,
336 "DataCtrlPowerDifference_dB_6"),
337 TestCase::QUICK);
339 LteRrcSap::PdschConfigDedicated::dB_4dot77,
340 "DataCtrlPowerDifference_dB_4dot77"),
341 TestCase::QUICK);
343 LteRrcSap::PdschConfigDedicated::dB_3,
344 "DataCtrlPowerDifference_dB_3"),
345 TestCase::QUICK);
347 LteRrcSap::PdschConfigDedicated::dB_1dot77,
348 "DataCtrlPowerDifference_dB_1dot77"),
349 TestCase::QUICK);
351 LteRrcSap::PdschConfigDedicated::dB0,
352 "DataCtrlPowerDifference_dB0"),
353 TestCase::QUICK);
355 LteRrcSap::PdschConfigDedicated::dB1,
356 "DataCtrlPowerDifference_dB1"),
357 TestCase::QUICK);
359 LteRrcSap::PdschConfigDedicated::dB2,
360 "DataCtrlPowerDifference_dB2"),
361 TestCase::QUICK);
363 LteRrcSap::PdschConfigDedicated::dB3,
364 "DataCtrlPowerDifference_dB3"),
365 TestCase::QUICK);
366
367 // RrcConnectionReconfiguration test
370 "RrcConnReconf-IdealRrc"),
371 TestCase::QUICK);
374 "RrcConnReconf-RealRrc"),
375 TestCase::QUICK);
376}
377
378double
380{
381 LteRrcSap::PdschConfigDedicated pdschConfigDedicated;
382 pdschConfigDedicated.pa = pa;
383 double rbTxpower =
384 txPower + LteRrcSap::ConvertPdschConfigDedicated2Double(pdschConfigDedicated);
385
386 return rbTxpower;
387}
388
394
400 std::string name,
401 uint16_t earfcn,
402 uint16_t bw,
403 double powerTx,
404 std::map<int, double> powerTxMap,
405 std::vector<int> activeRbs,
406 SpectrumValue& expected)
407 : TestCase("Downlink Power Control: " + name),
408 m_actual(LteSpectrumValueHelper::CreateTxPowerSpectralDensity(earfcn,
409 bw,
410 powerTx,
411 powerTxMap,
412 activeRbs)),
413 m_expected(Create<SpectrumValue>(expected))
414{
415 NS_LOG_INFO("Creating LteDownlinkPowerControlTestCase");
416}
417
419{
420}
421
422void
424{
425 NS_LOG_INFO("Creating LteDownlinkPowerControlSpectrumValueTestCase");
428 "SpectrumModel UID mismatch");
430 (*m_expected),
431 0.0000001,
432 "SpectrumValues not equal");
433}
434
436 uint8_t pa,
437 std::string name)
438 : TestCase("Downlink Power Control: " + name)
439{
440 m_changePdschConfigDedicated = changePower;
442 m_expectedPowerDiff = LteRrcSap::ConvertPdschConfigDedicated2Double(m_pdschConfigDedicated);
443 NS_LOG_INFO("Creating LteDownlinkPowerControlTestCase");
444}
445
447{
448}
449
450void
452{
454 Config::SetDefault("ns3::LteHelper::UseIdealRrc", BooleanValue(false));
455
460 Ptr<LteHelper> lteHelper = CreateObject<LteHelper>();
461 lteHelper->SetFfrAlgorithmType("ns3::LteFfrSimple");
462
463 // Create Nodes: eNodeB and UE
464 NodeContainer enbNodes;
465 NodeContainer ueNodes;
466 enbNodes.Create(1);
467 ueNodes.Create(1);
468 NodeContainer allNodes = NodeContainer(enbNodes, ueNodes);
469
470 // Install Mobility Model
472 mobility.SetMobilityModel("ns3::ConstantPositionMobilityModel");
473 mobility.Install(allNodes);
474
475 // Create Devices and install them in the Nodes (eNB and UE)
476 NetDeviceContainer enbDevs;
477 NetDeviceContainer ueDevs;
478 lteHelper->SetSchedulerType("ns3::PfFfMacScheduler");
479 enbDevs = lteHelper->InstallEnbDevice(enbNodes);
480 ueDevs = lteHelper->InstallUeDevice(ueNodes);
481
482 // Attach a UE to a eNB
483 lteHelper->Attach(ueDevs, enbDevs.Get(0));
484
485 PointerValue tmp;
486 enbDevs.Get(0)->GetAttribute("LteFfrAlgorithm", tmp);
487 Ptr<LteFfrSimple> simpleFfrAlgorithm = DynamicCast<LteFfrSimple>(tmp.GetObject());
490
491 // Activate the default EPS bearer
492 enum EpsBearer::Qci q = EpsBearer::NGBR_VIDEO_TCP_DEFAULT;
493 EpsBearer bearer(q);
494 lteHelper->ActivateDataRadioBearer(ueDevs, bearer);
495
496 // Use testing chunk processor in the PHY layer
497 // It will be used to calculate data and ctrl power in downlink
498
499 Ptr<LtePhy> ue1Phy = ueDevs.Get(0)->GetObject<LteUeNetDevice>()->GetPhy()->GetObject<LtePhy>();
500
501 Ptr<LteChunkProcessor> testDlDataPowerReceived = Create<LteChunkProcessor>();
502 LteSpectrumValueCatcher dlDataPowerReceivedCatcher;
503 testDlDataPowerReceived->AddCallback(
504 MakeCallback(&LteSpectrumValueCatcher::ReportValue, &dlDataPowerReceivedCatcher));
505 ue1Phy->GetDownlinkSpectrumPhy()->AddDataPowerChunkProcessor(testDlDataPowerReceived);
506
507 Ptr<LteChunkProcessor> testDlCtrlPowerReceived = Create<LteChunkProcessor>();
508 LteSpectrumValueCatcher dlCtrlPowerReceivedCatcher;
509 testDlCtrlPowerReceived->AddCallback(
510 MakeCallback(&LteSpectrumValueCatcher::ReportValue, &dlCtrlPowerReceivedCatcher));
511 ue1Phy->GetDownlinkSpectrumPhy()->AddRsPowerChunkProcessor(testDlCtrlPowerReceived);
512
513 Simulator::Stop(Seconds(0.400));
514 Simulator::Run();
515
516 double dataPower = 10.0 * std::log10(dlDataPowerReceivedCatcher.GetValue()->operator[](0));
517 double ctrlPower = 10.0 * std::log10(dlCtrlPowerReceivedCatcher.GetValue()->operator[](0));
518 double powerDiff = (-1.0) * ctrlPower + dataPower;
519
520 NS_LOG_DEBUG("DataPower: " << dataPower);
521 NS_LOG_DEBUG("CtrlPower: " << ctrlPower);
522 NS_LOG_DEBUG("PowerDifference: " << powerDiff);
523 NS_LOG_DEBUG("ExpectedPowerDifference: " << m_expectedPowerDiff);
524
526 powerDiff,
528 0.001,
529 "Downlink Data and Ctrl Power Difference are not equal within tolerance");
530
531 Simulator::Destroy();
532}
533
534void
537 std::string context,
538 uint64_t imsi,
539 uint16_t cellId,
540 uint16_t rnti)
541{
542 testcase->ConnectionReconfigurationUe(context, imsi, cellId, rnti);
543}
544
545void
548 std::string context,
549 uint64_t imsi,
550 uint16_t cellId,
551 uint16_t rnti)
552{
553 testcase->ConnectionReconfigurationEnb(context, imsi, cellId, rnti);
554}
555
556void
559 std::string context,
560 uint16_t rnti,
561 uint8_t pa)
562{
563 testcase->ChangePdschConfigDedicated(rnti, pa);
564}
565
567 LteDownlinkPowerControlRrcConnectionReconfigurationTestCase(bool useIdealRrc, std::string name)
568 : TestCase("Downlink Power Control: " + name),
569 m_useIdealRrc(useIdealRrc),
570 m_changePdschConfigDedicatedTriggered(false),
571 m_connectionReconfigurationUeReceived(false),
572 m_connectionReconfigurationEnbCompleted(false)
573{
574}
575
578{
579}
580
581void
583 std::string context,
584 uint64_t imsi,
585 uint16_t cellid,
586 uint16_t rnti)
587{
588 if (Simulator::Now() > MilliSeconds(100))
589 {
590 NS_LOG_DEBUG("eNb ConnectionReconfigurationCompleted");
592 }
593}
594
595void
597 std::string context,
598 uint64_t imsi,
599 uint16_t cellid,
600 uint16_t rnti)
601{
602 if (Simulator::Now() > MilliSeconds(100))
603 {
604 NS_LOG_DEBUG("Ue ConnectionReconfiguration");
606 }
607}
608
609void
611 uint16_t rnti,
612 uint8_t pa)
613{
614 NS_LOG_DEBUG("FFR Algorithm ChangePdschConfigDedicated");
616}
617
618void
620{
622 Config::SetDefault("ns3::LteHelper::UseIdealRrc", BooleanValue(m_useIdealRrc));
623
628 Ptr<LteHelper> lteHelper = CreateObject<LteHelper>();
629 lteHelper->SetFfrAlgorithmType("ns3::LteFfrSimple");
630
631 // Create Nodes: eNodeB and UE
632 NodeContainer enbNodes;
633 NodeContainer ueNodes;
634 enbNodes.Create(1);
635 ueNodes.Create(1);
636 NodeContainer allNodes = NodeContainer(enbNodes, ueNodes);
637
638 // Install Mobility Model
640 mobility.SetMobilityModel("ns3::ConstantPositionMobilityModel");
641 mobility.Install(allNodes);
642
643 // Create Devices and install them in the Nodes (eNB and UE)
644 NetDeviceContainer enbDevs;
645 NetDeviceContainer ueDevs;
646 lteHelper->SetSchedulerType("ns3::PfFfMacScheduler");
647 enbDevs = lteHelper->InstallEnbDevice(enbNodes);
648 ueDevs = lteHelper->InstallUeDevice(ueNodes);
649
650 // Attach a UE to a eNB
651 lteHelper->Attach(ueDevs, enbDevs.Get(0));
652
653 PointerValue tmp;
654 enbDevs.Get(0)->GetAttribute("LteFfrAlgorithm", tmp);
655 Ptr<LteFfrSimple> simpleFfrAlgorithm = DynamicCast<LteFfrSimple>(tmp.GetObject());
656 LteRrcSap::PdschConfigDedicated pdschConfigDedicated;
657 pdschConfigDedicated.pa = LteRrcSap::PdschConfigDedicated::dB_6;
658 simpleFfrAlgorithm->ChangePdschConfigDedicated(true);
659 simpleFfrAlgorithm->SetPdschConfigDedicated(pdschConfigDedicated);
660
661 // Activate the default EPS bearer
662 enum EpsBearer::Qci q = EpsBearer::NGBR_VIDEO_TCP_DEFAULT;
663 EpsBearer bearer(q);
664 lteHelper->ActivateDataRadioBearer(ueDevs, bearer);
665
666 Config::Connect("/NodeList/0/DeviceList/0/LteFfrAlgorithm/ChangePdschConfigDedicated",
668 Config::Connect("/NodeList/1/DeviceList/0/LteUeRrc/ConnectionReconfiguration",
670 Config::Connect("/NodeList/0/DeviceList/0/LteEnbRrc/ConnectionReconfiguration",
672
673 Simulator::Stop(Seconds(0.400));
674 Simulator::Run();
675
677 true,
678 "Ffr have not changed PdschConfigDedicated for UE");
680 true,
681 "Ue have not received RrcConnectionReconfiguration");
683 true,
684 "Enb have not received RrcConnectionReconfigurationCompleted");
685
686 Simulator::Destroy();
687}
AttributeValue implementation for Boolean.
Definition: boolean.h:37
This class contains the specification of EPS Bearers.
Definition: eps-bearer.h:91
Qci
QoS Class Indicator.
Definition: eps-bearer.h:106
void ChangePdschConfigDedicated(bool change)
Callback function that is used to be connected to trace ChangePdschConfigDedicated.
void SetPdschConfigDedicated(LteRrcSap::PdschConfigDedicated pdschConfigDedicated)
Set PDSCH config dedicated function.
void SetFfrAlgorithmType(std::string type)
Set the type of FFR algorithm to be used by eNodeB devices.
Definition: lte-helper.cc:316
NetDeviceContainer InstallEnbDevice(NodeContainer c)
Create a set of eNodeB devices.
Definition: lte-helper.cc:482
void SetSchedulerType(std::string type)
Set the type of scheduler to be used by eNodeB devices.
Definition: lte-helper.cc:289
void Attach(NetDeviceContainer ueDevices)
Enables automatic attachment of a set of UE devices to a suitable cell using Idle mode initial cell s...
Definition: lte-helper.cc:1044
void ActivateDataRadioBearer(NetDeviceContainer ueDevices, EpsBearer bearer)
Activate a Data Radio Bearer on a given UE devices (for LTE-only simulation).
Definition: lte-helper.cc:1441
NetDeviceContainer InstallUeDevice(NodeContainer c)
Create a set of UE devices.
Definition: lte-helper.cc:497
The LtePhy models the physical layer of LTE.
Definition: lte-phy.h:50
A sink to be plugged to the callback of LteChunkProcessor allowing to save and later retrieve the lat...
Ptr< SpectrumValue > GetValue()
This class defines all functions to create spectrum model for lte.
The LteUeNetDevice class implements the UE net device.
Helper class used to assign positions and mobility models to nodes.
holds a vector of ns3::NetDevice pointers
Ptr< NetDevice > Get(uint32_t i) const
Get the Ptr<NetDevice> stored in this container at a given index.
keep track of a set of node pointers.
void Create(uint32_t n)
Create n nodes and append pointers to them to the end of this NodeContainer.
Ptr< T > GetObject() const
Get a pointer to the requested aggregated Object.
Definition: object.h:471
Hold objects of type Ptr<T>.
Definition: pointer.h:37
Ptr< Object > GetObject() const
Get the Object referenced by the PointerValue.
Definition: pointer.cc:57
Set of values corresponding to a given SpectrumModel.
SpectrumModelUid_t GetSpectrumModelUid() const
encapsulates test code
Definition: test.h:1060
void AddTestCase(TestCase *testCase, TestDuration duration=QUICK)
Add an individual child TestCase to this test suite.
Definition: test.cc:305
A suite of tests to run.
Definition: test.h:1256
void Reset()
Reset the initial value of every attribute as well as the value of every global to what they were bef...
Definition: config.cc:856
void SetDefault(std::string name, const AttributeValue &value)
Definition: config.cc:891
void Connect(std::string path, const CallbackBase &cb)
Definition: config.cc:975
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:202
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
Definition: log.h:268
#define NS_LOG_INFO(msg)
Use NS_LOG to output a message of level LOG_INFO.
Definition: log.h:275
static LteDownlinkPowerControlTestSuite lteDownlinkPowerControlTestSuite
Static variable for test initialization.
auto MakeBoundCallback(R(*fnPtr)(Args...), BArgs... bargs)
Make Callbacks with varying number of bound arguments.
Definition: callback.h:752
Ptr< T > Create(Ts &&... args)
Create class instances by constructors with varying numbers of arguments and return them by Ptr.
Definition: ptr.h:481
Time Now()
create an ns3::Time instance which contains the current simulation time.
Definition: simulator.cc:296
#define NS_TEST_ASSERT_MSG_SPECTRUM_VALUE_EQ_TOL(actual, expected, tol, msg)
Test if two SpectrumValue instances are equal within a given tolerance.
#define NS_TEST_ASSERT_MSG_EQ(actual, limit, msg)
Test that an actual and expected (limit) value are equal and report and abort if not.
Definition: test.h:144
#define NS_TEST_ASSERT_MSG_EQ_TOL(actual, limit, tol, msg)
Test that actual and expected (limit) values are equal to plus or minus some tolerance and report and...
Definition: test.h:337
Time Seconds(double value)
Construct a Time in the indicated unit.
Definition: nstime.h:1336
Time MilliSeconds(uint64_t value)
Construct a Time in the indicated unit.
Definition: nstime.h:1348
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Callback< R, Args... > MakeCallback(R(T::*memPtr)(Args...), OBJ objPtr)
Build Callbacks for class method members which take varying numbers of arguments and potentially retu...
Definition: callback.h:691
mobility
Definition: third.py:96
PdschConfigDedicated structure.
Definition: lte-rrc-sap.h:163