A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
lte-test-carrier-aggregation.cc
Go to the documentation of this file.
1/*
2 * Copyright (c) 2016 Centre Tecnologic de Telecomunicacions de Catalunya (CTTC)
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: Biljana Bojovic <bbojovic@cttc.es>
18 *
19 */
20
22
23#include "ns3/double.h"
24#include "ns3/ff-mac-scheduler.h"
25#include "ns3/radio-bearer-stats-calculator.h"
26#include "ns3/string.h"
27#include <ns3/boolean.h>
28#include <ns3/constant-position-mobility-model.h>
29#include <ns3/enum.h>
30#include <ns3/eps-bearer.h>
31#include <ns3/log.h>
32#include <ns3/lte-enb-net-device.h>
33#include <ns3/lte-enb-phy.h>
34#include <ns3/lte-helper.h>
35#include <ns3/lte-ue-net-device.h>
36#include <ns3/lte-ue-phy.h>
37#include <ns3/lte-ue-rrc.h>
38#include <ns3/mobility-helper.h>
39#include <ns3/net-device-container.h>
40#include <ns3/node-container.h>
41#include <ns3/object.h>
42#include <ns3/packet.h>
43#include <ns3/ptr.h>
44#include <ns3/simulator.h>
45#include <ns3/spectrum-error-model.h>
46#include <ns3/spectrum-interference.h>
47#include <ns3/test.h>
48
49#include <errno.h>
50#include <iostream>
51#include <map>
52
53using namespace ns3;
54
55NS_LOG_COMPONENT_DEFINE("TestCarrierAggregation");
56
57bool CarrierAggregationTestCase::s_writeResults = false; // set to true to write response vectors
58const std::string dlResultsFileName = "carrier_aggregation_results_dl.txt";
59const std::string ulResultsFileName = "carrier_aggregation_results_ul.txt";
60
61void
63 std::string path,
65{
66 testcase->DlScheduling(dlInfo);
67}
68
69void
71 std::string path,
72 uint32_t frameNo,
73 uint32_t subframeNo,
74 uint16_t rnti,
75 uint8_t mcs,
76 uint16_t sizeTb,
77 uint8_t ccId)
78{
79 testcase->UlScheduling(frameNo, subframeNo, rnti, mcs, sizeTb, ccId);
80}
81
83 : TestSuite("lte-carrier-aggregation", Type::SYSTEM)
84{
85 NS_LOG_INFO("creating CarrierAggregationTestCase");
86
87 if (CarrierAggregationTestCase::s_writeResults) // write result vectors to file
88 {
89 std::cout << "\n Running TestCarrierAggregationSuite with activated option to write "
90 "results to files."
91 "Dl results will be written to "
92 << dlResultsFileName << " and uplink results to " << ulResultsFileName
93 << std::endl;
94
95 bool abort = false;
96
97 if (fopen(dlResultsFileName.c_str(), "r"))
98 {
99 std::cout << "\nResults file " << dlResultsFileName
100 << " already exists. Move it out of the way or specify another downlink "
101 "results file name."
102 << std::endl;
103 abort = true;
104 }
105 if (fopen(ulResultsFileName.c_str(), "r"))
106 {
107 std::cout << "\nResults file " << ulResultsFileName
108 << " already exists. Move it out of the way or specify another uplink "
109 "results file name."
110 << std::endl;
111 abort = true;
112 }
113
114 if (abort)
115 {
116 return;
117 }
118
119 AddTestCase(new CarrierAggregationTestCase(1, 0, 100, 100, 1), TestCase::Duration::QUICK);
120 AddTestCase(new CarrierAggregationTestCase(3, 0, 100, 100, 1), TestCase::Duration::QUICK);
121 AddTestCase(new CarrierAggregationTestCase(6, 0, 100, 100, 1), TestCase::Duration::QUICK);
122 AddTestCase(new CarrierAggregationTestCase(9, 0, 100, 100, 1), TestCase::Duration::QUICK);
123 AddTestCase(new CarrierAggregationTestCase(12, 0, 100, 100, 1), TestCase::Duration::QUICK);
124 AddTestCase(new CarrierAggregationTestCase(15, 0, 100, 100, 1), TestCase::Duration::QUICK);
125
126 AddTestCase(new CarrierAggregationTestCase(1, 0, 100, 100, 2), TestCase::Duration::QUICK);
127 AddTestCase(new CarrierAggregationTestCase(3, 0, 100, 100, 2), TestCase::Duration::QUICK);
128 AddTestCase(new CarrierAggregationTestCase(6, 0, 100, 100, 2), TestCase::Duration::QUICK);
129 AddTestCase(new CarrierAggregationTestCase(9, 0, 100, 100, 2), TestCase::Duration::QUICK);
130 AddTestCase(new CarrierAggregationTestCase(12, 0, 100, 100, 2), TestCase::Duration::QUICK);
131 AddTestCase(new CarrierAggregationTestCase(15, 0, 100, 100, 2), TestCase::Duration::QUICK);
132
133 AddTestCase(new CarrierAggregationTestCase(1, 0, 100, 100, 3), TestCase::Duration::QUICK);
134 AddTestCase(new CarrierAggregationTestCase(3, 0, 100, 100, 3), TestCase::Duration::QUICK);
135 AddTestCase(new CarrierAggregationTestCase(6, 0, 100, 100, 3), TestCase::Duration::QUICK);
136 AddTestCase(new CarrierAggregationTestCase(9, 0, 100, 100, 3), TestCase::Duration::QUICK);
137 AddTestCase(new CarrierAggregationTestCase(12, 0, 100, 100, 3), TestCase::Duration::QUICK);
138 AddTestCase(new CarrierAggregationTestCase(15, 0, 100, 100, 3), TestCase::Duration::QUICK);
139 }
140 else
141 {
142 // bandwidth is 25 and there are 2 carriers
143 AddTestCase(new CarrierAggregationTestCase(1, 0, 25, 25, 2), TestCase::Duration::EXTENSIVE);
144 AddTestCase(new CarrierAggregationTestCase(3, 0, 25, 25, 2), TestCase::Duration::EXTENSIVE);
145 AddTestCase(new CarrierAggregationTestCase(6, 0, 25, 25, 2), TestCase::Duration::EXTENSIVE);
146 AddTestCase(new CarrierAggregationTestCase(9, 0, 25, 25, 2), TestCase::Duration::EXTENSIVE);
147 AddTestCase(new CarrierAggregationTestCase(12, 0, 25, 25, 2),
148 TestCase::Duration::EXTENSIVE);
149 AddTestCase(new CarrierAggregationTestCase(15, 0, 25, 25, 2),
150 TestCase::Duration::EXTENSIVE);
151
152 AddTestCase(new CarrierAggregationTestCase(1, 4800, 25, 25, 2), TestCase::Duration::QUICK);
153 AddTestCase(new CarrierAggregationTestCase(3, 4800, 25, 25, 2),
154 TestCase::Duration::EXTENSIVE);
155 AddTestCase(new CarrierAggregationTestCase(6, 4800, 25, 25, 2),
156 TestCase::Duration::EXTENSIVE);
157 AddTestCase(new CarrierAggregationTestCase(9, 4800, 25, 25, 2),
158 TestCase::Duration::EXTENSIVE);
159 AddTestCase(new CarrierAggregationTestCase(12, 4800, 25, 25, 2),
160 TestCase::Duration::EXTENSIVE);
161 AddTestCase(new CarrierAggregationTestCase(15, 4800, 25, 25, 2),
162 TestCase::Duration::EXTENSIVE);
163
164 AddTestCase(new CarrierAggregationTestCase(1, 6000, 25, 25, 2),
165 TestCase::Duration::EXTENSIVE);
166 AddTestCase(new CarrierAggregationTestCase(3, 6000, 25, 25, 2),
167 TestCase::Duration::EXTENSIVE);
168 AddTestCase(new CarrierAggregationTestCase(6, 6000, 25, 25, 2),
169 TestCase::Duration::EXTENSIVE);
170 AddTestCase(new CarrierAggregationTestCase(9, 6000, 25, 25, 2),
171 TestCase::Duration::EXTENSIVE);
172 AddTestCase(new CarrierAggregationTestCase(12, 6000, 25, 25, 2),
173 TestCase::Duration::EXTENSIVE);
174 AddTestCase(new CarrierAggregationTestCase(15, 6000, 25, 25, 2),
175 TestCase::Duration::EXTENSIVE);
176
177 AddTestCase(new CarrierAggregationTestCase(1, 20000, 25, 25, 2),
178 TestCase::Duration::EXTENSIVE);
179 AddTestCase(new CarrierAggregationTestCase(3, 20000, 25, 25, 2),
180 TestCase::Duration::EXTENSIVE);
181 AddTestCase(new CarrierAggregationTestCase(6, 20000, 25, 25, 2),
182 TestCase::Duration::EXTENSIVE);
183 AddTestCase(new CarrierAggregationTestCase(9, 20000, 25, 25, 2),
184 TestCase::Duration::EXTENSIVE);
185 AddTestCase(new CarrierAggregationTestCase(12, 20000, 25, 25, 2),
186 TestCase::Duration::EXTENSIVE);
187 AddTestCase(new CarrierAggregationTestCase(15, 20000, 25, 25, 2),
188 TestCase::Duration::QUICK);
189
190 // bandwidth is 25 and there are 3 carriers
191 AddTestCase(new CarrierAggregationTestCase(1, 0, 25, 25, 3), TestCase::Duration::EXTENSIVE);
192 AddTestCase(new CarrierAggregationTestCase(3, 0, 25, 25, 3), TestCase::Duration::QUICK);
193 AddTestCase(new CarrierAggregationTestCase(6, 0, 25, 25, 3), TestCase::Duration::EXTENSIVE);
194 AddTestCase(new CarrierAggregationTestCase(9, 0, 25, 25, 3), TestCase::Duration::EXTENSIVE);
195 AddTestCase(new CarrierAggregationTestCase(12, 0, 25, 25, 3),
196 TestCase::Duration::EXTENSIVE);
197 AddTestCase(new CarrierAggregationTestCase(15, 0, 25, 25, 3),
198 TestCase::Duration::EXTENSIVE);
199
200 AddTestCase(new CarrierAggregationTestCase(1, 4800, 25, 25, 3), TestCase::Duration::QUICK);
201 AddTestCase(new CarrierAggregationTestCase(3, 4800, 25, 25, 3),
202 TestCase::Duration::EXTENSIVE);
203 AddTestCase(new CarrierAggregationTestCase(6, 4800, 25, 25, 3),
204 TestCase::Duration::EXTENSIVE);
205 AddTestCase(new CarrierAggregationTestCase(9, 4800, 25, 25, 3),
206 TestCase::Duration::EXTENSIVE);
207 AddTestCase(new CarrierAggregationTestCase(12, 4800, 25, 25, 3),
208 TestCase::Duration::EXTENSIVE);
209 AddTestCase(new CarrierAggregationTestCase(15, 4800, 25, 25, 3),
210 TestCase::Duration::EXTENSIVE);
211
212 AddTestCase(new CarrierAggregationTestCase(1, 6000, 25, 25, 3),
213 TestCase::Duration::EXTENSIVE);
214 AddTestCase(new CarrierAggregationTestCase(3, 6000, 25, 25, 3),
215 TestCase::Duration::EXTENSIVE);
216 AddTestCase(new CarrierAggregationTestCase(6, 6000, 25, 25, 3),
217 TestCase::Duration::EXTENSIVE);
218 AddTestCase(new CarrierAggregationTestCase(9, 6000, 25, 25, 3),
219 TestCase::Duration::EXTENSIVE);
220 AddTestCase(new CarrierAggregationTestCase(12, 6000, 25, 25, 3),
221 TestCase::Duration::EXTENSIVE);
222 AddTestCase(new CarrierAggregationTestCase(15, 6000, 25, 25, 3),
223 TestCase::Duration::EXTENSIVE);
224
225 AddTestCase(new CarrierAggregationTestCase(1, 20000, 25, 25, 3),
226 TestCase::Duration::EXTENSIVE);
227 AddTestCase(new CarrierAggregationTestCase(3, 20000, 25, 25, 3),
228 TestCase::Duration::EXTENSIVE);
229 AddTestCase(new CarrierAggregationTestCase(6, 20000, 25, 25, 3),
230 TestCase::Duration::EXTENSIVE);
231 AddTestCase(new CarrierAggregationTestCase(9, 20000, 25, 25, 3),
232 TestCase::Duration::EXTENSIVE);
233 AddTestCase(new CarrierAggregationTestCase(12, 20000, 25, 25, 3),
234 TestCase::Duration::EXTENSIVE);
235 AddTestCase(new CarrierAggregationTestCase(15, 20000, 25, 25, 3),
236 TestCase::Duration::EXTENSIVE);
237
238 // bandwidth = 6 RB and there are 3 carriers
239 AddTestCase(new CarrierAggregationTestCase(1, 0, 6, 6, 3), TestCase::Duration::EXTENSIVE);
240 AddTestCase(new CarrierAggregationTestCase(3, 0, 6, 6, 3), TestCase::Duration::EXTENSIVE);
241 AddTestCase(new CarrierAggregationTestCase(6, 0, 6, 6, 3), TestCase::Duration::EXTENSIVE);
242 AddTestCase(new CarrierAggregationTestCase(9, 0, 6, 6, 3), TestCase::Duration::EXTENSIVE);
243 AddTestCase(new CarrierAggregationTestCase(12, 0, 6, 6, 3), TestCase::Duration::EXTENSIVE);
244 AddTestCase(new CarrierAggregationTestCase(15, 0, 6, 6, 3), TestCase::Duration::EXTENSIVE);
245
246 AddTestCase(new CarrierAggregationTestCase(1, 4800, 6, 6, 3), TestCase::Duration::QUICK);
247 AddTestCase(new CarrierAggregationTestCase(3, 4800, 6, 6, 3),
248 TestCase::Duration::EXTENSIVE);
249 AddTestCase(new CarrierAggregationTestCase(6, 4800, 6, 6, 3),
250 TestCase::Duration::EXTENSIVE);
251 AddTestCase(new CarrierAggregationTestCase(9, 4800, 6, 6, 3),
252 TestCase::Duration::EXTENSIVE);
253 AddTestCase(new CarrierAggregationTestCase(12, 4800, 6, 6, 3),
254 TestCase::Duration::EXTENSIVE);
255 AddTestCase(new CarrierAggregationTestCase(15, 4800, 6, 6, 3),
256 TestCase::Duration::EXTENSIVE);
257 AddTestCase(new CarrierAggregationTestCase(1, 6000, 6, 6, 3),
258 TestCase::Duration::EXTENSIVE);
259 AddTestCase(new CarrierAggregationTestCase(3, 6000, 6, 6, 3),
260 TestCase::Duration::EXTENSIVE);
261 AddTestCase(new CarrierAggregationTestCase(6, 6000, 6, 6, 3),
262 TestCase::Duration::EXTENSIVE);
263 AddTestCase(new CarrierAggregationTestCase(9, 6000, 6, 6, 3),
264 TestCase::Duration::EXTENSIVE);
265 AddTestCase(new CarrierAggregationTestCase(12, 6000, 6, 6, 3),
266 TestCase::Duration::EXTENSIVE);
267 AddTestCase(new CarrierAggregationTestCase(15, 6000, 6, 6, 3),
268 TestCase::Duration::EXTENSIVE);
269 AddTestCase(new CarrierAggregationTestCase(1, 20000, 6, 6, 3),
270 TestCase::Duration::EXTENSIVE);
271 AddTestCase(new CarrierAggregationTestCase(3, 20000, 6, 6, 3),
272 TestCase::Duration::EXTENSIVE);
273 AddTestCase(new CarrierAggregationTestCase(6, 20000, 6, 6, 3),
274 TestCase::Duration::EXTENSIVE);
275 AddTestCase(new CarrierAggregationTestCase(9, 20000, 6, 6, 3),
276 TestCase::Duration::EXTENSIVE);
277 AddTestCase(new CarrierAggregationTestCase(12, 20000, 6, 6, 3),
278 TestCase::Duration::EXTENSIVE);
279 AddTestCase(new CarrierAggregationTestCase(15, 20000, 6, 6, 3),
280 TestCase::Duration::EXTENSIVE);
281
282 // bandwidth = 6 RB and there are 2 carriers
283 AddTestCase(new CarrierAggregationTestCase(1, 0, 6, 6, 2), TestCase::Duration::EXTENSIVE);
284 AddTestCase(new CarrierAggregationTestCase(3, 0, 6, 6, 2), TestCase::Duration::EXTENSIVE);
285 AddTestCase(new CarrierAggregationTestCase(6, 0, 6, 6, 2), TestCase::Duration::EXTENSIVE);
286 AddTestCase(new CarrierAggregationTestCase(9, 0, 6, 6, 2), TestCase::Duration::EXTENSIVE);
287 AddTestCase(new CarrierAggregationTestCase(12, 0, 6, 6, 2), TestCase::Duration::EXTENSIVE);
288 AddTestCase(new CarrierAggregationTestCase(15, 0, 6, 6, 2), TestCase::Duration::EXTENSIVE);
289
290 AddTestCase(new CarrierAggregationTestCase(1, 4800, 6, 6, 2),
291 TestCase::Duration::EXTENSIVE);
292 AddTestCase(new CarrierAggregationTestCase(3, 4800, 6, 6, 2),
293 TestCase::Duration::EXTENSIVE);
294 AddTestCase(new CarrierAggregationTestCase(6, 4800, 6, 6, 2),
295 TestCase::Duration::EXTENSIVE);
296 AddTestCase(new CarrierAggregationTestCase(9, 4800, 6, 6, 2),
297 TestCase::Duration::EXTENSIVE);
298 AddTestCase(new CarrierAggregationTestCase(12, 4800, 6, 6, 2),
299 TestCase::Duration::EXTENSIVE);
300 AddTestCase(new CarrierAggregationTestCase(15, 4800, 6, 6, 2),
301 TestCase::Duration::EXTENSIVE);
302
303 AddTestCase(new CarrierAggregationTestCase(1, 6000, 6, 6, 2),
304 TestCase::Duration::EXTENSIVE);
305 AddTestCase(new CarrierAggregationTestCase(3, 6000, 6, 6, 2),
306 TestCase::Duration::EXTENSIVE);
307 AddTestCase(new CarrierAggregationTestCase(6, 6000, 6, 6, 2),
308 TestCase::Duration::EXTENSIVE);
309 AddTestCase(new CarrierAggregationTestCase(9, 6000, 6, 6, 2),
310 TestCase::Duration::EXTENSIVE);
311 AddTestCase(new CarrierAggregationTestCase(12, 6000, 6, 6, 2),
312 TestCase::Duration::EXTENSIVE);
313 AddTestCase(new CarrierAggregationTestCase(15, 6000, 6, 6, 2), TestCase::Duration::QUICK);
314
315 AddTestCase(new CarrierAggregationTestCase(1, 20000, 6, 6, 2),
316 TestCase::Duration::EXTENSIVE);
317 AddTestCase(new CarrierAggregationTestCase(3, 20000, 6, 6, 2),
318 TestCase::Duration::EXTENSIVE);
319 AddTestCase(new CarrierAggregationTestCase(6, 20000, 6, 6, 2),
320 TestCase::Duration::EXTENSIVE);
321 AddTestCase(new CarrierAggregationTestCase(9, 20000, 6, 6, 2),
322 TestCase::Duration::EXTENSIVE);
323 AddTestCase(new CarrierAggregationTestCase(12, 20000, 6, 6, 2),
324 TestCase::Duration::EXTENSIVE);
325 AddTestCase(new CarrierAggregationTestCase(15, 20000, 6, 6, 2),
326 TestCase::Duration::EXTENSIVE);
327 }
328}
329
335
336std::string
338 uint16_t dist,
339 uint32_t dlBandwidth,
340 uint32_t ulBandwidth,
341 uint32_t numberOfComponentCarriers)
342{
343 std::ostringstream oss;
344 oss << nUser << " UEs, distance " << dist << " m"
345 << " dlBandwidth " << dlBandwidth << " ulBandwidth " << ulBandwidth
346 << " number of carriers " << numberOfComponentCarriers;
347 return oss.str();
348}
349
351 uint16_t dist,
352 uint32_t dlbandwidth,
353 uint32_t ulBandwidth,
354 uint32_t numberOfComponentCarriers)
355 : TestCase(BuildNameString(nUser, dist, dlbandwidth, ulBandwidth, numberOfComponentCarriers)),
356 m_nUser(nUser),
357 m_dist(dist),
358 m_dlBandwidth(dlbandwidth),
359 m_ulBandwidth(ulBandwidth),
360 m_numberOfComponentCarriers(numberOfComponentCarriers)
361{
362 m_dlThroughput = 0;
363 m_statsDuration = 0.6;
364}
365
367{
368}
369
370void
372{
375
376 Config::SetDefault("ns3::LteEnbNetDevice::DlEarfcn", UintegerValue(100));
377 Config::SetDefault("ns3::LteEnbNetDevice::UlEarfcn", UintegerValue(100 + 18000));
378 Config::SetDefault("ns3::LteEnbNetDevice::DlBandwidth", UintegerValue(m_dlBandwidth));
379 Config::SetDefault("ns3::LteEnbNetDevice::UlBandwidth", UintegerValue(m_ulBandwidth));
380 Config::SetDefault("ns3::LteUeNetDevice::DlEarfcn", UintegerValue(100));
381
382 Config::SetDefault("ns3::LteHelper::UseCa", BooleanValue(true));
383 Config::SetDefault("ns3::LteHelper::NumberOfComponentCarriers",
385 Config::SetDefault("ns3::LteHelper::EnbComponentCarrierManager",
386 StringValue("ns3::RrComponentCarrierManager"));
387 Config::SetDefault("ns3::LteSpectrumPhy::CtrlErrorModelEnabled", BooleanValue(false));
388 Config::SetDefault("ns3::LteSpectrumPhy::DataErrorModelEnabled", BooleanValue(false));
389 Config::SetDefault("ns3::LteHelper::UseIdealRrc", BooleanValue(true));
390
391 Config::SetDefault("ns3::MacStatsCalculator::DlOutputFilename",
392 StringValue(CreateTempDirFilename("DlMacStats.txt")));
393 Config::SetDefault("ns3::MacStatsCalculator::UlOutputFilename",
394 StringValue(CreateTempDirFilename("UlMacStats.txt")));
395 Config::SetDefault("ns3::RadioBearerStatsCalculator::DlRlcOutputFilename",
396 StringValue(CreateTempDirFilename("DlRlcStats.txt")));
397 Config::SetDefault("ns3::RadioBearerStatsCalculator::UlRlcOutputFilename",
398 StringValue(CreateTempDirFilename("UlRlcStats.txt")));
399 Config::SetDefault("ns3::RadioBearerStatsCalculator::DlPdcpOutputFilename",
400 StringValue(CreateTempDirFilename("DlPdcpStats.txt")));
401 Config::SetDefault("ns3::RadioBearerStatsCalculator::UlPdcpOutputFilename",
402 StringValue(CreateTempDirFilename("UlPdcpStats.txt")));
403 Config::SetDefault("ns3::PhyStatsCalculator::DlRsrpSinrFilename",
404 StringValue(CreateTempDirFilename("DlRsrpSinrStats.txt")));
405 Config::SetDefault("ns3::PhyStatsCalculator::UlSinrFilename",
406 StringValue(CreateTempDirFilename("UlSinrStats.txt")));
407 Config::SetDefault("ns3::PhyStatsCalculator::UlInterferenceFilename",
408 StringValue(CreateTempDirFilename("UlInterferenceStats.txt")));
409 Config::SetDefault("ns3::PhyRxStatsCalculator::DlRxOutputFilename",
410 StringValue(CreateTempDirFilename("DlRxPhyStats.txt")));
411 Config::SetDefault("ns3::PhyRxStatsCalculator::UlRxOutputFilename",
412 StringValue(CreateTempDirFilename("UlRxPhyStats.txt")));
413 Config::SetDefault("ns3::PhyTxStatsCalculator::DlTxOutputFilename",
414 StringValue(CreateTempDirFilename("DlTxPhyStats.txt")));
415 Config::SetDefault("ns3::PhyTxStatsCalculator::UlTxOutputFilename",
416 StringValue(CreateTempDirFilename("UlTxPhyStats.txt")));
417
422 Ptr<LteHelper> lteHelper = CreateObject<LteHelper>();
423
424 lteHelper->SetAttribute("PathlossModel", StringValue("ns3::FriisSpectrumPropagationLossModel"));
425
426 // Create Nodes: eNodeB and UE
427 NodeContainer enbNodes;
428 NodeContainer ueNodes;
429 enbNodes.Create(1);
430 ueNodes.Create(m_nUser);
431
432 // Install Mobility Model
433 MobilityHelper mobility;
434 mobility.SetMobilityModel("ns3::ConstantPositionMobilityModel");
435 mobility.Install(enbNodes);
436 mobility.SetMobilityModel("ns3::ConstantPositionMobilityModel");
437 mobility.Install(ueNodes);
438
439 // Create Devices and install them in the Nodes (eNB and UE)
440 NetDeviceContainer enbDevs;
441 NetDeviceContainer ueDevs;
442 lteHelper->SetSchedulerType("ns3::PfFfMacScheduler");
443 lteHelper->SetSchedulerAttribute("UlCqiFilter", EnumValue(FfMacScheduler::SRS_UL_CQI));
444 enbDevs = lteHelper->InstallEnbDevice(enbNodes);
445 ueDevs = lteHelper->InstallUeDevice(ueNodes);
446
447 // Attach a UE to a eNB
448 lteHelper->Attach(ueDevs, enbDevs.Get(0));
449
450 // Activate an EPS bearer
452 EpsBearer bearer(q);
453 lteHelper->ActivateDataRadioBearer(ueDevs, bearer);
454
455 Ptr<LteEnbNetDevice> lteEnbDev = enbDevs.Get(0)->GetObject<LteEnbNetDevice>();
456 Ptr<LteEnbPhy> enbPhy = lteEnbDev->GetPhy();
457 enbPhy->SetAttribute("TxPower", DoubleValue(30.0));
458 enbPhy->SetAttribute("NoiseFigure", DoubleValue(5.0));
459
460 // Set UEs' position and power
461 for (int i = 0; i < m_nUser; i++)
462 {
465 mm->SetPosition(Vector(m_dist, 0.0, 0.0));
466 Ptr<LteUeNetDevice> lteUeDev = ueDevs.Get(i)->GetObject<LteUeNetDevice>();
467 Ptr<LteUePhy> uePhy = lteUeDev->GetPhy();
468 uePhy->SetAttribute("TxPower", DoubleValue(23.0));
469 uePhy->SetAttribute("NoiseFigure", DoubleValue(9.0));
470 }
471
472 double statsStartTime = 0.300; // need to allow for RRC connection establishment + SRS
473
474 Simulator::Stop(Seconds(statsStartTime + m_statsDuration - 0.0001));
475
476 Config::Connect("/NodeList/*/DeviceList/*/ComponentCarrierMap/*/LteEnbMac/DlScheduling",
478
479 Config::Connect("/NodeList/*/DeviceList/*/ComponentCarrierMap/*/LteEnbMac/UlScheduling",
481
482 lteHelper->EnableTraces();
483
485
489 NS_LOG_INFO("DL - Test with " << m_nUser << " user(s) at distance " << m_dist);
490 std::vector<uint64_t> dlDataRxed;
491
492 // tolerance increases with the number of users because the lc 0 and lc 1 will go always over
493 // primary carrier, so as the number of users increases the difference between primary and
494 // secondary
495 // carrier will increase
496
497 bool testDownlinkShare = true;
498
499 for (auto itDownlink = m_ccDownlinkTraffic.begin(); itDownlink != m_ccDownlinkTraffic.end();
500 itDownlink++)
501 {
502 if (itDownlink == m_ccDownlinkTraffic.begin())
503 {
504 NS_LOG_INFO("Downlink traffic per carrier:" << itDownlink->second);
505 }
506 else
507 {
508 if (itDownlink->second != m_ccDownlinkTraffic.begin()->second)
509 {
510 testDownlinkShare = false;
511 break;
512 }
513 }
514 }
515
516 bool testUplinkShare = true;
517
518 for (auto itUplink = m_ccUplinkTraffic.begin(); itUplink != m_ccUplinkTraffic.end(); itUplink++)
519 {
520 if (itUplink == m_ccUplinkTraffic.begin())
521 {
522 NS_LOG_INFO("Uplink traffic per carrier:" << itUplink->second);
523 }
524 else
525 {
526 if (itUplink->second != m_ccUplinkTraffic.begin()->second)
527 {
528 testUplinkShare = false;
529 break;
530 }
531 }
532 }
533
536 "Number of carriers in uplink does not correspond to number of carriers "
537 "being configured in test.");
540 "Number of carriers in downlink does not correspond to number of "
541 "carriers being configured in test.");
542
543 NS_TEST_ASSERT_MSG_EQ(testDownlinkShare,
544 true,
545 " Downlink traffic not split equally between carriers!");
546 NS_TEST_ASSERT_MSG_EQ(testUplinkShare,
547 true,
548 " Uplink traffic not split equally between carriers");
549
550 if (s_writeResults)
551 {
553 }
554
556}
557
558void
560{
561 // NS_LOG_FUNCTION (dlInfo.frameNo << dlInfo.subframeNo << dlInfo.rnti << (uint32_t)
562 // dlInfo.mcsTb1 << dlInfo.sizeTb1 << (uint32_t) dlInfo.mcsTb2 <<
563 // dlInfo.sizeTb2<<(uint16_t)dlInfo.componentCarrierId);
564 // need to allow for RRC connection establishment + CQI feedback reception + persistent data
565 // transmission
566 if (Simulator::Now() > MilliSeconds(300))
567 {
569 {
570 m_ccDownlinkTraffic.insert(
571 std::pair<uint8_t, uint32_t>(dlInfo.componentCarrierId,
572 dlInfo.sizeTb1 + dlInfo.sizeTb2));
573 }
574 else
575 {
576 m_ccDownlinkTraffic[dlInfo.componentCarrierId] += (dlInfo.sizeTb1 + dlInfo.sizeTb2);
577 }
578
579 m_dlThroughput += dlInfo.sizeTb1 + dlInfo.sizeTb2;
580 }
581}
582
583void
585 uint32_t subframeNo,
586 uint16_t rnti,
587 uint8_t mcs,
588 uint16_t sizeTb,
589 uint8_t componentCarrierId)
590{
591 // NS_LOG_FUNCTION (frameNo << subframeNo << rnti << (uint32_t) mcs << sizeTb);
592 // need to allow for RRC connection establishment + SRS transmission
593 if (Simulator::Now() > MilliSeconds(300))
594 {
595 if (m_ccUplinkTraffic.find(componentCarrierId) == m_ccUplinkTraffic.end())
596 {
597 m_ccUplinkTraffic.insert(std::pair<uint8_t, uint32_t>(componentCarrierId, sizeTb));
598 }
599 else
600 {
601 m_ccUplinkTraffic[componentCarrierId] += sizeTb;
602 }
603
604 m_ulThroughput += sizeTb;
605 }
606}
607
608void
610{
611 std::ofstream dlOutFile;
612 dlOutFile.open(dlResultsFileName, std::ofstream::out | std::ofstream::app);
613 dlOutFile.setf(std::ios_base::fixed);
614
615 if (!dlOutFile.is_open())
616 {
617 NS_LOG_ERROR("Can't open file " << dlResultsFileName);
618 return;
619 }
620 dlOutFile << m_nUser << " " << m_numberOfComponentCarriers << " "
621 << ((m_dlThroughput * 8) / m_statsDuration) / m_nUser << std::endl;
622 dlOutFile.close();
623
624 std::ofstream ulOutFile;
625 ulOutFile.open(ulResultsFileName, std::ofstream::out | std::ofstream::app);
626 ulOutFile.setf(std::ios_base::fixed);
627
628 if (!ulOutFile.is_open())
629 {
630 NS_LOG_ERROR("Can't open file " << ulResultsFileName);
631 return;
632 }
633 ulOutFile << m_nUser << " " << m_numberOfComponentCarriers << " "
634 << ((m_ulThroughput * 8) / m_statsDuration) / m_nUser << std::endl;
635 ulOutFile.close();
636}
This system test program creates different test cases with a single eNB and several UEs,...
void DoRun() override
Implementation to actually run this TestCase.
uint32_t m_numberOfComponentCarriers
number of component carriers
void DlScheduling(DlSchedulingCallbackInfo dlInfo)
DL Scheduling function that is used in this test as callback function of DL scheduling trace.
static bool s_writeResults
write results flag, determines whether to write results to outoput files
CarrierAggregationTestCase(uint16_t nUser, uint16_t dist, uint32_t dlbandwidth, uint32_t ulBandwidth, uint32_t numberOfComponentCarriers)
Constructor of test case.
uint16_t m_nUser
the number of users
std::map< uint8_t, uint32_t > m_ccDownlinkTraffic
CC DL traffic.
void UlScheduling(uint32_t frameNo, uint32_t subframeNo, uint16_t rnti, uint8_t mcs, uint16_t sizeTb, uint8_t componentCarrierId)
UL Scheduling function that is used in this test as callback function of UL sceduling trace.
void WriteResultToFile() const
Write result to file function.
static std::string BuildNameString(uint16_t nUser, uint16_t dist, uint32_t dlBandwidth, uint32_t ulBandwidth, uint32_t numberOfComponentCarriers)
Builds the test name string based on provided parameter values.
std::map< uint8_t, uint32_t > m_ccUplinkTraffic
CC UL traffic.
Test Carrier Aggregation Suite.
AttributeValue implementation for Boolean.
Definition: boolean.h:37
Mobility model for which the current position does not change once it has been set and until it is se...
This class can be used to hold variables of floating point type such as 'double' or 'float'.
Definition: double.h:42
Hold variables of type enum.
Definition: enum.h:62
This class contains the specification of EPS Bearers.
Definition: eps-bearer.h:91
Qci
QoS Class Indicator.
Definition: eps-bearer.h:106
@ GBR_CONV_VOICE
GBR Conversational Voice.
Definition: eps-bearer.h:107
The eNodeB device implementation.
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< Node > Get(uint32_t i) const
Get the Ptr<Node> stored in this container at a given index.
Ptr< T > GetObject() const
Get a pointer to the requested aggregated Object.
Definition: object.h:522
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:77
static void Destroy()
Execute the events scheduled with ScheduleDestroy().
Definition: simulator.cc:142
static Time Now()
Return the current simulation virtual time.
Definition: simulator.cc:208
static void Run()
Run the simulation.
Definition: simulator.cc:178
static void Stop()
Tell the Simulator the calling event should be the last one executed.
Definition: simulator.cc:186
Hold variables of type string.
Definition: string.h:56
encapsulates test code
Definition: test.h:1061
void AddTestCase(TestCase *testCase, Duration duration=Duration::QUICK)
Add an individual child TestCase to this test suite.
Definition: test.cc:301
std::string CreateTempDirFilename(std::string filename)
Construct the full path to a file in a temporary directory.
Definition: test.cc:438
A suite of tests to run.
Definition: test.h:1268
Type
Type of test.
Definition: test.h:1275
Hold an unsigned integer type.
Definition: uinteger.h:45
void SetDefault(std::string name, const AttributeValue &value)
Definition: config.cc:894
void Connect(std::string path, const CallbackBase &cb)
Definition: config.cc:978
#define NS_LOG_ERROR(msg)
Use NS_LOG to output a message of level LOG_ERROR.
Definition: log.h:254
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:202
#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:275
static TestCarrierAggregationSuite lenaTestRrFfMacSchedulerSuite
Static variable for test initialization.
auto MakeBoundCallback(R(*fnPtr)(Args...), BArgs &&... bargs)
Make Callbacks with varying number of bound arguments.
Definition: callback.h:765
#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:145
Time Seconds(double value)
Construct a Time in the indicated unit.
Definition: nstime.h:1326
Time MilliSeconds(uint64_t value)
Construct a Time in the indicated unit.
Definition: nstime.h:1338
const std::string ulResultsFileName
const std::string dlResultsFileName
void LteTestUlSchedulingCallback(CarrierAggregationTestCase *testcase, std::string path, uint32_t frameNo, uint32_t subframeNo, uint16_t rnti, uint8_t mcs, uint16_t sizeTb, uint8_t ccId)
void LteTestDlSchedulingCallback(CarrierAggregationTestCase *testcase, std::string path, DlSchedulingCallbackInfo dlInfo)
Every class exported by the ns3 library is enclosed in the ns3 namespace.
DlSchedulingCallbackInfo structure.
Definition: lte-common.h:237
uint16_t sizeTb2
size TB2
Definition: lte-common.h:244
uint16_t sizeTb1
size TB1
Definition: lte-common.h:242
uint8_t componentCarrierId
component carrier ID
Definition: lte-common.h:245