A Discrete-Event Network Simulator
API
lte-test-fdbet-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("LenaTestFdBetFfMacScheduler");
57
59 : TestSuite("lte-fdbet-ff-mac-scheduler", SYSTEM)
60{
61 NS_LOG_INFO("creating LenaTestFdBetFfMacSchedulerSuite");
62
63 bool errorModel = false;
64
65 // Test Case 1: AMC works in FDBET
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 -> 8 PRB at Itbs 26 -> 749 -> 749000 bytes/sec
72 // 6 users -> 4 PRB at Itbs 26 -> 373 -> 373000 bytes/sec
73 // 12 users -> 2 PRB at Itbs 26 -> 185 -> 185000 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 LenaFdBetFfMacSchedulerTestCase1(1, 0, 2196000, 2292000, errorModel),
81 TestCase::EXTENSIVE);
82 AddTestCase(new LenaFdBetFfMacSchedulerTestCase1(3, 0, 749000, 749000, errorModel),
83 TestCase::EXTENSIVE);
84 AddTestCase(new LenaFdBetFfMacSchedulerTestCase1(6, 0, 373000, 373000, errorModel),
85 TestCase::EXTENSIVE);
86 AddTestCase(new LenaFdBetFfMacSchedulerTestCase1(12, 0, 185000, 184670, errorModel),
87 TestCase::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 -> 8 PRB at Itbs 20 -> 469 -> 469000 bytes/sec
92 // 6 users -> 4 PRB at Itbs 20 -> 233 -> 233000 bytes/sec
93 // 12 users -> 2 PRB at Itbs 20 -> 113 -> 113000 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 LenaFdBetFfMacSchedulerTestCase1(1, 4800, 1383000, 807000, errorModel),
101 TestCase::EXTENSIVE);
102 AddTestCase(new LenaFdBetFfMacSchedulerTestCase1(3, 4800, 469000, 253000, errorModel),
103 TestCase::EXTENSIVE);
104 AddTestCase(new LenaFdBetFfMacSchedulerTestCase1(6, 4800, 233500, 125000, errorModel),
105 TestCase::EXTENSIVE);
106 AddTestCase(new LenaFdBetFfMacSchedulerTestCase1(12, 4800, 113000, 62000, errorModel),
107 TestCase::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 -> 8 PRB at Itbs 18 -> 389 -> 389000 bytes/sec
112 // 6 users -> 4 PRB at Itbs 18 -> 193 -> 193000 bytes/sec
113 // 12 users -> 2 PRB at Itbs 18 -> 97 -> 97000 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 LenaFdBetFfMacSchedulerTestCase1(1, 6000, 1191000, 621000, errorModel),
120 TestCase::EXTENSIVE);
121 AddTestCase(new LenaFdBetFfMacSchedulerTestCase1(3, 6000, 389000, 201000, errorModel),
122 TestCase::EXTENSIVE);
123 AddTestCase(new LenaFdBetFfMacSchedulerTestCase1(6, 6000, 193000, 97000, errorModel),
124 TestCase::EXTENSIVE);
125 AddTestCase(new LenaFdBetFfMacSchedulerTestCase1(12, 6000, 97000, 48667, errorModel),
126 TestCase::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 -> 8 PRB at Itbs 13 -> 253 -> 253000 bytes/sec
131 // 6 users -> 4 PRB at Itbs 13 -> 125 -> 125000 bytes/sec
132 // 12 users -> 2 PRB at Itbs 13 -> 61 -> 61000 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 LenaFdBetFfMacSchedulerTestCase1(1, 10000, 775000, 421000, errorModel),
140 TestCase::EXTENSIVE);
141 AddTestCase(new LenaFdBetFfMacSchedulerTestCase1(3, 10000, 253000, 137000, errorModel),
142 TestCase::EXTENSIVE);
143 AddTestCase(new LenaFdBetFfMacSchedulerTestCase1(6, 10000, 125000, 67000, errorModel),
144 TestCase::EXTENSIVE);
145 AddTestCase(new LenaFdBetFfMacSchedulerTestCase1(12, 10000, 61000, 32667, errorModel),
146 TestCase::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 -> 8 PRB at Itbs 8 -> 137 -> 137000 bytes/sec
151 // 6 users -> 4 PRB at Itbs 8 -> 67 -> 67000 bytes/sec
152 // 12 users -> 2 PRB at Itbs 8 -> 32 -> 32000 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 LenaFdBetFfMacSchedulerTestCase1(1, 20000, 421000, 137000, errorModel),
160 TestCase::EXTENSIVE);
161 AddTestCase(new LenaFdBetFfMacSchedulerTestCase1(3, 20000, 137000, 41000, errorModel),
162 TestCase::EXTENSIVE);
163 AddTestCase(new LenaFdBetFfMacSchedulerTestCase1(6, 20000, 67000, 22000, errorModel),
164 TestCase::EXTENSIVE);
165 AddTestCase(new LenaFdBetFfMacSchedulerTestCase1(12, 20000, 32000, 12000, errorModel),
166 TestCase::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 LenaFdBetFfMacSchedulerTestCase1(1, 100000, 0, 0, errorModel), TestCase::QUICK);
171
172 // Test Case 2: fairness check
173
174 std::vector<double> dist;
175 dist.push_back(0); // User 0 distance --> MCS 28
176 dist.push_back(4800); // User 1 distance --> MCS 22
177 dist.push_back(6000); // User 2 distance --> MCS 14
178 dist.push_back(10000); // User 3 distance --> MCS 8
179 dist.push_back(20000); // User 4 distance --> MCS 8
180 std::vector<uint32_t> estAchievableRateDl;
181 estAchievableRateDl.push_back(2196000);
182 estAchievableRateDl.push_back(1383000);
183 estAchievableRateDl.push_back(775000);
184 estAchievableRateDl.push_back(421000);
185 estAchievableRateDl.push_back(421000);
186 std::vector<uint32_t> estThrFdBetUl;
187 estThrFdBetUl.push_back(469000); // User 0 estimated TTI throughput from FDBET
188 estThrFdBetUl.push_back(157000); // User 1 estimated TTI throughput from FDBET
189 estThrFdBetUl.push_back(125000); // User 2 estimated TTI throughput from FDBET
190 estThrFdBetUl.push_back(85000); // User 3 estimated TTI throughput from FDBET
191 estThrFdBetUl.push_back(26000); // User 4 estimated TTI throughput from FDBET
193 new LenaFdBetFfMacSchedulerTestCase2(dist, estAchievableRateDl, estThrFdBetUl, errorModel),
194 TestCase::QUICK);
195}
196
198
199// --------------- T E S T - C A S E # 1 ------------------------------
200
201std::string
203{
204 std::ostringstream oss;
205 oss << nUser << " UEs, distance " << dist << " m";
206 return oss.str();
207}
208
210 double dist,
211 double thrRefDl,
212 double thrRefUl,
213 bool errorModelEnabled)
214 : TestCase(BuildNameString(nUser, dist)),
215 m_nUser(nUser),
216 m_dist(dist),
217 m_thrRefDl(thrRefDl),
218 m_thrRefUl(thrRefUl),
219 m_errorModelEnabled(errorModelEnabled)
220{
221}
222
224{
225}
226
227void
229{
231 {
232 Config::SetDefault("ns3::LteSpectrumPhy::CtrlErrorModelEnabled", BooleanValue(false));
233 Config::SetDefault("ns3::LteSpectrumPhy::DataErrorModelEnabled", BooleanValue(false));
234 }
235
236 Config::SetDefault("ns3::LteHelper::UseIdealRrc", BooleanValue(true));
237 Config::SetDefault("ns3::MacStatsCalculator::DlOutputFilename",
238 StringValue(CreateTempDirFilename("DlMacStats.txt")));
239 Config::SetDefault("ns3::MacStatsCalculator::UlOutputFilename",
240 StringValue(CreateTempDirFilename("UlMacStats.txt")));
241 Config::SetDefault("ns3::RadioBearerStatsCalculator::DlRlcOutputFilename",
242 StringValue(CreateTempDirFilename("DlRlcStats.txt")));
243 Config::SetDefault("ns3::RadioBearerStatsCalculator::UlRlcOutputFilename",
244 StringValue(CreateTempDirFilename("UlRlcStats.txt")));
245
250 Ptr<LteHelper> lteHelper = CreateObject<LteHelper>();
251
252 lteHelper->SetAttribute("PathlossModel", StringValue("ns3::FriisSpectrumPropagationLossModel"));
253
254 // Create Nodes: eNodeB and UE
255 NodeContainer enbNodes;
256 NodeContainer ueNodes;
257 enbNodes.Create(1);
258 ueNodes.Create(m_nUser);
259
260 // Install Mobility Model
262 mobility.SetMobilityModel("ns3::ConstantPositionMobilityModel");
263 mobility.Install(enbNodes);
264 mobility.SetMobilityModel("ns3::ConstantPositionMobilityModel");
265 mobility.Install(ueNodes);
266
267 // Create Devices and install them in the Nodes (eNB and UE)
268 NetDeviceContainer enbDevs;
269 NetDeviceContainer ueDevs;
270 lteHelper->SetSchedulerType("ns3::FdBetFfMacScheduler");
271 lteHelper->SetSchedulerAttribute("UlCqiFilter", EnumValue(FfMacScheduler::SRS_UL_CQI));
272 enbDevs = lteHelper->InstallEnbDevice(enbNodes);
273 ueDevs = lteHelper->InstallUeDevice(ueNodes);
274
275 // Attach a UE to a eNB
276 lteHelper->Attach(ueDevs, enbDevs.Get(0));
277
278 // Activate an EPS bearer
279 enum EpsBearer::Qci q = EpsBearer::GBR_CONV_VOICE;
280 EpsBearer bearer(q);
281 lteHelper->ActivateDataRadioBearer(ueDevs, bearer);
282
283 Ptr<LteEnbNetDevice> lteEnbDev = enbDevs.Get(0)->GetObject<LteEnbNetDevice>();
284 Ptr<LteEnbPhy> enbPhy = lteEnbDev->GetPhy();
285 enbPhy->SetAttribute("TxPower", DoubleValue(30.0));
286 enbPhy->SetAttribute("NoiseFigure", DoubleValue(5.0));
287
288 // Set UEs' position and power
289 for (int i = 0; i < m_nUser; i++)
290 {
293 mm->SetPosition(Vector(m_dist, 0.0, 0.0));
294 Ptr<LteUeNetDevice> lteUeDev = ueDevs.Get(i)->GetObject<LteUeNetDevice>();
295 Ptr<LteUePhy> uePhy = lteUeDev->GetPhy();
296 uePhy->SetAttribute("TxPower", DoubleValue(23.0));
297 uePhy->SetAttribute("NoiseFigure", DoubleValue(9.0));
298 }
299
300 double statsStartTime = 0.300; // need to allow for RRC connection establishment + SRS
301 double statsDuration = 0.6;
302 double tolerance = 0.1;
303 Simulator::Stop(Seconds(statsStartTime + statsDuration - 0.000001));
304
305 lteHelper->EnableMacTraces();
306 lteHelper->EnableRlcTraces();
307 Ptr<RadioBearerStatsCalculator> rlcStats = lteHelper->GetRlcStats();
308 rlcStats->SetAttribute("StartTime", TimeValue(Seconds(statsStartTime)));
309 rlcStats->SetAttribute("EpochDuration", TimeValue(Seconds(statsDuration)));
310
311 Simulator::Run();
312
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 }
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
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 }
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 }
372 Simulator::Destroy();
373}
374
375// --------------- T E S T - C A S E # 2 ------------------------------
376
377std::string
378LenaFdBetFfMacSchedulerTestCase2::BuildNameString(uint16_t nUser, std::vector<double> dist)
379{
380 std::ostringstream oss;
381 oss << "distances (m) = [ ";
382 for (std::vector<double>::iterator 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> achievableRateDl,
393 std::vector<uint32_t> estThrFdBetUl,
394 bool errorModelEnabled)
395 : TestCase(BuildNameString(dist.size(), dist)),
396 m_nUser(dist.size()),
397 m_dist(dist),
398 m_achievableRateDl(achievableRateDl),
399 m_estThrFdBetUl(estThrFdBetUl),
400 m_errorModelEnabled(errorModelEnabled)
401{
402}
403
405{
406}
407
408void
410{
411 NS_LOG_FUNCTION(this);
412
414 {
415 Config::SetDefault("ns3::LteSpectrumPhy::CtrlErrorModelEnabled", BooleanValue(false));
416 Config::SetDefault("ns3::LteSpectrumPhy::DataErrorModelEnabled", BooleanValue(false));
417 }
418 Config::SetDefault("ns3::LteHelper::UseIdealRrc", BooleanValue(false));
419 Config::SetDefault("ns3::MacStatsCalculator::DlOutputFilename",
420 StringValue(CreateTempDirFilename("DlMacStats.txt")));
421 Config::SetDefault("ns3::MacStatsCalculator::UlOutputFilename",
422 StringValue(CreateTempDirFilename("UlMacStats.txt")));
423 Config::SetDefault("ns3::RadioBearerStatsCalculator::DlRlcOutputFilename",
424 StringValue(CreateTempDirFilename("DlRlcStats.txt")));
425 Config::SetDefault("ns3::RadioBearerStatsCalculator::UlRlcOutputFilename",
426 StringValue(CreateTempDirFilename("UlRlcStats.txt")));
427
432 Ptr<LteHelper> lteHelper = CreateObject<LteHelper>();
433
434 lteHelper->SetAttribute("PathlossModel", StringValue("ns3::FriisSpectrumPropagationLossModel"));
435
436 // Create Nodes: eNodeB and UE
437 NodeContainer enbNodes;
438 NodeContainer ueNodes;
439 enbNodes.Create(1);
440 ueNodes.Create(m_nUser);
441
442 // Install Mobility Model
444 mobility.SetMobilityModel("ns3::ConstantPositionMobilityModel");
445 mobility.Install(enbNodes);
446 mobility.SetMobilityModel("ns3::ConstantPositionMobilityModel");
447 mobility.Install(ueNodes);
448
449 // Create Devices and install them in the Nodes (eNB and UE)
450 NetDeviceContainer enbDevs;
451 NetDeviceContainer ueDevs;
452 lteHelper->SetSchedulerType("ns3::FdBetFfMacScheduler");
453 lteHelper->SetSchedulerAttribute("UlCqiFilter", EnumValue(FfMacScheduler::SRS_UL_CQI));
454 enbDevs = lteHelper->InstallEnbDevice(enbNodes);
455 ueDevs = lteHelper->InstallUeDevice(ueNodes);
456
457 // Attach a UE to a eNB
458 lteHelper->Attach(ueDevs, enbDevs.Get(0));
459
460 // Activate an EPS bearer
461 enum EpsBearer::Qci q = EpsBearer::GBR_CONV_VOICE;
462 EpsBearer bearer(q);
463 lteHelper->ActivateDataRadioBearer(ueDevs, bearer);
464
465 Ptr<LteEnbNetDevice> lteEnbDev = enbDevs.Get(0)->GetObject<LteEnbNetDevice>();
466 Ptr<LteEnbPhy> enbPhy = lteEnbDev->GetPhy();
467 enbPhy->SetAttribute("TxPower", DoubleValue(30.0));
468 enbPhy->SetAttribute("NoiseFigure", DoubleValue(5.0));
469
470 // Set UEs' position and power
471 for (int i = 0; i < m_nUser; i++)
472 {
475 mm->SetPosition(Vector(m_dist.at(i), 0.0, 0.0));
476 Ptr<LteUeNetDevice> lteUeDev = ueDevs.Get(i)->GetObject<LteUeNetDevice>();
477 Ptr<LteUePhy> uePhy = lteUeDev->GetPhy();
478 uePhy->SetAttribute("TxPower", DoubleValue(23.0));
479 uePhy->SetAttribute("NoiseFigure", DoubleValue(9.0));
480 }
481
482 double statsStartTime = 0.300; // need to allow for RRC connection establishment + SRS
483 double statsDuration = 0.4;
484 double tolerance = 0.1;
485 Simulator::Stop(Seconds(statsStartTime + statsDuration - 0.000001));
486
487 lteHelper->EnableMacTraces();
488 lteHelper->EnableRlcTraces();
489 Ptr<RadioBearerStatsCalculator> rlcStats = lteHelper->GetRlcStats();
490 rlcStats->SetAttribute("StartTime", TimeValue(Seconds(statsStartTime)));
491 rlcStats->SetAttribute("EpochDuration", TimeValue(Seconds(statsDuration)));
492
493 Simulator::Run();
494
495 NS_LOG_INFO("DL - Test with " << m_nUser << " user(s)");
496 std::vector<uint64_t> dlDataRxed;
497 double totalData = 0;
498 double estTotalThr = 0;
499 double estUeThr = 0;
500 for (int i = 0; i < m_nUser; i++)
501 {
502 // get the imsi
503 uint64_t imsi = ueDevs.Get(i)->GetObject<LteUeNetDevice>()->GetImsi();
504 // get the lcId
505 uint8_t lcId = 3;
506 dlDataRxed.push_back(rlcStats->GetDlRxData(imsi, lcId));
507 totalData += (double)dlDataRxed.at(i);
508 estTotalThr += 1 / m_achievableRateDl.at(i);
509 NS_LOG_INFO("\tUser " << i << " dist " << m_dist.at(i) << " imsi " << imsi << " bytes rxed "
510 << (double)dlDataRxed.at(i) << " thr "
511 << (double)dlDataRxed.at(i) / statsDuration << " ref " << m_nUser);
512 }
513
514 estTotalThr = m_nUser * (1 / estTotalThr);
515 estUeThr = estTotalThr / m_nUser;
520 for (int i = 0; i < m_nUser; i++)
521 {
522 double thrRatio = (double)1 / m_nUser;
523 double estThrRatio = (double)dlDataRxed.at(i) / totalData;
524 NS_LOG_INFO("\tUser " << i << " thrRatio " << thrRatio << " estThrRatio " << estThrRatio);
525 NS_TEST_ASSERT_MSG_EQ_TOL(estThrRatio, thrRatio, tolerance, " Unfair Throughput!");
526 NS_TEST_ASSERT_MSG_EQ_TOL((double)dlDataRxed.at(i) / statsDuration,
527 estUeThr,
528 estUeThr * tolerance,
529 " Unfair Throughput!");
530 }
531
536 NS_LOG_INFO("UL - Test with " << m_nUser);
537 std::vector<uint64_t> ulDataRxed;
538 for (int i = 0; i < m_nUser; i++)
539 {
540 // get the imsi
541 uint64_t imsi = ueDevs.Get(i)->GetObject<LteUeNetDevice>()->GetImsi();
542 // get the lcId
543 uint8_t lcId = 3;
544 ulDataRxed.push_back(rlcStats->GetUlRxData(imsi, lcId));
545 NS_LOG_INFO("\tUser " << i << " dist " << m_dist.at(i) << " bytes rxed "
546 << (double)ulDataRxed.at(i) << " thr "
547 << (double)ulDataRxed.at(i) / statsDuration << " ref "
548 << (double)m_estThrFdBetUl.at(i));
549 NS_TEST_ASSERT_MSG_EQ_TOL((double)ulDataRxed.at(i) / statsDuration,
550 (double)m_estThrFdBetUl.at(i),
551 (double)m_estThrFdBetUl.at(i) * tolerance,
552 " Unfair Throughput!");
553 }
554 Simulator::Destroy();
555}
This system test program creates different test cases with a single eNB and several UEs,...
static std::string BuildNameString(uint16_t nUser, double dist)
Builds the test name string based on provided parameter values.
LenaFdBetFfMacSchedulerTestCase1(uint16_t nUser, double dist, double thrRefDl, double thrRefUl, bool errorModelEnabled)
Constructor.
void DoRun() override
Implementation to actually run this TestCase.
double m_dist
distance between the nodes
Test case is simillar to the one defined in LenaFdBetFfMacSchedulerTestCase1, with the difference tha...
void DoRun() override
Implementation to actually run this TestCase.
bool m_errorModelEnabled
specifies whether the error model is enabled
std::vector< double > m_dist
distance between the nodes
static std::string BuildNameString(uint16_t nUser, std::vector< double > dist)
Builds the test name string based on provided parameter values.
std::vector< uint32_t > m_achievableRateDl
DL achievable rate.
std::vector< uint32_t > m_estThrFdBetUl
estimated throughput FDBET UL
LenaFdBetFfMacSchedulerTestCase2(std::vector< double > dist, std::vector< uint32_t > achievableRateDl, std::vector< uint32_t > estThrFdBetUl, bool errorModelEnabled)
Constructor.
Test suite for FDBetFfMacScheduler test case.
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:56
This class contains the specification of EPS Bearers.
Definition: eps-bearer.h:91
Qci
QoS Class Indicator.
Definition: eps-bearer.h:106
The eNodeB device implementation.
Ptr< LteEnbPhy > GetPhy() const
Ptr< RadioBearerStatsCalculator > GetRlcStats()
Definition: lte-helper.cc:1708
void SetSchedulerAttribute(std::string n, const AttributeValue &v)
Set an attribute for the scheduler to be created.
Definition: lte-helper.cc:303
NetDeviceContainer InstallEnbDevice(NodeContainer c)
Create a set of eNodeB devices.
Definition: lte-helper.cc:482
void SetSchedulerType(std::string type)
Set the type of scheduler to be used by eNodeB devices.
Definition: lte-helper.cc:289
void Attach(NetDeviceContainer ueDevices)
Enables automatic attachment of a set of UE devices to a suitable cell using Idle mode initial cell s...
Definition: lte-helper.cc:1044
void EnableRlcTraces()
Enable trace sinks for RLC layer.
Definition: lte-helper.cc:1563
void ActivateDataRadioBearer(NetDeviceContainer ueDevices, EpsBearer bearer)
Activate a Data Radio Bearer on a given UE devices (for LTE-only simulation).
Definition: lte-helper.cc:1441
NetDeviceContainer InstallUeDevice(NodeContainer c)
Create a set of UE devices.
Definition: lte-helper.cc:497
void EnableMacTraces()
Enable trace sinks for MAC layer.
Definition: lte-helper.cc:1666
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.
void SetAttribute(std::string name, const AttributeValue &value)
Set a single attribute, raising fatal errors if unsuccessful.
Definition: object-base.cc:258
Ptr< T > GetObject() const
Get a pointer to the requested aggregated Object.
Definition: object.h:471
Hold variables of type string.
Definition: string.h:42
encapsulates test code
Definition: test.h:1060
void AddTestCase(TestCase *testCase, TestDuration duration=QUICK)
Add an individual child TestCase to this test suite.
Definition: test.cc:305
std::string CreateTempDirFilename(std::string filename)
Construct the full path to a file in a temporary directory.
Definition: test.cc:442
A suite of tests to run.
Definition: test.h:1256
AttributeValue implementation for Time.
Definition: nstime.h:1425
void SetDefault(std::string name, const AttributeValue &value)
Definition: config.cc:891
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:202
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by ",...
#define NS_LOG_INFO(msg)
Use NS_LOG to output a message of level LOG_INFO.
Definition: log.h:275
#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:337
Time Seconds(double value)
Construct a Time in the indicated unit.
Definition: nstime.h:1338
static LenaTestFdBetFfMacSchedulerSuite lenaTestFdBetFfMacSchedulerSuite
Every class exported by the ns3 library is enclosed in the ns3 namespace.
mobility
Definition: third.py:96