A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
lte-test-pf-ff-mac-scheduler.cc
Go to the documentation of this file.
1/*
2 * Copyright (c) 2011, 2012 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 */
9
11
12#include "ns3/double.h"
13#include "ns3/radio-bearer-stats-calculator.h"
14#include "ns3/string.h"
15#include <ns3/boolean.h>
16#include <ns3/constant-position-mobility-model.h>
17#include <ns3/enum.h>
18#include <ns3/eps-bearer.h>
19#include <ns3/ff-mac-scheduler.h>
20#include <ns3/log.h>
21#include <ns3/lte-enb-net-device.h>
22#include <ns3/lte-enb-phy.h>
23#include <ns3/lte-helper.h>
24#include <ns3/lte-ue-net-device.h>
25#include <ns3/lte-ue-phy.h>
26#include <ns3/lte-ue-rrc.h>
27#include <ns3/mobility-helper.h>
28#include <ns3/net-device-container.h>
29#include <ns3/node-container.h>
30#include <ns3/object.h>
31#include <ns3/packet.h>
32#include <ns3/ptr.h>
33#include <ns3/simulator.h>
34#include <ns3/spectrum-error-model.h>
35#include <ns3/spectrum-interference.h>
36#include <ns3/test.h>
37
38#include <iostream>
39#include <sstream>
40#include <string>
41
42using namespace ns3;
43
44NS_LOG_COMPONENT_DEFINE("LenaTestPfFfMacScheduler");
45
47 : TestSuite("lte-pf-ff-mac-scheduler", Type::SYSTEM)
48{
49 NS_LOG_INFO("creating LenaTestPfFfMacSchedulerSuite");
50
51 bool errorModel = false;
52
53 // Test Case 1: AMC works in PF
54
55 // DOWNLINK - DISTANCE 0 -> MCS 28 -> Itbs 26 (from table 7.1.7.2.1-1 of 36.213)
56 // 1 user -> 24 PRB at Itbs 26 -> 2196 -> 2196000 bytes/sec
57 // 3 users -> 2196000 among 3 users -> 732000 bytes/sec
58 // 6 users -> 2196000 among 6 users -> 366000 bytes/sec
59 // 12 users -> 2196000 among 12 users -> 183000 bytes/sec
60 // 15 users -> 2196000 among 15 users -> 146400 bytes/sec
61 // UPLINK- DISTANCE 0 -> MCS 28 -> Itbs 26 (from table 7.1.7.2.1-1 of 36.213)
62 // 1 user -> 25 PRB at Itbs 26 -> 2292 -> 2292000 bytes/sec
63 // 3 users -> 8 PRB at Itbs 26 -> 749 -> 749000 bytes/sec
64 // 6 users -> 4 PRB at Itbs 26 -> 373 -> 373000 bytes/sec
65 // after the patch enforcing min 3 PRBs per UE:
66 // 12 users -> 3 PRB at Itbs 26 -> 277 bytes * 8/12 UE/TTI -> 184670 bytes/sec
67 // 15 users -> 3 PRB at Itbs 26 -> 277 bytes * 8/15 UE/TTI -> 147730 bytes/sec
68 AddTestCase(new LenaPfFfMacSchedulerTestCase1(1, 0, 2196000, 2292000, errorModel),
69 TestCase::Duration::EXTENSIVE);
70 AddTestCase(new LenaPfFfMacSchedulerTestCase1(3, 0, 732000, 749000, errorModel),
71 TestCase::Duration::EXTENSIVE);
72 AddTestCase(new LenaPfFfMacSchedulerTestCase1(6, 0, 366000, 373000, errorModel),
73 TestCase::Duration::EXTENSIVE);
74 AddTestCase(new LenaPfFfMacSchedulerTestCase1(12, 0, 183000, 184670, errorModel),
75 TestCase::Duration::EXTENSIVE);
76 AddTestCase(new LenaPfFfMacSchedulerTestCase1(15, 0, 146400, 147730, errorModel),
77 TestCase::Duration::EXTENSIVE);
78
79 // DOWNLINK - DISTANCE 4800 -> MCS 22 -> Itbs 20 (from table 7.1.7.2.1-1 of 36.213)
80 // 1 user -> 24 PRB at Itbs 15 -> 1383 -> 1383000 bytes/sec
81 // 3 users -> 1383000 among 3 users -> 461000 bytes/sec
82 // 6 users -> 1383000 among 6 users -> 230500 bytes/sec
83 // 12 users -> 1383000 among 12 users -> 115250 bytes/sec
84 // 15 users -> 1383000 among 15 users -> 92200 bytes/sec
85 // UPLINK - DISTANCE 4800 -> MCS 14 -> Itbs 13 (from table 7.1.7.2.1-1 of 36.213)
86 // 1 user -> 25 PRB at Itbs 13 -> 807 -> 807000 bytes/sec
87 // 3 users -> 8 PRB at Itbs 13 -> 253 -> 253000 bytes/sec
88 // 6 users -> 4 PRB at Itbs 13 -> 125 -> 125000 bytes/sec
89 // after the patch enforcing min 3 PRBs per UE:
90 // 12 users -> 3 PRB at Itbs 13 -> 93 bytes * 8/12 UE/TTI -> 62000 bytes/sec
91 // 15 users -> 3 PRB at Itbs 13 -> 93 bytes * 8/15 UE/TTI -> 49600 bytes/sec
92 AddTestCase(new LenaPfFfMacSchedulerTestCase1(1, 4800, 1383000, 807000, errorModel),
93 TestCase::Duration::EXTENSIVE);
94 AddTestCase(new LenaPfFfMacSchedulerTestCase1(3, 4800, 461000, 253000, errorModel),
95 TestCase::Duration::EXTENSIVE);
96 AddTestCase(new LenaPfFfMacSchedulerTestCase1(6, 4800, 230500, 125000, errorModel),
97 TestCase::Duration::EXTENSIVE);
98 AddTestCase(new LenaPfFfMacSchedulerTestCase1(12, 4800, 115250, 62000, errorModel),
99 TestCase::Duration::EXTENSIVE);
100 AddTestCase(new LenaPfFfMacSchedulerTestCase1(15, 4800, 92200, 49600, errorModel),
101 TestCase::Duration::EXTENSIVE);
102
103 // DOWNLINK - DISTANCE 6000 -> MCS 20 -> Itbs 18 (from table 7.1.7.2.1-1 of 36.213)
104 // 1 user -> 24 PRB at Itbs 20 -> 1191 -> 1191000 bytes/sec
105 // 3 users -> 1191000 among 3 users -> 397000 bytes/sec
106 // 6 users -> 1191000 among 6 users -> 198500 bytes/sec
107 // 12 users -> 1191000 among 12 users -> 99250 bytes/sec
108 // 15 users -> 1191000 among 15 users -> 79400 bytes/sec
109 // UPLINK - DISTANCE 6000 -> MCS 12 -> Itbs 11 (from table 7.1.7.2.1-1 of 36.213)
110 // 1 user -> 25 PRB at Itbs 11 -> 621 -> 621000 bytes/sec
111 // 3 users -> 8 PRB at Itbs 11 -> 201 -> 201000 bytes/sec
112 // 6 users -> 4 PRB at Itbs 11 -> 97 -> 97000 bytes/sec
113 // after the patch enforcing min 3 PRBs per UE:
114 // 12 users -> 3 PRB at Itbs 11 -> 73 bytes * 8/12 UE/TTI -> 48667 bytes/sec
115 // 15 users -> 3 PRB at Itbs 11 -> 73 bytes * 8/15 UE/TTI -> 38993 bytes/sec
116 AddTestCase(new LenaPfFfMacSchedulerTestCase1(1, 6000, 1191000, 621000, errorModel),
117 TestCase::Duration::EXTENSIVE);
118 AddTestCase(new LenaPfFfMacSchedulerTestCase1(3, 6000, 397000, 201000, errorModel),
119 TestCase::Duration::EXTENSIVE);
120 AddTestCase(new LenaPfFfMacSchedulerTestCase1(6, 6000, 198500, 97000, errorModel),
121 TestCase::Duration::EXTENSIVE);
122 AddTestCase(new LenaPfFfMacSchedulerTestCase1(12, 6000, 99250, 48667, errorModel),
123 TestCase::Duration::EXTENSIVE);
124 AddTestCase(new LenaPfFfMacSchedulerTestCase1(15, 6000, 79400, 38993, errorModel),
125 TestCase::Duration::EXTENSIVE);
126
127 // DOWNLINK - DISTANCE 10000 -> MCS 14 -> Itbs 13 (from table 7.1.7.2.1-1 of 36.213)
128 // 1 user -> 24 PRB at Itbs 13 -> 871 -> 775000 bytes/sec
129 // 3 users -> 775000 among 3 users -> 258333 bytes/sec
130 // 6 users -> 775000 among 6 users -> 129167 bytes/sec
131 // 12 users -> 775000 among 12 users -> 64583 bytes/sec
132 // 15 users -> 775000 among 15 users -> 51667 bytes/sec
133 // UPLINK - DISTANCE 10000 -> MCS 8 -> Itbs 8 (from table 7.1.7.2.1-1 of 36.213)
134 // 1 user -> 24 PRB at Itbs 8 -> 437 -> 437000 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 // 15 users -> 3 PRB at Itbs 8 -> 49 bytes * 8/15 UE/TTI -> 26133 bytes/sec
140 AddTestCase(new LenaPfFfMacSchedulerTestCase1(1, 10000, 775000, 437000, errorModel),
141 TestCase::Duration::EXTENSIVE);
142 AddTestCase(new LenaPfFfMacSchedulerTestCase1(3, 10000, 258333, 137000, errorModel),
143 TestCase::Duration::EXTENSIVE);
144 AddTestCase(new LenaPfFfMacSchedulerTestCase1(6, 10000, 129167, 67000, errorModel),
145 TestCase::Duration::EXTENSIVE);
146 AddTestCase(new LenaPfFfMacSchedulerTestCase1(12, 10000, 64583, 32667, errorModel),
147 TestCase::Duration::EXTENSIVE);
148 AddTestCase(new LenaPfFfMacSchedulerTestCase1(15, 10000, 51667, 26133, errorModel),
149 TestCase::Duration::EXTENSIVE);
150
151 // DONWLINK - DISTANCE 20000 -> MCS 8 -> Itbs 8 (from table 7.1.7.2.1-1 of 36.213)
152 // 1 user -> 24 PRB at Itbs 8 -> 421 -> 421000 bytes/sec
153 // 3 users -> 421000 among 3 users -> 140333 bytes/sec
154 // 6 users -> 421000 among 6 users -> 70167 bytes/sec
155 // 12 users -> 421000 among 12 users -> 35083 bytes/sec
156 // 15 users -> 421000 among 15 users -> 28067 bytes/sec
157 // UPLINK - DISTANCE 20000 -> MCS 2 -> Itbs 2 (from table 7.1.7.2.1-1 of 36.213)
158 // 1 user -> 25 PRB at Itbs 2 -> 233 -> 137000 bytes/sec
159 // 3 users -> 8 PRB at Itbs 2 -> 69 -> 41000 bytes/sec
160 // 6 users -> 4 PRB at Itbs 2 -> 32 -> 22000 bytes/sec
161 // after the patch enforcing min 3 PRBs per UE:
162 // 12 users -> 3 PRB at Itbs 2 -> 26 bytes * 8/12 UE/TTI -> 12000 bytes/sec
163 // 15 users -> 3 PRB at Itbs 2 -> 26 bytes * 8/15 UE/TTI -> 9600 bytes/sec
164 AddTestCase(new LenaPfFfMacSchedulerTestCase1(1, 20000, 421000, 137000, errorModel),
165 TestCase::Duration::EXTENSIVE);
166 AddTestCase(new LenaPfFfMacSchedulerTestCase1(3, 20000, 140333, 41000, errorModel),
167 TestCase::Duration::EXTENSIVE);
168 AddTestCase(new LenaPfFfMacSchedulerTestCase1(6, 20000, 70167, 22000, errorModel),
169 TestCase::Duration::EXTENSIVE);
170 AddTestCase(new LenaPfFfMacSchedulerTestCase1(12, 20000, 35083, 12000, errorModel),
171 TestCase::Duration::EXTENSIVE);
172 AddTestCase(new LenaPfFfMacSchedulerTestCase1(15, 20000, 28067, 9600, errorModel),
173 TestCase::Duration::EXTENSIVE);
174
175 // DOWNLINK - DISTANCE 100000 -> CQI == 0 -> out of range -> 0 bytes/sec
176 // UPLINK - DISTANCE 100000 -> CQI == 0 -> out of range -> 0 bytes/sec
177 AddTestCase(new LenaPfFfMacSchedulerTestCase1(1, 100000, 0, 0, errorModel),
178 TestCase::Duration::QUICK);
179
180 // Test Case 2: fairness check
181
182 std::vector<double> dist;
183 dist.push_back(0); // User 0 distance --> MCS 28
184 dist.push_back(4800); // User 1 distance --> MCS 22
185 dist.push_back(6000); // User 2 distance --> MCS 16
186 dist.push_back(10000); // User 3 distance --> MCS 8
187 dist.push_back(20000); // User 4 distance --> MCS 8
188 std::vector<uint32_t> estThrPfDl;
189 estThrPfDl.push_back(90000); // User 0 estimated TTI throughput from PF
190 estThrPfDl.push_back(37000); // User 1 estimated TTI throughput from PF
191 estThrPfDl.push_back(37000); // User 2 estimated TTI throughput from PF
192 estThrPfDl.push_back(17400); // User 3 estimated TTI throughput from PF
193 estThrPfDl.push_back(17400); // User 4 estimated TTI throughput from PF
194 std::vector<uint32_t> estThrPfUl;
195 estThrPfUl.push_back(469000); // User 0 estimated TTI throughput from PF
196 estThrPfUl.push_back(157000); // User 1 estimated TTI throughput from PF
197 estThrPfUl.push_back(125000); // User 2 estimated TTI throughput from PF
198 estThrPfUl.push_back(85000); // User 3 estimated TTI throughput from PF
199 estThrPfUl.push_back(26000); // User 4 estimated TTI throughput from PF
200 AddTestCase(new LenaPfFfMacSchedulerTestCase2(dist, estThrPfDl, estThrPfUl, errorModel),
201 TestCase::Duration::QUICK);
202}
203
204/**
205 * @ingroup lte-test
206 * Static variable for test initialization
207 */
209
210// --------------- T E S T - C A S E # 1 ------------------------------
211
212std::string
214{
215 std::ostringstream oss;
216 oss << nUser << " UEs, distance " << dist << " m";
217 return oss.str();
218}
219
221 double dist,
222 double thrRefDl,
223 double thrRefUl,
224 bool errorModelEnabled)
225 : TestCase(BuildNameString(nUser, dist)),
226 m_nUser(nUser),
227 m_dist(dist),
228 m_thrRefDl(thrRefDl),
229 m_thrRefUl(thrRefUl),
230 m_errorModelEnabled(errorModelEnabled)
231{
232}
233
237
238void
240{
241 NS_LOG_FUNCTION(this << m_nUser << m_dist);
242
244 {
245 Config::SetDefault("ns3::LteSpectrumPhy::CtrlErrorModelEnabled", BooleanValue(false));
246 Config::SetDefault("ns3::LteSpectrumPhy::DataErrorModelEnabled", BooleanValue(false));
247 }
248 Config::SetDefault("ns3::LteHelper::UseIdealRrc", BooleanValue(true));
249 Config::SetDefault("ns3::MacStatsCalculator::DlOutputFilename",
250 StringValue(CreateTempDirFilename("DlMacStats.txt")));
251 Config::SetDefault("ns3::MacStatsCalculator::UlOutputFilename",
252 StringValue(CreateTempDirFilename("UlMacStats.txt")));
253 Config::SetDefault("ns3::RadioBearerStatsCalculator::DlRlcOutputFilename",
254 StringValue(CreateTempDirFilename("DlRlcStats.txt")));
255 Config::SetDefault("ns3::RadioBearerStatsCalculator::UlRlcOutputFilename",
256 StringValue(CreateTempDirFilename("UlRlcStats.txt")));
257
258 /**
259 * Initialize Simulation Scenario: 1 eNB and m_nUser UEs
260 */
261
263 lteHelper->SetAttribute("PathlossModel", StringValue("ns3::FriisSpectrumPropagationLossModel"));
264
265 // Create Nodes: eNodeB and UE
266 NodeContainer enbNodes;
267 NodeContainer ueNodes;
268 enbNodes.Create(1);
269 ueNodes.Create(m_nUser);
270
271 // Install Mobility Model
272 MobilityHelper mobility;
273 mobility.SetMobilityModel("ns3::ConstantPositionMobilityModel");
274 mobility.Install(enbNodes);
275 mobility.SetMobilityModel("ns3::ConstantPositionMobilityModel");
276 mobility.Install(ueNodes);
277
278 // Create Devices and install them in the Nodes (eNB and UE)
279 NetDeviceContainer enbDevs;
280 NetDeviceContainer ueDevs;
281 lteHelper->SetSchedulerType("ns3::PfFfMacScheduler");
282 lteHelper->SetSchedulerAttribute("UlCqiFilter", EnumValue(FfMacScheduler::SRS_UL_CQI));
283 enbDevs = lteHelper->InstallEnbDevice(enbNodes);
284 ueDevs = lteHelper->InstallUeDevice(ueNodes);
285
286 // Attach a UE to a eNB
287 lteHelper->Attach(ueDevs, enbDevs.Get(0));
288
289 // Activate an EPS bearer
291 EpsBearer bearer(q);
292 lteHelper->ActivateDataRadioBearer(ueDevs, bearer);
293
294 Ptr<LteEnbNetDevice> lteEnbDev = enbDevs.Get(0)->GetObject<LteEnbNetDevice>();
295 Ptr<LteEnbPhy> enbPhy = lteEnbDev->GetPhy();
296 enbPhy->SetAttribute("TxPower", DoubleValue(30.0));
297 enbPhy->SetAttribute("NoiseFigure", DoubleValue(5.0));
298
299 // Set UEs' position and power
300 for (int i = 0; i < m_nUser; i++)
301 {
304 mm->SetPosition(Vector(m_dist, 0.0, 0.0));
305 Ptr<LteUeNetDevice> lteUeDev = ueDevs.Get(i)->GetObject<LteUeNetDevice>();
306 Ptr<LteUePhy> uePhy = lteUeDev->GetPhy();
307 uePhy->SetAttribute("TxPower", DoubleValue(23.0));
308 uePhy->SetAttribute("NoiseFigure", DoubleValue(9.0));
309 }
310
311 double statsStartTime = 0.300; // need to allow for RRC connection establishment + SRS
312 double statsDuration = 0.6;
313 double tolerance = 0.1;
314 Simulator::Stop(Seconds(statsStartTime + statsDuration - 0.000001));
315
316 lteHelper->EnableMacTraces();
317 lteHelper->EnableRlcTraces();
318 Ptr<RadioBearerStatsCalculator> rlcStats = lteHelper->GetRlcStats();
319 rlcStats->SetAttribute("StartTime", TimeValue(Seconds(statsStartTime)));
320 rlcStats->SetAttribute("EpochDuration", TimeValue(Seconds(statsDuration)));
321
323
324 /**
325 * Check that the downlink assignment is done in a "proportional fair" manner
326 */
327 NS_LOG_INFO("DL - Test with " << m_nUser << " user(s) at distance " << m_dist);
328 std::vector<uint64_t> dlDataRxed;
329 for (int i = 0; i < m_nUser; i++)
330 {
331 // get the imsi
332 uint64_t imsi = ueDevs.Get(i)->GetObject<LteUeNetDevice>()->GetImsi();
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 }
339 /**
340 * Check that the assignment is done in a "proportional fair" manner among users
341 * with equal SINRs: the bandwidth should be distributed according to the
342 * ratio of the estimated throughput per TTI of each user; therefore equally
343 * partitioning the whole bandwidth achievable from a single users in a TTI
344 */
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
353 /**
354 * Check that the uplink assignment is done in a "proportional fair" manner
355 */
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 }
369 /**
370 * Check that the assignment is done in a "proportional fair" manner among users
371 * with equal SINRs: the bandwidth should be distributed according to the
372 * ratio of the estimated throughput per TTI of each user; therefore equally
373 * partitioning the whole bandwidth achievable from a single users in a TTI
374 */
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
388LenaPfFfMacSchedulerTestCase2::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<uint32_t> estThrPfDl,
402 std::vector<uint32_t> estThrPfUl,
403 bool errorModelEnabled)
404 : TestCase(BuildNameString(dist.size(), dist)),
405 m_nUser(dist.size()),
406 m_dist(dist),
407 m_estThrPfDl(estThrPfDl),
408 m_estThrPfUl(estThrPfUl),
409 m_errorModelEnabled(errorModelEnabled)
410{
411}
412
416
417void
419{
420 NS_LOG_FUNCTION(this);
422 {
423 Config::SetDefault("ns3::LteSpectrumPhy::CtrlErrorModelEnabled", BooleanValue(false));
424 Config::SetDefault("ns3::LteSpectrumPhy::DataErrorModelEnabled", BooleanValue(false));
425 }
426 Config::SetDefault("ns3::LteHelper::UseIdealRrc", BooleanValue(false));
427 Config::SetDefault("ns3::MacStatsCalculator::DlOutputFilename",
428 StringValue(CreateTempDirFilename("DlMacStats.txt")));
429 Config::SetDefault("ns3::MacStatsCalculator::UlOutputFilename",
430 StringValue(CreateTempDirFilename("UlMacStats.txt")));
431 Config::SetDefault("ns3::RadioBearerStatsCalculator::DlRlcOutputFilename",
432 StringValue(CreateTempDirFilename("DlRlcStats.txt")));
433 Config::SetDefault("ns3::RadioBearerStatsCalculator::UlRlcOutputFilename",
434 StringValue(CreateTempDirFilename("UlRlcStats.txt")));
435
436 /**
437 * Initialize Simulation Scenario: 1 eNB and m_nUser UEs
438 */
439
441
442 lteHelper->SetAttribute("PathlossModel", StringValue("ns3::FriisSpectrumPropagationLossModel"));
443
444 // Create Nodes: eNodeB and UE
445 NodeContainer enbNodes;
446 NodeContainer ueNodes;
447 enbNodes.Create(1);
448 ueNodes.Create(m_nUser);
449
450 // Install Mobility Model
451 MobilityHelper mobility;
452 mobility.SetMobilityModel("ns3::ConstantPositionMobilityModel");
453 mobility.Install(enbNodes);
454 mobility.SetMobilityModel("ns3::ConstantPositionMobilityModel");
455 mobility.Install(ueNodes);
456
457 // Create Devices and install them in the Nodes (eNB and UE)
458 NetDeviceContainer enbDevs;
459 NetDeviceContainer ueDevs;
460 lteHelper->SetSchedulerType("ns3::PfFfMacScheduler");
461 lteHelper->SetSchedulerAttribute("UlCqiFilter", EnumValue(FfMacScheduler::SRS_UL_CQI));
462 enbDevs = lteHelper->InstallEnbDevice(enbNodes);
463 ueDevs = lteHelper->InstallUeDevice(ueNodes);
464
465 // Attach a UE to a eNB
466 lteHelper->Attach(ueDevs, enbDevs.Get(0));
467
468 // Activate an EPS bearer
470 EpsBearer bearer(q);
471 lteHelper->ActivateDataRadioBearer(ueDevs, bearer);
472
473 Ptr<LteEnbNetDevice> lteEnbDev = enbDevs.Get(0)->GetObject<LteEnbNetDevice>();
474 Ptr<LteEnbPhy> enbPhy = lteEnbDev->GetPhy();
475 enbPhy->SetAttribute("TxPower", DoubleValue(30.0));
476 enbPhy->SetAttribute("NoiseFigure", DoubleValue(5.0));
477
478 // Set UEs' position and power
479 for (int i = 0; i < m_nUser; i++)
480 {
483 mm->SetPosition(Vector(m_dist.at(i), 0.0, 0.0));
484 Ptr<LteUeNetDevice> lteUeDev = ueDevs.Get(i)->GetObject<LteUeNetDevice>();
485 Ptr<LteUePhy> uePhy = lteUeDev->GetPhy();
486 uePhy->SetAttribute("TxPower", DoubleValue(23.0));
487 uePhy->SetAttribute("NoiseFigure", DoubleValue(9.0));
488 }
489
490 double statsStartTime = 0.300; // need to allow for RRC connection establishment + SRS
491 double statsDuration = 0.4;
492 double tolerance = 0.1;
493 Simulator::Stop(Seconds(statsStartTime + statsDuration - 0.000001));
494
495 lteHelper->EnableRlcTraces();
496 Ptr<RadioBearerStatsCalculator> rlcStats = lteHelper->GetRlcStats();
497 rlcStats->SetAttribute("StartTime", TimeValue(Seconds(statsStartTime)));
498 rlcStats->SetAttribute("EpochDuration", TimeValue(Seconds(statsDuration)));
499
501
502 NS_LOG_INFO("DL - Test with " << m_nUser << " user(s)");
503 std::vector<uint64_t> dlDataRxed;
504 double totalData = 0;
505 double totalEstThrPf = 0;
506 for (int i = 0; i < m_nUser; i++)
507 {
508 // get the imsi
509 uint64_t imsi = ueDevs.Get(i)->GetObject<LteUeNetDevice>()->GetImsi();
510 // get the lcId
511 uint8_t lcId = 3;
512 dlDataRxed.push_back(rlcStats->GetDlRxData(imsi, lcId));
513 totalData += (double)dlDataRxed.at(i);
514 NS_LOG_INFO("\tUser " << i << " dist " << m_dist.at(i) << " imsi " << imsi << " bytes rxed "
515 << (double)dlDataRxed.at(i) << " thr "
516 << (double)dlDataRxed.at(i) / statsDuration);
517 totalEstThrPf += m_estThrPfDl.at(i);
518 }
519
520 /**
521 * Check that the assignment is done in a "proportional fair" manner among users
522 * with different SINRs: the bandwidth should be distributed according to the
523 * ratio of the estimated throughput per TTI of each user.
524 */
525 for (int i = 0; i < m_nUser; i++)
526 {
527 double thrRatio = (double)dlDataRxed.at(i) / totalData;
528 double estThrRatio = (double)m_estThrPfDl.at(i) / totalEstThrPf;
529 NS_LOG_INFO("\tUser " << i << " thrRatio " << thrRatio << " estThrRatio " << estThrRatio);
530 NS_TEST_ASSERT_MSG_EQ_TOL(estThrRatio, thrRatio, tolerance, " Unfair Throughput!");
531 }
532
533 /**
534 * Check that the assignment in uplink is done in a round robin manner.
535 */
536
537 NS_LOG_INFO("UL - Test with " << m_nUser);
538 std::vector<uint64_t> ulDataRxed;
539 for (int i = 0; i < m_nUser; i++)
540 {
541 // get the imsi
542 uint64_t imsi = ueDevs.Get(i)->GetObject<LteUeNetDevice>()->GetImsi();
543 // get the lcId
544 uint8_t lcId = 3;
545 ulDataRxed.push_back(rlcStats->GetUlRxData(imsi, lcId));
546 NS_LOG_INFO("\tUser " << i << " dist " << m_dist.at(i) << " bytes rxed "
547 << (double)ulDataRxed.at(i) << " thr "
548 << (double)ulDataRxed.at(i) / statsDuration << " ref "
549 << (double)m_estThrPfUl.at(i));
550 NS_TEST_ASSERT_MSG_EQ_TOL((double)ulDataRxed.at(i) / statsDuration,
551 (double)m_estThrPfUl.at(i),
552 (double)m_estThrPfUl.at(i) * tolerance,
553 " Unfair Throughput!");
554 }
556}
This system test program creates different test cases with a single eNB and several UEs,...
static std::string BuildNameString(uint16_t nUser, double dist)
Build name string.
bool m_errorModelEnabled
whether error model is enabled
void DoRun() override
Implementation to actually run this TestCase.
double m_thrRefUl
the UL throughput reference
double m_thrRefDl
the DL throughput reference
LenaPfFfMacSchedulerTestCase1(uint16_t nUser, double dist, double thrRefDl, double thrRefUl, bool errorModelEnabled)
Constructor.
double m_dist
the distance between nodes
Lena PfFf Mac Scheduler Test Case 2.
LenaPfFfMacSchedulerTestCase2(std::vector< double > dist, std::vector< uint32_t > estThrPfDl, std::vector< uint32_t > estThrPfUl, bool errorModelEnabled)
Constructor.
std::vector< uint32_t > m_estThrPfUl
the estimated UL throughput
bool m_errorModelEnabled
indicates whether the error model is enabled
std::vector< uint32_t > m_estThrPfDl
the estimated DL throughput
std::vector< double > m_dist
the distance between nodes
static std::string BuildNameString(uint16_t nUser, std::vector< double > dist)
Builds the test name string based on provided parameter values.
void DoRun() override
Implementation to actually run this TestCase.
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 LenaTestPfFfMacSchedulerSuite lenaTestPfFfMacSchedulerSuite
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.