A Discrete-Event Network Simulator
API
lte-test-tdbet-ff-mac-scheduler.cc
Go to the documentation of this file.
1/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
2/*
3 * Copyright (c) 2011 Centre Tecnologic de Telecomunicacions de Catalunya (CTTC)
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 2 as
7 * published by the Free Software Foundation;
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 *
18 * Author: Marco Miozzo <marco.miozzo@cttc.es>,
19 * Nicola Baldo <nbaldo@cttc.es>
20 * Dizhi Zhou <dizhi.zhou@gmail.com>
21 */
22
23#include <iostream>
24#include <sstream>
25#include <string>
26
27#include <ns3/object.h>
28#include <ns3/spectrum-interference.h>
29#include <ns3/spectrum-error-model.h>
30#include <ns3/log.h>
31#include <ns3/test.h>
32#include <ns3/simulator.h>
33#include <ns3/packet.h>
34#include <ns3/ptr.h>
35#include "ns3/radio-bearer-stats-calculator.h"
36#include <ns3/constant-position-mobility-model.h>
37#include <ns3/ff-mac-scheduler.h>
38#include <ns3/eps-bearer.h>
39#include <ns3/node-container.h>
40#include <ns3/mobility-helper.h>
41#include <ns3/net-device-container.h>
42#include <ns3/lte-ue-net-device.h>
43#include <ns3/lte-enb-net-device.h>
44#include <ns3/lte-ue-rrc.h>
45#include <ns3/lte-helper.h>
46#include "ns3/string.h"
47#include "ns3/double.h"
48#include <ns3/lte-enb-phy.h>
49#include <ns3/lte-ue-phy.h>
50#include <ns3/boolean.h>
51#include <ns3/enum.h>
52
54
55using namespace ns3;
56
57NS_LOG_COMPONENT_DEFINE ("LenaTestTdBetFfMacScheduler");
58
60 : TestSuite ("lte-tdbet-ff-mac-scheduler", SYSTEM)
61{
62 NS_LOG_INFO ("creating LenaTestTdBetFfMacSchedulerSuite");
63
64 bool errorModel = false;
65
66 //Test Case 1: AMC works in TDBET
67
68 //Note: here the MCS is calculated by the wideband CQI
69
70 // DOWNLINK- DISTANCE 0 -> MCS 28 -> Itbs 26 (from table 7.1.7.2.1-1 of 36.213)
71 // 1 user -> 24 PRB at Itbs 26 -> 2196 -> 2196000 bytes/sec
72 // 3 users -> 2196000 among 3 users -> 732000 bytes/sec
73 // 6 users -> 2196000 among 6 users -> 366000 bytes/sec
74 // 12 users -> 2196000 among 12 users -> 183000 bytes/sec
75 // UPLINK- DISTANCE 0 -> MCS 28 -> Itbs 26 (from table 7.1.7.2.1-1 of 36.213)
76 // 1 user -> 25 PRB at Itbs 26 -> 2292 -> 2292000 bytes/sec
77 // 3 users -> 8 PRB at Itbs 26 -> 749 -> 749000 bytes/sec
78 // 6 users -> 4 PRB at Itbs 26 -> 373 -> 373000 bytes/sec
79 // after the patch enforcing min 3 PRBs per UE:
80 // 12 users -> 3 PRB at Itbs 26 -> 277 bytes * 8/12 UE/TTI -> 184670 bytes/sec
81 AddTestCase (new LenaTdBetFfMacSchedulerTestCase1 (1,0,2196000,2292000, errorModel), TestCase::EXTENSIVE);
82 AddTestCase (new LenaTdBetFfMacSchedulerTestCase1 (3,0,732000,749000, errorModel), TestCase::EXTENSIVE);
83 AddTestCase (new LenaTdBetFfMacSchedulerTestCase1 (6,0,366000,373000, errorModel), TestCase::EXTENSIVE);
84 AddTestCase (new LenaTdBetFfMacSchedulerTestCase1 (12,0,183000,184670, errorModel), TestCase::EXTENSIVE);
85
86 // DOWNLINK - DISTANCE 4800 -> MCS 22 -> Itbs 20 (from table 7.1.7.2.1-1 of 36.213)
87 // 1 user -> 24 PRB at Itbs 20 -> 1383 -> 1383000 bytes/sec
88 // 3 users -> 1383000 among 3 users ->461000 bytes/sec
89 // 6 users -> 1383000 among 6 users ->230500 bytes/sec
90 // 12 users -> 1383000 among 12 users ->115250 bytes/sec
91 // UPLINK - DISTANCE 4800 -> MCS 14 -> Itbs 13 (from table 7.1.7.2.1-1 of 36.213)
92 // 1 user -> 25 PRB at Itbs 13 -> 807 -> 807000 bytes/sec
93 // 3 users -> 8 PRB at Itbs 13 -> 253 -> 253000 bytes/sec
94 // 6 users -> 4 PRB at Itbs 13 -> 125 -> 125000 bytes/sec
95 // after the patch enforcing min 3 PRBs per UE:
96 // 12 users -> 3 PRB at Itbs 13 -> 93 bytes * 8/12 UE/TTI -> 62000 bytes/sec
97 AddTestCase (new LenaTdBetFfMacSchedulerTestCase1 (1,4800,1383000,807000, errorModel), TestCase::EXTENSIVE);
98 AddTestCase (new LenaTdBetFfMacSchedulerTestCase1 (3,4800,461000,253000, errorModel), TestCase::EXTENSIVE);
99 AddTestCase (new LenaTdBetFfMacSchedulerTestCase1 (6,4800,230500,125000, errorModel), TestCase::EXTENSIVE);
100 AddTestCase (new LenaTdBetFfMacSchedulerTestCase1 (12,4800,115250,62000, errorModel), TestCase::EXTENSIVE);
101
102 // DOWNLINK - DISTANCE 6000 -> MCS 20 -> Itbs 18 (from table 7.1.7.2.1-1 of 36.213)
103 // 1 user -> 24 PRB at Itbs 18 -> 1191 -> 1191000 byte/sec
104 // 3 users -> 1191000 among 3 users ->397000 bytes/sec
105 // 6 users -> 1191000 among 6 users ->198500 bytes/sec
106 // 12 users -> 1191000 among 12 users ->99250 bytes/sec
107 // UPLINK - DISTANCE 6000 -> MCS 12 -> Itbs 11 (from table 7.1.7.2.1-1 of 36.213)
108 // 1 user -> 25 PRB at Itbs 11 -> 621 -> 621000 bytes/sec
109 // 3 users -> 8 PRB at Itbs 11 -> 201 -> 201000 bytes/sec
110 // 6 users -> 4 PRB at Itbs 11 -> 97 -> 97000 bytes/sec
111 // 12 users -> 3 PRB at Itbs 11 -> 73 bytes * 8/12 UE/TTI -> 48667 bytes/sec
112 AddTestCase (new LenaTdBetFfMacSchedulerTestCase1 (1,6000,1191000,621000,errorModel), TestCase::EXTENSIVE);
113 AddTestCase (new LenaTdBetFfMacSchedulerTestCase1 (3,6000,397000,201000,errorModel), TestCase::EXTENSIVE);
114 AddTestCase (new LenaTdBetFfMacSchedulerTestCase1 (6,6000,198500,97000,errorModel), TestCase::EXTENSIVE);
115 AddTestCase (new LenaTdBetFfMacSchedulerTestCase1 (12,6000,99250,48667,errorModel), TestCase::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 -> 775000 among 3 users -> 258333 bytes/sec
120 // 6 users -> 775000 among 6 users -> 129166 bytes/sec
121 // 12 users -> 775000 among 12 users ->64583 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 LenaTdBetFfMacSchedulerTestCase1 (1,10000,775000,421000,errorModel), TestCase::EXTENSIVE);
129 AddTestCase (new LenaTdBetFfMacSchedulerTestCase1 (3,10000,258333,137000,errorModel), TestCase::EXTENSIVE);
130 AddTestCase (new LenaTdBetFfMacSchedulerTestCase1 (6,10000,129166,67000,errorModel), TestCase::EXTENSIVE);
131 AddTestCase (new LenaTdBetFfMacSchedulerTestCase1 (12,10000,64583,32667,errorModel), TestCase::EXTENSIVE);
132
133 // DOWNLINK - DISTANCE 20000 -> MCS 8 -> Itbs 8 (from table 7.1.7.2.1-1 of 36.213)
134 // 1 user -> 24 PRB at Itbs 8 -> 421 -> 421000 bytes/sec
135 // 3 users -> 421000 among 3 users ->140333 bytes/sec
136 // 6 users -> 421000 among 6 users ->70166 bytes/sec
137 // 12 users -> 421000 among 12 users ->35083 bytes/sec
138 // UPLINK - DISTANCE 20000 -> MCS 2 -> Itbs 2 (from table 7.1.7.2.1-1 of 36.213)
139 // 1 user -> 25 PRB at Itbs 2 -> 137 -> 137000 bytes/sec
140 // 3 users -> 8 PRB at Itbs 2 -> 41 -> 41000 bytes/sec
141 // 6 users -> 4 PRB at Itbs 2 -> 22 -> 22000 bytes/sec
142 // after the patch enforcing min 3 PRBs per UE:
143 // 12 users -> 3 PRB at Itbs 2 -> 18 bytes * 8/12 UE/TTI -> 12000 bytes/sec
144 AddTestCase (new LenaTdBetFfMacSchedulerTestCase1 (1,20000,421000,137000,errorModel), TestCase::EXTENSIVE);
145 AddTestCase (new LenaTdBetFfMacSchedulerTestCase1 (3,20000,140333,41000,errorModel), TestCase::EXTENSIVE);
146 AddTestCase (new LenaTdBetFfMacSchedulerTestCase1 (6,20000,70166,22000,errorModel), TestCase::EXTENSIVE);
147 AddTestCase (new LenaTdBetFfMacSchedulerTestCase1 (12,20000,35083,12000,errorModel), TestCase::EXTENSIVE);
148
149 // DOWNLINK - DISTANCE 100000 -> CQI == 0 -> out of range -> 0 bytes/sec
150 // UPLINK - DISTANCE 100000 -> CQI == 0 -> out of range -> 0 bytes/sec
151 AddTestCase (new LenaTdBetFfMacSchedulerTestCase1 (1,100000,0,0,errorModel), TestCase::QUICK);
152
153 // Test Case 2: fairness check
154
155 std::vector<double> dist;
156 dist.push_back (0); // User 0 distance --> MCS 28
157 dist.push_back (4800); // User 1 distance --> MCS 22
158 dist.push_back (6000); // User 2 distance --> MCS 14
159 dist.push_back (10000); // User 3 distance --> MCS 8
160 dist.push_back (20000); // User 4 distance --> MCS 8
161 std::vector<uint32_t> estAchievableRateDl;
162 estAchievableRateDl.push_back (2196000);
163 estAchievableRateDl.push_back (1383000);
164 estAchievableRateDl.push_back (775000);
165 estAchievableRateDl.push_back (421000);
166 estAchievableRateDl.push_back (421000);
167 std::vector<uint32_t> estThrTdBetUl;
168 estThrTdBetUl.push_back (469000); // User 0 estimated TTI throughput from TDBET
169 estThrTdBetUl.push_back (157000); // User 1 estimated TTI throughput from TDBET
170 estThrTdBetUl.push_back (125000); // User 2 estimated TTI throughput from TDBET
171 estThrTdBetUl.push_back (85000); // User 3 estimated TTI throughput from TDBET
172 estThrTdBetUl.push_back (26000); // User 4 estimated TTI throughput from TDBET
173 AddTestCase (new LenaTdBetFfMacSchedulerTestCase2 (dist, estAchievableRateDl, estThrTdBetUl, errorModel), TestCase::QUICK);
174}
175
177
178
179// --------------- T E S T - C A S E # 1 ------------------------------
180
181
182std::string
184{
185 std::ostringstream oss;
186 oss << nUser << " UEs, distance " << dist << " m";
187 return oss.str ();
188}
189
190LenaTdBetFfMacSchedulerTestCase1::LenaTdBetFfMacSchedulerTestCase1 (uint16_t nUser, double dist, double thrRefDl, double thrRefUl, bool errorModelEnabled)
191 : TestCase (BuildNameString (nUser, dist)),
192 m_nUser (nUser),
193 m_dist (dist),
194 m_thrRefDl (thrRefDl),
195 m_thrRefUl (thrRefUl),
196 m_errorModelEnabled (errorModelEnabled)
197{
198}
199
201{
202}
203
204void
206{
208 {
209 Config::SetDefault ("ns3::LteSpectrumPhy::CtrlErrorModelEnabled", BooleanValue (false));
210 Config::SetDefault ("ns3::LteSpectrumPhy::DataErrorModelEnabled", BooleanValue (false));
211 }
212
213 Config::SetDefault ("ns3::LteHelper::UseIdealRrc", BooleanValue (true));
214 Config::SetDefault ("ns3::MacStatsCalculator::DlOutputFilename", StringValue (CreateTempDirFilename ("DlMacStats.txt")));
215 Config::SetDefault ("ns3::MacStatsCalculator::UlOutputFilename", StringValue (CreateTempDirFilename ("UlMacStats.txt")));
216 Config::SetDefault ("ns3::RadioBearerStatsCalculator::DlRlcOutputFilename", StringValue (CreateTempDirFilename ("DlRlcStats.txt")));
217 Config::SetDefault ("ns3::RadioBearerStatsCalculator::UlRlcOutputFilename", StringValue (CreateTempDirFilename ("UlRlcStats.txt")));
218
219 //Disable Uplink Power Control
220 Config::SetDefault ("ns3::LteUePhy::EnableUplinkPowerControl", BooleanValue (false));
221
226 Ptr<LteHelper> lteHelper = CreateObject<LteHelper> ();
227
228 lteHelper->SetAttribute ("PathlossModel", StringValue ("ns3::FriisSpectrumPropagationLossModel"));
229
230 // Create Nodes: eNodeB and UE
231 NodeContainer enbNodes;
232 NodeContainer ueNodes;
233 enbNodes.Create (1);
234 ueNodes.Create (m_nUser);
235
236 // Install Mobility Model
238 mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel");
239 mobility.Install (enbNodes);
240 mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel");
241 mobility.Install (ueNodes);
242
243 // Create Devices and install them in the Nodes (eNB and UE)
244 NetDeviceContainer enbDevs;
245 NetDeviceContainer ueDevs;
246 lteHelper->SetSchedulerType ("ns3::TdBetFfMacScheduler");
247 lteHelper->SetSchedulerAttribute ("UlCqiFilter", EnumValue (FfMacScheduler::SRS_UL_CQI));
248 enbDevs = lteHelper->InstallEnbDevice (enbNodes);
249 ueDevs = lteHelper->InstallUeDevice (ueNodes);
250
251 // Attach a UE to a eNB
252 lteHelper->Attach (ueDevs, enbDevs.Get (0));
253
254 // Activate an EPS bearer
255 enum EpsBearer::Qci q = EpsBearer::GBR_CONV_VOICE;
256 EpsBearer bearer (q);
257 lteHelper->ActivateDataRadioBearer (ueDevs, bearer);
258
259 Ptr<LteEnbNetDevice> lteEnbDev = enbDevs.Get (0)->GetObject<LteEnbNetDevice> ();
260 Ptr<LteEnbPhy> enbPhy = lteEnbDev->GetPhy ();
261 enbPhy->SetAttribute ("TxPower", DoubleValue (30.0));
262 enbPhy->SetAttribute ("NoiseFigure", DoubleValue (5.0));
263
264 // Set UEs' position and power
265 for (int i = 0; i < m_nUser; i++)
266 {
268 mm->SetPosition (Vector (m_dist, 0.0, 0.0));
269 Ptr<LteUeNetDevice> lteUeDev = ueDevs.Get (i)->GetObject<LteUeNetDevice> ();
270 Ptr<LteUePhy> uePhy = lteUeDev->GetPhy ();
271 uePhy->SetAttribute ("TxPower", DoubleValue (23.0));
272 uePhy->SetAttribute ("NoiseFigure", DoubleValue (9.0));
273 }
274
275 double statsStartTime = 0.300; // need to allow for RRC connection establishment + SRS
276 double statsDuration = 0.6;
277 double tolerance = 0.1;
278 Simulator::Stop (Seconds (statsStartTime + statsDuration - 0.000001));
279
280 lteHelper->EnableMacTraces ();
281 lteHelper->EnableRlcTraces ();
282 Ptr<RadioBearerStatsCalculator> rlcStats = lteHelper->GetRlcStats ();
283 rlcStats->SetAttribute ("StartTime", TimeValue (Seconds (statsStartTime)));
284 rlcStats->SetAttribute ("EpochDuration", TimeValue (Seconds (statsDuration)));
285
286 NS_LOG_DEBUG ("Start ");
287
289
293 NS_LOG_INFO ("DL - Test with " << m_nUser << " user(s) at distance " << m_dist);
294 std::vector <uint64_t> dlDataRxed;
295 for (int i = 0; i < m_nUser; i++)
296 {
297 // get the imsi
298 uint64_t imsi = ueDevs.Get (i)->GetObject<LteUeNetDevice> ()->GetImsi ();
299 // get the lcId
300 uint8_t lcId = 3;
301 dlDataRxed.push_back (rlcStats->GetDlRxData (imsi, lcId));
302 NS_LOG_INFO ("\tUser " << i << " imsi " << imsi << " bytes rxed " << (double)dlDataRxed.at (i) << " thr " << (double)dlDataRxed.at (i) / statsDuration << " ref " << m_thrRefDl);
303 }
310 for (int i = 0; i < m_nUser; i++)
311 {
312 NS_TEST_ASSERT_MSG_EQ_TOL ((double)dlDataRxed.at (i) / statsDuration, m_thrRefDl, m_thrRefDl * tolerance, " Unfair Throughput!");
313 }
314
318 NS_LOG_INFO ("UL - Test with " << m_nUser << " user(s) at distance " << m_dist);
319 std::vector <uint64_t> ulDataRxed;
320 for (int i = 0; i < m_nUser; i++)
321 {
322 // get the imsi
323 uint64_t imsi = ueDevs.Get (i)->GetObject<LteUeNetDevice> ()->GetImsi ();
324 // get the lcId
325 uint8_t lcId = 3;
326 ulDataRxed.push_back (rlcStats->GetUlRxData (imsi, lcId));
327 NS_LOG_INFO ("\tUser " << i << " imsi " << imsi << " bytes rxed " << (double)ulDataRxed.at (i) << " thr " << (double)ulDataRxed.at (i) / statsDuration << " ref " << m_thrRefUl);
328 }
335 for (int i = 0; i < m_nUser; i++)
336 {
337 NS_TEST_ASSERT_MSG_EQ_TOL ((double)ulDataRxed.at (i) / statsDuration, m_thrRefUl, m_thrRefUl * tolerance, " Unfair Throughput!");
338 }
339 Simulator::Destroy ();
340
341}
342
343
344
345// --------------- T E S T - C A S E # 2 ------------------------------
346
347
348std::string
349LenaTdBetFfMacSchedulerTestCase2::BuildNameString (uint16_t nUser, std::vector<double> dist)
350{
351 std::ostringstream oss;
352 oss << "distances (m) = [ " ;
353 for (std::vector<double>::iterator it = dist.begin (); it != dist.end (); ++it)
354 {
355 oss << *it << " ";
356 }
357 oss << "]";
358 return oss.str ();
359}
360
361
362LenaTdBetFfMacSchedulerTestCase2::LenaTdBetFfMacSchedulerTestCase2 (std::vector<double> dist, std::vector<uint32_t> estAchievableRateDl, std::vector<uint32_t> estThrTdBetUl, bool errorModelEnabled)
363 : TestCase (BuildNameString (dist.size (), dist)),
364 m_nUser (dist.size ()),
365 m_dist (dist),
366 m_achievableRateDl (estAchievableRateDl),
367 m_estThrTdBetUl (estThrTdBetUl),
368 m_errorModelEnabled (errorModelEnabled)
369{
370}
371
373{
374}
375
376void
378{
379
380 NS_LOG_FUNCTION (this);
381
383 {
384 Config::SetDefault ("ns3::LteSpectrumPhy::CtrlErrorModelEnabled", BooleanValue (false));
385 Config::SetDefault ("ns3::LteSpectrumPhy::DataErrorModelEnabled", BooleanValue (false));
386 }
387 Config::SetDefault ("ns3::LteHelper::UseIdealRrc", BooleanValue (false));
388 Config::SetDefault ("ns3::MacStatsCalculator::DlOutputFilename", StringValue (CreateTempDirFilename ("DlMacStats.txt")));
389 Config::SetDefault ("ns3::MacStatsCalculator::UlOutputFilename", StringValue (CreateTempDirFilename ("UlMacStats.txt")));
390 Config::SetDefault ("ns3::RadioBearerStatsCalculator::DlRlcOutputFilename", StringValue (CreateTempDirFilename ("DlRlcStats.txt")));
391 Config::SetDefault ("ns3::RadioBearerStatsCalculator::UlRlcOutputFilename", StringValue (CreateTempDirFilename ("UlRlcStats.txt")));
392
397 Ptr<LteHelper> lteHelper = CreateObject<LteHelper> ();
398
399 lteHelper->SetAttribute ("PathlossModel", StringValue ("ns3::FriisSpectrumPropagationLossModel"));
400
401 // Create Nodes: eNodeB and UE
402 NodeContainer enbNodes;
403 NodeContainer ueNodes;
404 enbNodes.Create (1);
405 ueNodes.Create (m_nUser);
406
407 // Install Mobility Model
409 mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel");
410 mobility.Install (enbNodes);
411 mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel");
412 mobility.Install (ueNodes);
413
414 // Create Devices and install them in the Nodes (eNB and UE)
415 NetDeviceContainer enbDevs;
416 NetDeviceContainer ueDevs;
417 lteHelper->SetSchedulerType ("ns3::TdBetFfMacScheduler");
418 lteHelper->SetSchedulerAttribute ("UlCqiFilter", EnumValue (FfMacScheduler::SRS_UL_CQI));
419 enbDevs = lteHelper->InstallEnbDevice (enbNodes);
420 ueDevs = lteHelper->InstallUeDevice (ueNodes);
421
422 // Attach a UE to a eNB
423 lteHelper->Attach (ueDevs, enbDevs.Get (0));
424
425 // Activate an EPS bearer
426 enum EpsBearer::Qci q = EpsBearer::GBR_CONV_VOICE;
427 EpsBearer bearer (q);
428 lteHelper->ActivateDataRadioBearer (ueDevs, bearer);
429
430 Ptr<LteEnbNetDevice> lteEnbDev = enbDevs.Get (0)->GetObject<LteEnbNetDevice> ();
431 Ptr<LteEnbPhy> enbPhy = lteEnbDev->GetPhy ();
432 enbPhy->SetAttribute ("TxPower", DoubleValue (30.0));
433 enbPhy->SetAttribute ("NoiseFigure", DoubleValue (5.0));
434
435 // Set UEs' position and power
436 for (int i = 0; i < m_nUser; i++)
437 {
439 mm->SetPosition (Vector (m_dist.at (i), 0.0, 0.0));
440 Ptr<LteUeNetDevice> lteUeDev = ueDevs.Get (i)->GetObject<LteUeNetDevice> ();
441 Ptr<LteUePhy> uePhy = lteUeDev->GetPhy ();
442 uePhy->SetAttribute ("TxPower", DoubleValue (23.0));
443 uePhy->SetAttribute ("NoiseFigure", DoubleValue (9.0));
444 }
445
446
447 double statsStartTime = 0.300; // need to allow for RRC connection establishment + SRS
448 double statsDuration = 0.4;
449 double tolerance = 0.1;
450 Simulator::Stop (Seconds (statsStartTime + statsDuration - 0.000001));
451
452 lteHelper->EnableMacTraces ();
453 lteHelper->EnableRlcTraces ();
454 Ptr<RadioBearerStatsCalculator> rlcStats = lteHelper->GetRlcStats ();
455 rlcStats->SetAttribute ("StartTime", TimeValue (Seconds (statsStartTime)));
456 rlcStats->SetAttribute ("EpochDuration", TimeValue (Seconds (statsDuration)));
457
459
460 NS_LOG_INFO ("DL - Test with " << m_nUser << " user(s)");
461 std::vector <uint64_t> dlDataRxed;
462 double totalData = 0;
463 double estTotalThr = 0;
464 double estUeThr = 0;
465 for (int i = 0; i < m_nUser; i++)
466 {
467 // get the imsi
468 uint64_t imsi = ueDevs.Get (i)->GetObject<LteUeNetDevice> ()->GetImsi ();
469 // get the lcId
470 uint8_t lcId = 3;
471 dlDataRxed.push_back (rlcStats->GetDlRxData (imsi, lcId));
472 totalData += (double)dlDataRxed.at (i);
473 estTotalThr += 1 / m_achievableRateDl.at (i);
474 NS_LOG_INFO ("\tUser " << i << " dist " << m_dist.at (i) << " imsi " << imsi << " bytes rxed " << (double)dlDataRxed.at (i) << " thr " << (double)dlDataRxed.at (i) / statsDuration << " ref " << m_nUser);
475 }
476
477 estTotalThr = m_nUser * (1 / estTotalThr);
478 estUeThr = estTotalThr / m_nUser;
483 for (int i = 0; i < m_nUser; i++)
484 {
485 double thrRatio = (double) 1 / m_nUser;
486 double estThrRatio = (double)dlDataRxed.at (i) / totalData;
487 NS_LOG_INFO ("\tUser " << i << " thrRatio " << thrRatio << " estThrRatio " << estThrRatio);
488 NS_TEST_ASSERT_MSG_EQ_TOL (estThrRatio, thrRatio, tolerance, " Unfair Throughput!");
489 NS_TEST_ASSERT_MSG_EQ_TOL ((double)dlDataRxed.at (i) / statsDuration, estUeThr, estUeThr * tolerance, " Unfair Throughput!");
490
491 }
492
497 NS_LOG_INFO ("UL - Test with " << m_nUser);
498 std::vector <uint64_t> ulDataRxed;
499 for (int i = 0; i < m_nUser; i++)
500 {
501 // get the imsi
502 uint64_t imsi = ueDevs.Get (i)->GetObject<LteUeNetDevice> ()->GetImsi ();
503 // get the lcId
504 uint8_t lcId = 3;
505 ulDataRxed.push_back (rlcStats->GetUlRxData (imsi, lcId));
506 NS_LOG_INFO ("\tUser " << i << " dist " << m_dist.at (i) << " bytes rxed " << (double)ulDataRxed.at (i) << " thr " << (double)ulDataRxed.at (i) / statsDuration << " ref " << (double)m_estThrTdBetUl.at (i));
507 NS_TEST_ASSERT_MSG_EQ_TOL ((double)ulDataRxed.at (i) / statsDuration, (double)m_estThrTdBetUl.at (i), (double)m_estThrTdBetUl.at (i) * tolerance, " Unfair Throughput!");
508 }
509 Simulator::Destroy ();
510
511}
void Run(ObjectFactory &factory, uint32_t pop, uint32_t total, uint32_t runs, Ptr< RandomVariableStream > eventStream, bool calRev)
Perform the runs for a single scheduler type.
This system test program creates different test cases with a single eNB and several UEs,...
bool m_errorModelEnabled
indicates whether the error model is enabled
static std::string BuildNameString(uint16_t nUser, double dist)
Builds the test name string based on provided parameter values.
double m_thrRefUl
the UL throughput reference
virtual void DoRun(void)
Implementation to actually run this TestCase.
double m_thrRefDl
the DL throughput reference
LenaTdBetFfMacSchedulerTestCase1(uint16_t nUser, double dist, double thrRefDl, double thrRefUl, bool errorModelEnabled)
Constructor.
double m_dist
the distance between UE nodes and eNodeB
Lena TdBet Ff Mac Scheduler Test Case.
static std::string BuildNameString(uint16_t nUser, std::vector< double > dist)
Build name string.
virtual void DoRun(void)
Implementation to actually run this TestCase.
std::vector< double > m_dist
the distance between nodes
LenaTdBetFfMacSchedulerTestCase2(std::vector< double > dist, std::vector< uint32_t > achievableRateDl, std::vector< uint32_t > estThrTdBetUl, bool errorModelEnabled)
Constructor.
std::vector< uint32_t > m_estThrTdBetUl
etimated TDBET UL throughput
bool m_errorModelEnabled
indicates whether the error model is enabled
std::vector< uint32_t > m_achievableRateDl
DL achievable rate.
Test suite for TdBetFfMacScheduler tests.
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:41
Hold variables of type enum.
Definition: enum.h:55
This class contains the specification of EPS Bearers.
Definition: eps-bearer.h:92
Qci
QoS Class Indicator.
Definition: eps-bearer.h:107
The eNodeB device implementation.
Ptr< LteEnbPhy > GetPhy(void) const
void SetSchedulerAttribute(std::string n, const AttributeValue &v)
Set an attribute for the scheduler to be created.
Definition: lte-helper.cc:293
NetDeviceContainer InstallEnbDevice(NodeContainer c)
Create a set of eNodeB devices.
Definition: lte-helper.cc:474
Ptr< RadioBearerStatsCalculator > GetRlcStats(void)
Definition: lte-helper.cc:1576
void SetSchedulerType(std::string type)
Set the type of scheduler to be used by eNodeB devices.
Definition: lte-helper.cc:279
void Attach(NetDeviceContainer ueDevices)
Enables automatic attachment of a set of UE devices to a suitable cell using Idle mode initial cell s...
Definition: lte-helper.cc:959
void EnableRlcTraces(void)
Enable trace sinks for RLC layer.
Definition: lte-helper.cc:1435
void ActivateDataRadioBearer(NetDeviceContainer ueDevices, EpsBearer bearer)
Activate a Data Radio Bearer on a given UE devices (for LTE-only simulation).
Definition: lte-helper.cc:1313
NetDeviceContainer InstallUeDevice(NodeContainer c)
Create a set of UE devices.
Definition: lte-helper.cc:489
void EnableMacTraces(void)
Enable trace sinks for MAC layer.
Definition: lte-helper.cc:1533
The LteUeNetDevice class implements the UE net device.
Helper class used to assign positions and mobility models to nodes.
holds a vector of ns3::NetDevice pointers
Ptr< NetDevice > Get(uint32_t i) const
Get the Ptr<NetDevice> stored in this container at a given index.
keep track of a set of node pointers.
void Create(uint32_t n)
Create n nodes and append pointers to them to the end of this NodeContainer.
Ptr< Node > Get(uint32_t i) const
Get the Ptr<Node> stored in this container at a given index.
void SetAttribute(std::string name, const AttributeValue &value)
Set a single attribute, raising fatal errors if unsuccessful.
Definition: object-base.cc:256
Ptr< T > GetObject(void) const
Get a pointer to the requested aggregated Object.
Definition: object.h:470
Hold variables of type string.
Definition: string.h:41
encapsulates test code
Definition: test.h:994
void AddTestCase(TestCase *testCase, TestDuration duration=QUICK)
Add an individual child TestCase to this test suite.
Definition: test.cc:299
std::string CreateTempDirFilename(std::string filename)
Construct the full path to a file in a temporary directory.
Definition: test.cc:430
A suite of tests to run.
Definition: test.h:1188
AttributeValue implementation for Time.
Definition: nstime.h:1309
void SetDefault(std::string name, const AttributeValue &value)
Definition: config.cc:849
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:205
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
Definition: log.h:273
#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:281
#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:323
Time Seconds(double value)
Construct a Time in the indicated unit.
Definition: nstime.h:1245
static LenaTestTdBetFfMacSchedulerSuite lenaTestTdBetFfMacSchedulerSuite
Every class exported by the ns3 library is enclosed in the ns3 namespace.
mobility
Definition: third.py:98