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