A Discrete-Event Network Simulator
API
lte-test-downlink-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 
22 #include <ns3/simulator.h>
23 #include <ns3/log.h>
24 #include <ns3/callback.h>
25 #include <ns3/config.h>
26 #include <ns3/string.h>
27 #include <ns3/double.h>
28 #include <ns3/enum.h>
29 #include <ns3/boolean.h>
30 #include <ns3/pointer.h>
31 
32 #include "ns3/mobility-helper.h"
33 #include "ns3/lte-helper.h"
34 
35 #include <ns3/ff-mac-scheduler.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-ue-net-device.h>
40 #include <ns3/lte-ue-phy.h>
41 #include <ns3/lte-ue-rrc.h>
42 
43 #include "lte-ffr-simple.h"
44 #include <ns3/lte-common.h>
45 
46 
47 #include <ns3/lte-chunk-processor.h>
48 
50 #include <ns3/lte-rrc-sap.h>
51 
52 using namespace ns3;
53 
54 NS_LOG_COMPONENT_DEFINE ("LteDownlinkPowerControlTest");
55 
61  : TestSuite ("lte-downlink-power-control", SYSTEM)
62 {
63 // LogLevel logLevel = (LogLevel)(LOG_PREFIX_FUNC | LOG_PREFIX_TIME | LOG_LEVEL_DEBUG);
64 // LogComponentEnable ("LteDownlinkPowerControlTest", logLevel);
65  NS_LOG_INFO ("Creating LteDownlinkPowerControlTestSuite");
66 
67  // Spectrum helper test
68  {
69  std::vector<int> activeRbs_txpowdB30nrb6run1earfcn500 (4);
70  activeRbs_txpowdB30nrb6run1earfcn500[0] = 0;
71  activeRbs_txpowdB30nrb6run1earfcn500[1] = 2;
72  activeRbs_txpowdB30nrb6run1earfcn500[2] = 3;
73  activeRbs_txpowdB30nrb6run1earfcn500[3] = 5;
74 
75  uint16_t earfcn = 500;
76  uint8_t bw = 6;
77  double powerTx = 30;
78 
79  std::map<int, double> powerTxMap;
80  double rbTxPower = powerTx;
81 
82  rbTxPower = CalculateRbTxPower (powerTx, LteRrcSap::PdschConfigDedicated::dB_6);
83  powerTxMap.insert (std::pair<int,double>(0, rbTxPower));
84 
85  rbTxPower = CalculateRbTxPower (powerTx, LteRrcSap::PdschConfigDedicated::dB_3);
86  powerTxMap.insert (std::pair<int,double>(2, rbTxPower));
87 
88  rbTxPower = CalculateRbTxPower (powerTx, LteRrcSap::PdschConfigDedicated::dB0);
89  powerTxMap.insert (std::pair<int,double>(3, rbTxPower));
90 
91  rbTxPower = CalculateRbTxPower (powerTx, LteRrcSap::PdschConfigDedicated::dB2);
92  powerTxMap.insert (std::pair<int,double>(5, rbTxPower));
93 
94  SpectrumValue spectrumValue_txpowdB30nrb6run1earfcn500 (LteSpectrumValueHelper::GetSpectrumModel (500, 6));
95  spectrumValue_txpowdB30nrb6run1earfcn500[0] = 2.325820769916e-07;
96  spectrumValue_txpowdB30nrb6run1earfcn500[1] = 0.000000000000e+00;
97  spectrumValue_txpowdB30nrb6run1earfcn500[2] = 4.640622533585e-07;
98  spectrumValue_txpowdB30nrb6run1earfcn500[3] = 9.259259259259e-07;
99  spectrumValue_txpowdB30nrb6run1earfcn500[4] = 0.000000000000e+00;
100  spectrumValue_txpowdB30nrb6run1earfcn500[5] = 1.467493696723e-06;
101 
102  AddTestCase (new LteDownlinkPowerControlSpectrumValueTestCase ("txpowdB30nrb6run1earfcn500_allRbPower",
103  earfcn, bw, powerTx,
104  powerTxMap, activeRbs_txpowdB30nrb6run1earfcn500,
105  spectrumValue_txpowdB30nrb6run1earfcn500), TestCase::QUICK);
106  }
107  {
108  //if power for RB not present, but RB is active, use powerTx
109  std::vector<int> activeRbs_txpowdB30nrb6run1earfcn500 (4);
110  activeRbs_txpowdB30nrb6run1earfcn500[0] = 0;
111  activeRbs_txpowdB30nrb6run1earfcn500[1] = 2;
112  activeRbs_txpowdB30nrb6run1earfcn500[2] = 3;
113  activeRbs_txpowdB30nrb6run1earfcn500[3] = 5;
114 
115  uint16_t earfcn = 500;
116  uint8_t bw = 6;
117  double powerTx = 30;
118 
119  std::map<int, double> powerTxMap;
120  double rbTxPower = powerTx;
121 
122  rbTxPower = CalculateRbTxPower (powerTx, LteRrcSap::PdschConfigDedicated::dB_3);
123  powerTxMap.insert (std::pair<int,double>(2, rbTxPower));
124 
125  rbTxPower = CalculateRbTxPower (powerTx, LteRrcSap::PdschConfigDedicated::dB0);
126  powerTxMap.insert (std::pair<int,double>(3, rbTxPower));
127 
128  rbTxPower = CalculateRbTxPower (powerTx, LteRrcSap::PdschConfigDedicated::dB2);
129  powerTxMap.insert (std::pair<int,double>(5, rbTxPower));
130 
131  SpectrumValue spectrumValue_txpowdB30nrb6run1earfcn500 (LteSpectrumValueHelper::GetSpectrumModel (500, 6));
132  spectrumValue_txpowdB30nrb6run1earfcn500[0] = 9.259259259259e-07;
133  spectrumValue_txpowdB30nrb6run1earfcn500[1] = 0.000000000000e+00;
134  spectrumValue_txpowdB30nrb6run1earfcn500[2] = 4.640622533585e-07;
135  spectrumValue_txpowdB30nrb6run1earfcn500[3] = 9.259259259259e-07;
136  spectrumValue_txpowdB30nrb6run1earfcn500[4] = 0.000000000000e+00;
137  spectrumValue_txpowdB30nrb6run1earfcn500[5] = 1.467493696723e-06;
138 
139  AddTestCase (new LteDownlinkPowerControlSpectrumValueTestCase ("txpowdB30nrb6run1earfcn500",
140  earfcn, bw, powerTx,
141  powerTxMap, activeRbs_txpowdB30nrb6run1earfcn500,
142  spectrumValue_txpowdB30nrb6run1earfcn500), TestCase::QUICK);
143  }
144  {
145  std::vector<int> activeRbs_txpowdB30nrb25run1earfcn500 (15);
146  activeRbs_txpowdB30nrb25run1earfcn500[0] = 0;
147  activeRbs_txpowdB30nrb25run1earfcn500[1] = 1;
148  activeRbs_txpowdB30nrb25run1earfcn500[2] = 2;
149  activeRbs_txpowdB30nrb25run1earfcn500[3] = 3;
150  activeRbs_txpowdB30nrb25run1earfcn500[4] = 7;
151  activeRbs_txpowdB30nrb25run1earfcn500[5] = 8;
152  activeRbs_txpowdB30nrb25run1earfcn500[6] = 9;
153  activeRbs_txpowdB30nrb25run1earfcn500[7] = 11;
154  activeRbs_txpowdB30nrb25run1earfcn500[8] = 13;
155  activeRbs_txpowdB30nrb25run1earfcn500[9] = 14;
156  activeRbs_txpowdB30nrb25run1earfcn500[10] = 18;
157  activeRbs_txpowdB30nrb25run1earfcn500[11] = 19;
158  activeRbs_txpowdB30nrb25run1earfcn500[12] = 20;
159  activeRbs_txpowdB30nrb25run1earfcn500[13] = 21;
160  activeRbs_txpowdB30nrb25run1earfcn500[14] = 24;
161 
162  uint16_t earfcn = 500;
163  uint8_t bw = 25;
164  double powerTx = 30;
165 
166  std::map<int, double> powerTxMap;
167  double rbTxPower = powerTx;
168  rbTxPower = CalculateRbTxPower (powerTx, LteRrcSap::PdschConfigDedicated::dB_3);
169  powerTxMap.insert (std::pair<int,double>(0, rbTxPower));
170  rbTxPower = CalculateRbTxPower (powerTx, LteRrcSap::PdschConfigDedicated::dB_4dot77);
171  powerTxMap.insert (std::pair<int,double>(1, rbTxPower));
172  rbTxPower = CalculateRbTxPower (powerTx, LteRrcSap::PdschConfigDedicated::dB_6);
173  powerTxMap.insert (std::pair<int,double>(2, rbTxPower));
174  rbTxPower = CalculateRbTxPower (powerTx, LteRrcSap::PdschConfigDedicated::dB1);
175  powerTxMap.insert (std::pair<int,double>(3, rbTxPower));
176  rbTxPower = CalculateRbTxPower (powerTx, LteRrcSap::PdschConfigDedicated::dB2);
177  powerTxMap.insert (std::pair<int,double>(7, rbTxPower));
178  rbTxPower = CalculateRbTxPower (powerTx, LteRrcSap::PdschConfigDedicated::dB2);
179  powerTxMap.insert (std::pair<int,double>(8, rbTxPower));
180  rbTxPower = CalculateRbTxPower (powerTx, LteRrcSap::PdschConfigDedicated::dB2);
181  powerTxMap.insert (std::pair<int,double>(9, rbTxPower));
182  rbTxPower = CalculateRbTxPower (powerTx, LteRrcSap::PdschConfigDedicated::dB_1dot77);
183  powerTxMap.insert (std::pair<int,double>(11, rbTxPower));
184  rbTxPower = CalculateRbTxPower (powerTx, LteRrcSap::PdschConfigDedicated::dB2);
185  powerTxMap.insert (std::pair<int,double>(13, rbTxPower));
186  rbTxPower = CalculateRbTxPower (powerTx, LteRrcSap::PdschConfigDedicated::dB_3);
187  powerTxMap.insert (std::pair<int,double>(14, rbTxPower));
188  rbTxPower = CalculateRbTxPower (powerTx, LteRrcSap::PdschConfigDedicated::dB0);
189  powerTxMap.insert (std::pair<int,double>(18, rbTxPower));
190  rbTxPower = CalculateRbTxPower (powerTx, LteRrcSap::PdschConfigDedicated::dB_3);
191  powerTxMap.insert (std::pair<int,double>(19, rbTxPower));
192  rbTxPower = CalculateRbTxPower (powerTx, LteRrcSap::PdschConfigDedicated::dB_3);
193  powerTxMap.insert (std::pair<int,double>(20, rbTxPower));
194  rbTxPower = CalculateRbTxPower (powerTx, LteRrcSap::PdschConfigDedicated::dB_4dot77);
195  powerTxMap.insert (std::pair<int,double>(21, rbTxPower));
196  rbTxPower = CalculateRbTxPower (powerTx, LteRrcSap::PdschConfigDedicated::dB3);
197  powerTxMap.insert (std::pair<int,double>(24, rbTxPower));
198 
199 
200  SpectrumValue spectrumValue_txpowdB30nrb25run1earfcn500 (LteSpectrumValueHelper::GetSpectrumModel (500, bw));
201  spectrumValue_txpowdB30nrb25run1earfcn500[0] = 1.113749408060e-07;
202  spectrumValue_txpowdB30nrb25run1earfcn500[1] = 7.409475839182e-08;
203  spectrumValue_txpowdB30nrb25run1earfcn500[2] = 5.581969847799e-08;
204  spectrumValue_txpowdB30nrb25run1earfcn500[3] = 2.797612026209e-07;
205  spectrumValue_txpowdB30nrb25run1earfcn500[4] = 0.000000000000e+00;
206  spectrumValue_txpowdB30nrb25run1earfcn500[5] = 0.000000000000e+00;
207  spectrumValue_txpowdB30nrb25run1earfcn500[6] = 0.000000000000e+00;
208  spectrumValue_txpowdB30nrb25run1earfcn500[7] = 3.521984872135e-07;
209  spectrumValue_txpowdB30nrb25run1earfcn500[8] = 3.521984872135e-07;
210  spectrumValue_txpowdB30nrb25run1earfcn500[9] = 3.521984872135e-07;
211  spectrumValue_txpowdB30nrb25run1earfcn500[10] = 0.000000000000e+00;
212  spectrumValue_txpowdB30nrb25run1earfcn500[11] = 1.478384791559e-07;
213  spectrumValue_txpowdB30nrb25run1earfcn500[12] = 0.000000000000e+00;
214  spectrumValue_txpowdB30nrb25run1earfcn500[13] = 3.521984872135e-07;
215  spectrumValue_txpowdB30nrb25run1earfcn500[14] = 1.113749408060e-07;
216  spectrumValue_txpowdB30nrb25run1earfcn500[15] = 0.000000000000e+00;
217  spectrumValue_txpowdB30nrb25run1earfcn500[16] = 0.000000000000e+00;
218  spectrumValue_txpowdB30nrb25run1earfcn500[17] = 0.000000000000e+00;
219  spectrumValue_txpowdB30nrb25run1earfcn500[18] = 2.222222222222e-07;
220  spectrumValue_txpowdB30nrb25run1earfcn500[19] = 1.113749408060e-07;
221  spectrumValue_txpowdB30nrb25run1earfcn500[20] = 1.113749408060e-07;
222  spectrumValue_txpowdB30nrb25run1earfcn500[21] = 7.409475839182e-08;
223  spectrumValue_txpowdB30nrb25run1earfcn500[22] = 0.000000000000e+00;
224  spectrumValue_txpowdB30nrb25run1earfcn500[23] = 0.000000000000e+00;
225  spectrumValue_txpowdB30nrb25run1earfcn500[24] = 4.433916255486e-07;
226 
227  AddTestCase (new LteDownlinkPowerControlSpectrumValueTestCase ("txpowdB30nrb25run1earfcn500_allRbPower",
228  earfcn, bw, powerTx,
229  powerTxMap, activeRbs_txpowdB30nrb25run1earfcn500,
230  spectrumValue_txpowdB30nrb25run1earfcn500), TestCase::QUICK);
231  }
232  {
233  //if power for RB not present, but RB is active, use powerTx
234  std::vector<int> activeRbs_txpowdB30nrb25run1earfcn500 (15);
235  activeRbs_txpowdB30nrb25run1earfcn500[0] = 0;
236  activeRbs_txpowdB30nrb25run1earfcn500[1] = 1;
237  activeRbs_txpowdB30nrb25run1earfcn500[2] = 2;
238  activeRbs_txpowdB30nrb25run1earfcn500[3] = 3;
239  activeRbs_txpowdB30nrb25run1earfcn500[4] = 7;
240  activeRbs_txpowdB30nrb25run1earfcn500[5] = 8;
241  activeRbs_txpowdB30nrb25run1earfcn500[6] = 9;
242  activeRbs_txpowdB30nrb25run1earfcn500[7] = 11;
243  activeRbs_txpowdB30nrb25run1earfcn500[8] = 13;
244  activeRbs_txpowdB30nrb25run1earfcn500[9] = 14;
245  activeRbs_txpowdB30nrb25run1earfcn500[10] = 18;
246  activeRbs_txpowdB30nrb25run1earfcn500[11] = 19;
247  activeRbs_txpowdB30nrb25run1earfcn500[12] = 20;
248  activeRbs_txpowdB30nrb25run1earfcn500[13] = 21;
249  activeRbs_txpowdB30nrb25run1earfcn500[14] = 24;
250 
251  uint16_t earfcn = 500;
252  uint8_t bw = 25;
253  double powerTx = 30;
254 
255  std::map<int, double> powerTxMap;
256  double rbTxPower = powerTx;
257  rbTxPower = CalculateRbTxPower (powerTx, LteRrcSap::PdschConfigDedicated::dB_3);
258  powerTxMap.insert (std::pair<int,double>(0, rbTxPower));
259  rbTxPower = CalculateRbTxPower (powerTx, LteRrcSap::PdschConfigDedicated::dB_6);
260  powerTxMap.insert (std::pair<int,double>(2, rbTxPower));
261  rbTxPower = CalculateRbTxPower (powerTx, LteRrcSap::PdschConfigDedicated::dB1);
262  powerTxMap.insert (std::pair<int,double>(3, rbTxPower));
263  rbTxPower = CalculateRbTxPower (powerTx, LteRrcSap::PdschConfigDedicated::dB2);
264  powerTxMap.insert (std::pair<int,double>(7, rbTxPower));
265  rbTxPower = CalculateRbTxPower (powerTx, LteRrcSap::PdschConfigDedicated::dB2);
266  powerTxMap.insert (std::pair<int,double>(8, rbTxPower));
267  rbTxPower = CalculateRbTxPower (powerTx, LteRrcSap::PdschConfigDedicated::dB2);
268  powerTxMap.insert (std::pair<int,double>(13, rbTxPower));
269  rbTxPower = CalculateRbTxPower (powerTx, LteRrcSap::PdschConfigDedicated::dB_3);
270  powerTxMap.insert (std::pair<int,double>(14, rbTxPower));
271  rbTxPower = CalculateRbTxPower (powerTx, LteRrcSap::PdschConfigDedicated::dB0);
272  powerTxMap.insert (std::pair<int,double>(18, rbTxPower));
273  rbTxPower = CalculateRbTxPower (powerTx, LteRrcSap::PdschConfigDedicated::dB_3);
274  powerTxMap.insert (std::pair<int,double>(19, rbTxPower));
275  rbTxPower = CalculateRbTxPower (powerTx, LteRrcSap::PdschConfigDedicated::dB3);
276  powerTxMap.insert (std::pair<int,double>(24, rbTxPower));
277 
278 
279  SpectrumValue spectrumValue_txpowdB30nrb25run1earfcn500 (LteSpectrumValueHelper::GetSpectrumModel (500, bw));
280  spectrumValue_txpowdB30nrb25run1earfcn500[0] = 1.113749408060e-07;
281  spectrumValue_txpowdB30nrb25run1earfcn500[1] = 2.222222222222e-07;
282  spectrumValue_txpowdB30nrb25run1earfcn500[2] = 5.581969847799e-08;
283  spectrumValue_txpowdB30nrb25run1earfcn500[3] = 2.797612026209e-07;
284  spectrumValue_txpowdB30nrb25run1earfcn500[4] = 0.000000000000e+00;
285  spectrumValue_txpowdB30nrb25run1earfcn500[5] = 0.000000000000e+00;
286  spectrumValue_txpowdB30nrb25run1earfcn500[6] = 0.000000000000e+00;
287  spectrumValue_txpowdB30nrb25run1earfcn500[7] = 3.521984872135e-07;
288  spectrumValue_txpowdB30nrb25run1earfcn500[8] = 3.521984872135e-07;
289  spectrumValue_txpowdB30nrb25run1earfcn500[9] = 2.222222222222e-07;
290  spectrumValue_txpowdB30nrb25run1earfcn500[10] = 0.000000000000e+00;
291  spectrumValue_txpowdB30nrb25run1earfcn500[11] = 2.222222222222e-07;
292  spectrumValue_txpowdB30nrb25run1earfcn500[12] = 0.000000000000e+00;
293  spectrumValue_txpowdB30nrb25run1earfcn500[13] = 3.521984872135e-07;
294  spectrumValue_txpowdB30nrb25run1earfcn500[14] = 1.113749408060e-07;
295  spectrumValue_txpowdB30nrb25run1earfcn500[15] = 0.000000000000e+00;
296  spectrumValue_txpowdB30nrb25run1earfcn500[16] = 0.000000000000e+00;
297  spectrumValue_txpowdB30nrb25run1earfcn500[17] = 0.000000000000e+00;
298  spectrumValue_txpowdB30nrb25run1earfcn500[18] = 2.222222222222e-07;
299  spectrumValue_txpowdB30nrb25run1earfcn500[19] = 1.113749408060e-07;
300  spectrumValue_txpowdB30nrb25run1earfcn500[20] = 2.222222222222e-07;
301  spectrumValue_txpowdB30nrb25run1earfcn500[21] = 2.222222222222e-07;
302  spectrumValue_txpowdB30nrb25run1earfcn500[22] = 0.000000000000e+00;
303  spectrumValue_txpowdB30nrb25run1earfcn500[23] = 0.000000000000e+00;
304  spectrumValue_txpowdB30nrb25run1earfcn500[24] = 4.433916255486e-07;
305 
306  AddTestCase (new LteDownlinkPowerControlSpectrumValueTestCase ("txpowdB30nrb25run1earfcn500",
307  earfcn, bw, powerTx,
308  powerTxMap, activeRbs_txpowdB30nrb25run1earfcn500,
309  spectrumValue_txpowdB30nrb25run1earfcn500), TestCase::QUICK);
310  }
311 
312 
313  // Downlink DATA and CONTROL channels power comparison
314  AddTestCase (new LteDownlinkPowerControlTestCase (false, LteRrcSap::PdschConfigDedicated::dB0,
315  "DataCtrlPowerDifference_noChange"), TestCase::QUICK);
316  AddTestCase (new LteDownlinkPowerControlTestCase (true, LteRrcSap::PdschConfigDedicated::dB_6,
317  "DataCtrlPowerDifference_dB_6"), TestCase::QUICK);
318  AddTestCase (new LteDownlinkPowerControlTestCase (true, LteRrcSap::PdschConfigDedicated::dB_4dot77,
319  "DataCtrlPowerDifference_dB_4dot77"), TestCase::QUICK);
320  AddTestCase (new LteDownlinkPowerControlTestCase (true, LteRrcSap::PdschConfigDedicated::dB_3,
321  "DataCtrlPowerDifference_dB_3"), TestCase::QUICK);
322  AddTestCase (new LteDownlinkPowerControlTestCase (true, LteRrcSap::PdschConfigDedicated::dB_1dot77,
323  "DataCtrlPowerDifference_dB_1dot77"), TestCase::QUICK);
324  AddTestCase (new LteDownlinkPowerControlTestCase (true, LteRrcSap::PdschConfigDedicated::dB0,
325  "DataCtrlPowerDifference_dB0"), TestCase::QUICK);
326  AddTestCase (new LteDownlinkPowerControlTestCase (true, LteRrcSap::PdschConfigDedicated::dB1,
327  "DataCtrlPowerDifference_dB1"), TestCase::QUICK);
328  AddTestCase (new LteDownlinkPowerControlTestCase (true, LteRrcSap::PdschConfigDedicated::dB2,
329  "DataCtrlPowerDifference_dB2"), TestCase::QUICK);
330  AddTestCase (new LteDownlinkPowerControlTestCase (true, LteRrcSap::PdschConfigDedicated::dB3,
331  "DataCtrlPowerDifference_dB3"), TestCase::QUICK);
332 
333 
334  // RrcConnectionReconfiguration test
335  AddTestCase (new LteDownlinkPowerControlRrcConnectionReconfigurationTestCase (false, "RrcConnReconf-IdealRrc"), TestCase::QUICK);
336  AddTestCase (new LteDownlinkPowerControlRrcConnectionReconfigurationTestCase (true, "RrcConnReconf-RealRrc"), TestCase::QUICK);
337 
338 
339 }
340 
341 double
343 {
344  LteRrcSap::PdschConfigDedicated pdschConfigDedicated;
345  pdschConfigDedicated.pa = pa;
346  double rbTxpower = txPower + LteRrcSap::ConvertPdschConfigDedicated2Double (pdschConfigDedicated);
347 
348  return rbTxpower;
349 }
350 
352 
353 
359  uint16_t earfcn, uint16_t bw, double powerTx,
360  std::map<int, double> powerTxMap, std::vector <int> activeRbs,
361  SpectrumValue& expected)
362  : TestCase ("Downlink Power Control: " + name),
363  m_actual (LteSpectrumValueHelper::CreateTxPowerSpectralDensity (earfcn, bw, powerTx, powerTxMap, activeRbs)),
364  m_expected (Create<SpectrumValue> (expected))
365 {
366  NS_LOG_INFO ("Creating LteDownlinkPowerControlTestCase");
367 }
368 
370 {
371 }
372 
373 void
375 {
376  NS_LOG_INFO ("Creating LteDownlinkPowerControlSpectrumValueTestCase");
377  NS_TEST_ASSERT_MSG_EQ (m_actual->GetSpectrumModelUid (), m_expected->GetSpectrumModelUid (), "SpectrumModel UID mismatch");
378  NS_TEST_ASSERT_MSG_SPECTRUM_VALUE_EQ_TOL ((*m_actual), (*m_expected), 0.0000001, "SpectrumValues not equal");
379 
380 }
381 
382 LteDownlinkPowerControlTestCase::LteDownlinkPowerControlTestCase (bool changePower, uint8_t pa, std::string name)
383  : TestCase ("Downlink Power Control: " + name)
384 {
385  m_changePdschConfigDedicated = changePower;
387  m_expectedPowerDiff = LteRrcSap::ConvertPdschConfigDedicated2Double (m_pdschConfigDedicated);
388  NS_LOG_INFO ("Creating LteDownlinkPowerControlTestCase");
389 }
390 
392 {
393 }
394 
395 void
397 {
398  Config::Reset ();
399  Config::SetDefault ("ns3::LteHelper::UseIdealRrc", BooleanValue (false));
400 
405  Ptr<LteHelper> lteHelper = CreateObject<LteHelper> ();
406  lteHelper->SetFfrAlgorithmType ("ns3::LteFfrSimple");
407 
408  // Create Nodes: eNodeB and UE
409  NodeContainer enbNodes;
410  NodeContainer ueNodes;
411  enbNodes.Create (1);
412  ueNodes.Create (1);
413  NodeContainer allNodes = NodeContainer ( enbNodes, ueNodes );
414 
415  // Install Mobility Model
417  mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel");
418  mobility.Install (allNodes);
419 
420  // Create Devices and install them in the Nodes (eNB and UE)
421  NetDeviceContainer enbDevs;
422  NetDeviceContainer ueDevs;
423  lteHelper->SetSchedulerType ("ns3::PfFfMacScheduler");
424  enbDevs = lteHelper->InstallEnbDevice (enbNodes);
425  ueDevs = lteHelper->InstallUeDevice (ueNodes);
426 
427  // Attach a UE to a eNB
428  lteHelper->Attach (ueDevs, enbDevs.Get (0));
429 
430  PointerValue tmp;
431  enbDevs.Get (0)->GetAttribute ("LteFfrAlgorithm", tmp);
432  Ptr<LteFfrSimple> simpleFfrAlgorithm = DynamicCast<LteFfrSimple>(tmp.GetObject ());
434  simpleFfrAlgorithm->SetPdschConfigDedicated (m_pdschConfigDedicated);
435 
436  // Activate the default EPS bearer
437  enum EpsBearer::Qci q = EpsBearer::NGBR_VIDEO_TCP_DEFAULT;
438  EpsBearer bearer (q);
439  lteHelper->ActivateDataRadioBearer (ueDevs, bearer);
440 
441  // Use testing chunk processor in the PHY layer
442  // It will be used to calculate data and ctrl power in downlink
443 
444  Ptr<LtePhy> ue1Phy = ueDevs.Get (0)->GetObject<LteUeNetDevice> ()->GetPhy ()->GetObject<LtePhy> ();
445 
446  Ptr<LteChunkProcessor> testDlDataPowerReceived = Create<LteChunkProcessor> ();
447  LteSpectrumValueCatcher dlDataPowerReceivedCatcher;
448  testDlDataPowerReceived->AddCallback (MakeCallback (&LteSpectrumValueCatcher::ReportValue, &dlDataPowerReceivedCatcher));
449  ue1Phy->GetDownlinkSpectrumPhy ()->AddDataPowerChunkProcessor (testDlDataPowerReceived);
450 
451  Ptr<LteChunkProcessor> testDlCtrlPowerReceived = Create<LteChunkProcessor> ();
452  LteSpectrumValueCatcher dlCtrlPowerReceivedCatcher;
453  testDlCtrlPowerReceived->AddCallback (MakeCallback (&LteSpectrumValueCatcher::ReportValue, &dlCtrlPowerReceivedCatcher));
454  ue1Phy->GetDownlinkSpectrumPhy ()->AddRsPowerChunkProcessor (testDlCtrlPowerReceived);
455 
456  Simulator::Stop (Seconds (0.400));
457  Simulator::Run ();
458 
459  double dataPower = 10.0 * std::log10 (dlDataPowerReceivedCatcher.GetValue ()->operator[] (0));
460  double ctrlPower = 10.0 * std::log10 (dlCtrlPowerReceivedCatcher.GetValue ()->operator[] (0));
461  double powerDiff = (-1.0)*ctrlPower + dataPower;
462 
463  NS_LOG_DEBUG ("DataPower: " << dataPower);
464  NS_LOG_DEBUG ("CtrlPower: " << ctrlPower);
465  NS_LOG_DEBUG ("PowerDifference: " << powerDiff);
466  NS_LOG_DEBUG ("ExpectedPowerDifference: " << m_expectedPowerDiff);
467 
469  "Downlink Data and Ctrl Power Difference are not equal within tolerance");
470 
471  Simulator::Destroy ();
472 }
473 
474 void
476  std::string context, uint64_t imsi, uint16_t cellId, uint16_t rnti)
477 {
478  testcase->ConnectionReconfigurationUe (context, imsi, cellId, rnti);
479 }
480 
481 void
483  std::string context, uint64_t imsi, uint16_t cellId, uint16_t rnti)
484 {
485  testcase->ConnectionReconfigurationEnb (context, imsi, cellId, rnti);
486 }
487 
488 void
490  std::string context, uint16_t rnti, uint8_t pa)
491 {
492  testcase->ChangePdschConfigDedicated (rnti, pa);
493 }
494 
495 
497  : TestCase ("Downlink Power Control: " + name),
498  m_useIdealRrc (useIdealRrc),
499  m_changePdschConfigDedicatedTriggered (false),
500  m_connectionReconfigurationUeReceived (false),
501  m_connectionReconfigurationEnbCompleted (false)
502 {
503 
504 }
505 
507 {
508 }
509 
510 void
511 LteDownlinkPowerControlRrcConnectionReconfigurationTestCase::ConnectionReconfigurationEnb (std::string context, uint64_t imsi, uint16_t cellid, uint16_t rnti)
512 {
513  if (Simulator::Now () > MilliSeconds (100))
514  {
515  NS_LOG_DEBUG ("eNb ConnectionReconfigurationCompleted");
517  }
518 }
519 
520 void
521 LteDownlinkPowerControlRrcConnectionReconfigurationTestCase::ConnectionReconfigurationUe (std::string context, uint64_t imsi, uint16_t cellid, uint16_t rnti)
522 {
523  if (Simulator::Now () > MilliSeconds (100))
524  {
525  NS_LOG_DEBUG ("Ue ConnectionReconfiguration");
527  }
528 }
529 
530 void
532 {
533  NS_LOG_DEBUG ("FFR Algorithm ChangePdschConfigDedicated");
535 }
536 
537 void
539 {
540  Config::Reset ();
541  Config::SetDefault ("ns3::LteHelper::UseIdealRrc", BooleanValue (m_useIdealRrc));
542 
547  Ptr<LteHelper> lteHelper = CreateObject<LteHelper> ();
548  lteHelper->SetFfrAlgorithmType ("ns3::LteFfrSimple");
549 
550  // Create Nodes: eNodeB and UE
551  NodeContainer enbNodes;
552  NodeContainer ueNodes;
553  enbNodes.Create (1);
554  ueNodes.Create (1);
555  NodeContainer allNodes = NodeContainer ( enbNodes, ueNodes );
556 
557  // Install Mobility Model
559  mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel");
560  mobility.Install (allNodes);
561 
562  // Create Devices and install them in the Nodes (eNB and UE)
563  NetDeviceContainer enbDevs;
564  NetDeviceContainer ueDevs;
565  lteHelper->SetSchedulerType ("ns3::PfFfMacScheduler");
566  enbDevs = lteHelper->InstallEnbDevice (enbNodes);
567  ueDevs = lteHelper->InstallUeDevice (ueNodes);
568 
569  // Attach a UE to a eNB
570  lteHelper->Attach (ueDevs, enbDevs.Get (0));
571 
572  PointerValue tmp;
573  enbDevs.Get (0)->GetAttribute ("LteFfrAlgorithm", tmp);
574  Ptr<LteFfrSimple> simpleFfrAlgorithm = DynamicCast<LteFfrSimple>(tmp.GetObject ());
575  LteRrcSap::PdschConfigDedicated pdschConfigDedicated;
576  pdschConfigDedicated.pa = LteRrcSap::PdschConfigDedicated::dB_6;
577  simpleFfrAlgorithm->ChangePdschConfigDedicated (true);
578  simpleFfrAlgorithm->SetPdschConfigDedicated (pdschConfigDedicated);
579 
580  // Activate the default EPS bearer
581  enum EpsBearer::Qci q = EpsBearer::NGBR_VIDEO_TCP_DEFAULT;
582  EpsBearer bearer (q);
583  lteHelper->ActivateDataRadioBearer (ueDevs, bearer);
584 
585  Config::Connect ("/NodeList/0/DeviceList/0/LteFfrAlgorithm/ChangePdschConfigDedicated",
587  Config::Connect ("/NodeList/1/DeviceList/0/LteUeRrc/ConnectionReconfiguration",
589  Config::Connect ("/NodeList/0/DeviceList/0/LteEnbRrc/ConnectionReconfiguration",
591 
592  Simulator::Stop (Seconds (0.400));
593  Simulator::Run ();
594 
596  "Ffr have not changed PdschConfigDedicated for UE");
598  "Ue have not received RrcConnectionReconfiguration");
600  "Enb have not received RrcConnectionReconfigurationCompleted");
601 
602  Simulator::Destroy ();
603 }
604 
AttributeValue implementation for Boolean.
Definition: boolean.h:37
This class contains the specification of EPS Bearers.
Definition: eps-bearer.h:92
Qci
QoS Class Indicator.
Definition: eps-bearer.h:107
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:306
NetDeviceContainer InstallEnbDevice(NodeContainer c)
Create a set of eNodeB devices.
Definition: lte-helper.cc:474
void SetSchedulerType(std::string type)
Set the type of scheduler to be used by eNodeB devices.
Definition: lte-helper.cc:279
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:959
void ActivateDataRadioBearer(NetDeviceContainer ueDevices, EpsBearer bearer)
Activate a Data Radio Bearer on a given UE devices (for LTE-only simulation).
Definition: lte-helper.cc:1313
NetDeviceContainer InstallUeDevice(NodeContainer c)
Create a set of UE devices.
Definition: lte-helper.cc:489
The LtePhy models the physical layer of LTE.
Definition: lte-phy.h:53
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.
void GetAttribute(std::string name, AttributeValue &value) const
Get the value of an attribute, raising fatal errors if unsuccessful.
Definition: object-base.cc:294
Ptr< T > GetObject(void) const
Get a pointer to the requested aggregated Object.
Definition: object.h:470
Hold objects of type Ptr<T>.
Definition: pointer.h:37
Ptr< Object > GetObject(void) const
Get the Object referenced by the PointerValue.
Definition: pointer.cc:55
Set of values corresponding to a given SpectrumModel.
SpectrumModelUid_t GetSpectrumModelUid() const
encapsulates test code
Definition: test.h:994
void AddTestCase(TestCase *testCase, TestDuration duration=QUICK)
Add an individual child TestCase to this test suite.
Definition: test.cc:299
A suite of tests to run.
Definition: test.h:1188
void Reset(void)
Reset the initial value of every attribute as well as the value of every global to what they were bef...
Definition: config.cc:820
void SetDefault(std::string name, const AttributeValue &value)
Definition: config.cc:849
void Connect(std::string path, const CallbackBase &cb)
Definition: config.cc:920
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:205
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
Definition: log.h:273
#define NS_LOG_INFO(msg)
Use NS_LOG to output a message of level LOG_INFO.
Definition: log.h:281
Callback< R > MakeBoundCallback(R(*fnPtr)(TX), ARG a1)
Make Callbacks with one bound argument.
Definition: callback.h:1709
Ptr< T > Create(Ts &&... args)
Create class instances by constructors with varying numbers of arguments and return them by Ptr.
Definition: ptr.h:409
Time Now(void)
create an ns3::Time instance which contains the current simulation time.
Definition: simulator.cc:287
#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:141
#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:323
Time Seconds(double value)
Construct a Time in the indicated unit.
Definition: nstime.h:1244
Time MilliSeconds(uint64_t value)
Construct a Time in the indicated unit.
Definition: nstime.h:1252
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Callback< R, Ts... > MakeCallback(R(T::*memPtr)(Ts...), OBJ objPtr)
Build Callbacks for class method members which take varying numbers of arguments and potentially retu...
Definition: callback.h:1648
mobility
Definition: third.py:108
PdschConfigDedicated structure.
Definition: lte-rrc-sap.h:155