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 * 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 */
20
22
23#include "ns3/double.h"
24#include "ns3/radio-bearer-stats-calculator.h"
25#include "ns3/string.h"
26#include <ns3/boolean.h>
27#include <ns3/constant-position-mobility-model.h>
28#include <ns3/enum.h>
29#include <ns3/eps-bearer.h>
30#include <ns3/ff-mac-scheduler.h>
31#include <ns3/log.h>
32#include <ns3/lte-enb-net-device.h>
33#include <ns3/lte-enb-phy.h>
34#include <ns3/lte-helper.h>
35#include <ns3/lte-ue-net-device.h>
36#include <ns3/lte-ue-phy.h>
37#include <ns3/lte-ue-rrc.h>
38#include <ns3/mobility-helper.h>
39#include <ns3/net-device-container.h>
40#include <ns3/node-container.h>
41#include <ns3/object.h>
42#include <ns3/packet.h>
43#include <ns3/ptr.h>
44#include <ns3/simulator.h>
45#include <ns3/spectrum-error-model.h>
46#include <ns3/spectrum-interference.h>
47#include <ns3/test.h>
48
49#include <iostream>
50#include <sstream>
51#include <string>
52
53using namespace ns3;
54
55NS_LOG_COMPONENT_DEFINE("LenaTestPfFfMacScheduler");
56
58 : TestSuite("lte-pf-ff-mac-scheduler", Type::SYSTEM)
59{
60 NS_LOG_INFO("creating LenaTestPfFfMacSchedulerSuite");
61
62 bool errorModel = false;
63
64 // Test Case 1: AMC works in PF
65
66 // DOWNLINK - DISTANCE 0 -> MCS 28 -> Itbs 26 (from table 7.1.7.2.1-1 of 36.213)
67 // 1 user -> 24 PRB at Itbs 26 -> 2196 -> 2196000 bytes/sec
68 // 3 users -> 2196000 among 3 users -> 732000 bytes/sec
69 // 6 users -> 2196000 among 6 users -> 366000 bytes/sec
70 // 12 users -> 2196000 among 12 users -> 183000 bytes/sec
71 // 15 users -> 2196000 among 15 users -> 146400 bytes/sec
72 // UPLINK- DISTANCE 0 -> MCS 28 -> Itbs 26 (from table 7.1.7.2.1-1 of 36.213)
73 // 1 user -> 25 PRB at Itbs 26 -> 2292 -> 2292000 bytes/sec
74 // 3 users -> 8 PRB at Itbs 26 -> 749 -> 749000 bytes/sec
75 // 6 users -> 4 PRB at Itbs 26 -> 373 -> 373000 bytes/sec
76 // after the patch enforcing min 3 PRBs per UE:
77 // 12 users -> 3 PRB at Itbs 26 -> 277 bytes * 8/12 UE/TTI -> 184670 bytes/sec
78 // 15 users -> 3 PRB at Itbs 26 -> 277 bytes * 8/15 UE/TTI -> 147730 bytes/sec
79 AddTestCase(new LenaPfFfMacSchedulerTestCase1(1, 0, 2196000, 2292000, errorModel),
80 TestCase::Duration::EXTENSIVE);
81 AddTestCase(new LenaPfFfMacSchedulerTestCase1(3, 0, 732000, 749000, errorModel),
82 TestCase::Duration::EXTENSIVE);
83 AddTestCase(new LenaPfFfMacSchedulerTestCase1(6, 0, 366000, 373000, errorModel),
84 TestCase::Duration::EXTENSIVE);
85 AddTestCase(new LenaPfFfMacSchedulerTestCase1(12, 0, 183000, 184670, errorModel),
86 TestCase::Duration::EXTENSIVE);
87 AddTestCase(new LenaPfFfMacSchedulerTestCase1(15, 0, 146400, 147730, errorModel),
88 TestCase::Duration::EXTENSIVE);
89
90 // DOWNLINK - DISTANCE 4800 -> MCS 22 -> Itbs 20 (from table 7.1.7.2.1-1 of 36.213)
91 // 1 user -> 24 PRB at Itbs 15 -> 1383 -> 1383000 bytes/sec
92 // 3 users -> 1383000 among 3 users -> 461000 bytes/sec
93 // 6 users -> 1383000 among 6 users -> 230500 bytes/sec
94 // 12 users -> 1383000 among 12 users -> 115250 bytes/sec
95 // 15 users -> 1383000 among 15 users -> 92200 bytes/sec
96 // UPLINK - DISTANCE 4800 -> MCS 14 -> Itbs 13 (from table 7.1.7.2.1-1 of 36.213)
97 // 1 user -> 25 PRB at Itbs 13 -> 807 -> 807000 bytes/sec
98 // 3 users -> 8 PRB at Itbs 13 -> 253 -> 253000 bytes/sec
99 // 6 users -> 4 PRB at Itbs 13 -> 125 -> 125000 bytes/sec
100 // after the patch enforcing min 3 PRBs per UE:
101 // 12 users -> 3 PRB at Itbs 13 -> 93 bytes * 8/12 UE/TTI -> 62000 bytes/sec
102 // 15 users -> 3 PRB at Itbs 13 -> 93 bytes * 8/15 UE/TTI -> 49600 bytes/sec
103 AddTestCase(new LenaPfFfMacSchedulerTestCase1(1, 4800, 1383000, 807000, errorModel),
104 TestCase::Duration::EXTENSIVE);
105 AddTestCase(new LenaPfFfMacSchedulerTestCase1(3, 4800, 461000, 253000, errorModel),
106 TestCase::Duration::EXTENSIVE);
107 AddTestCase(new LenaPfFfMacSchedulerTestCase1(6, 4800, 230500, 125000, errorModel),
108 TestCase::Duration::EXTENSIVE);
109 AddTestCase(new LenaPfFfMacSchedulerTestCase1(12, 4800, 115250, 62000, errorModel),
110 TestCase::Duration::EXTENSIVE);
111 AddTestCase(new LenaPfFfMacSchedulerTestCase1(15, 4800, 92200, 49600, errorModel),
112 TestCase::Duration::EXTENSIVE);
113
114 // DOWNLINK - DISTANCE 6000 -> MCS 20 -> Itbs 18 (from table 7.1.7.2.1-1 of 36.213)
115 // 1 user -> 24 PRB at Itbs 20 -> 1191 -> 1191000 bytes/sec
116 // 3 users -> 1191000 among 3 users -> 397000 bytes/sec
117 // 6 users -> 1191000 among 6 users -> 198500 bytes/sec
118 // 12 users -> 1191000 among 12 users -> 99250 bytes/sec
119 // 15 users -> 1191000 among 15 users -> 79400 bytes/sec
120 // UPLINK - DISTANCE 6000 -> MCS 12 -> Itbs 11 (from table 7.1.7.2.1-1 of 36.213)
121 // 1 user -> 25 PRB at Itbs 11 -> 621 -> 621000 bytes/sec
122 // 3 users -> 8 PRB at Itbs 11 -> 201 -> 201000 bytes/sec
123 // 6 users -> 4 PRB at Itbs 11 -> 97 -> 97000 bytes/sec
124 // after the patch enforcing min 3 PRBs per UE:
125 // 12 users -> 3 PRB at Itbs 11 -> 73 bytes * 8/12 UE/TTI -> 48667 bytes/sec
126 // 15 users -> 3 PRB at Itbs 11 -> 73 bytes * 8/15 UE/TTI -> 38993 bytes/sec
127 AddTestCase(new LenaPfFfMacSchedulerTestCase1(1, 6000, 1191000, 621000, errorModel),
128 TestCase::Duration::EXTENSIVE);
129 AddTestCase(new LenaPfFfMacSchedulerTestCase1(3, 6000, 397000, 201000, errorModel),
130 TestCase::Duration::EXTENSIVE);
131 AddTestCase(new LenaPfFfMacSchedulerTestCase1(6, 6000, 198500, 97000, errorModel),
132 TestCase::Duration::EXTENSIVE);
133 AddTestCase(new LenaPfFfMacSchedulerTestCase1(12, 6000, 99250, 48667, errorModel),
134 TestCase::Duration::EXTENSIVE);
135 AddTestCase(new LenaPfFfMacSchedulerTestCase1(15, 6000, 79400, 38993, errorModel),
136 TestCase::Duration::EXTENSIVE);
137
138 // DOWNLINK - DISTANCE 10000 -> MCS 14 -> Itbs 13 (from table 7.1.7.2.1-1 of 36.213)
139 // 1 user -> 24 PRB at Itbs 13 -> 871 -> 775000 bytes/sec
140 // 3 users -> 775000 among 3 users -> 258333 bytes/sec
141 // 6 users -> 775000 among 6 users -> 129167 bytes/sec
142 // 12 users -> 775000 among 12 users -> 64583 bytes/sec
143 // 15 users -> 775000 among 15 users -> 51667 bytes/sec
144 // UPLINK - DISTANCE 10000 -> MCS 8 -> Itbs 8 (from table 7.1.7.2.1-1 of 36.213)
145 // 1 user -> 24 PRB at Itbs 8 -> 437 -> 437000 bytes/sec
146 // 3 users -> 8 PRB at Itbs 8 -> 137 -> 137000 bytes/sec
147 // 6 users -> 4 PRB at Itbs 8 -> 67 -> 67000 bytes/sec
148 // after the patch enforcing min 3 PRBs per UE:
149 // 12 users -> 3 PRB at Itbs 8 -> 49 bytes * 8/12 UE/TTI -> 32667 bytes/sec
150 // 15 users -> 3 PRB at Itbs 8 -> 49 bytes * 8/15 UE/TTI -> 26133 bytes/sec
151 AddTestCase(new LenaPfFfMacSchedulerTestCase1(1, 10000, 775000, 437000, errorModel),
152 TestCase::Duration::EXTENSIVE);
153 AddTestCase(new LenaPfFfMacSchedulerTestCase1(3, 10000, 258333, 137000, errorModel),
154 TestCase::Duration::EXTENSIVE);
155 AddTestCase(new LenaPfFfMacSchedulerTestCase1(6, 10000, 129167, 67000, errorModel),
156 TestCase::Duration::EXTENSIVE);
157 AddTestCase(new LenaPfFfMacSchedulerTestCase1(12, 10000, 64583, 32667, errorModel),
158 TestCase::Duration::EXTENSIVE);
159 AddTestCase(new LenaPfFfMacSchedulerTestCase1(15, 10000, 51667, 26133, errorModel),
160 TestCase::Duration::EXTENSIVE);
161
162 // DONWLINK - DISTANCE 20000 -> MCS 8 -> Itbs 8 (from table 7.1.7.2.1-1 of 36.213)
163 // 1 user -> 24 PRB at Itbs 8 -> 421 -> 421000 bytes/sec
164 // 3 users -> 421000 among 3 users -> 140333 bytes/sec
165 // 6 users -> 421000 among 6 users -> 70167 bytes/sec
166 // 12 users -> 421000 among 12 users -> 35083 bytes/sec
167 // 15 users -> 421000 among 15 users -> 28067 bytes/sec
168 // UPLINK - DISTANCE 20000 -> MCS 2 -> Itbs 2 (from table 7.1.7.2.1-1 of 36.213)
169 // 1 user -> 25 PRB at Itbs 2 -> 233 -> 137000 bytes/sec
170 // 3 users -> 8 PRB at Itbs 2 -> 69 -> 41000 bytes/sec
171 // 6 users -> 4 PRB at Itbs 2 -> 32 -> 22000 bytes/sec
172 // after the patch enforcing min 3 PRBs per UE:
173 // 12 users -> 3 PRB at Itbs 2 -> 26 bytes * 8/12 UE/TTI -> 12000 bytes/sec
174 // 15 users -> 3 PRB at Itbs 2 -> 26 bytes * 8/15 UE/TTI -> 9600 bytes/sec
175 AddTestCase(new LenaPfFfMacSchedulerTestCase1(1, 20000, 421000, 137000, errorModel),
176 TestCase::Duration::EXTENSIVE);
177 AddTestCase(new LenaPfFfMacSchedulerTestCase1(3, 20000, 140333, 41000, errorModel),
178 TestCase::Duration::EXTENSIVE);
179 AddTestCase(new LenaPfFfMacSchedulerTestCase1(6, 20000, 70167, 22000, errorModel),
180 TestCase::Duration::EXTENSIVE);
181 AddTestCase(new LenaPfFfMacSchedulerTestCase1(12, 20000, 35083, 12000, errorModel),
182 TestCase::Duration::EXTENSIVE);
183 AddTestCase(new LenaPfFfMacSchedulerTestCase1(15, 20000, 28067, 9600, errorModel),
184 TestCase::Duration::EXTENSIVE);
185
186 // DOWNLINK - DISTANCE 100000 -> CQI == 0 -> out of range -> 0 bytes/sec
187 // UPLINK - DISTANCE 100000 -> CQI == 0 -> out of range -> 0 bytes/sec
188 AddTestCase(new LenaPfFfMacSchedulerTestCase1(1, 100000, 0, 0, errorModel),
189 TestCase::Duration::QUICK);
190
191 // Test Case 2: fairness check
192
193 std::vector<double> dist;
194 dist.push_back(0); // User 0 distance --> MCS 28
195 dist.push_back(4800); // User 1 distance --> MCS 22
196 dist.push_back(6000); // User 2 distance --> MCS 16
197 dist.push_back(10000); // User 3 distance --> MCS 8
198 dist.push_back(20000); // User 4 distance --> MCS 8
199 std::vector<uint32_t> estThrPfDl;
200 estThrPfDl.push_back(90000); // User 0 estimated TTI throughput from PF
201 estThrPfDl.push_back(37000); // User 1 estimated TTI throughput from PF
202 estThrPfDl.push_back(37000); // User 2 estimated TTI throughput from PF
203 estThrPfDl.push_back(17400); // User 3 estimated TTI throughput from PF
204 estThrPfDl.push_back(17400); // User 4 estimated TTI throughput from PF
205 std::vector<uint32_t> estThrPfUl;
206 estThrPfUl.push_back(469000); // User 0 estimated TTI throughput from PF
207 estThrPfUl.push_back(157000); // User 1 estimated TTI throughput from PF
208 estThrPfUl.push_back(125000); // User 2 estimated TTI throughput from PF
209 estThrPfUl.push_back(85000); // User 3 estimated TTI throughput from PF
210 estThrPfUl.push_back(26000); // User 4 estimated TTI throughput from PF
211 AddTestCase(new LenaPfFfMacSchedulerTestCase2(dist, estThrPfDl, estThrPfUl, errorModel),
212 TestCase::Duration::QUICK);
213}
214
215/**
216 * \ingroup lte-test
217 * Static variable for test initialization
218 */
220
221// --------------- T E S T - C A S E # 1 ------------------------------
222
223std::string
225{
226 std::ostringstream oss;
227 oss << nUser << " UEs, distance " << dist << " m";
228 return oss.str();
229}
230
232 double dist,
233 double thrRefDl,
234 double thrRefUl,
235 bool errorModelEnabled)
236 : TestCase(BuildNameString(nUser, dist)),
237 m_nUser(nUser),
238 m_dist(dist),
239 m_thrRefDl(thrRefDl),
240 m_thrRefUl(thrRefUl),
241 m_errorModelEnabled(errorModelEnabled)
242{
243}
244
246{
247}
248
249void
251{
252 NS_LOG_FUNCTION(this << m_nUser << m_dist);
253
255 {
256 Config::SetDefault("ns3::LteSpectrumPhy::CtrlErrorModelEnabled", BooleanValue(false));
257 Config::SetDefault("ns3::LteSpectrumPhy::DataErrorModelEnabled", BooleanValue(false));
258 }
259 Config::SetDefault("ns3::LteHelper::UseIdealRrc", BooleanValue(true));
260 Config::SetDefault("ns3::MacStatsCalculator::DlOutputFilename",
261 StringValue(CreateTempDirFilename("DlMacStats.txt")));
262 Config::SetDefault("ns3::MacStatsCalculator::UlOutputFilename",
263 StringValue(CreateTempDirFilename("UlMacStats.txt")));
264 Config::SetDefault("ns3::RadioBearerStatsCalculator::DlRlcOutputFilename",
265 StringValue(CreateTempDirFilename("DlRlcStats.txt")));
266 Config::SetDefault("ns3::RadioBearerStatsCalculator::UlRlcOutputFilename",
267 StringValue(CreateTempDirFilename("UlRlcStats.txt")));
268
269 /**
270 * Initialize Simulation Scenario: 1 eNB and m_nUser UEs
271 */
272
273 Ptr<LteHelper> lteHelper = CreateObject<LteHelper>();
274 lteHelper->SetAttribute("PathlossModel", StringValue("ns3::FriisSpectrumPropagationLossModel"));
275
276 // Create Nodes: eNodeB and UE
277 NodeContainer enbNodes;
278 NodeContainer ueNodes;
279 enbNodes.Create(1);
280 ueNodes.Create(m_nUser);
281
282 // Install Mobility Model
283 MobilityHelper mobility;
284 mobility.SetMobilityModel("ns3::ConstantPositionMobilityModel");
285 mobility.Install(enbNodes);
286 mobility.SetMobilityModel("ns3::ConstantPositionMobilityModel");
287 mobility.Install(ueNodes);
288
289 // Create Devices and install them in the Nodes (eNB and UE)
290 NetDeviceContainer enbDevs;
291 NetDeviceContainer ueDevs;
292 lteHelper->SetSchedulerType("ns3::PfFfMacScheduler");
293 lteHelper->SetSchedulerAttribute("UlCqiFilter", EnumValue(FfMacScheduler::SRS_UL_CQI));
294 enbDevs = lteHelper->InstallEnbDevice(enbNodes);
295 ueDevs = lteHelper->InstallUeDevice(ueNodes);
296
297 // Attach a UE to a eNB
298 lteHelper->Attach(ueDevs, enbDevs.Get(0));
299
300 // Activate an EPS bearer
302 EpsBearer bearer(q);
303 lteHelper->ActivateDataRadioBearer(ueDevs, bearer);
304
305 Ptr<LteEnbNetDevice> lteEnbDev = enbDevs.Get(0)->GetObject<LteEnbNetDevice>();
306 Ptr<LteEnbPhy> enbPhy = lteEnbDev->GetPhy();
307 enbPhy->SetAttribute("TxPower", DoubleValue(30.0));
308 enbPhy->SetAttribute("NoiseFigure", DoubleValue(5.0));
309
310 // Set UEs' position and power
311 for (int i = 0; i < m_nUser; i++)
312 {
315 mm->SetPosition(Vector(m_dist, 0.0, 0.0));
316 Ptr<LteUeNetDevice> lteUeDev = ueDevs.Get(i)->GetObject<LteUeNetDevice>();
317 Ptr<LteUePhy> uePhy = lteUeDev->GetPhy();
318 uePhy->SetAttribute("TxPower", DoubleValue(23.0));
319 uePhy->SetAttribute("NoiseFigure", DoubleValue(9.0));
320 }
321
322 double statsStartTime = 0.300; // need to allow for RRC connection establishment + SRS
323 double statsDuration = 0.6;
324 double tolerance = 0.1;
325 Simulator::Stop(Seconds(statsStartTime + statsDuration - 0.000001));
326
327 lteHelper->EnableMacTraces();
328 lteHelper->EnableRlcTraces();
329 Ptr<RadioBearerStatsCalculator> rlcStats = lteHelper->GetRlcStats();
330 rlcStats->SetAttribute("StartTime", TimeValue(Seconds(statsStartTime)));
331 rlcStats->SetAttribute("EpochDuration", TimeValue(Seconds(statsDuration)));
332
334
335 /**
336 * Check that the downlink assignment is done in a "proportional fair" manner
337 */
338 NS_LOG_INFO("DL - Test with " << m_nUser << " user(s) at distance " << m_dist);
339 std::vector<uint64_t> dlDataRxed;
340 for (int i = 0; i < m_nUser; i++)
341 {
342 // get the imsi
343 uint64_t imsi = ueDevs.Get(i)->GetObject<LteUeNetDevice>()->GetImsi();
344 uint8_t lcId = 3;
345 dlDataRxed.push_back(rlcStats->GetDlRxData(imsi, lcId));
346 NS_LOG_INFO("\tUser " << i << " imsi " << imsi << " bytes rxed " << (double)dlDataRxed.at(i)
347 << " thr " << (double)dlDataRxed.at(i) / statsDuration << " ref "
348 << m_thrRefDl);
349 }
350 /**
351 * Check that the assignment is done in a "proportional fair" manner among users
352 * with equal SINRs: the bandwidth should be distributed according to the
353 * ratio of the estimated throughput per TTI of each user; therefore equally
354 * partitioning the whole bandwidth achievable from a single users in a TTI
355 */
356 for (int i = 0; i < m_nUser; i++)
357 {
358 NS_TEST_ASSERT_MSG_EQ_TOL((double)dlDataRxed.at(i) / statsDuration,
360 m_thrRefDl * tolerance,
361 " Unfair Throughput!");
362 }
363
364 /**
365 * Check that the uplink assignment is done in a "proportional fair" manner
366 */
367 NS_LOG_INFO("UL - Test with " << m_nUser << " user(s) at distance " << m_dist);
368 std::vector<uint64_t> ulDataRxed;
369 for (int i = 0; i < m_nUser; i++)
370 {
371 // get the imsi
372 uint64_t imsi = ueDevs.Get(i)->GetObject<LteUeNetDevice>()->GetImsi();
373 // get the lcId
374 uint8_t lcId = 3;
375 ulDataRxed.push_back(rlcStats->GetUlRxData(imsi, lcId));
376 NS_LOG_INFO("\tUser " << i << " imsi " << imsi << " bytes rxed " << (double)ulDataRxed.at(i)
377 << " thr " << (double)ulDataRxed.at(i) / statsDuration << " ref "
378 << m_thrRefUl);
379 }
380 /**
381 * Check that the assignment is done in a "proportional fair" manner among users
382 * with equal SINRs: the bandwidth should be distributed according to the
383 * ratio of the estimated throughput per TTI of each user; therefore equally
384 * partitioning the whole bandwidth achievable from a single users in a TTI
385 */
386 for (int i = 0; i < m_nUser; i++)
387 {
388 NS_TEST_ASSERT_MSG_EQ_TOL((double)ulDataRxed.at(i) / statsDuration,
390 m_thrRefUl * tolerance,
391 " Unfair Throughput!");
392 }
394}
395
396// --------------- T E S T - C A S E # 2 ------------------------------
397
398std::string
399LenaPfFfMacSchedulerTestCase2::BuildNameString(uint16_t nUser, std::vector<double> dist)
400{
401 std::ostringstream oss;
402 oss << "distances (m) = [ ";
403 for (auto it = dist.begin(); it != dist.end(); ++it)
404 {
405 oss << *it << " ";
406 }
407 oss << "]";
408 return oss.str();
409}
410
412 std::vector<uint32_t> estThrPfDl,
413 std::vector<uint32_t> estThrPfUl,
414 bool errorModelEnabled)
415 : TestCase(BuildNameString(dist.size(), dist)),
416 m_nUser(dist.size()),
417 m_dist(dist),
418 m_estThrPfDl(estThrPfDl),
419 m_estThrPfUl(estThrPfUl),
420 m_errorModelEnabled(errorModelEnabled)
421{
422}
423
425{
426}
427
428void
430{
431 NS_LOG_FUNCTION(this);
433 {
434 Config::SetDefault("ns3::LteSpectrumPhy::CtrlErrorModelEnabled", BooleanValue(false));
435 Config::SetDefault("ns3::LteSpectrumPhy::DataErrorModelEnabled", BooleanValue(false));
436 }
437 Config::SetDefault("ns3::LteHelper::UseIdealRrc", BooleanValue(false));
438 Config::SetDefault("ns3::MacStatsCalculator::DlOutputFilename",
439 StringValue(CreateTempDirFilename("DlMacStats.txt")));
440 Config::SetDefault("ns3::MacStatsCalculator::UlOutputFilename",
441 StringValue(CreateTempDirFilename("UlMacStats.txt")));
442 Config::SetDefault("ns3::RadioBearerStatsCalculator::DlRlcOutputFilename",
443 StringValue(CreateTempDirFilename("DlRlcStats.txt")));
444 Config::SetDefault("ns3::RadioBearerStatsCalculator::UlRlcOutputFilename",
445 StringValue(CreateTempDirFilename("UlRlcStats.txt")));
446
447 /**
448 * Initialize Simulation Scenario: 1 eNB and m_nUser UEs
449 */
450
451 Ptr<LteHelper> lteHelper = CreateObject<LteHelper>();
452
453 lteHelper->SetAttribute("PathlossModel", StringValue("ns3::FriisSpectrumPropagationLossModel"));
454
455 // Create Nodes: eNodeB and UE
456 NodeContainer enbNodes;
457 NodeContainer ueNodes;
458 enbNodes.Create(1);
459 ueNodes.Create(m_nUser);
460
461 // Install Mobility Model
462 MobilityHelper mobility;
463 mobility.SetMobilityModel("ns3::ConstantPositionMobilityModel");
464 mobility.Install(enbNodes);
465 mobility.SetMobilityModel("ns3::ConstantPositionMobilityModel");
466 mobility.Install(ueNodes);
467
468 // Create Devices and install them in the Nodes (eNB and UE)
469 NetDeviceContainer enbDevs;
470 NetDeviceContainer ueDevs;
471 lteHelper->SetSchedulerType("ns3::PfFfMacScheduler");
472 lteHelper->SetSchedulerAttribute("UlCqiFilter", EnumValue(FfMacScheduler::SRS_UL_CQI));
473 enbDevs = lteHelper->InstallEnbDevice(enbNodes);
474 ueDevs = lteHelper->InstallUeDevice(ueNodes);
475
476 // Attach a UE to a eNB
477 lteHelper->Attach(ueDevs, enbDevs.Get(0));
478
479 // Activate an EPS bearer
481 EpsBearer bearer(q);
482 lteHelper->ActivateDataRadioBearer(ueDevs, bearer);
483
484 Ptr<LteEnbNetDevice> lteEnbDev = enbDevs.Get(0)->GetObject<LteEnbNetDevice>();
485 Ptr<LteEnbPhy> enbPhy = lteEnbDev->GetPhy();
486 enbPhy->SetAttribute("TxPower", DoubleValue(30.0));
487 enbPhy->SetAttribute("NoiseFigure", DoubleValue(5.0));
488
489 // Set UEs' position and power
490 for (int i = 0; i < m_nUser; i++)
491 {
494 mm->SetPosition(Vector(m_dist.at(i), 0.0, 0.0));
495 Ptr<LteUeNetDevice> lteUeDev = ueDevs.Get(i)->GetObject<LteUeNetDevice>();
496 Ptr<LteUePhy> uePhy = lteUeDev->GetPhy();
497 uePhy->SetAttribute("TxPower", DoubleValue(23.0));
498 uePhy->SetAttribute("NoiseFigure", DoubleValue(9.0));
499 }
500
501 double statsStartTime = 0.300; // need to allow for RRC connection establishment + SRS
502 double statsDuration = 0.4;
503 double tolerance = 0.1;
504 Simulator::Stop(Seconds(statsStartTime + statsDuration - 0.000001));
505
506 lteHelper->EnableRlcTraces();
507 Ptr<RadioBearerStatsCalculator> rlcStats = lteHelper->GetRlcStats();
508 rlcStats->SetAttribute("StartTime", TimeValue(Seconds(statsStartTime)));
509 rlcStats->SetAttribute("EpochDuration", TimeValue(Seconds(statsDuration)));
510
512
513 NS_LOG_INFO("DL - Test with " << m_nUser << " user(s)");
514 std::vector<uint64_t> dlDataRxed;
515 double totalData = 0;
516 double totalEstThrPf = 0;
517 for (int i = 0; i < m_nUser; i++)
518 {
519 // get the imsi
520 uint64_t imsi = ueDevs.Get(i)->GetObject<LteUeNetDevice>()->GetImsi();
521 // get the lcId
522 uint8_t lcId = 3;
523 dlDataRxed.push_back(rlcStats->GetDlRxData(imsi, lcId));
524 totalData += (double)dlDataRxed.at(i);
525 NS_LOG_INFO("\tUser " << i << " dist " << m_dist.at(i) << " imsi " << imsi << " bytes rxed "
526 << (double)dlDataRxed.at(i) << " thr "
527 << (double)dlDataRxed.at(i) / statsDuration);
528 totalEstThrPf += m_estThrPfDl.at(i);
529 }
530
531 /**
532 * Check that the assignment is done in a "proportional fair" manner among users
533 * with different SINRs: the bandwidth should be distributed according to the
534 * ratio of the estimated throughput per TTI of each user.
535 */
536 for (int i = 0; i < m_nUser; i++)
537 {
538 double thrRatio = (double)dlDataRxed.at(i) / totalData;
539 double estThrRatio = (double)m_estThrPfDl.at(i) / totalEstThrPf;
540 NS_LOG_INFO("\tUser " << i << " thrRatio " << thrRatio << " estThrRatio " << estThrRatio);
541 NS_TEST_ASSERT_MSG_EQ_TOL(estThrRatio, thrRatio, tolerance, " Unfair Throughput!");
542 }
543
544 /**
545 * Check that the assignment in uplink is done in a round robin manner.
546 */
547
548 NS_LOG_INFO("UL - Test with " << m_nUser);
549 std::vector<uint64_t> ulDataRxed;
550 for (int i = 0; i < m_nUser; i++)
551 {
552 // get the imsi
553 uint64_t imsi = ueDevs.Get(i)->GetObject<LteUeNetDevice>()->GetImsi();
554 // get the lcId
555 uint8_t lcId = 3;
556 ulDataRxed.push_back(rlcStats->GetUlRxData(imsi, lcId));
557 NS_LOG_INFO("\tUser " << i << " dist " << m_dist.at(i) << " bytes rxed "
558 << (double)ulDataRxed.at(i) << " thr "
559 << (double)ulDataRxed.at(i) / statsDuration << " ref "
560 << (double)m_estThrPfUl.at(i));
561 NS_TEST_ASSERT_MSG_EQ_TOL((double)ulDataRxed.at(i) / statsDuration,
562 (double)m_estThrPfUl.at(i),
563 (double)m_estThrPfUl.at(i) * tolerance,
564 " Unfair Throughput!");
565 }
567}
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:37
Mobility model for which the current position does not change once it has been set and until it is se...
This class can be used to hold variables of floating point type such as 'double' or 'float'.
Definition: double.h:42
Hold variables of type enum.
Definition: enum.h:62
This class contains the specification of EPS Bearers.
Definition: eps-bearer.h:91
Qci
QoS Class Indicator.
Definition: eps-bearer.h:106
@ GBR_CONV_VOICE
GBR Conversational Voice.
Definition: eps-bearer.h:107
The eNodeB device implementation.
The LteUeNetDevice class implements the UE net device.
Helper class used to assign positions and mobility models to nodes.
holds a vector of ns3::NetDevice pointers
Ptr< NetDevice > Get(uint32_t i) const
Get the Ptr<NetDevice> stored in this container at a given index.
keep track of a set of node pointers.
void Create(uint32_t n)
Create n nodes and append pointers to them to the end of this NodeContainer.
Ptr< Node > Get(uint32_t i) const
Get the Ptr<Node> stored in this container at a given index.
Ptr< T > GetObject() const
Get a pointer to the requested aggregated Object.
Definition: object.h:522
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:77
static void Destroy()
Execute the events scheduled with ScheduleDestroy().
Definition: simulator.cc:142
static void Run()
Run the simulation.
Definition: simulator.cc:178
static void Stop()
Tell the Simulator the calling event should be the last one executed.
Definition: simulator.cc:186
Hold variables of type string.
Definition: string.h:56
encapsulates test code
Definition: test.h:1061
void AddTestCase(TestCase *testCase, Duration duration=Duration::QUICK)
Add an individual child TestCase to this test suite.
Definition: test.cc:301
std::string CreateTempDirFilename(std::string filename)
Construct the full path to a file in a temporary directory.
Definition: test.cc:438
A suite of tests to run.
Definition: test.h:1268
Type
Type of test.
Definition: test.h:1275
AttributeValue implementation for Time.
Definition: nstime.h:1413
void SetDefault(std::string name, const AttributeValue &value)
Definition: config.cc:894
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:202
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by ",...
#define NS_LOG_INFO(msg)
Use NS_LOG to output a message of level LOG_INFO.
Definition: log.h:275
static LenaTestPfFfMacSchedulerSuite lenaTestPfFfMacSchedulerSuite
Static variable for test initialization.
#define NS_TEST_ASSERT_MSG_EQ_TOL(actual, limit, tol, msg)
Test that actual and expected (limit) values are equal to plus or minus some tolerance and report and...
Definition: test.h:338
Time Seconds(double value)
Construct a Time in the indicated unit.
Definition: nstime.h:1326
Every class exported by the ns3 library is enclosed in the ns3 namespace.