A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
lte-test-tdbet-ff-mac-scheduler.cc
Go to the documentation of this file.
1/*
2 * Copyright (c) 2011 Centre Tecnologic de Telecomunicacions de Catalunya (CTTC)
3 *
4 * SPDX-License-Identifier: GPL-2.0-only
5 *
6 * Author: Marco Miozzo <marco.miozzo@cttc.es>,
7 * Nicola Baldo <nbaldo@cttc.es>
8 * Dizhi Zhou <dizhi.zhou@gmail.com>
9 */
10
12
13#include "ns3/double.h"
14#include "ns3/radio-bearer-stats-calculator.h"
15#include "ns3/string.h"
16#include <ns3/boolean.h>
17#include <ns3/constant-position-mobility-model.h>
18#include <ns3/enum.h>
19#include <ns3/eps-bearer.h>
20#include <ns3/ff-mac-scheduler.h>
21#include <ns3/log.h>
22#include <ns3/lte-enb-net-device.h>
23#include <ns3/lte-enb-phy.h>
24#include <ns3/lte-helper.h>
25#include <ns3/lte-ue-net-device.h>
26#include <ns3/lte-ue-phy.h>
27#include <ns3/lte-ue-rrc.h>
28#include <ns3/mobility-helper.h>
29#include <ns3/net-device-container.h>
30#include <ns3/node-container.h>
31#include <ns3/object.h>
32#include <ns3/packet.h>
33#include <ns3/ptr.h>
34#include <ns3/simulator.h>
35#include <ns3/spectrum-error-model.h>
36#include <ns3/spectrum-interference.h>
37#include <ns3/test.h>
38
39#include <iostream>
40#include <sstream>
41#include <string>
42
43using namespace ns3;
44
45NS_LOG_COMPONENT_DEFINE("LenaTestTdBetFfMacScheduler");
46
48 : TestSuite("lte-tdbet-ff-mac-scheduler", Type::SYSTEM)
49{
50 NS_LOG_INFO("creating LenaTestTdBetFfMacSchedulerSuite");
51
52 bool errorModel = false;
53
54 // Test Case 1: AMC works in TDBET
55
56 // Note: here the MCS is calculated by the wideband CQI
57
58 // DOWNLINK- DISTANCE 0 -> MCS 28 -> Itbs 26 (from table 7.1.7.2.1-1 of 36.213)
59 // 1 user -> 24 PRB at Itbs 26 -> 2196 -> 2196000 bytes/sec
60 // 3 users -> 2196000 among 3 users -> 732000 bytes/sec
61 // 6 users -> 2196000 among 6 users -> 366000 bytes/sec
62 // 12 users -> 2196000 among 12 users -> 183000 bytes/sec
63 // UPLINK- DISTANCE 0 -> MCS 28 -> Itbs 26 (from table 7.1.7.2.1-1 of 36.213)
64 // 1 user -> 25 PRB at Itbs 26 -> 2292 -> 2292000 bytes/sec
65 // 3 users -> 8 PRB at Itbs 26 -> 749 -> 749000 bytes/sec
66 // 6 users -> 4 PRB at Itbs 26 -> 373 -> 373000 bytes/sec
67 // after the patch enforcing min 3 PRBs per UE:
68 // 12 users -> 3 PRB at Itbs 26 -> 277 bytes * 8/12 UE/TTI -> 184670 bytes/sec
69 AddTestCase(new LenaTdBetFfMacSchedulerTestCase1(1, 0, 2196000, 2292000, errorModel),
70 TestCase::Duration::EXTENSIVE);
71 AddTestCase(new LenaTdBetFfMacSchedulerTestCase1(3, 0, 732000, 749000, errorModel),
72 TestCase::Duration::EXTENSIVE);
73 AddTestCase(new LenaTdBetFfMacSchedulerTestCase1(6, 0, 366000, 373000, errorModel),
74 TestCase::Duration::EXTENSIVE);
75 AddTestCase(new LenaTdBetFfMacSchedulerTestCase1(12, 0, 183000, 184670, errorModel),
76 TestCase::Duration::EXTENSIVE);
77
78 // DOWNLINK - DISTANCE 4800 -> MCS 22 -> Itbs 20 (from table 7.1.7.2.1-1 of 36.213)
79 // 1 user -> 24 PRB at Itbs 20 -> 1383 -> 1383000 bytes/sec
80 // 3 users -> 1383000 among 3 users ->461000 bytes/sec
81 // 6 users -> 1383000 among 6 users ->230500 bytes/sec
82 // 12 users -> 1383000 among 12 users ->115250 bytes/sec
83 // UPLINK - DISTANCE 4800 -> MCS 14 -> Itbs 13 (from table 7.1.7.2.1-1 of 36.213)
84 // 1 user -> 25 PRB at Itbs 13 -> 807 -> 807000 bytes/sec
85 // 3 users -> 8 PRB at Itbs 13 -> 253 -> 253000 bytes/sec
86 // 6 users -> 4 PRB at Itbs 13 -> 125 -> 125000 bytes/sec
87 // after the patch enforcing min 3 PRBs per UE:
88 // 12 users -> 3 PRB at Itbs 13 -> 93 bytes * 8/12 UE/TTI -> 62000 bytes/sec
89 AddTestCase(new LenaTdBetFfMacSchedulerTestCase1(1, 4800, 1383000, 807000, errorModel),
90 TestCase::Duration::EXTENSIVE);
91 AddTestCase(new LenaTdBetFfMacSchedulerTestCase1(3, 4800, 461000, 253000, errorModel),
92 TestCase::Duration::EXTENSIVE);
93 AddTestCase(new LenaTdBetFfMacSchedulerTestCase1(6, 4800, 230500, 125000, errorModel),
94 TestCase::Duration::EXTENSIVE);
95 AddTestCase(new LenaTdBetFfMacSchedulerTestCase1(12, 4800, 115250, 62000, errorModel),
96 TestCase::Duration::EXTENSIVE);
97
98 // DOWNLINK - DISTANCE 6000 -> MCS 20 -> Itbs 18 (from table 7.1.7.2.1-1 of 36.213)
99 // 1 user -> 24 PRB at Itbs 18 -> 1191 -> 1191000 byte/sec
100 // 3 users -> 1191000 among 3 users ->397000 bytes/sec
101 // 6 users -> 1191000 among 6 users ->198500 bytes/sec
102 // 12 users -> 1191000 among 12 users ->99250 bytes/sec
103 // UPLINK - DISTANCE 6000 -> MCS 12 -> Itbs 11 (from table 7.1.7.2.1-1 of 36.213)
104 // 1 user -> 25 PRB at Itbs 11 -> 621 -> 621000 bytes/sec
105 // 3 users -> 8 PRB at Itbs 11 -> 201 -> 201000 bytes/sec
106 // 6 users -> 4 PRB at Itbs 11 -> 97 -> 97000 bytes/sec
107 // 12 users -> 3 PRB at Itbs 11 -> 73 bytes * 8/12 UE/TTI -> 48667 bytes/sec
108 AddTestCase(new LenaTdBetFfMacSchedulerTestCase1(1, 6000, 1191000, 621000, errorModel),
109 TestCase::Duration::EXTENSIVE);
110 AddTestCase(new LenaTdBetFfMacSchedulerTestCase1(3, 6000, 397000, 201000, errorModel),
111 TestCase::Duration::EXTENSIVE);
112 AddTestCase(new LenaTdBetFfMacSchedulerTestCase1(6, 6000, 198500, 97000, errorModel),
113 TestCase::Duration::EXTENSIVE);
114 AddTestCase(new LenaTdBetFfMacSchedulerTestCase1(12, 6000, 99250, 48667, errorModel),
115 TestCase::Duration::EXTENSIVE);
116
117 // DOWNLINK - DISTANCE 10000 -> MCS 14 -> Itbs 13 (from table 7.1.7.2.1-1 of 36.213)
118 // 1 user -> 24 PRB at Itbs 13 -> 775 -> 775000 byte/sec
119 // 3 users -> 775000 among 3 users -> 258333 bytes/sec
120 // 6 users -> 775000 among 6 users -> 129166 bytes/sec
121 // 12 users -> 775000 among 12 users ->64583 bytes/sec
122 // UPLINK - DISTANCE 9000 -> MCS 8 -> Itbs 8 (from table 7.1.7.2.1-1 of 36.213)
123 // 1 user -> 24 PRB at Itbs 8 -> 421 -> 421000 bytes/sec
124 // 3 users -> 8 PRB at Itbs 8 -> 137 -> 137000 bytes/sec
125 // 6 users -> 4 PRB at Itbs 8 -> 67 -> 67000 bytes/sec
126 // after the patch enforcing min 3 PRBs per UE:
127 // 12 users -> 3 PRB at Itbs 8 -> 49 bytes * 8/12 UE/TTI -> 32667 bytes/sec
128 AddTestCase(new LenaTdBetFfMacSchedulerTestCase1(1, 10000, 775000, 421000, errorModel),
129 TestCase::Duration::EXTENSIVE);
130 AddTestCase(new LenaTdBetFfMacSchedulerTestCase1(3, 10000, 258333, 137000, errorModel),
131 TestCase::Duration::EXTENSIVE);
132 AddTestCase(new LenaTdBetFfMacSchedulerTestCase1(6, 10000, 129166, 67000, errorModel),
133 TestCase::Duration::EXTENSIVE);
134 AddTestCase(new LenaTdBetFfMacSchedulerTestCase1(12, 10000, 64583, 32667, errorModel),
135 TestCase::Duration::EXTENSIVE);
136
137 // DOWNLINK - DISTANCE 20000 -> MCS 8 -> Itbs 8 (from table 7.1.7.2.1-1 of 36.213)
138 // 1 user -> 24 PRB at Itbs 8 -> 421 -> 421000 bytes/sec
139 // 3 users -> 421000 among 3 users ->140333 bytes/sec
140 // 6 users -> 421000 among 6 users ->70166 bytes/sec
141 // 12 users -> 421000 among 12 users ->35083 bytes/sec
142 // UPLINK - DISTANCE 20000 -> MCS 2 -> Itbs 2 (from table 7.1.7.2.1-1 of 36.213)
143 // 1 user -> 25 PRB at Itbs 2 -> 137 -> 137000 bytes/sec
144 // 3 users -> 8 PRB at Itbs 2 -> 41 -> 41000 bytes/sec
145 // 6 users -> 4 PRB at Itbs 2 -> 22 -> 22000 bytes/sec
146 // after the patch enforcing min 3 PRBs per UE:
147 // 12 users -> 3 PRB at Itbs 2 -> 18 bytes * 8/12 UE/TTI -> 12000 bytes/sec
148 AddTestCase(new LenaTdBetFfMacSchedulerTestCase1(1, 20000, 421000, 137000, errorModel),
149 TestCase::Duration::EXTENSIVE);
150 AddTestCase(new LenaTdBetFfMacSchedulerTestCase1(3, 20000, 140333, 41000, errorModel),
151 TestCase::Duration::EXTENSIVE);
152 AddTestCase(new LenaTdBetFfMacSchedulerTestCase1(6, 20000, 70166, 22000, errorModel),
153 TestCase::Duration::EXTENSIVE);
154 AddTestCase(new LenaTdBetFfMacSchedulerTestCase1(12, 20000, 35083, 12000, errorModel),
155 TestCase::Duration::EXTENSIVE);
156
157 // DOWNLINK - DISTANCE 100000 -> CQI == 0 -> out of range -> 0 bytes/sec
158 // UPLINK - DISTANCE 100000 -> CQI == 0 -> out of range -> 0 bytes/sec
159 AddTestCase(new LenaTdBetFfMacSchedulerTestCase1(1, 100000, 0, 0, errorModel),
160 TestCase::Duration::QUICK);
161
162 // Test Case 2: fairness check
163
164 std::vector<double> dist;
165 dist.push_back(0); // User 0 distance --> MCS 28
166 dist.push_back(4800); // User 1 distance --> MCS 22
167 dist.push_back(6000); // User 2 distance --> MCS 14
168 dist.push_back(10000); // User 3 distance --> MCS 8
169 dist.push_back(20000); // User 4 distance --> MCS 8
170 std::vector<uint32_t> estAchievableRateDl;
171 estAchievableRateDl.push_back(2196000);
172 estAchievableRateDl.push_back(1383000);
173 estAchievableRateDl.push_back(775000);
174 estAchievableRateDl.push_back(421000);
175 estAchievableRateDl.push_back(421000);
176 std::vector<uint32_t> estThrTdBetUl;
177 estThrTdBetUl.push_back(469000); // User 0 estimated TTI throughput from TDBET
178 estThrTdBetUl.push_back(157000); // User 1 estimated TTI throughput from TDBET
179 estThrTdBetUl.push_back(125000); // User 2 estimated TTI throughput from TDBET
180 estThrTdBetUl.push_back(85000); // User 3 estimated TTI throughput from TDBET
181 estThrTdBetUl.push_back(26000); // User 4 estimated TTI throughput from TDBET
183 new LenaTdBetFfMacSchedulerTestCase2(dist, estAchievableRateDl, estThrTdBetUl, errorModel),
184 TestCase::Duration::QUICK);
185}
186
187/**
188 * @ingroup lte-test
189 * Static variable for test initialization
190 */
192
193// --------------- T E S T - C A S E # 1 ------------------------------
194
195std::string
197{
198 std::ostringstream oss;
199 oss << nUser << " UEs, distance " << dist << " m";
200 return oss.str();
201}
202
204 double dist,
205 double thrRefDl,
206 double thrRefUl,
207 bool errorModelEnabled)
208 : TestCase(BuildNameString(nUser, dist)),
209 m_nUser(nUser),
210 m_dist(dist),
211 m_thrRefDl(thrRefDl),
212 m_thrRefUl(thrRefUl),
213 m_errorModelEnabled(errorModelEnabled)
214{
215}
216
220
221void
223{
225 {
226 Config::SetDefault("ns3::LteSpectrumPhy::CtrlErrorModelEnabled", BooleanValue(false));
227 Config::SetDefault("ns3::LteSpectrumPhy::DataErrorModelEnabled", BooleanValue(false));
228 }
229
230 Config::SetDefault("ns3::LteHelper::UseIdealRrc", BooleanValue(true));
231 Config::SetDefault("ns3::MacStatsCalculator::DlOutputFilename",
232 StringValue(CreateTempDirFilename("DlMacStats.txt")));
233 Config::SetDefault("ns3::MacStatsCalculator::UlOutputFilename",
234 StringValue(CreateTempDirFilename("UlMacStats.txt")));
235 Config::SetDefault("ns3::RadioBearerStatsCalculator::DlRlcOutputFilename",
236 StringValue(CreateTempDirFilename("DlRlcStats.txt")));
237 Config::SetDefault("ns3::RadioBearerStatsCalculator::UlRlcOutputFilename",
238 StringValue(CreateTempDirFilename("UlRlcStats.txt")));
239
240 // Disable Uplink Power Control
241 Config::SetDefault("ns3::LteUePhy::EnableUplinkPowerControl", BooleanValue(false));
242
243 /**
244 * Initialize Simulation Scenario: 1 eNB and m_nUser UEs
245 */
246
248
249 lteHelper->SetAttribute("PathlossModel", StringValue("ns3::FriisSpectrumPropagationLossModel"));
250
251 // Create Nodes: eNodeB and UE
252 NodeContainer enbNodes;
253 NodeContainer ueNodes;
254 enbNodes.Create(1);
255 ueNodes.Create(m_nUser);
256
257 // Install Mobility Model
258 MobilityHelper mobility;
259 mobility.SetMobilityModel("ns3::ConstantPositionMobilityModel");
260 mobility.Install(enbNodes);
261 mobility.SetMobilityModel("ns3::ConstantPositionMobilityModel");
262 mobility.Install(ueNodes);
263
264 // Create Devices and install them in the Nodes (eNB and UE)
265 NetDeviceContainer enbDevs;
266 NetDeviceContainer ueDevs;
267 lteHelper->SetSchedulerType("ns3::TdBetFfMacScheduler");
268 lteHelper->SetSchedulerAttribute("UlCqiFilter", EnumValue(FfMacScheduler::SRS_UL_CQI));
269 enbDevs = lteHelper->InstallEnbDevice(enbNodes);
270 ueDevs = lteHelper->InstallUeDevice(ueNodes);
271
272 // Attach a UE to a eNB
273 lteHelper->Attach(ueDevs, enbDevs.Get(0));
274
275 // Activate an EPS bearer
277 EpsBearer bearer(q);
278 lteHelper->ActivateDataRadioBearer(ueDevs, bearer);
279
280 Ptr<LteEnbNetDevice> lteEnbDev = enbDevs.Get(0)->GetObject<LteEnbNetDevice>();
281 Ptr<LteEnbPhy> enbPhy = lteEnbDev->GetPhy();
282 enbPhy->SetAttribute("TxPower", DoubleValue(30.0));
283 enbPhy->SetAttribute("NoiseFigure", DoubleValue(5.0));
284
285 // Set UEs' position and power
286 for (int i = 0; i < m_nUser; i++)
287 {
290 mm->SetPosition(Vector(m_dist, 0.0, 0.0));
291 Ptr<LteUeNetDevice> lteUeDev = ueDevs.Get(i)->GetObject<LteUeNetDevice>();
292 Ptr<LteUePhy> uePhy = lteUeDev->GetPhy();
293 uePhy->SetAttribute("TxPower", DoubleValue(23.0));
294 uePhy->SetAttribute("NoiseFigure", DoubleValue(9.0));
295 }
296
297 double statsStartTime = 0.300; // need to allow for RRC connection establishment + SRS
298 double statsDuration = 0.6;
299 double tolerance = 0.1;
300 Simulator::Stop(Seconds(statsStartTime + statsDuration - 0.000001));
301
302 lteHelper->EnableMacTraces();
303 lteHelper->EnableRlcTraces();
304 Ptr<RadioBearerStatsCalculator> rlcStats = lteHelper->GetRlcStats();
305 rlcStats->SetAttribute("StartTime", TimeValue(Seconds(statsStartTime)));
306 rlcStats->SetAttribute("EpochDuration", TimeValue(Seconds(statsDuration)));
307
308 NS_LOG_DEBUG("Start ");
309
311
312 /**
313 * Check that the downlink assignment is done in a "TD blind equal throughput" manner
314 */
315 NS_LOG_INFO("DL - Test with " << m_nUser << " user(s) at distance " << m_dist);
316 std::vector<uint64_t> dlDataRxed;
317 for (int i = 0; i < m_nUser; i++)
318 {
319 // get the imsi
320 uint64_t imsi = ueDevs.Get(i)->GetObject<LteUeNetDevice>()->GetImsi();
321 // get the lcId
322 uint8_t lcId = 3;
323 dlDataRxed.push_back(rlcStats->GetDlRxData(imsi, lcId));
324 NS_LOG_INFO("\tUser " << i << " imsi " << imsi << " bytes rxed " << (double)dlDataRxed.at(i)
325 << " thr " << (double)dlDataRxed.at(i) / statsDuration << " ref "
326 << m_thrRefDl);
327 }
328 /**
329 * Check that the assignment is done in a "TD blind equal throughput" manner among users
330 * with equal SINRs: the bandwidth should be distributed according to the
331 * ratio of the estimated throughput per TTI of each user; therefore equally
332 * partitioning the whole bandwidth achievable from a single users in a TTI
333 */
334 for (int i = 0; i < m_nUser; i++)
335 {
336 NS_TEST_ASSERT_MSG_EQ_TOL((double)dlDataRxed.at(i) / statsDuration,
338 m_thrRefDl * tolerance,
339 " Unfair Throughput!");
340 }
341
342 /**
343 * Check that the uplink assignment is done in a "TD blind equal throughput" manner
344 */
345 NS_LOG_INFO("UL - Test with " << m_nUser << " user(s) at distance " << m_dist);
346 std::vector<uint64_t> ulDataRxed;
347 for (int i = 0; i < m_nUser; i++)
348 {
349 // get the imsi
350 uint64_t imsi = ueDevs.Get(i)->GetObject<LteUeNetDevice>()->GetImsi();
351 // get the lcId
352 uint8_t lcId = 3;
353 ulDataRxed.push_back(rlcStats->GetUlRxData(imsi, lcId));
354 NS_LOG_INFO("\tUser " << i << " imsi " << imsi << " bytes rxed " << (double)ulDataRxed.at(i)
355 << " thr " << (double)ulDataRxed.at(i) / statsDuration << " ref "
356 << m_thrRefUl);
357 }
358 /**
359 * Check that the assignment is done in a "TD blind equal throughput" manner among users
360 * with equal SINRs: the bandwidth should be distributed according to the
361 * ratio of the estimated throughput per TTI of each user; therefore equally
362 * partitioning the whole bandwidth achievable from a single users in a TTI
363 */
364 for (int i = 0; i < m_nUser; i++)
365 {
366 NS_TEST_ASSERT_MSG_EQ_TOL((double)ulDataRxed.at(i) / statsDuration,
368 m_thrRefUl * tolerance,
369 " Unfair Throughput!");
370 }
372}
373
374// --------------- T E S T - C A S E # 2 ------------------------------
375
376std::string
377LenaTdBetFfMacSchedulerTestCase2::BuildNameString(uint16_t nUser, std::vector<double> dist)
378{
379 std::ostringstream oss;
380 oss << "distances (m) = [ ";
381 for (auto it = dist.begin(); it != dist.end(); ++it)
382 {
383 oss << *it << " ";
384 }
385 oss << "]";
386 return oss.str();
387}
388
390 std::vector<double> dist,
391 std::vector<uint32_t> estAchievableRateDl,
392 std::vector<uint32_t> estThrTdBetUl,
393 bool errorModelEnabled)
394 : TestCase(BuildNameString(dist.size(), dist)),
395 m_nUser(dist.size()),
396 m_dist(dist),
397 m_achievableRateDl(estAchievableRateDl),
398 m_estThrTdBetUl(estThrTdBetUl),
399 m_errorModelEnabled(errorModelEnabled)
400{
401}
402
406
407void
409{
410 NS_LOG_FUNCTION(this);
411
413 {
414 Config::SetDefault("ns3::LteSpectrumPhy::CtrlErrorModelEnabled", BooleanValue(false));
415 Config::SetDefault("ns3::LteSpectrumPhy::DataErrorModelEnabled", BooleanValue(false));
416 }
417 Config::SetDefault("ns3::LteHelper::UseIdealRrc", BooleanValue(false));
418 Config::SetDefault("ns3::MacStatsCalculator::DlOutputFilename",
419 StringValue(CreateTempDirFilename("DlMacStats.txt")));
420 Config::SetDefault("ns3::MacStatsCalculator::UlOutputFilename",
421 StringValue(CreateTempDirFilename("UlMacStats.txt")));
422 Config::SetDefault("ns3::RadioBearerStatsCalculator::DlRlcOutputFilename",
423 StringValue(CreateTempDirFilename("DlRlcStats.txt")));
424 Config::SetDefault("ns3::RadioBearerStatsCalculator::UlRlcOutputFilename",
425 StringValue(CreateTempDirFilename("UlRlcStats.txt")));
426
427 /**
428 * Initialize Simulation Scenario: 1 eNB and m_nUser UEs
429 */
430
432
433 lteHelper->SetAttribute("PathlossModel", StringValue("ns3::FriisSpectrumPropagationLossModel"));
434
435 // Create Nodes: eNodeB and UE
436 NodeContainer enbNodes;
437 NodeContainer ueNodes;
438 enbNodes.Create(1);
439 ueNodes.Create(m_nUser);
440
441 // Install Mobility Model
442 MobilityHelper mobility;
443 mobility.SetMobilityModel("ns3::ConstantPositionMobilityModel");
444 mobility.Install(enbNodes);
445 mobility.SetMobilityModel("ns3::ConstantPositionMobilityModel");
446 mobility.Install(ueNodes);
447
448 // Create Devices and install them in the Nodes (eNB and UE)
449 NetDeviceContainer enbDevs;
450 NetDeviceContainer ueDevs;
451 lteHelper->SetSchedulerType("ns3::TdBetFfMacScheduler");
452 lteHelper->SetSchedulerAttribute("UlCqiFilter", EnumValue(FfMacScheduler::SRS_UL_CQI));
453 enbDevs = lteHelper->InstallEnbDevice(enbNodes);
454 ueDevs = lteHelper->InstallUeDevice(ueNodes);
455
456 // Attach a UE to a eNB
457 lteHelper->Attach(ueDevs, enbDevs.Get(0));
458
459 // Activate an EPS bearer
461 EpsBearer bearer(q);
462 lteHelper->ActivateDataRadioBearer(ueDevs, bearer);
463
464 Ptr<LteEnbNetDevice> lteEnbDev = enbDevs.Get(0)->GetObject<LteEnbNetDevice>();
465 Ptr<LteEnbPhy> enbPhy = lteEnbDev->GetPhy();
466 enbPhy->SetAttribute("TxPower", DoubleValue(30.0));
467 enbPhy->SetAttribute("NoiseFigure", DoubleValue(5.0));
468
469 // Set UEs' position and power
470 for (int i = 0; i < m_nUser; i++)
471 {
474 mm->SetPosition(Vector(m_dist.at(i), 0.0, 0.0));
475 Ptr<LteUeNetDevice> lteUeDev = ueDevs.Get(i)->GetObject<LteUeNetDevice>();
476 Ptr<LteUePhy> uePhy = lteUeDev->GetPhy();
477 uePhy->SetAttribute("TxPower", DoubleValue(23.0));
478 uePhy->SetAttribute("NoiseFigure", DoubleValue(9.0));
479 }
480
481 double statsStartTime = 0.300; // need to allow for RRC connection establishment + SRS
482 double statsDuration = 0.4;
483 double tolerance = 0.1;
484 Simulator::Stop(Seconds(statsStartTime + statsDuration - 0.000001));
485
486 lteHelper->EnableMacTraces();
487 lteHelper->EnableRlcTraces();
488 Ptr<RadioBearerStatsCalculator> rlcStats = lteHelper->GetRlcStats();
489 rlcStats->SetAttribute("StartTime", TimeValue(Seconds(statsStartTime)));
490 rlcStats->SetAttribute("EpochDuration", TimeValue(Seconds(statsDuration)));
491
493
494 NS_LOG_INFO("DL - Test with " << m_nUser << " user(s)");
495 std::vector<uint64_t> dlDataRxed;
496 double totalData = 0;
497 double estTotalThr = 0;
498 double estUeThr = 0;
499 for (int i = 0; i < m_nUser; i++)
500 {
501 // get the imsi
502 uint64_t imsi = ueDevs.Get(i)->GetObject<LteUeNetDevice>()->GetImsi();
503 // get the lcId
504 uint8_t lcId = 3;
505 dlDataRxed.push_back(rlcStats->GetDlRxData(imsi, lcId));
506 totalData += (double)dlDataRxed.at(i);
507 estTotalThr += 1 / m_achievableRateDl.at(i);
508 NS_LOG_INFO("\tUser " << i << " dist " << m_dist.at(i) << " imsi " << imsi << " bytes rxed "
509 << (double)dlDataRxed.at(i) << " thr "
510 << (double)dlDataRxed.at(i) / statsDuration << " ref " << m_nUser);
511 }
512
513 estTotalThr = m_nUser * (1 / estTotalThr);
514 estUeThr = estTotalThr / m_nUser;
515 /**
516 * Check that the assignment is done in a "TD blind equal throughput" manner among users
517 * with different SINRs: the bandwidth should be distributed equally in long term
518 */
519 for (int i = 0; i < m_nUser; i++)
520 {
521 double thrRatio = 1.0 / m_nUser;
522 double estThrRatio = (double)dlDataRxed.at(i) / totalData;
523 NS_LOG_INFO("\tUser " << i << " thrRatio " << thrRatio << " estThrRatio " << estThrRatio);
524 NS_TEST_ASSERT_MSG_EQ_TOL(estThrRatio, thrRatio, tolerance, " Unfair Throughput!");
525 NS_TEST_ASSERT_MSG_EQ_TOL((double)dlDataRxed.at(i) / statsDuration,
526 estUeThr,
527 estUeThr * tolerance,
528 " Unfair Throughput!");
529 }
530
531 /**
532 * Check that the assignment in uplink is done in a round robin manner.
533 */
534
535 NS_LOG_INFO("UL - Test with " << m_nUser);
536 std::vector<uint64_t> ulDataRxed;
537 for (int i = 0; i < m_nUser; i++)
538 {
539 // get the imsi
540 uint64_t imsi = ueDevs.Get(i)->GetObject<LteUeNetDevice>()->GetImsi();
541 // get the lcId
542 uint8_t lcId = 3;
543 ulDataRxed.push_back(rlcStats->GetUlRxData(imsi, lcId));
544 NS_LOG_INFO("\tUser " << i << " dist " << m_dist.at(i) << " bytes rxed "
545 << (double)ulDataRxed.at(i) << " thr "
546 << (double)ulDataRxed.at(i) / statsDuration << " ref "
547 << (double)m_estThrTdBetUl.at(i));
548 NS_TEST_ASSERT_MSG_EQ_TOL((double)ulDataRxed.at(i) / statsDuration,
549 (double)m_estThrTdBetUl.at(i),
550 (double)m_estThrTdBetUl.at(i) * tolerance,
551 " Unfair Throughput!");
552 }
554}
This system test program creates different test cases with a single eNB and several UEs,...
bool m_errorModelEnabled
indicates whether the error model is enabled
static std::string BuildNameString(uint16_t nUser, double dist)
Builds the test name string based on provided parameter values.
void DoRun() override
Implementation to actually run this TestCase.
double m_thrRefUl
the UL throughput reference
double m_thrRefDl
the DL throughput reference
LenaTdBetFfMacSchedulerTestCase1(uint16_t nUser, double dist, double thrRefDl, double thrRefUl, bool errorModelEnabled)
Constructor.
double m_dist
the distance between UE nodes and eNodeB
Lena TdBet Ff Mac Scheduler Test Case.
static std::string BuildNameString(uint16_t nUser, std::vector< double > dist)
Build name string.
void DoRun() override
Implementation to actually run this TestCase.
std::vector< double > m_dist
the distance between nodes
LenaTdBetFfMacSchedulerTestCase2(std::vector< double > dist, std::vector< uint32_t > achievableRateDl, std::vector< uint32_t > estThrTdBetUl, bool errorModelEnabled)
Constructor.
std::vector< uint32_t > m_estThrTdBetUl
etimated TDBET UL throughput
bool m_errorModelEnabled
indicates whether the error model is enabled
std::vector< uint32_t > m_achievableRateDl
DL achievable rate.
Test suite for TdBetFfMacScheduler tests.
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 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
A suite of tests to run.
Definition test.h:1267
Type
Type of test.
Definition test.h:1274
AttributeValue implementation for Time.
Definition nstime.h:1431
void SetDefault(std::string name, const AttributeValue &value)
Definition config.cc:883
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition log.h:191
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
Definition log.h:257
#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 LenaTestTdBetFfMacSchedulerSuite lenaTestTdBetFfMacSchedulerSuite
Static variable for test initialization.
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_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:327
Time Seconds(double value)
Construct a Time in the indicated unit.
Definition nstime.h:1344
Every class exported by the ns3 library is enclosed in the ns3 namespace.