A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
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 * 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("LenaTestFdBetFfMacScheduler");
46
48 : TestSuite("lte-fdbet-ff-mac-scheduler", Type::SYSTEM)
49{
50 NS_LOG_INFO("creating LenaTestFdBetFfMacSchedulerSuite");
51
52 bool errorModel = false;
53
54 // Test Case 1: AMC works in FDBET
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 -> 8 PRB at Itbs 26 -> 749 -> 749000 bytes/sec
61 // 6 users -> 4 PRB at Itbs 26 -> 373 -> 373000 bytes/sec
62 // 12 users -> 2 PRB at Itbs 26 -> 185 -> 185000 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 LenaFdBetFfMacSchedulerTestCase1(1, 0, 2196000, 2292000, errorModel),
70 TestCase::Duration::EXTENSIVE);
71 AddTestCase(new LenaFdBetFfMacSchedulerTestCase1(3, 0, 749000, 749000, errorModel),
72 TestCase::Duration::EXTENSIVE);
73 AddTestCase(new LenaFdBetFfMacSchedulerTestCase1(6, 0, 373000, 373000, errorModel),
74 TestCase::Duration::EXTENSIVE);
75 AddTestCase(new LenaFdBetFfMacSchedulerTestCase1(12, 0, 185000, 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 -> 8 PRB at Itbs 20 -> 469 -> 469000 bytes/sec
81 // 6 users -> 4 PRB at Itbs 20 -> 233 -> 233000 bytes/sec
82 // 12 users -> 2 PRB at Itbs 20 -> 113 -> 113000 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 LenaFdBetFfMacSchedulerTestCase1(1, 4800, 1383000, 807000, errorModel),
90 TestCase::Duration::EXTENSIVE);
91 AddTestCase(new LenaFdBetFfMacSchedulerTestCase1(3, 4800, 469000, 253000, errorModel),
92 TestCase::Duration::EXTENSIVE);
93 AddTestCase(new LenaFdBetFfMacSchedulerTestCase1(6, 4800, 233500, 125000, errorModel),
94 TestCase::Duration::EXTENSIVE);
95 AddTestCase(new LenaFdBetFfMacSchedulerTestCase1(12, 4800, 113000, 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 -> 8 PRB at Itbs 18 -> 389 -> 389000 bytes/sec
101 // 6 users -> 4 PRB at Itbs 18 -> 193 -> 193000 bytes/sec
102 // 12 users -> 2 PRB at Itbs 18 -> 97 -> 97000 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 LenaFdBetFfMacSchedulerTestCase1(1, 6000, 1191000, 621000, errorModel),
109 TestCase::Duration::EXTENSIVE);
110 AddTestCase(new LenaFdBetFfMacSchedulerTestCase1(3, 6000, 389000, 201000, errorModel),
111 TestCase::Duration::EXTENSIVE);
112 AddTestCase(new LenaFdBetFfMacSchedulerTestCase1(6, 6000, 193000, 97000, errorModel),
113 TestCase::Duration::EXTENSIVE);
114 AddTestCase(new LenaFdBetFfMacSchedulerTestCase1(12, 6000, 97000, 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 -> 8 PRB at Itbs 13 -> 253 -> 253000 bytes/sec
120 // 6 users -> 4 PRB at Itbs 13 -> 125 -> 125000 bytes/sec
121 // 12 users -> 2 PRB at Itbs 13 -> 61 -> 61000 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 LenaFdBetFfMacSchedulerTestCase1(1, 10000, 775000, 421000, errorModel),
129 TestCase::Duration::EXTENSIVE);
130 AddTestCase(new LenaFdBetFfMacSchedulerTestCase1(3, 10000, 253000, 137000, errorModel),
131 TestCase::Duration::EXTENSIVE);
132 AddTestCase(new LenaFdBetFfMacSchedulerTestCase1(6, 10000, 125000, 67000, errorModel),
133 TestCase::Duration::EXTENSIVE);
134 AddTestCase(new LenaFdBetFfMacSchedulerTestCase1(12, 10000, 61000, 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 -> 8 PRB at Itbs 8 -> 137 -> 137000 bytes/sec
140 // 6 users -> 4 PRB at Itbs 8 -> 67 -> 67000 bytes/sec
141 // 12 users -> 2 PRB at Itbs 8 -> 32 -> 32000 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 LenaFdBetFfMacSchedulerTestCase1(1, 20000, 421000, 137000, errorModel),
149 TestCase::Duration::EXTENSIVE);
150 AddTestCase(new LenaFdBetFfMacSchedulerTestCase1(3, 20000, 137000, 41000, errorModel),
151 TestCase::Duration::EXTENSIVE);
152 AddTestCase(new LenaFdBetFfMacSchedulerTestCase1(6, 20000, 67000, 22000, errorModel),
153 TestCase::Duration::EXTENSIVE);
154 AddTestCase(new LenaFdBetFfMacSchedulerTestCase1(12, 20000, 32000, 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 LenaFdBetFfMacSchedulerTestCase1(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> estThrFdBetUl;
177 estThrFdBetUl.push_back(469000); // User 0 estimated TTI throughput from FDBET
178 estThrFdBetUl.push_back(157000); // User 1 estimated TTI throughput from FDBET
179 estThrFdBetUl.push_back(125000); // User 2 estimated TTI throughput from FDBET
180 estThrFdBetUl.push_back(85000); // User 3 estimated TTI throughput from FDBET
181 estThrFdBetUl.push_back(26000); // User 4 estimated TTI throughput from FDBET
183 new LenaFdBetFfMacSchedulerTestCase2(dist, estAchievableRateDl, estThrFdBetUl, 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 /**
241 * Initialize Simulation Scenario: 1 eNB and m_nUser UEs
242 */
243
245
246 lteHelper->SetAttribute("PathlossModel", StringValue("ns3::FriisSpectrumPropagationLossModel"));
247
248 // Create Nodes: eNodeB and UE
249 NodeContainer enbNodes;
250 NodeContainer ueNodes;
251 enbNodes.Create(1);
252 ueNodes.Create(m_nUser);
253
254 // Install Mobility Model
255 MobilityHelper mobility;
256 mobility.SetMobilityModel("ns3::ConstantPositionMobilityModel");
257 mobility.Install(enbNodes);
258 mobility.SetMobilityModel("ns3::ConstantPositionMobilityModel");
259 mobility.Install(ueNodes);
260
261 // Create Devices and install them in the Nodes (eNB and UE)
262 NetDeviceContainer enbDevs;
263 NetDeviceContainer ueDevs;
264 lteHelper->SetSchedulerType("ns3::FdBetFfMacScheduler");
265 lteHelper->SetSchedulerAttribute("UlCqiFilter", EnumValue(FfMacScheduler::SRS_UL_CQI));
266 enbDevs = lteHelper->InstallEnbDevice(enbNodes);
267 ueDevs = lteHelper->InstallUeDevice(ueNodes);
268
269 // Attach a UE to a eNB
270 lteHelper->Attach(ueDevs, enbDevs.Get(0));
271
272 // Activate an EPS bearer
274 EpsBearer bearer(q);
275 lteHelper->ActivateDataRadioBearer(ueDevs, bearer);
276
277 Ptr<LteEnbNetDevice> lteEnbDev = enbDevs.Get(0)->GetObject<LteEnbNetDevice>();
278 Ptr<LteEnbPhy> enbPhy = lteEnbDev->GetPhy();
279 enbPhy->SetAttribute("TxPower", DoubleValue(30.0));
280 enbPhy->SetAttribute("NoiseFigure", DoubleValue(5.0));
281
282 // Set UEs' position and power
283 for (int i = 0; i < m_nUser; i++)
284 {
287 mm->SetPosition(Vector(m_dist, 0.0, 0.0));
288 Ptr<LteUeNetDevice> lteUeDev = ueDevs.Get(i)->GetObject<LteUeNetDevice>();
289 Ptr<LteUePhy> uePhy = lteUeDev->GetPhy();
290 uePhy->SetAttribute("TxPower", DoubleValue(23.0));
291 uePhy->SetAttribute("NoiseFigure", DoubleValue(9.0));
292 }
293
294 double statsStartTime = 0.300; // need to allow for RRC connection establishment + SRS
295 double statsDuration = 0.6;
296 double tolerance = 0.1;
297 Simulator::Stop(Seconds(statsStartTime + statsDuration - 0.000001));
298
299 lteHelper->EnableMacTraces();
300 lteHelper->EnableRlcTraces();
301 Ptr<RadioBearerStatsCalculator> rlcStats = lteHelper->GetRlcStats();
302 rlcStats->SetAttribute("StartTime", TimeValue(Seconds(statsStartTime)));
303 rlcStats->SetAttribute("EpochDuration", TimeValue(Seconds(statsDuration)));
304
306
307 /**
308 * Check that the downlink assignment is done in a "FD blind equal throughput" manner
309 */
310 NS_LOG_INFO("DL - Test with " << m_nUser << " user(s) at distance " << m_dist);
311 std::vector<uint64_t> dlDataRxed;
312 for (int i = 0; i < m_nUser; i++)
313 {
314 // get the imsi
315 uint64_t imsi = ueDevs.Get(i)->GetObject<LteUeNetDevice>()->GetImsi();
316 // get the lcId
317 uint8_t lcId = 3;
318 dlDataRxed.push_back(rlcStats->GetDlRxData(imsi, lcId));
319 NS_LOG_INFO("\tUser " << i << " imsi " << imsi << " bytes rxed " << (double)dlDataRxed.at(i)
320 << " thr " << (double)dlDataRxed.at(i) / statsDuration << " ref "
321 << m_thrRefDl);
322 }
323 /**
324 * Check that the assignment is done in a "FD blind equal throughput" manner among users
325 * with equal SINRs: the bandwidth should be distributed according to the
326 * ratio of the estimated throughput per TTI of each user; therefore equally
327 * partitioning the whole bandwidth achievable from a single users in a TTI
328 */
329 for (int i = 0; i < m_nUser; i++)
330 {
331 NS_TEST_ASSERT_MSG_EQ_TOL((double)dlDataRxed.at(i) / statsDuration,
333 m_thrRefDl * tolerance,
334 " Unfair Throughput!");
335 }
336
337 /**
338 * Check that the uplink assignment is done in a "FD blind equal throughput" manner
339 */
340 NS_LOG_INFO("UL - Test with " << m_nUser << " user(s) at distance " << m_dist);
341 std::vector<uint64_t> ulDataRxed;
342 for (int i = 0; i < m_nUser; i++)
343 {
344 // get the imsi
345 uint64_t imsi = ueDevs.Get(i)->GetObject<LteUeNetDevice>()->GetImsi();
346 // get the lcId
347 uint8_t lcId = 3;
348 ulDataRxed.push_back(rlcStats->GetUlRxData(imsi, lcId));
349 NS_LOG_INFO("\tUser " << i << " imsi " << imsi << " bytes rxed " << (double)ulDataRxed.at(i)
350 << " thr " << (double)ulDataRxed.at(i) / statsDuration << " ref "
351 << m_thrRefUl);
352 }
353 /**
354 * Check that the assignment is done in a "FD blind equal throughput" manner among users
355 * with equal SINRs: the bandwidth should be distributed according to the
356 * ratio of the estimated throughput per TTI of each user; therefore equally
357 * partitioning the whole bandwidth achievable from a single users in a TTI
358 */
359 for (int i = 0; i < m_nUser; i++)
360 {
361 NS_TEST_ASSERT_MSG_EQ_TOL((double)ulDataRxed.at(i) / statsDuration,
363 m_thrRefUl * tolerance,
364 " Unfair Throughput!");
365 }
367}
368
369// --------------- T E S T - C A S E # 2 ------------------------------
370
371std::string
372LenaFdBetFfMacSchedulerTestCase2::BuildNameString(uint16_t nUser, std::vector<double> dist)
373{
374 std::ostringstream oss;
375 oss << "distances (m) = [ ";
376 for (auto it = dist.begin(); it != dist.end(); ++it)
377 {
378 oss << *it << " ";
379 }
380 oss << "]";
381 return oss.str();
382}
383
385 std::vector<double> dist,
386 std::vector<uint32_t> achievableRateDl,
387 std::vector<uint32_t> estThrFdBetUl,
388 bool errorModelEnabled)
389 : TestCase(BuildNameString(dist.size(), dist)),
390 m_nUser(dist.size()),
391 m_dist(dist),
392 m_achievableRateDl(achievableRateDl),
393 m_estThrFdBetUl(estThrFdBetUl),
394 m_errorModelEnabled(errorModelEnabled)
395{
396}
397
401
402void
404{
405 NS_LOG_FUNCTION(this);
406
408 {
409 Config::SetDefault("ns3::LteSpectrumPhy::CtrlErrorModelEnabled", BooleanValue(false));
410 Config::SetDefault("ns3::LteSpectrumPhy::DataErrorModelEnabled", BooleanValue(false));
411 }
412 Config::SetDefault("ns3::LteHelper::UseIdealRrc", BooleanValue(false));
413 Config::SetDefault("ns3::MacStatsCalculator::DlOutputFilename",
414 StringValue(CreateTempDirFilename("DlMacStats.txt")));
415 Config::SetDefault("ns3::MacStatsCalculator::UlOutputFilename",
416 StringValue(CreateTempDirFilename("UlMacStats.txt")));
417 Config::SetDefault("ns3::RadioBearerStatsCalculator::DlRlcOutputFilename",
418 StringValue(CreateTempDirFilename("DlRlcStats.txt")));
419 Config::SetDefault("ns3::RadioBearerStatsCalculator::UlRlcOutputFilename",
420 StringValue(CreateTempDirFilename("UlRlcStats.txt")));
421
422 /**
423 * Initialize Simulation Scenario: 1 eNB and m_nUser UEs
424 */
425
427
428 lteHelper->SetAttribute("PathlossModel", StringValue("ns3::FriisSpectrumPropagationLossModel"));
429
430 // Create Nodes: eNodeB and UE
431 NodeContainer enbNodes;
432 NodeContainer ueNodes;
433 enbNodes.Create(1);
434 ueNodes.Create(m_nUser);
435
436 // Install Mobility Model
437 MobilityHelper mobility;
438 mobility.SetMobilityModel("ns3::ConstantPositionMobilityModel");
439 mobility.Install(enbNodes);
440 mobility.SetMobilityModel("ns3::ConstantPositionMobilityModel");
441 mobility.Install(ueNodes);
442
443 // Create Devices and install them in the Nodes (eNB and UE)
444 NetDeviceContainer enbDevs;
445 NetDeviceContainer ueDevs;
446 lteHelper->SetSchedulerType("ns3::FdBetFfMacScheduler");
447 lteHelper->SetSchedulerAttribute("UlCqiFilter", EnumValue(FfMacScheduler::SRS_UL_CQI));
448 enbDevs = lteHelper->InstallEnbDevice(enbNodes);
449 ueDevs = lteHelper->InstallUeDevice(ueNodes);
450
451 // Attach a UE to a eNB
452 lteHelper->Attach(ueDevs, enbDevs.Get(0));
453
454 // Activate an EPS bearer
456 EpsBearer bearer(q);
457 lteHelper->ActivateDataRadioBearer(ueDevs, bearer);
458
459 Ptr<LteEnbNetDevice> lteEnbDev = enbDevs.Get(0)->GetObject<LteEnbNetDevice>();
460 Ptr<LteEnbPhy> enbPhy = lteEnbDev->GetPhy();
461 enbPhy->SetAttribute("TxPower", DoubleValue(30.0));
462 enbPhy->SetAttribute("NoiseFigure", DoubleValue(5.0));
463
464 // Set UEs' position and power
465 for (int i = 0; i < m_nUser; i++)
466 {
469 mm->SetPosition(Vector(m_dist.at(i), 0.0, 0.0));
470 Ptr<LteUeNetDevice> lteUeDev = ueDevs.Get(i)->GetObject<LteUeNetDevice>();
471 Ptr<LteUePhy> uePhy = lteUeDev->GetPhy();
472 uePhy->SetAttribute("TxPower", DoubleValue(23.0));
473 uePhy->SetAttribute("NoiseFigure", DoubleValue(9.0));
474 }
475
476 double statsStartTime = 0.300; // need to allow for RRC connection establishment + SRS
477 double statsDuration = 0.4;
478 double tolerance = 0.1;
479 Simulator::Stop(Seconds(statsStartTime + statsDuration - 0.000001));
480
481 lteHelper->EnableMacTraces();
482 lteHelper->EnableRlcTraces();
483 Ptr<RadioBearerStatsCalculator> rlcStats = lteHelper->GetRlcStats();
484 rlcStats->SetAttribute("StartTime", TimeValue(Seconds(statsStartTime)));
485 rlcStats->SetAttribute("EpochDuration", TimeValue(Seconds(statsDuration)));
486
488
489 NS_LOG_INFO("DL - Test with " << m_nUser << " user(s)");
490 std::vector<uint64_t> dlDataRxed;
491 double totalData = 0;
492 double estTotalThr = 0;
493 double estUeThr = 0;
494 for (int i = 0; i < m_nUser; i++)
495 {
496 // get the imsi
497 uint64_t imsi = ueDevs.Get(i)->GetObject<LteUeNetDevice>()->GetImsi();
498 // get the lcId
499 uint8_t lcId = 3;
500 dlDataRxed.push_back(rlcStats->GetDlRxData(imsi, lcId));
501 totalData += (double)dlDataRxed.at(i);
502 estTotalThr += 1 / m_achievableRateDl.at(i);
503 NS_LOG_INFO("\tUser " << i << " dist " << m_dist.at(i) << " imsi " << imsi << " bytes rxed "
504 << (double)dlDataRxed.at(i) << " thr "
505 << (double)dlDataRxed.at(i) / statsDuration << " ref " << m_nUser);
506 }
507
508 estTotalThr = m_nUser * (1 / estTotalThr);
509 estUeThr = estTotalThr / m_nUser;
510 /**
511 * Check that the assignment is done in a "FD blind equal throughput" manner among users
512 * with different SINRs: the bandwidth should be distributed equally in long term
513 */
514 for (int i = 0; i < m_nUser; i++)
515 {
516 double thrRatio = 1.0 / m_nUser;
517 double estThrRatio = (double)dlDataRxed.at(i) / totalData;
518 NS_LOG_INFO("\tUser " << i << " thrRatio " << thrRatio << " estThrRatio " << estThrRatio);
519 NS_TEST_ASSERT_MSG_EQ_TOL(estThrRatio, thrRatio, tolerance, " Unfair Throughput!");
520 NS_TEST_ASSERT_MSG_EQ_TOL((double)dlDataRxed.at(i) / statsDuration,
521 estUeThr,
522 estUeThr * tolerance,
523 " Unfair Throughput!");
524 }
525
526 /**
527 * Check that the assignment in uplink is done in a round robin manner.
528 */
529
530 NS_LOG_INFO("UL - Test with " << m_nUser);
531 std::vector<uint64_t> ulDataRxed;
532 for (int i = 0; i < m_nUser; i++)
533 {
534 // get the imsi
535 uint64_t imsi = ueDevs.Get(i)->GetObject<LteUeNetDevice>()->GetImsi();
536 // get the lcId
537 uint8_t lcId = 3;
538 ulDataRxed.push_back(rlcStats->GetUlRxData(imsi, lcId));
539 NS_LOG_INFO("\tUser " << i << " dist " << m_dist.at(i) << " bytes rxed "
540 << (double)ulDataRxed.at(i) << " thr "
541 << (double)ulDataRxed.at(i) / statsDuration << " ref "
542 << (double)m_estThrFdBetUl.at(i));
543 NS_TEST_ASSERT_MSG_EQ_TOL((double)ulDataRxed.at(i) / statsDuration,
544 (double)m_estThrFdBetUl.at(i),
545 (double)m_estThrFdBetUl.at(i) * tolerance,
546 " Unfair Throughput!");
547 }
549}
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.
Test case is similar to the one defined in LenaFdBetFfMacSchedulerTestCase1, with the difference that...
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: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_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 LenaTestFdBetFfMacSchedulerSuite lenaTestFdBetFfMacSchedulerSuite
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.