A Discrete-Event Network Simulator
API
lte-test-pf-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, 2012 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  */
21 
22 #include <iostream>
23 #include <sstream>
24 #include <string>
25 
26 #include <ns3/object.h>
27 #include <ns3/spectrum-interference.h>
28 #include <ns3/spectrum-error-model.h>
29 #include <ns3/log.h>
30 #include <ns3/test.h>
31 #include <ns3/simulator.h>
32 #include <ns3/packet.h>
33 #include <ns3/ptr.h>
34 #include "ns3/radio-bearer-stats-calculator.h"
35 #include <ns3/constant-position-mobility-model.h>
36 #include <ns3/ff-mac-scheduler.h>
37 #include <ns3/eps-bearer.h>
38 #include <ns3/node-container.h>
39 #include <ns3/mobility-helper.h>
40 #include <ns3/net-device-container.h>
41 #include <ns3/lte-ue-net-device.h>
42 #include <ns3/lte-enb-net-device.h>
43 #include <ns3/lte-ue-rrc.h>
44 #include <ns3/lte-helper.h>
45 #include "ns3/string.h"
46 #include "ns3/double.h"
47 #include <ns3/lte-enb-phy.h>
48 #include <ns3/lte-ue-phy.h>
49 #include <ns3/boolean.h>
50 #include <ns3/enum.h>
51 
53 
54 using namespace ns3;
55 
56 NS_LOG_COMPONENT_DEFINE ("LenaTestPfFfMacScheduler");
57 
59  : TestSuite ("lte-pf-ff-mac-scheduler", SYSTEM)
60 {
61  NS_LOG_INFO ("creating LenaTestPfFfMacSchedulerSuite");
62 
63  bool errorModel = false;
64 
65 
66  //Test Case 1: AMC works in PF
67 
68  // DOWNLINK - DISTANCE 0 -> MCS 28 -> Itbs 26 (from table 7.1.7.2.1-1 of 36.213)
69  // 1 user -> 24 PRB at Itbs 26 -> 2196 -> 2196000 bytes/sec
70  // 3 users -> 2196000 among 3 users -> 732000 bytes/sec
71  // 6 users -> 2196000 among 6 users -> 366000 bytes/sec
72  // 12 users -> 2196000 among 12 users -> 183000 bytes/sec
73  // 15 users -> 2196000 among 15 users -> 146400 bytes/sec
74  // UPLINK- DISTANCE 0 -> MCS 28 -> Itbs 26 (from table 7.1.7.2.1-1 of 36.213)
75  // 1 user -> 25 PRB at Itbs 26 -> 2292 -> 2292000 bytes/sec
76  // 3 users -> 8 PRB at Itbs 26 -> 749 -> 749000 bytes/sec
77  // 6 users -> 4 PRB at Itbs 26 -> 373 -> 373000 bytes/sec
78  // after the patch enforcing min 3 PRBs per UE:
79  // 12 users -> 3 PRB at Itbs 26 -> 277 bytes * 8/12 UE/TTI -> 184670 bytes/sec
80  // 15 users -> 3 PRB at Itbs 26 -> 277 bytes * 8/15 UE/TTI -> 147730 bytes/sec
81  AddTestCase (new LenaPfFfMacSchedulerTestCase1 (1,0,2196000,2292000,errorModel), TestCase::EXTENSIVE);
82  AddTestCase (new LenaPfFfMacSchedulerTestCase1 (3,0,732000,749000,errorModel), TestCase::EXTENSIVE);
83  AddTestCase (new LenaPfFfMacSchedulerTestCase1 (6,0,366000,373000,errorModel), TestCase::EXTENSIVE);
84  AddTestCase (new LenaPfFfMacSchedulerTestCase1 (12,0,183000,184670,errorModel), TestCase::EXTENSIVE);
85  AddTestCase (new LenaPfFfMacSchedulerTestCase1 (15,0,146400,147730,errorModel), TestCase::EXTENSIVE);
86 
87 
88  // DOWNLINK - DISTANCE 4800 -> MCS 22 -> Itbs 20 (from table 7.1.7.2.1-1 of 36.213)
89  // 1 user -> 24 PRB at Itbs 15 -> 1383 -> 1383000 bytes/sec
90  // 3 users -> 1383000 among 3 users -> 461000 bytes/sec
91  // 6 users -> 1383000 among 6 users -> 230500 bytes/sec
92  // 12 users -> 1383000 among 12 users -> 115250 bytes/sec
93  // 15 users -> 1383000 among 15 users -> 92200 bytes/sec
94  // UPLINK - DISTANCE 4800 -> MCS 14 -> Itbs 13 (from table 7.1.7.2.1-1 of 36.213)
95  // 1 user -> 25 PRB at Itbs 13 -> 807 -> 807000 bytes/sec
96  // 3 users -> 8 PRB at Itbs 13 -> 253 -> 253000 bytes/sec
97  // 6 users -> 4 PRB at Itbs 13 -> 125 -> 125000 bytes/sec
98  // after the patch enforcing min 3 PRBs per UE:
99  // 12 users -> 3 PRB at Itbs 13 -> 93 bytes * 8/12 UE/TTI -> 62000 bytes/sec
100  // 15 users -> 3 PRB at Itbs 13 -> 93 bytes * 8/15 UE/TTI -> 49600 bytes/sec
101  AddTestCase (new LenaPfFfMacSchedulerTestCase1 (1,4800,1383000,807000,errorModel), TestCase::EXTENSIVE);
102  AddTestCase (new LenaPfFfMacSchedulerTestCase1 (3,4800,461000,253000,errorModel), TestCase::EXTENSIVE);
103  AddTestCase (new LenaPfFfMacSchedulerTestCase1 (6,4800,230500,125000,errorModel), TestCase::EXTENSIVE);
104  AddTestCase (new LenaPfFfMacSchedulerTestCase1 (12,4800,115250,62000,errorModel), TestCase::EXTENSIVE);
105  AddTestCase (new LenaPfFfMacSchedulerTestCase1 (15,4800,92200,49600,errorModel), TestCase::EXTENSIVE);
106 
107  // DOWNLINK - DISTANCE 6000 -> MCS 20 -> Itbs 18 (from table 7.1.7.2.1-1 of 36.213)
108  // 1 user -> 24 PRB at Itbs 20 -> 1191 -> 1191000 bytes/sec
109  // 3 users -> 1191000 among 3 users -> 397000 bytes/sec
110  // 6 users -> 1191000 among 6 users -> 198500 bytes/sec
111  // 12 users -> 1191000 among 12 users -> 99250 bytes/sec
112  // 15 users -> 1191000 among 15 users -> 79400 bytes/sec
113  // UPLINK - DISTANCE 6000 -> MCS 12 -> Itbs 11 (from table 7.1.7.2.1-1 of 36.213)
114  // 1 user -> 25 PRB at Itbs 11 -> 621 -> 621000 bytes/sec
115  // 3 users -> 8 PRB at Itbs 11 -> 201 -> 201000 bytes/sec
116  // 6 users -> 4 PRB at Itbs 11 -> 97 -> 97000 bytes/sec
117  // after the patch enforcing min 3 PRBs per UE:
118  // 12 users -> 3 PRB at Itbs 11 -> 73 bytes * 8/12 UE/TTI -> 48667 bytes/sec
119  // 15 users -> 3 PRB at Itbs 11 -> 73 bytes * 8/15 UE/TTI -> 38993 bytes/sec
120  AddTestCase (new LenaPfFfMacSchedulerTestCase1 (1,6000,1191000,621000,errorModel), TestCase::EXTENSIVE);
121  AddTestCase (new LenaPfFfMacSchedulerTestCase1 (3,6000,397000,201000,errorModel), TestCase::EXTENSIVE);
122  AddTestCase (new LenaPfFfMacSchedulerTestCase1 (6,6000,198500,97000,errorModel), TestCase::EXTENSIVE);
123  AddTestCase (new LenaPfFfMacSchedulerTestCase1 (12,6000,99250,48667,errorModel), TestCase::EXTENSIVE);
124  AddTestCase (new LenaPfFfMacSchedulerTestCase1 (15,6000,79400,38993,errorModel), TestCase::EXTENSIVE);
125 
126  // DOWNLINK - DISTANCE 10000 -> MCS 14 -> Itbs 13 (from table 7.1.7.2.1-1 of 36.213)
127  // 1 user -> 24 PRB at Itbs 13 -> 871 -> 775000 bytes/sec
128  // 3 users -> 775000 among 3 users -> 258333 bytes/sec
129  // 6 users -> 775000 among 6 users -> 129167 bytes/sec
130  // 12 users -> 775000 among 12 users -> 64583 bytes/sec
131  // 15 users -> 775000 among 15 users -> 51667 bytes/sec
132  // UPLINK - DISTANCE 10000 -> MCS 8 -> Itbs 8 (from table 7.1.7.2.1-1 of 36.213)
133  // 1 user -> 24 PRB at Itbs 8 -> 437 -> 437000 bytes/sec
134  // 3 users -> 8 PRB at Itbs 8 -> 137 -> 137000 bytes/sec
135  // 6 users -> 4 PRB at Itbs 8 -> 67 -> 67000 bytes/sec
136  // after the patch enforcing min 3 PRBs per UE:
137  // 12 users -> 3 PRB at Itbs 8 -> 49 bytes * 8/12 UE/TTI -> 32667 bytes/sec
138  // 15 users -> 3 PRB at Itbs 8 -> 49 bytes * 8/15 UE/TTI -> 26133 bytes/sec
139  AddTestCase (new LenaPfFfMacSchedulerTestCase1 (1,10000,775000,437000,errorModel), TestCase::EXTENSIVE);
140  AddTestCase (new LenaPfFfMacSchedulerTestCase1 (3,10000,258333,137000,errorModel), TestCase::EXTENSIVE);
141  AddTestCase (new LenaPfFfMacSchedulerTestCase1 (6,10000,129167,67000,errorModel), TestCase::EXTENSIVE);
142  AddTestCase (new LenaPfFfMacSchedulerTestCase1 (12,10000,64583,32667,errorModel), TestCase::EXTENSIVE);
143  AddTestCase (new LenaPfFfMacSchedulerTestCase1 (15,10000,51667,26133,errorModel), TestCase::EXTENSIVE);
144 
145  // DONWLINK - DISTANCE 20000 -> MCS 8 -> Itbs 8 (from table 7.1.7.2.1-1 of 36.213)
146  // 1 user -> 24 PRB at Itbs 8 -> 421 -> 421000 bytes/sec
147  // 3 users -> 421000 among 3 users -> 140333 bytes/sec
148  // 6 users -> 421000 among 6 users -> 70167 bytes/sec
149  // 12 users -> 421000 among 12 users -> 35083 bytes/sec
150  // 15 users -> 421000 among 15 users -> 28067 bytes/sec
151  // UPLINK - DISTANCE 20000 -> MCS 2 -> Itbs 2 (from table 7.1.7.2.1-1 of 36.213)
152  // 1 user -> 25 PRB at Itbs 2 -> 233 -> 137000 bytes/sec
153  // 3 users -> 8 PRB at Itbs 2 -> 69 -> 41000 bytes/sec
154  // 6 users -> 4 PRB at Itbs 2 -> 32 -> 22000 bytes/sec
155  // after the patch enforcing min 3 PRBs per UE:
156  // 12 users -> 3 PRB at Itbs 2 -> 26 bytes * 8/12 UE/TTI -> 12000 bytes/sec
157  // 15 users -> 3 PRB at Itbs 2 -> 26 bytes * 8/15 UE/TTI -> 9600 bytes/sec
158  AddTestCase (new LenaPfFfMacSchedulerTestCase1 (1,20000,421000,137000,errorModel), TestCase::EXTENSIVE);
159  AddTestCase (new LenaPfFfMacSchedulerTestCase1 (3,20000,140333,41000,errorModel), TestCase::EXTENSIVE);
160  AddTestCase (new LenaPfFfMacSchedulerTestCase1 (6,20000,70167,22000,errorModel), TestCase::EXTENSIVE);
161  AddTestCase (new LenaPfFfMacSchedulerTestCase1 (12,20000,35083,12000,errorModel), TestCase::EXTENSIVE);
162  AddTestCase (new LenaPfFfMacSchedulerTestCase1 (15,20000,28067,9600,errorModel), TestCase::EXTENSIVE);
163 
164  // DOWNLINK - DISTANCE 100000 -> CQI == 0 -> out of range -> 0 bytes/sec
165  // UPLINK - DISTANCE 100000 -> CQI == 0 -> out of range -> 0 bytes/sec
166  AddTestCase (new LenaPfFfMacSchedulerTestCase1 (1,100000,0,0,errorModel), TestCase::QUICK);
167 
168 
169  // Test Case 2: fairness check
170 
171  std::vector<double> dist;
172  dist.push_back (0); // User 0 distance --> MCS 28
173  dist.push_back (4800); // User 1 distance --> MCS 22
174  dist.push_back (6000); // User 2 distance --> MCS 16
175  dist.push_back (10000); // User 3 distance --> MCS 8
176  dist.push_back (20000); // User 4 distance --> MCS 8
177  std::vector<uint32_t> estThrPfDl;
178  estThrPfDl.push_back (90000); // User 0 estimated TTI throughput from PF
179  estThrPfDl.push_back (37000); // User 1 estimated TTI throughput from PF
180  estThrPfDl.push_back (37000); // User 2 estimated TTI throughput from PF
181  estThrPfDl.push_back (17400); // User 3 estimated TTI throughput from PF
182  estThrPfDl.push_back (17400); // User 4 estimated TTI throughput from PF
183  std::vector<uint32_t> estThrPfUl;
184  estThrPfUl.push_back (469000); // User 0 estimated TTI throughput from PF
185  estThrPfUl.push_back (157000); // User 1 estimated TTI throughput from PF
186  estThrPfUl.push_back (125000); // User 2 estimated TTI throughput from PF
187  estThrPfUl.push_back (85000); // User 3 estimated TTI throughput from PF
188  estThrPfUl.push_back (26000); // User 4 estimated TTI throughput from PF
189  AddTestCase (new LenaPfFfMacSchedulerTestCase2 (dist, estThrPfDl, estThrPfUl,errorModel), TestCase::QUICK);
190 
191 
192 }
193 
195 
196 
197 // --------------- T E S T - C A S E # 1 ------------------------------
198 
199 
200 std::string
202 {
203  std::ostringstream oss;
204  oss << nUser << " UEs, distance " << dist << " m";
205  return oss.str ();
206 }
207 
208 LenaPfFfMacSchedulerTestCase1::LenaPfFfMacSchedulerTestCase1 (uint16_t nUser, double dist, double thrRefDl, double thrRefUl, bool errorModelEnabled)
209  : TestCase (BuildNameString (nUser, dist)),
210  m_nUser (nUser),
211  m_dist (dist),
212  m_thrRefDl (thrRefDl),
213  m_thrRefUl (thrRefUl),
214  m_errorModelEnabled (errorModelEnabled)
215 {
216 }
217 
219 {
220 }
221 
222 void
224 {
225  NS_LOG_FUNCTION (this << m_nUser << m_dist);
226 
227  if (!m_errorModelEnabled)
228  {
229  Config::SetDefault ("ns3::LteSpectrumPhy::CtrlErrorModelEnabled", BooleanValue (false));
230  Config::SetDefault ("ns3::LteSpectrumPhy::DataErrorModelEnabled", BooleanValue (false));
231  }
232  Config::SetDefault ("ns3::LteHelper::UseIdealRrc", BooleanValue (true));
233  Config::SetDefault ("ns3::MacStatsCalculator::DlOutputFilename", StringValue (CreateTempDirFilename ("DlMacStats.txt")));
234  Config::SetDefault ("ns3::MacStatsCalculator::UlOutputFilename", StringValue (CreateTempDirFilename ("UlMacStats.txt")));
235  Config::SetDefault ("ns3::RadioBearerStatsCalculator::DlRlcOutputFilename", StringValue (CreateTempDirFilename ("DlRlcStats.txt")));
236  Config::SetDefault ("ns3::RadioBearerStatsCalculator::UlRlcOutputFilename", StringValue (CreateTempDirFilename ("UlRlcStats.txt")));
237 
243  Ptr<LteHelper> lteHelper = CreateObject<LteHelper> ();
244  lteHelper->SetAttribute ("PathlossModel", StringValue ("ns3::FriisSpectrumPropagationLossModel"));
245 
246  // Create Nodes: eNodeB and UE
247  NodeContainer enbNodes;
248  NodeContainer ueNodes;
249  enbNodes.Create (1);
250  ueNodes.Create (m_nUser);
251 
252  // Install Mobility Model
254  mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel");
255  mobility.Install (enbNodes);
256  mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel");
257  mobility.Install (ueNodes);
258 
259  // Create Devices and install them in the Nodes (eNB and UE)
260  NetDeviceContainer enbDevs;
261  NetDeviceContainer ueDevs;
262  lteHelper->SetSchedulerType ("ns3::PfFfMacScheduler");
263  lteHelper->SetSchedulerAttribute ("UlCqiFilter", EnumValue (FfMacScheduler::SRS_UL_CQI));
264  enbDevs = lteHelper->InstallEnbDevice (enbNodes);
265  ueDevs = lteHelper->InstallUeDevice (ueNodes);
266 
267  // Attach a UE to a eNB
268  lteHelper->Attach (ueDevs, enbDevs.Get (0));
269 
270  // Activate an EPS bearer
271  enum EpsBearer::Qci q = EpsBearer::GBR_CONV_VOICE;
272  EpsBearer bearer (q);
273  lteHelper->ActivateDataRadioBearer (ueDevs, bearer);
274 
275 
276  Ptr<LteEnbNetDevice> lteEnbDev = enbDevs.Get (0)->GetObject<LteEnbNetDevice> ();
277  Ptr<LteEnbPhy> enbPhy = lteEnbDev->GetPhy ();
278  enbPhy->SetAttribute ("TxPower", DoubleValue (30.0));
279  enbPhy->SetAttribute ("NoiseFigure", DoubleValue (5.0));
280 
281  // Set UEs' position and power
282  for (int i = 0; i < m_nUser; i++)
283  {
285  mm->SetPosition (Vector (m_dist, 0.0, 0.0));
286  Ptr<LteUeNetDevice> lteUeDev = ueDevs.Get (i)->GetObject<LteUeNetDevice> ();
287  Ptr<LteUePhy> uePhy = lteUeDev->GetPhy ();
288  uePhy->SetAttribute ("TxPower", DoubleValue (23.0));
289  uePhy->SetAttribute ("NoiseFigure", DoubleValue (9.0));
290  }
291 
292 
293  double statsStartTime = 0.300; // need to allow for RRC connection establishment + SRS
294  double statsDuration = 0.6;
295  double tolerance = 0.1;
296  Simulator::Stop (Seconds (statsStartTime + statsDuration - 0.000001));
297 
298  lteHelper->EnableMacTraces ();
299  lteHelper->EnableRlcTraces ();
300  Ptr<RadioBearerStatsCalculator> rlcStats = lteHelper->GetRlcStats ();
301  rlcStats->SetAttribute ("StartTime", TimeValue (Seconds (statsStartTime)));
302  rlcStats->SetAttribute ("EpochDuration", TimeValue (Seconds (statsDuration)));
303 
304 
305  Simulator::Run ();
306 
310  NS_LOG_INFO ("DL - Test with " << m_nUser << " user(s) at distance " << m_dist);
311  std::vector <uint64_t> dlDataRxed;
312  for (int i = 0; i < m_nUser; i++)
313  {
314  // get the imsi
315  uint64_t imsi = ueDevs.Get (i)->GetObject<LteUeNetDevice> ()->GetImsi ();
316  uint8_t lcId = 3;
317  dlDataRxed.push_back (rlcStats->GetDlRxData (imsi, lcId));
318  NS_LOG_INFO ("\tUser " << i << " imsi " << imsi << " bytes rxed " << (double)dlDataRxed.at (i) << " thr " << (double)dlDataRxed.at (i) / statsDuration << " ref " << m_thrRefDl);
319  }
326  for (int i = 0; i < m_nUser; i++)
327  {
328  NS_TEST_ASSERT_MSG_EQ_TOL ((double)dlDataRxed.at (i) / statsDuration, m_thrRefDl, m_thrRefDl * tolerance, " Unfair Throughput!");
329  }
330 
334  NS_LOG_INFO ("UL - Test with " << m_nUser << " user(s) at distance " << m_dist);
335  std::vector <uint64_t> ulDataRxed;
336  for (int i = 0; i < m_nUser; i++)
337  {
338  // get the imsi
339  uint64_t imsi = ueDevs.Get (i)->GetObject<LteUeNetDevice> ()->GetImsi ();
340  // get the lcId
341  uint8_t lcId = 3;
342  ulDataRxed.push_back (rlcStats->GetUlRxData (imsi, lcId));
343  NS_LOG_INFO ("\tUser " << i << " imsi " << imsi << " bytes rxed " << (double)ulDataRxed.at (i) << " thr " << (double)ulDataRxed.at (i) / statsDuration << " ref " << m_thrRefUl);
344  }
351  for (int i = 0; i < m_nUser; i++)
352  {
353  NS_TEST_ASSERT_MSG_EQ_TOL ((double)ulDataRxed.at (i) / statsDuration, m_thrRefUl, m_thrRefUl * tolerance, " Unfair Throughput!");
354  }
355  Simulator::Destroy ();
356 
357 }
358 
359 
360 
361 // --------------- T E S T - C A S E # 2 ------------------------------
362 
363 
364 std::string
365 LenaPfFfMacSchedulerTestCase2::BuildNameString (uint16_t nUser, std::vector<double> dist)
366 {
367  std::ostringstream oss;
368  oss << "distances (m) = [ " ;
369  for (std::vector<double>::iterator it = dist.begin (); it != dist.end (); ++it)
370  {
371  oss << *it << " ";
372  }
373  oss << "]";
374  return oss.str ();
375 }
376 
377 
378 LenaPfFfMacSchedulerTestCase2::LenaPfFfMacSchedulerTestCase2 (std::vector<double> dist, std::vector<uint32_t> estThrPfDl, std::vector<uint32_t> estThrPfUl, bool errorModelEnabled)
379  : TestCase (BuildNameString (dist.size (), dist)),
380  m_nUser (dist.size ()),
381  m_dist (dist),
382  m_estThrPfDl (estThrPfDl),
383  m_estThrPfUl (estThrPfUl),
384  m_errorModelEnabled (errorModelEnabled)
385 {
386 }
387 
389 {
390 }
391 
392 void
394 {
395  NS_LOG_FUNCTION (this);
396  if (!m_errorModelEnabled)
397  {
398  Config::SetDefault ("ns3::LteSpectrumPhy::CtrlErrorModelEnabled", BooleanValue (false));
399  Config::SetDefault ("ns3::LteSpectrumPhy::DataErrorModelEnabled", BooleanValue (false));
400  }
401  Config::SetDefault ("ns3::LteHelper::UseIdealRrc", BooleanValue (false));
402  Config::SetDefault ("ns3::MacStatsCalculator::DlOutputFilename", StringValue (CreateTempDirFilename ("DlMacStats.txt")));
403  Config::SetDefault ("ns3::MacStatsCalculator::UlOutputFilename", StringValue (CreateTempDirFilename ("UlMacStats.txt")));
404  Config::SetDefault ("ns3::RadioBearerStatsCalculator::DlRlcOutputFilename", StringValue (CreateTempDirFilename ("DlRlcStats.txt")));
405  Config::SetDefault ("ns3::RadioBearerStatsCalculator::UlRlcOutputFilename", StringValue (CreateTempDirFilename ("UlRlcStats.txt")));
406 
411  Ptr<LteHelper> lteHelper = CreateObject<LteHelper> ();
412 
413  lteHelper->SetAttribute ("PathlossModel", StringValue ("ns3::FriisSpectrumPropagationLossModel"));
414 
415  // Create Nodes: eNodeB and UE
416  NodeContainer enbNodes;
417  NodeContainer ueNodes;
418  enbNodes.Create (1);
419  ueNodes.Create (m_nUser);
420 
421  // Install Mobility Model
423  mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel");
424  mobility.Install (enbNodes);
425  mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel");
426  mobility.Install (ueNodes);
427 
428  // Create Devices and install them in the Nodes (eNB and UE)
429  NetDeviceContainer enbDevs;
430  NetDeviceContainer ueDevs;
431  lteHelper->SetSchedulerType ("ns3::PfFfMacScheduler");
432  lteHelper->SetSchedulerAttribute ("UlCqiFilter", EnumValue (FfMacScheduler::SRS_UL_CQI));
433  enbDevs = lteHelper->InstallEnbDevice (enbNodes);
434  ueDevs = lteHelper->InstallUeDevice (ueNodes);
435 
436  // Attach a UE to a eNB
437  lteHelper->Attach (ueDevs, enbDevs.Get (0));
438 
439  // Activate an EPS bearer
440  enum EpsBearer::Qci q = EpsBearer::GBR_CONV_VOICE;
441  EpsBearer bearer (q);
442  lteHelper->ActivateDataRadioBearer (ueDevs, bearer);
443 
444  Ptr<LteEnbNetDevice> lteEnbDev = enbDevs.Get (0)->GetObject<LteEnbNetDevice> ();
445  Ptr<LteEnbPhy> enbPhy = lteEnbDev->GetPhy ();
446  enbPhy->SetAttribute ("TxPower", DoubleValue (30.0));
447  enbPhy->SetAttribute ("NoiseFigure", DoubleValue (5.0));
448 
449  // Set UEs' position and power
450  for (int i = 0; i < m_nUser; i++)
451  {
453  mm->SetPosition (Vector (m_dist.at (i), 0.0, 0.0));
454  Ptr<LteUeNetDevice> lteUeDev = ueDevs.Get (i)->GetObject<LteUeNetDevice> ();
455  Ptr<LteUePhy> uePhy = lteUeDev->GetPhy ();
456  uePhy->SetAttribute ("TxPower", DoubleValue (23.0));
457  uePhy->SetAttribute ("NoiseFigure", DoubleValue (9.0));
458  }
459 
460  double statsStartTime = 0.300; // need to allow for RRC connection establishment + SRS
461  double statsDuration = 0.4;
462  double tolerance = 0.1;
463  Simulator::Stop (Seconds (statsStartTime + statsDuration - 0.000001));
464 
465  lteHelper->EnableRlcTraces ();
466  Ptr<RadioBearerStatsCalculator> rlcStats = lteHelper->GetRlcStats ();
467  rlcStats->SetAttribute ("StartTime", TimeValue (Seconds (statsStartTime)));
468  rlcStats->SetAttribute ("EpochDuration", TimeValue (Seconds (statsDuration)));
469 
470 
471  Simulator::Run ();
472 
473  NS_LOG_INFO ("DL - Test with " << m_nUser << " user(s)");
474  std::vector <uint64_t> dlDataRxed;
475  double totalData = 0;
476  double totalEstThrPf = 0;
477  for (int i = 0; i < m_nUser; i++)
478  {
479  // get the imsi
480  uint64_t imsi = ueDevs.Get (i)->GetObject<LteUeNetDevice> ()->GetImsi ();
481  // get the lcId
482  uint8_t lcId = 3;
483  dlDataRxed.push_back (rlcStats->GetDlRxData (imsi, lcId));
484  totalData += (double)dlDataRxed.at (i);
485  NS_LOG_INFO ("\tUser " << i << " dist " << m_dist.at (i) << " imsi " << imsi << " bytes rxed " << (double)dlDataRxed.at (i) << " thr " << (double)dlDataRxed.at (i) / statsDuration);
486  totalEstThrPf += m_estThrPfDl.at (i);
487  }
488 
494  for (int i = 0; i < m_nUser; i++)
495  {
496  double thrRatio = (double)dlDataRxed.at (i) / totalData;
497  double estThrRatio = (double)m_estThrPfDl.at (i) / totalEstThrPf;
498  NS_LOG_INFO ("\tUser " << i << " thrRatio " << thrRatio << " estThrRatio " << estThrRatio);
499  NS_TEST_ASSERT_MSG_EQ_TOL (estThrRatio, thrRatio, tolerance, " Unfair Throughput!");
500  }
501 
506  NS_LOG_INFO ("UL - Test with " << m_nUser);
507  std::vector <uint64_t> ulDataRxed;
508  for (int i = 0; i < m_nUser; i++)
509  {
510  // get the imsi
511  uint64_t imsi = ueDevs.Get (i)->GetObject<LteUeNetDevice> ()->GetImsi ();
512  // get the lcId
513  uint8_t lcId = 3;
514  ulDataRxed.push_back (rlcStats->GetUlRxData (imsi, lcId));
515  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_estThrPfUl.at (i));
516  NS_TEST_ASSERT_MSG_EQ_TOL ((double)ulDataRxed.at (i) / statsDuration, (double)m_estThrPfUl.at (i), (double)m_estThrPfUl.at (i) * tolerance, " Unfair Throughput!");
517  }
518  Simulator::Destroy ();
519 
520 }
Ptr< NetDevice > Get(uint32_t i) const
Get the Ptr<NetDevice> stored in this container at a given index.
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by "...
AttributeValue implementation for Boolean.
Definition: boolean.h:36
NetDeviceContainer InstallEnbDevice(NodeContainer c)
Create a set of eNodeB devices.
Definition: lte-helper.cc:474
Hold variables of type string.
Definition: string.h:41
A suite of tests to run.
Definition: test.h:1342
Mobility model for which the current position does not change once it has been set and until it is se...
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:961
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:204
void EnableRlcTraces(void)
Enable trace sinks for RLC layer.
Definition: lte-helper.cc:1436
#define NS_LOG_INFO(msg)
Use NS_LOG to output a message of level LOG_INFO.
Definition: log.h:280
static LenaTestPfFfMacSchedulerSuite lenaTestPfFfMacSchedulerSuite
encapsulates test code
Definition: test.h:1155
LenaPfFfMacSchedulerTestCase2(std::vector< double > dist, std::vector< uint32_t > estThrPfDl, std::vector< uint32_t > estThrPfUl, bool errorModelEnabled)
Constructor.
void ActivateDataRadioBearer(NetDeviceContainer ueDevices, EpsBearer bearer)
Activate a Data Radio Bearer on a given UE devices (for LTE-only simulation).
Definition: lte-helper.cc:1314
virtual void DoRun(void)
Implementation to actually run this TestCase.
void SetSchedulerType(std::string type)
Set the type of scheduler to be used by eNodeB devices.
Definition: lte-helper.cc:279
mobility
Definition: third.py:108
double m_dist
the distance between nodes
Hold variables of type enum.
Definition: enum.h:54
bool m_errorModelEnabled
indicates whether the error model is enabled
AttributeValue implementation for Time.
Definition: nstime.h:1124
void AddTestCase(TestCase *testCase, TestDuration duration=QUICK)
Add an individual child TestCase to this test suite.
Definition: test.cc:299
uint64_t GetDlRxData(uint64_t imsi, uint8_t lcid)
Gets the number of received downlink data bytes.
void SetSchedulerAttribute(std::string n, const AttributeValue &v)
Set an attribute for the scheduler to be created.
Definition: lte-helper.cc:293
holds a vector of ns3::NetDevice pointers
bool m_errorModelEnabled
whether error model is enabled
Ptr< LteEnbPhy > GetPhy(void) const
#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:380
std::vector< uint32_t > m_estThrPfUl
the estimated UL throughput
std::vector< double > m_dist
the distance between nodes
Ptr< T > GetObject(void) const
Get a pointer to the requested aggregated Object.
Definition: object.h:459
Every class exported by the ns3 library is enclosed in the ns3 namespace.
static std::string BuildNameString(uint16_t nUser, double dist)
Build name string.
keep track of a set of node pointers.
Ptr< LteUePhy > GetPhy(void) const
Get the Phy.
This class contains the specification of EPS Bearers.
Definition: eps-bearer.h:91
void SetPosition(const Vector &position)
Ptr< RadioBearerStatsCalculator > GetRlcStats(void)
Definition: lte-helper.cc:1573
NetDeviceContainer InstallUeDevice(NodeContainer c)
Create a set of UE devices.
Definition: lte-helper.cc:489
static std::string BuildNameString(uint16_t nUser, std::vector< double > dist)
Builds the test name string based on provided parameter values.
Helper class used to assign positions and mobility models to nodes.
uint64_t GetUlRxData(uint64_t imsi, uint8_t lcid)
Gets the number of received uplink data bytes.
virtual void DoRun(void)
Implementation to actually run this TestCase.
Lena PfFf Mac Scheduler Test Case 2.
std::string CreateTempDirFilename(std::string filename)
Construct the full path to a file in a temporary directory.
Definition: test.cc:430
double m_thrRefUl
the UL throughput reference
Time Seconds(double value)
Construct a Time in the indicated unit.
Definition: nstime.h:1062
void SetDefault(std::string name, const AttributeValue &value)
Definition: config.cc:810
double m_thrRefDl
the DL throughput reference
Ptr< Node > Get(uint32_t i) const
Get the Ptr<Node> stored in this container at a given index.
std::vector< uint32_t > m_estThrPfDl
the estimated DL throughput
Qci
QoS Class Indicator.
Definition: eps-bearer.h:106
void Create(uint32_t n)
Create n nodes and append pointers to them to the end of this NodeContainer.
void EnableMacTraces(void)
Enable trace sinks for MAC layer.
Definition: lte-helper.cc:1530
This class can be used to hold variables of floating point type such as &#39;double&#39; or &#39;float&#39;...
Definition: double.h:41
void SetAttribute(std::string name, const AttributeValue &value)
Set a single attribute, raising fatal errors if unsuccessful.
Definition: object-base.cc:185
The eNodeB device implementation.
This system test program creates different test cases with a single eNB and several UEs...
LenaPfFfMacSchedulerTestCase1(uint16_t nUser, double dist, double thrRefDl, double thrRefUl, bool errorModelEnabled)
Constructor.
The LteUeNetDevice class implements the UE net device.