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/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("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{
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 /**
242 * Initialize Simulation Scenario: 1 eNB and m_nUser UEs
243 */
244
246
247 lteHelper->SetAttribute("PathlossModel", StringValue("ns3::FriisSpectrumPropagationLossModel"));
248
249 // Create Nodes: eNodeB and UE
250 NodeContainer enbNodes;
251 NodeContainer ueNodes;
252 enbNodes.Create(1);
253 ueNodes.Create(m_nUser);
254
255 // Install Mobility Model
256 MobilityHelper mobility;
257 mobility.SetMobilityModel("ns3::ConstantPositionMobilityModel");
258 mobility.Install(enbNodes);
259 mobility.SetMobilityModel("ns3::ConstantPositionMobilityModel");
260 mobility.Install(ueNodes);
261
262 // Create Devices and install them in the Nodes (eNB and UE)
263 NetDeviceContainer enbDevs;
264 NetDeviceContainer ueDevs;
265 lteHelper->SetSchedulerType("ns3::FdBetFfMacScheduler");
266 lteHelper->SetSchedulerAttribute("UlCqiFilter", EnumValue(FfMacScheduler::SRS_UL_CQI));
267 enbDevs = lteHelper->InstallEnbDevice(enbNodes);
268 ueDevs = lteHelper->InstallUeDevice(ueNodes);
269
270 // Attach a UE to a eNB
271 lteHelper->Attach(ueDevs, enbDevs.Get(0));
272
273 // Activate an EPS bearer
275 EpsBearer bearer(q);
276 lteHelper->ActivateDataRadioBearer(ueDevs, bearer);
277
278 Ptr<LteEnbNetDevice> lteEnbDev = enbDevs.Get(0)->GetObject<LteEnbNetDevice>();
279 Ptr<LteEnbPhy> enbPhy = lteEnbDev->GetPhy();
280 enbPhy->SetAttribute("TxPower", DoubleValue(30.0));
281 enbPhy->SetAttribute("NoiseFigure", DoubleValue(5.0));
282
283 // Set UEs' position and power
284 for (int i = 0; i < m_nUser; i++)
285 {
288 mm->SetPosition(Vector(m_dist, 0.0, 0.0));
289 Ptr<LteUeNetDevice> lteUeDev = ueDevs.Get(i)->GetObject<LteUeNetDevice>();
290 Ptr<LteUePhy> uePhy = lteUeDev->GetPhy();
291 uePhy->SetAttribute("TxPower", DoubleValue(23.0));
292 uePhy->SetAttribute("NoiseFigure", DoubleValue(9.0));
293 }
294
295 double statsStartTime = 0.300; // need to allow for RRC connection establishment + SRS
296 double statsDuration = 0.6;
297 double tolerance = 0.1;
298 Simulator::Stop(Seconds(statsStartTime + statsDuration - 0.000001));
299
300 lteHelper->EnableMacTraces();
301 lteHelper->EnableRlcTraces();
302 Ptr<RadioBearerStatsCalculator> rlcStats = lteHelper->GetRlcStats();
303 rlcStats->SetAttribute("StartTime", TimeValue(Seconds(statsStartTime)));
304 rlcStats->SetAttribute("EpochDuration", TimeValue(Seconds(statsDuration)));
305
307
308 /**
309 * Check that the downlink assignment is done in a "FD blind equal throughput" manner
310 */
311 NS_LOG_INFO("DL - Test with " << m_nUser << " user(s) at distance " << m_dist);
312 std::vector<uint64_t> dlDataRxed;
313 for (int i = 0; i < m_nUser; i++)
314 {
315 // get the imsi
316 uint64_t imsi = ueDevs.Get(i)->GetObject<LteUeNetDevice>()->GetImsi();
317 // get the lcId
318 uint8_t lcId = 3;
319 dlDataRxed.push_back(rlcStats->GetDlRxData(imsi, lcId));
320 NS_LOG_INFO("\tUser " << i << " imsi " << imsi << " bytes rxed " << (double)dlDataRxed.at(i)
321 << " thr " << (double)dlDataRxed.at(i) / statsDuration << " ref "
322 << m_thrRefDl);
323 }
324 /**
325 * Check that the assignment is done in a "FD blind equal throughput" manner among users
326 * with equal SINRs: the bandwidth should be distributed according to the
327 * ratio of the estimated throughput per TTI of each user; therefore equally
328 * partitioning the whole bandwidth achievable from a single users in a TTI
329 */
330 for (int i = 0; i < m_nUser; i++)
331 {
332 NS_TEST_ASSERT_MSG_EQ_TOL((double)dlDataRxed.at(i) / statsDuration,
334 m_thrRefDl * tolerance,
335 " Unfair Throughput!");
336 }
337
338 /**
339 * Check that the uplink assignment is done in a "FD blind equal throughput" manner
340 */
341 NS_LOG_INFO("UL - Test with " << m_nUser << " user(s) at distance " << m_dist);
342 std::vector<uint64_t> ulDataRxed;
343 for (int i = 0; i < m_nUser; i++)
344 {
345 // get the imsi
346 uint64_t imsi = ueDevs.Get(i)->GetObject<LteUeNetDevice>()->GetImsi();
347 // get the lcId
348 uint8_t lcId = 3;
349 ulDataRxed.push_back(rlcStats->GetUlRxData(imsi, lcId));
350 NS_LOG_INFO("\tUser " << i << " imsi " << imsi << " bytes rxed " << (double)ulDataRxed.at(i)
351 << " thr " << (double)ulDataRxed.at(i) / statsDuration << " ref "
352 << m_thrRefUl);
353 }
354 /**
355 * Check that the assignment is done in a "FD blind equal throughput" manner among users
356 * with equal SINRs: the bandwidth should be distributed according to the
357 * ratio of the estimated throughput per TTI of each user; therefore equally
358 * partitioning the whole bandwidth achievable from a single users in a TTI
359 */
360 for (int i = 0; i < m_nUser; i++)
361 {
362 NS_TEST_ASSERT_MSG_EQ_TOL((double)ulDataRxed.at(i) / statsDuration,
364 m_thrRefUl * tolerance,
365 " Unfair Throughput!");
366 }
368}
369
370// --------------- T E S T - C A S E # 2 ------------------------------
371
372std::string
373LenaFdBetFfMacSchedulerTestCase2::BuildNameString(uint16_t nUser, std::vector<double> dist)
374{
375 std::ostringstream oss;
376 oss << "distances (m) = [ ";
377 for (auto it = dist.begin(); it != dist.end(); ++it)
378 {
379 oss << *it << " ";
380 }
381 oss << "]";
382 return oss.str();
383}
384
386 std::vector<double> dist,
387 std::vector<uint32_t> achievableRateDl,
388 std::vector<uint32_t> estThrFdBetUl,
389 bool errorModelEnabled)
390 : TestCase(BuildNameString(dist.size(), dist)),
391 m_nUser(dist.size()),
392 m_dist(dist),
393 m_achievableRateDl(achievableRateDl),
394 m_estThrFdBetUl(estThrFdBetUl),
395 m_errorModelEnabled(errorModelEnabled)
396{
397}
398
402
403void
405{
406 NS_LOG_FUNCTION(this);
407 SetDataDir(NS_TEST_SOURCEDIR);
408
410 {
411 Config::SetDefault("ns3::LteSpectrumPhy::CtrlErrorModelEnabled", BooleanValue(false));
412 Config::SetDefault("ns3::LteSpectrumPhy::DataErrorModelEnabled", BooleanValue(false));
413 }
414 Config::SetDefault("ns3::LteHelper::UseIdealRrc", BooleanValue(false));
415 Config::SetDefault("ns3::MacStatsCalculator::DlOutputFilename",
416 StringValue(CreateTempDirFilename("DlMacStats.txt")));
417 Config::SetDefault("ns3::MacStatsCalculator::UlOutputFilename",
418 StringValue(CreateTempDirFilename("UlMacStats.txt")));
419 Config::SetDefault("ns3::RadioBearerStatsCalculator::DlRlcOutputFilename",
420 StringValue(CreateTempDirFilename("DlRlcStats.txt")));
421 Config::SetDefault("ns3::RadioBearerStatsCalculator::UlRlcOutputFilename",
422 StringValue(CreateTempDirFilename("UlRlcStats.txt")));
423
424 /**
425 * Initialize Simulation Scenario: 1 eNB and m_nUser UEs
426 */
427
429
430 lteHelper->SetAttribute("PathlossModel", StringValue("ns3::FriisSpectrumPropagationLossModel"));
431
432 // Create Nodes: eNodeB and UE
433 NodeContainer enbNodes;
434 NodeContainer ueNodes;
435 enbNodes.Create(1);
436 ueNodes.Create(m_nUser);
437
438 // Install Mobility Model
439 MobilityHelper mobility;
440 mobility.SetMobilityModel("ns3::ConstantPositionMobilityModel");
441 mobility.Install(enbNodes);
442 mobility.SetMobilityModel("ns3::ConstantPositionMobilityModel");
443 mobility.Install(ueNodes);
444
445 // Create Devices and install them in the Nodes (eNB and UE)
446 NetDeviceContainer enbDevs;
447 NetDeviceContainer ueDevs;
448 lteHelper->SetSchedulerType("ns3::FdBetFfMacScheduler");
449 lteHelper->SetSchedulerAttribute("UlCqiFilter", EnumValue(FfMacScheduler::SRS_UL_CQI));
450 enbDevs = lteHelper->InstallEnbDevice(enbNodes);
451 ueDevs = lteHelper->InstallUeDevice(ueNodes);
452
453 // Attach a UE to a eNB
454 lteHelper->Attach(ueDevs, enbDevs.Get(0));
455
456 // Activate an EPS bearer
458 EpsBearer bearer(q);
459 lteHelper->ActivateDataRadioBearer(ueDevs, bearer);
460
461 Ptr<LteEnbNetDevice> lteEnbDev = enbDevs.Get(0)->GetObject<LteEnbNetDevice>();
462 Ptr<LteEnbPhy> enbPhy = lteEnbDev->GetPhy();
463 enbPhy->SetAttribute("TxPower", DoubleValue(30.0));
464 enbPhy->SetAttribute("NoiseFigure", DoubleValue(5.0));
465
466 // Set UEs' position and power
467 for (int i = 0; i < m_nUser; i++)
468 {
471 mm->SetPosition(Vector(m_dist.at(i), 0.0, 0.0));
472 Ptr<LteUeNetDevice> lteUeDev = ueDevs.Get(i)->GetObject<LteUeNetDevice>();
473 Ptr<LteUePhy> uePhy = lteUeDev->GetPhy();
474 uePhy->SetAttribute("TxPower", DoubleValue(23.0));
475 uePhy->SetAttribute("NoiseFigure", DoubleValue(9.0));
476 }
477
478 double statsStartTime = 0.300; // need to allow for RRC connection establishment + SRS
479 double statsDuration = 0.4;
480 double tolerance = 0.1;
481 Simulator::Stop(Seconds(statsStartTime + statsDuration - 0.000001));
482
483 lteHelper->EnableMacTraces();
484 lteHelper->EnableRlcTraces();
485 Ptr<RadioBearerStatsCalculator> rlcStats = lteHelper->GetRlcStats();
486 rlcStats->SetAttribute("StartTime", TimeValue(Seconds(statsStartTime)));
487 rlcStats->SetAttribute("EpochDuration", TimeValue(Seconds(statsDuration)));
488
490
491 NS_LOG_INFO("DL - Test with " << m_nUser << " user(s)");
492 std::vector<uint64_t> dlDataRxed;
493 double totalData = 0;
494 double estTotalThr = 0;
495 double estUeThr = 0;
496 for (int i = 0; i < m_nUser; i++)
497 {
498 // get the imsi
499 uint64_t imsi = ueDevs.Get(i)->GetObject<LteUeNetDevice>()->GetImsi();
500 // get the lcId
501 uint8_t lcId = 3;
502 dlDataRxed.push_back(rlcStats->GetDlRxData(imsi, lcId));
503 totalData += (double)dlDataRxed.at(i);
504 estTotalThr += 1 / m_achievableRateDl.at(i);
505 NS_LOG_INFO("\tUser " << i << " dist " << m_dist.at(i) << " imsi " << imsi << " bytes rxed "
506 << (double)dlDataRxed.at(i) << " thr "
507 << (double)dlDataRxed.at(i) / statsDuration << " ref " << m_nUser);
508 }
509
510 estTotalThr = m_nUser * (1 / estTotalThr);
511 estUeThr = estTotalThr / m_nUser;
512 /**
513 * Check that the assignment is done in a "FD blind equal throughput" manner among users
514 * with different SINRs: the bandwidth should be distributed equally in long term
515 */
516 for (int i = 0; i < m_nUser; i++)
517 {
518 double thrRatio = 1.0 / m_nUser;
519 double estThrRatio = (double)dlDataRxed.at(i) / totalData;
520 NS_LOG_INFO("\tUser " << i << " thrRatio " << thrRatio << " estThrRatio " << estThrRatio);
521 NS_TEST_ASSERT_MSG_EQ_TOL(estThrRatio, thrRatio, tolerance, " Unfair Throughput!");
522 NS_TEST_ASSERT_MSG_EQ_TOL((double)dlDataRxed.at(i) / statsDuration,
523 estUeThr,
524 estUeThr * tolerance,
525 " Unfair Throughput!");
526 }
527
528 /**
529 * Check that the assignment in uplink is done in a round robin manner.
530 */
531
532 NS_LOG_INFO("UL - Test with " << m_nUser);
533 std::vector<uint64_t> ulDataRxed;
534 for (int i = 0; i < m_nUser; i++)
535 {
536 // get the imsi
537 uint64_t imsi = ueDevs.Get(i)->GetObject<LteUeNetDevice>()->GetImsi();
538 // get the lcId
539 uint8_t lcId = 3;
540 ulDataRxed.push_back(rlcStats->GetUlRxData(imsi, lcId));
541 NS_LOG_INFO("\tUser " << i << " dist " << m_dist.at(i) << " bytes rxed "
542 << (double)ulDataRxed.at(i) << " thr "
543 << (double)ulDataRxed.at(i) / statsDuration << " ref "
544 << (double)m_estThrFdBetUl.at(i));
545 NS_TEST_ASSERT_MSG_EQ_TOL((double)ulDataRxed.at(i) / statsDuration,
546 (double)m_estThrFdBetUl.at(i),
547 (double)m_estThrFdBetUl.at(i) * tolerance,
548 " Unfair Throughput!");
549 }
551}
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
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_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:1345
Every class exported by the ns3 library is enclosed in the ns3 namespace.