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/boolean.h"
14#include "ns3/constant-position-mobility-model.h"
15#include "ns3/double.h"
16#include "ns3/enum.h"
17#include "ns3/eps-bearer.h"
18#include "ns3/ff-mac-scheduler.h"
19#include "ns3/log.h"
20#include "ns3/lte-enb-net-device.h"
21#include "ns3/lte-enb-phy.h"
22#include "ns3/lte-helper.h"
23#include "ns3/lte-ue-net-device.h"
24#include "ns3/lte-ue-phy.h"
25#include "ns3/lte-ue-rrc.h"
26#include "ns3/mobility-helper.h"
27#include "ns3/net-device-container.h"
28#include "ns3/node-container.h"
29#include "ns3/object.h"
30#include "ns3/packet.h"
31#include "ns3/ptr.h"
32#include "ns3/radio-bearer-stats-calculator.h"
33#include "ns3/simulator.h"
34#include "ns3/spectrum-error-model.h"
35#include "ns3/spectrum-interference.h"
36#include "ns3/string.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{
224 SetDataDir(NS_TEST_SOURCEDIR);
226 {
227 Config::SetDefault("ns3::LteSpectrumPhy::CtrlErrorModelEnabled", BooleanValue(false));
228 Config::SetDefault("ns3::LteSpectrumPhy::DataErrorModelEnabled", BooleanValue(false));
229 }
230
231 Config::SetDefault("ns3::LteHelper::UseIdealRrc", BooleanValue(true));
232 Config::SetDefault("ns3::MacStatsCalculator::DlOutputFilename",
233 StringValue(CreateTempDirFilename("DlMacStats.txt")));
234 Config::SetDefault("ns3::MacStatsCalculator::UlOutputFilename",
235 StringValue(CreateTempDirFilename("UlMacStats.txt")));
236 Config::SetDefault("ns3::RadioBearerStatsCalculator::DlRlcOutputFilename",
237 StringValue(CreateTempDirFilename("DlRlcStats.txt")));
238 Config::SetDefault("ns3::RadioBearerStatsCalculator::UlRlcOutputFilename",
239 StringValue(CreateTempDirFilename("UlRlcStats.txt")));
240
241 // Disable Uplink Power Control
242 Config::SetDefault("ns3::LteUePhy::EnableUplinkPowerControl", BooleanValue(false));
243
244 /**
245 * Initialize Simulation Scenario: 1 eNB and m_nUser UEs
246 */
247
249
250 lteHelper->SetAttribute("PathlossModel", StringValue("ns3::FriisSpectrumPropagationLossModel"));
251
252 // Create Nodes: eNodeB and UE
253 NodeContainer enbNodes;
254 NodeContainer ueNodes;
255 enbNodes.Create(1);
256 ueNodes.Create(m_nUser);
257
258 // Install Mobility Model
259 MobilityHelper mobility;
260 mobility.SetMobilityModel("ns3::ConstantPositionMobilityModel");
261 mobility.Install(enbNodes);
262 mobility.SetMobilityModel("ns3::ConstantPositionMobilityModel");
263 mobility.Install(ueNodes);
264
265 // Create Devices and install them in the Nodes (eNB and UE)
266 NetDeviceContainer enbDevs;
267 NetDeviceContainer ueDevs;
268 lteHelper->SetSchedulerType("ns3::TdBetFfMacScheduler");
269 lteHelper->SetSchedulerAttribute("UlCqiFilter", EnumValue(FfMacScheduler::SRS_UL_CQI));
270 enbDevs = lteHelper->InstallEnbDevice(enbNodes);
271 ueDevs = lteHelper->InstallUeDevice(ueNodes);
272
273 // Attach a UE to a eNB
274 lteHelper->Attach(ueDevs, enbDevs.Get(0));
275
276 // Activate an EPS bearer
278 EpsBearer bearer(q);
279 lteHelper->ActivateDataRadioBearer(ueDevs, bearer);
280
281 Ptr<LteEnbNetDevice> lteEnbDev = enbDevs.Get(0)->GetObject<LteEnbNetDevice>();
282 Ptr<LteEnbPhy> enbPhy = lteEnbDev->GetPhy();
283 enbPhy->SetAttribute("TxPower", DoubleValue(30.0));
284 enbPhy->SetAttribute("NoiseFigure", DoubleValue(5.0));
285
286 // Set UEs' position and power
287 for (int i = 0; i < m_nUser; i++)
288 {
291 mm->SetPosition(Vector(m_dist, 0.0, 0.0));
292 Ptr<LteUeNetDevice> lteUeDev = ueDevs.Get(i)->GetObject<LteUeNetDevice>();
293 Ptr<LteUePhy> uePhy = lteUeDev->GetPhy();
294 uePhy->SetAttribute("TxPower", DoubleValue(23.0));
295 uePhy->SetAttribute("NoiseFigure", DoubleValue(9.0));
296 }
297
298 double statsStartTime = 0.300; // need to allow for RRC connection establishment + SRS
299 double statsDuration = 0.6;
300 double tolerance = 0.1;
301 Simulator::Stop(Seconds(statsStartTime + statsDuration - 0.000001));
302
303 lteHelper->EnableMacTraces();
304 lteHelper->EnableRlcTraces();
305 Ptr<RadioBearerStatsCalculator> rlcStats = lteHelper->GetRlcStats();
306 rlcStats->SetAttribute("StartTime", TimeValue(Seconds(statsStartTime)));
307 rlcStats->SetAttribute("EpochDuration", TimeValue(Seconds(statsDuration)));
308
309 NS_LOG_DEBUG("Start ");
310
312
313 /**
314 * Check that the downlink assignment is done in a "TD blind equal throughput" manner
315 */
316 NS_LOG_INFO("DL - Test with " << m_nUser << " user(s) at distance " << m_dist);
317 std::vector<uint64_t> dlDataRxed;
318 for (int i = 0; i < m_nUser; i++)
319 {
320 // get the imsi
321 uint64_t imsi = ueDevs.Get(i)->GetObject<LteUeNetDevice>()->GetImsi();
322 // get the lcId
323 uint8_t lcId = 3;
324 dlDataRxed.push_back(rlcStats->GetDlRxData(imsi, lcId));
325 NS_LOG_INFO("\tUser " << i << " imsi " << imsi << " bytes rxed " << (double)dlDataRxed.at(i)
326 << " thr " << (double)dlDataRxed.at(i) / statsDuration << " ref "
327 << m_thrRefDl);
328 }
329 /**
330 * Check that the assignment is done in a "TD blind equal throughput" manner among users
331 * with equal SINRs: the bandwidth should be distributed according to the
332 * ratio of the estimated throughput per TTI of each user; therefore equally
333 * partitioning the whole bandwidth achievable from a single users in a TTI
334 */
335 for (int i = 0; i < m_nUser; i++)
336 {
337 NS_TEST_ASSERT_MSG_EQ_TOL((double)dlDataRxed.at(i) / statsDuration,
339 m_thrRefDl * tolerance,
340 " Unfair Throughput!");
341 }
342
343 /**
344 * Check that the uplink assignment is done in a "TD blind equal throughput" manner
345 */
346 NS_LOG_INFO("UL - Test with " << m_nUser << " user(s) at distance " << m_dist);
347 std::vector<uint64_t> ulDataRxed;
348 for (int i = 0; i < m_nUser; i++)
349 {
350 // get the imsi
351 uint64_t imsi = ueDevs.Get(i)->GetObject<LteUeNetDevice>()->GetImsi();
352 // get the lcId
353 uint8_t lcId = 3;
354 ulDataRxed.push_back(rlcStats->GetUlRxData(imsi, lcId));
355 NS_LOG_INFO("\tUser " << i << " imsi " << imsi << " bytes rxed " << (double)ulDataRxed.at(i)
356 << " thr " << (double)ulDataRxed.at(i) / statsDuration << " ref "
357 << m_thrRefUl);
358 }
359 /**
360 * Check that the assignment is done in a "TD blind equal throughput" manner among users
361 * with equal SINRs: the bandwidth should be distributed according to the
362 * ratio of the estimated throughput per TTI of each user; therefore equally
363 * partitioning the whole bandwidth achievable from a single users in a TTI
364 */
365 for (int i = 0; i < m_nUser; i++)
366 {
367 NS_TEST_ASSERT_MSG_EQ_TOL((double)ulDataRxed.at(i) / statsDuration,
369 m_thrRefUl * tolerance,
370 " Unfair Throughput!");
371 }
373}
374
375// --------------- T E S T - C A S E # 2 ------------------------------
376
377std::string
378LenaTdBetFfMacSchedulerTestCase2::BuildNameString(uint16_t nUser, std::vector<double> dist)
379{
380 std::ostringstream oss;
381 oss << "distances (m) = [ ";
382 for (auto it = dist.begin(); it != dist.end(); ++it)
383 {
384 oss << *it << " ";
385 }
386 oss << "]";
387 return oss.str();
388}
389
391 std::vector<double> dist,
392 std::vector<uint32_t> estAchievableRateDl,
393 std::vector<uint32_t> estThrTdBetUl,
394 bool errorModelEnabled)
395 : TestCase(BuildNameString(dist.size(), dist)),
396 m_nUser(dist.size()),
397 m_dist(dist),
398 m_achievableRateDl(estAchievableRateDl),
399 m_estThrTdBetUl(estThrTdBetUl),
400 m_errorModelEnabled(errorModelEnabled)
401{
402}
403
407
408void
410{
411 NS_LOG_FUNCTION(this);
412 SetDataDir(NS_TEST_SOURCEDIR);
413
415 {
416 Config::SetDefault("ns3::LteSpectrumPhy::CtrlErrorModelEnabled", BooleanValue(false));
417 Config::SetDefault("ns3::LteSpectrumPhy::DataErrorModelEnabled", BooleanValue(false));
418 }
419 Config::SetDefault("ns3::LteHelper::UseIdealRrc", BooleanValue(false));
420 Config::SetDefault("ns3::MacStatsCalculator::DlOutputFilename",
421 StringValue(CreateTempDirFilename("DlMacStats.txt")));
422 Config::SetDefault("ns3::MacStatsCalculator::UlOutputFilename",
423 StringValue(CreateTempDirFilename("UlMacStats.txt")));
424 Config::SetDefault("ns3::RadioBearerStatsCalculator::DlRlcOutputFilename",
425 StringValue(CreateTempDirFilename("DlRlcStats.txt")));
426 Config::SetDefault("ns3::RadioBearerStatsCalculator::UlRlcOutputFilename",
427 StringValue(CreateTempDirFilename("UlRlcStats.txt")));
428
429 /**
430 * Initialize Simulation Scenario: 1 eNB and m_nUser UEs
431 */
432
434
435 lteHelper->SetAttribute("PathlossModel", StringValue("ns3::FriisSpectrumPropagationLossModel"));
436
437 // Create Nodes: eNodeB and UE
438 NodeContainer enbNodes;
439 NodeContainer ueNodes;
440 enbNodes.Create(1);
441 ueNodes.Create(m_nUser);
442
443 // Install Mobility Model
444 MobilityHelper mobility;
445 mobility.SetMobilityModel("ns3::ConstantPositionMobilityModel");
446 mobility.Install(enbNodes);
447 mobility.SetMobilityModel("ns3::ConstantPositionMobilityModel");
448 mobility.Install(ueNodes);
449
450 // Create Devices and install them in the Nodes (eNB and UE)
451 NetDeviceContainer enbDevs;
452 NetDeviceContainer ueDevs;
453 lteHelper->SetSchedulerType("ns3::TdBetFfMacScheduler");
454 lteHelper->SetSchedulerAttribute("UlCqiFilter", EnumValue(FfMacScheduler::SRS_UL_CQI));
455 enbDevs = lteHelper->InstallEnbDevice(enbNodes);
456 ueDevs = lteHelper->InstallUeDevice(ueNodes);
457
458 // Attach a UE to a eNB
459 lteHelper->Attach(ueDevs, enbDevs.Get(0));
460
461 // Activate an EPS bearer
463 EpsBearer bearer(q);
464 lteHelper->ActivateDataRadioBearer(ueDevs, bearer);
465
466 Ptr<LteEnbNetDevice> lteEnbDev = enbDevs.Get(0)->GetObject<LteEnbNetDevice>();
467 Ptr<LteEnbPhy> enbPhy = lteEnbDev->GetPhy();
468 enbPhy->SetAttribute("TxPower", DoubleValue(30.0));
469 enbPhy->SetAttribute("NoiseFigure", DoubleValue(5.0));
470
471 // Set UEs' position and power
472 for (int i = 0; i < m_nUser; i++)
473 {
476 mm->SetPosition(Vector(m_dist.at(i), 0.0, 0.0));
477 Ptr<LteUeNetDevice> lteUeDev = ueDevs.Get(i)->GetObject<LteUeNetDevice>();
478 Ptr<LteUePhy> uePhy = lteUeDev->GetPhy();
479 uePhy->SetAttribute("TxPower", DoubleValue(23.0));
480 uePhy->SetAttribute("NoiseFigure", DoubleValue(9.0));
481 }
482
483 double statsStartTime = 0.300; // need to allow for RRC connection establishment + SRS
484 double statsDuration = 0.4;
485 double tolerance = 0.1;
486 Simulator::Stop(Seconds(statsStartTime + statsDuration - 0.000001));
487
488 lteHelper->EnableMacTraces();
489 lteHelper->EnableRlcTraces();
490 Ptr<RadioBearerStatsCalculator> rlcStats = lteHelper->GetRlcStats();
491 rlcStats->SetAttribute("StartTime", TimeValue(Seconds(statsStartTime)));
492 rlcStats->SetAttribute("EpochDuration", TimeValue(Seconds(statsDuration)));
493
495
496 NS_LOG_INFO("DL - Test with " << m_nUser << " user(s)");
497 std::vector<uint64_t> dlDataRxed;
498 double totalData = 0;
499 double estTotalThr = 0;
500 double estUeThr = 0;
501 for (int i = 0; i < m_nUser; i++)
502 {
503 // get the imsi
504 uint64_t imsi = ueDevs.Get(i)->GetObject<LteUeNetDevice>()->GetImsi();
505 // get the lcId
506 uint8_t lcId = 3;
507 dlDataRxed.push_back(rlcStats->GetDlRxData(imsi, lcId));
508 totalData += (double)dlDataRxed.at(i);
509 estTotalThr += 1 / m_achievableRateDl.at(i);
510 NS_LOG_INFO("\tUser " << i << " dist " << m_dist.at(i) << " imsi " << imsi << " bytes rxed "
511 << (double)dlDataRxed.at(i) << " thr "
512 << (double)dlDataRxed.at(i) / statsDuration << " ref " << m_nUser);
513 }
514
515 estTotalThr = m_nUser * (1 / estTotalThr);
516 estUeThr = estTotalThr / m_nUser;
517 /**
518 * Check that the assignment is done in a "TD blind equal throughput" manner among users
519 * with different SINRs: the bandwidth should be distributed equally in long term
520 */
521 for (int i = 0; i < m_nUser; i++)
522 {
523 double thrRatio = 1.0 / m_nUser;
524 double estThrRatio = (double)dlDataRxed.at(i) / totalData;
525 NS_LOG_INFO("\tUser " << i << " thrRatio " << thrRatio << " estThrRatio " << estThrRatio);
526 NS_TEST_ASSERT_MSG_EQ_TOL(estThrRatio, thrRatio, tolerance, " Unfair Throughput!");
527 NS_TEST_ASSERT_MSG_EQ_TOL((double)dlDataRxed.at(i) / statsDuration,
528 estUeThr,
529 estUeThr * tolerance,
530 " Unfair Throughput!");
531 }
532
533 /**
534 * Check that the assignment in uplink is done in a round robin manner.
535 */
536
537 NS_LOG_INFO("UL - Test with " << m_nUser);
538 std::vector<uint64_t> ulDataRxed;
539 for (int i = 0; i < m_nUser; i++)
540 {
541 // get the imsi
542 uint64_t imsi = ueDevs.Get(i)->GetObject<LteUeNetDevice>()->GetImsi();
543 // get the lcId
544 uint8_t lcId = 3;
545 ulDataRxed.push_back(rlcStats->GetUlRxData(imsi, lcId));
546 NS_LOG_INFO("\tUser " << i << " dist " << m_dist.at(i) << " bytes rxed "
547 << (double)ulDataRxed.at(i) << " thr "
548 << (double)ulDataRxed.at(i) / statsDuration << " ref "
549 << (double)m_estThrTdBetUl.at(i));
550 NS_TEST_ASSERT_MSG_EQ_TOL((double)ulDataRxed.at(i) / statsDuration,
551 (double)m_estThrTdBetUl.at(i),
552 (double)m_estThrTdBetUl.at(i) * tolerance,
553 " Unfair Throughput!");
554 }
556}
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
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
AttributeValue implementation for Time.
Definition nstime.h:1432
void SetDefault(std::string name, const AttributeValue &value)
Definition config.cc:886
#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:1345
Every class exported by the ns3 library is enclosed in the ns3 namespace.