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