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/eps-bearer.h>
37 #include <ns3/node-container.h>
38 #include <ns3/mobility-helper.h>
39 #include <ns3/net-device-container.h>
40 #include <ns3/lte-ue-net-device.h>
41 #include <ns3/lte-enb-net-device.h>
42 #include <ns3/lte-ue-rrc.h>
43 #include <ns3/lte-helper.h>
44 #include "ns3/string.h"
45 #include "ns3/double.h"
46 #include <ns3/lte-enb-phy.h>
47 #include <ns3/lte-ue-phy.h>
48 #include <ns3/boolean.h>
49 #include <ns3/enum.h>
50 
52 
53 using namespace ns3;
54 
55 NS_LOG_COMPONENT_DEFINE ("LenaTestPfFfMacScheduler");
56 
58  : TestSuite ("lte-pf-ff-mac-scheduler", SYSTEM)
59 {
60  NS_LOG_INFO ("creating LenaTestPfFfMacSchedulerSuite");
61 
62  bool errorModel = false;
63 
64 
65  //Test Case 1: AMC works in PF
66 
67  // DOWNLINK - DISTANCE 0 -> MCS 28 -> Itbs 26 (from table 7.1.7.2.1-1 of 36.213)
68  // 1 user -> 24 PRB at Itbs 26 -> 2196 -> 2196000 bytes/sec
69  // 3 users -> 2196000 among 3 users -> 732000 bytes/sec
70  // 6 users -> 2196000 among 6 users -> 366000 bytes/sec
71  // 12 users -> 2196000 among 12 users -> 183000 bytes/sec
72  // 15 users -> 2196000 among 15 users -> 146400 bytes/sec
73  // UPLINK- DISTANCE 0 -> MCS 28 -> Itbs 26 (from table 7.1.7.2.1-1 of 36.213)
74  // 1 user -> 25 PRB at Itbs 26 -> 2292 -> 2292000 bytes/sec
75  // 3 users -> 8 PRB at Itbs 26 -> 749 -> 749000 bytes/sec
76  // 6 users -> 4 PRB at Itbs 26 -> 373 -> 373000 bytes/sec
77  // after the patch enforcing min 3 PRBs per UE:
78  // 12 users -> 3 PRB at Itbs 26 -> 277 bytes * 8/12 UE/TTI -> 184670 bytes/sec
79  // 15 users -> 3 PRB at Itbs 26 -> 277 bytes * 8/15 UE/TTI -> 147730 bytes/sec
80  AddTestCase (new LenaPfFfMacSchedulerTestCase1 (1,0,2196000,2292000,errorModel), TestCase::EXTENSIVE);
81  AddTestCase (new LenaPfFfMacSchedulerTestCase1 (3,0,732000,749000,errorModel), TestCase::EXTENSIVE);
82  AddTestCase (new LenaPfFfMacSchedulerTestCase1 (6,0,366000,373000,errorModel), TestCase::EXTENSIVE);
83  AddTestCase (new LenaPfFfMacSchedulerTestCase1 (12,0,183000,184670,errorModel), TestCase::EXTENSIVE);
84  AddTestCase (new LenaPfFfMacSchedulerTestCase1 (15,0,146400,147730,errorModel), TestCase::EXTENSIVE);
85 
86 
87  // DOWNLINK - DISTANCE 4800 -> MCS 22 -> Itbs 20 (from table 7.1.7.2.1-1 of 36.213)
88  // 1 user -> 24 PRB at Itbs 15 -> 1383 -> 1383000 bytes/sec
89  // 3 users -> 1383000 among 3 users -> 461000 bytes/sec
90  // 6 users -> 1383000 among 6 users -> 230500 bytes/sec
91  // 12 users -> 1383000 among 12 users -> 115250 bytes/sec
92  // 15 users -> 1383000 among 15 users -> 92200 bytes/sec
93  // UPLINK - DISTANCE 4800 -> MCS 14 -> Itbs 13 (from table 7.1.7.2.1-1 of 36.213)
94  // 1 user -> 25 PRB at Itbs 13 -> 807 -> 807000 bytes/sec
95  // 3 users -> 8 PRB at Itbs 13 -> 253 -> 253000 bytes/sec
96  // 6 users -> 4 PRB at Itbs 13 -> 125 -> 125000 bytes/sec
97  // after the patch enforcing min 3 PRBs per UE:
98  // 12 users -> 3 PRB at Itbs 13 -> 93 bytes * 8/12 UE/TTI -> 62000 bytes/sec
99  // 15 users -> 3 PRB at Itbs 13 -> 93 bytes * 8/15 UE/TTI -> 49600 bytes/sec
100  AddTestCase (new LenaPfFfMacSchedulerTestCase1 (1,4800,1383000,807000,errorModel), TestCase::EXTENSIVE);
101  AddTestCase (new LenaPfFfMacSchedulerTestCase1 (3,4800,461000,253000,errorModel), TestCase::EXTENSIVE);
102  AddTestCase (new LenaPfFfMacSchedulerTestCase1 (6,4800,230500,125000,errorModel), TestCase::EXTENSIVE);
103  AddTestCase (new LenaPfFfMacSchedulerTestCase1 (12,4800,115250,62000,errorModel), TestCase::EXTENSIVE);
104  AddTestCase (new LenaPfFfMacSchedulerTestCase1 (15,4800,92200,49600,errorModel), TestCase::EXTENSIVE);
105 
106  // DOWNLINK - DISTANCE 6000 -> MCS 20 -> Itbs 18 (from table 7.1.7.2.1-1 of 36.213)
107  // 1 user -> 24 PRB at Itbs 20 -> 1191 -> 1191000 bytes/sec
108  // 3 users -> 1191000 among 3 users -> 397000 bytes/sec
109  // 6 users -> 1191000 among 6 users -> 198500 bytes/sec
110  // 12 users -> 1191000 among 12 users -> 99250 bytes/sec
111  // 15 users -> 1191000 among 15 users -> 79400 bytes/sec
112  // UPLINK - DISTANCE 6000 -> MCS 12 -> Itbs 11 (from table 7.1.7.2.1-1 of 36.213)
113  // 1 user -> 25 PRB at Itbs 11 -> 621 -> 621000 bytes/sec
114  // 3 users -> 8 PRB at Itbs 11 -> 201 -> 201000 bytes/sec
115  // 6 users -> 4 PRB at Itbs 11 -> 97 -> 97000 bytes/sec
116  // after the patch enforcing min 3 PRBs per UE:
117  // 12 users -> 3 PRB at Itbs 11 -> 73 bytes * 8/12 UE/TTI -> 48667 bytes/sec
118  // 15 users -> 3 PRB at Itbs 11 -> 73 bytes * 8/15 UE/TTI -> 38993 bytes/sec
119  AddTestCase (new LenaPfFfMacSchedulerTestCase1 (1,6000,1191000,621000,errorModel), TestCase::EXTENSIVE);
120  AddTestCase (new LenaPfFfMacSchedulerTestCase1 (3,6000,397000,201000,errorModel), TestCase::EXTENSIVE);
121  AddTestCase (new LenaPfFfMacSchedulerTestCase1 (6,6000,198500,97000,errorModel), TestCase::EXTENSIVE);
122  AddTestCase (new LenaPfFfMacSchedulerTestCase1 (12,6000,99250,48667,errorModel), TestCase::EXTENSIVE);
123  AddTestCase (new LenaPfFfMacSchedulerTestCase1 (15,6000,79400,38993,errorModel), TestCase::EXTENSIVE);
124 
125  // DOWNLINK - DISTANCE 10000 -> MCS 14 -> Itbs 13 (from table 7.1.7.2.1-1 of 36.213)
126  // 1 user -> 24 PRB at Itbs 13 -> 871 -> 775000 bytes/sec
127  // 3 users -> 775000 among 3 users -> 258333 bytes/sec
128  // 6 users -> 775000 among 6 users -> 129167 bytes/sec
129  // 12 users -> 775000 among 12 users -> 64583 bytes/sec
130  // 15 users -> 775000 among 15 users -> 51667 bytes/sec
131  // UPLINK - DISTANCE 10000 -> MCS 8 -> Itbs 8 (from table 7.1.7.2.1-1 of 36.213)
132  // 1 user -> 24 PRB at Itbs 8 -> 437 -> 437000 bytes/sec
133  // 3 users -> 8 PRB at Itbs 8 -> 137 -> 137000 bytes/sec
134  // 6 users -> 4 PRB at Itbs 8 -> 67 -> 67000 bytes/sec
135  // after the patch enforcing min 3 PRBs per UE:
136  // 12 users -> 3 PRB at Itbs 8 -> 49 bytes * 8/12 UE/TTI -> 32667 bytes/sec
137  // 15 users -> 3 PRB at Itbs 8 -> 49 bytes * 8/15 UE/TTI -> 26133 bytes/sec
138  AddTestCase (new LenaPfFfMacSchedulerTestCase1 (1,10000,775000,437000,errorModel), TestCase::EXTENSIVE);
139  AddTestCase (new LenaPfFfMacSchedulerTestCase1 (3,10000,258333,137000,errorModel), TestCase::EXTENSIVE);
140  AddTestCase (new LenaPfFfMacSchedulerTestCase1 (6,10000,129167,67000,errorModel), TestCase::EXTENSIVE);
141  AddTestCase (new LenaPfFfMacSchedulerTestCase1 (12,10000,64583,32667,errorModel), TestCase::EXTENSIVE);
142  AddTestCase (new LenaPfFfMacSchedulerTestCase1 (15,10000,51667,26133,errorModel), TestCase::EXTENSIVE);
143 
144  // DONWLINK - DISTANCE 20000 -> MCS 8 -> Itbs 8 (from table 7.1.7.2.1-1 of 36.213)
145  // 1 user -> 24 PRB at Itbs 8 -> 421 -> 421000 bytes/sec
146  // 3 users -> 421000 among 3 users -> 140333 bytes/sec
147  // 6 users -> 421000 among 6 users -> 70167 bytes/sec
148  // 12 users -> 421000 among 12 users -> 35083 bytes/sec
149  // 15 users -> 421000 among 15 users -> 28067 bytes/sec
150  // UPLINK - DISTANCE 20000 -> MCS 2 -> Itbs 2 (from table 7.1.7.2.1-1 of 36.213)
151  // 1 user -> 25 PRB at Itbs 2 -> 233 -> 137000 bytes/sec
152  // 3 users -> 8 PRB at Itbs 2 -> 69 -> 41000 bytes/sec
153  // 6 users -> 4 PRB at Itbs 2 -> 32 -> 22000 bytes/sec
154  // after the patch enforcing min 3 PRBs per UE:
155  // 12 users -> 3 PRB at Itbs 2 -> 26 bytes * 8/12 UE/TTI -> 12000 bytes/sec
156  // 15 users -> 3 PRB at Itbs 2 -> 26 bytes * 8/15 UE/TTI -> 9600 bytes/sec
157  AddTestCase (new LenaPfFfMacSchedulerTestCase1 (1,20000,421000,137000,errorModel), TestCase::EXTENSIVE);
158  AddTestCase (new LenaPfFfMacSchedulerTestCase1 (3,20000,140333,41000,errorModel), TestCase::EXTENSIVE);
159  AddTestCase (new LenaPfFfMacSchedulerTestCase1 (6,20000,70167,22000,errorModel), TestCase::EXTENSIVE);
160  AddTestCase (new LenaPfFfMacSchedulerTestCase1 (12,20000,35083,12000,errorModel), TestCase::EXTENSIVE);
161  AddTestCase (new LenaPfFfMacSchedulerTestCase1 (15,20000,28067,9600,errorModel), TestCase::EXTENSIVE);
162 
163 
164  // Test Case 2: fairness check
165 
166  std::vector<uint16_t> dist;
167  dist.push_back (0); // User 0 distance --> MCS 28
168  dist.push_back (4800); // User 1 distance --> MCS 22
169  dist.push_back (6000); // User 2 distance --> MCS 16
170  dist.push_back (10000); // User 3 distance --> MCS 8
171  dist.push_back (20000); // User 4 distance --> MCS 8
172  std::vector<uint32_t> estThrPfDl;
173  estThrPfDl.push_back (90000); // User 0 estimated TTI throughput from PF
174  estThrPfDl.push_back (37000); // User 1 estimated TTI throughput from PF
175  estThrPfDl.push_back (37000); // User 2 estimated TTI throughput from PF
176  estThrPfDl.push_back (17400); // User 3 estimated TTI throughput from PF
177  estThrPfDl.push_back (17400); // User 4 estimated TTI throughput from PF
178  std::vector<uint32_t> estThrPfUl;
179  estThrPfUl.push_back (469000); // User 0 estimated TTI throughput from PF
180  estThrPfUl.push_back (157000); // User 1 estimated TTI throughput from PF
181  estThrPfUl.push_back (125000); // User 2 estimated TTI throughput from PF
182  estThrPfUl.push_back (85000); // User 3 estimated TTI throughput from PF
183  estThrPfUl.push_back (26000); // User 4 estimated TTI throughput from PF
184  AddTestCase (new LenaPfFfMacSchedulerTestCase2 (dist, estThrPfDl, estThrPfUl,errorModel), TestCase::QUICK);
185 
186 
187 }
188 
190 
191 
192 // --------------- T E S T - C A S E # 1 ------------------------------
193 
194 
195 std::string
196 LenaPfFfMacSchedulerTestCase1::BuildNameString (uint16_t nUser, uint16_t dist)
197 {
198  std::ostringstream oss;
199  oss << nUser << " UEs, distance " << dist << " m";
200  return oss.str ();
201 }
202 
203 LenaPfFfMacSchedulerTestCase1::LenaPfFfMacSchedulerTestCase1 (uint16_t nUser, uint16_t dist, double thrRefDl, double thrRefUl, bool errorModelEnabled)
204  : TestCase (BuildNameString (nUser, dist)),
205  m_nUser (nUser),
206  m_dist (dist),
207  m_thrRefDl (thrRefDl),
208  m_thrRefUl (thrRefUl),
209  m_errorModelEnabled (errorModelEnabled)
210 {
211 }
212 
214 {
215 }
216 
217 void
219 {
220  NS_LOG_FUNCTION (this << m_nUser << m_dist);
221 
222  if (!m_errorModelEnabled)
223  {
224  Config::SetDefault ("ns3::LteSpectrumPhy::CtrlErrorModelEnabled", BooleanValue (false));
225  Config::SetDefault ("ns3::LteSpectrumPhy::DataErrorModelEnabled", BooleanValue (false));
226  }
227  Config::SetDefault ("ns3::LteHelper::UseIdealRrc", BooleanValue (true));
228 
234  Ptr<LteHelper> lteHelper = CreateObject<LteHelper> ();
235  lteHelper->SetAttribute ("PathlossModel", StringValue ("ns3::FriisSpectrumPropagationLossModel"));
236 
237  // Create Nodes: eNodeB and UE
238  NodeContainer enbNodes;
239  NodeContainer ueNodes;
240  enbNodes.Create (1);
241  ueNodes.Create (m_nUser);
242 
243  // Install Mobility Model
245  mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel");
246  mobility.Install (enbNodes);
247  mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel");
248  mobility.Install (ueNodes);
249 
250  // Create Devices and install them in the Nodes (eNB and UE)
251  NetDeviceContainer enbDevs;
252  NetDeviceContainer ueDevs;
253  lteHelper->SetSchedulerType ("ns3::PfFfMacScheduler");
254  enbDevs = lteHelper->InstallEnbDevice (enbNodes);
255  ueDevs = lteHelper->InstallUeDevice (ueNodes);
256 
257  // Attach a UE to a eNB
258  lteHelper->Attach (ueDevs, enbDevs.Get (0));
259 
260  // Activate an EPS bearer
261  enum EpsBearer::Qci q = EpsBearer::GBR_CONV_VOICE;
262  EpsBearer bearer (q);
263  lteHelper->ActivateDataRadioBearer (ueDevs, bearer);
264 
265 
266  Ptr<LteEnbNetDevice> lteEnbDev = enbDevs.Get (0)->GetObject<LteEnbNetDevice> ();
267  Ptr<LteEnbPhy> enbPhy = lteEnbDev->GetPhy ();
268  enbPhy->SetAttribute ("TxPower", DoubleValue (30.0));
269  enbPhy->SetAttribute ("NoiseFigure", DoubleValue (5.0));
270 
271  // Set UEs' position and power
272  for (int i = 0; i < m_nUser; i++)
273  {
275  mm->SetPosition (Vector (m_dist, 0.0, 0.0));
276  Ptr<LteUeNetDevice> lteUeDev = ueDevs.Get (i)->GetObject<LteUeNetDevice> ();
277  Ptr<LteUePhy> uePhy = lteUeDev->GetPhy ();
278  uePhy->SetAttribute ("TxPower", DoubleValue (23.0));
279  uePhy->SetAttribute ("NoiseFigure", DoubleValue (9.0));
280  }
281 
282 
283  double statsStartTime = 0.300; // need to allow for RRC connection establishment + SRS
284  double statsDuration = 0.6;
285  double tolerance = 0.1;
286  Simulator::Stop (Seconds (statsStartTime + statsDuration - 0.000001));
287 
288  lteHelper->EnableMacTraces ();
289  lteHelper->EnableRlcTraces ();
290  Ptr<RadioBearerStatsCalculator> rlcStats = lteHelper->GetRlcStats ();
291  rlcStats->SetAttribute ("StartTime", TimeValue (Seconds (statsStartTime)));
292  rlcStats->SetAttribute ("EpochDuration", TimeValue (Seconds (statsDuration)));
293 
294 
295  Simulator::Run ();
296 
300  NS_LOG_INFO ("DL - Test with " << m_nUser << " user(s) at distance " << m_dist);
301  std::vector <uint64_t> dlDataRxed;
302  for (int i = 0; i < m_nUser; i++)
303  {
304  // get the imsi
305  uint64_t imsi = ueDevs.Get (i)->GetObject<LteUeNetDevice> ()->GetImsi ();
306  uint8_t lcId = 3;
307  dlDataRxed.push_back (rlcStats->GetDlRxData (imsi, lcId));
308  NS_LOG_INFO ("\tUser " << i << " imsi " << imsi << " bytes rxed " << (double)dlDataRxed.at (i) << " thr " << (double)dlDataRxed.at (i) / statsDuration << " ref " << m_thrRefDl);
309  }
316  for (int i = 0; i < m_nUser; i++)
317  {
318  NS_TEST_ASSERT_MSG_EQ_TOL ((double)dlDataRxed.at (i) / statsDuration, m_thrRefDl, m_thrRefDl * tolerance, " Unfair Throughput!");
319  }
320 
324  NS_LOG_INFO ("UL - Test with " << m_nUser << " user(s) at distance " << m_dist);
325  std::vector <uint64_t> ulDataRxed;
326  for (int i = 0; i < m_nUser; i++)
327  {
328  // get the imsi
329  uint64_t imsi = ueDevs.Get (i)->GetObject<LteUeNetDevice> ()->GetImsi ();
330  // get the lcId
331  uint8_t lcId = 3;
332  ulDataRxed.push_back (rlcStats->GetUlRxData (imsi, lcId));
333  NS_LOG_INFO ("\tUser " << i << " imsi " << imsi << " bytes rxed " << (double)ulDataRxed.at (i) << " thr " << (double)ulDataRxed.at (i) / statsDuration << " ref " << m_thrRefUl);
334  }
341  for (int i = 0; i < m_nUser; i++)
342  {
343  NS_TEST_ASSERT_MSG_EQ_TOL ((double)ulDataRxed.at (i) / statsDuration, m_thrRefUl, m_thrRefUl * tolerance, " Unfair Throughput!");
344  }
345  Simulator::Destroy ();
346 
347 }
348 
349 
350 
351 // --------------- T E S T - C A S E # 2 ------------------------------
352 
353 
354 std::string
355 LenaPfFfMacSchedulerTestCase2::BuildNameString (uint16_t nUser, std::vector<uint16_t> dist)
356 {
357  std::ostringstream oss;
358  oss << "distances (m) = [ " ;
359  for (std::vector<uint16_t>::iterator it = dist.begin (); it != dist.end (); ++it)
360  {
361  oss << *it << " ";
362  }
363  oss << "]";
364  return oss.str ();
365 }
366 
367 
368 LenaPfFfMacSchedulerTestCase2::LenaPfFfMacSchedulerTestCase2 (std::vector<uint16_t> dist, std::vector<uint32_t> estThrPfDl, std::vector<uint32_t> estThrPfUl, bool errorModelEnabled)
369  : TestCase (BuildNameString (dist.size (), dist)),
370  m_nUser (dist.size ()),
371  m_dist (dist),
372  m_estThrPfDl (estThrPfDl),
373  m_estThrPfUl (estThrPfUl),
374  m_errorModelEnabled (errorModelEnabled)
375 {
376 }
377 
379 {
380 }
381 
382 void
384 {
385  NS_LOG_FUNCTION (this);
386  if (!m_errorModelEnabled)
387  {
388  Config::SetDefault ("ns3::LteSpectrumPhy::CtrlErrorModelEnabled", BooleanValue (false));
389  Config::SetDefault ("ns3::LteSpectrumPhy::DataErrorModelEnabled", BooleanValue (false));
390  }
391  Config::SetDefault ("ns3::LteHelper::UseIdealRrc", BooleanValue (false));
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::PfFfMacScheduler");
418  enbDevs = lteHelper->InstallEnbDevice (enbNodes);
419  ueDevs = lteHelper->InstallUeDevice (ueNodes);
420 
421  // Attach a UE to a eNB
422  lteHelper->Attach (ueDevs, enbDevs.Get (0));
423 
424  // Activate an EPS bearer
425  enum EpsBearer::Qci q = EpsBearer::GBR_CONV_VOICE;
426  EpsBearer bearer (q);
427  lteHelper->ActivateDataRadioBearer (ueDevs, bearer);
428 
429  Ptr<LteEnbNetDevice> lteEnbDev = enbDevs.Get (0)->GetObject<LteEnbNetDevice> ();
430  Ptr<LteEnbPhy> enbPhy = lteEnbDev->GetPhy ();
431  enbPhy->SetAttribute ("TxPower", DoubleValue (30.0));
432  enbPhy->SetAttribute ("NoiseFigure", DoubleValue (5.0));
433 
434  // Set UEs' position and power
435  for (int i = 0; i < m_nUser; i++)
436  {
438  mm->SetPosition (Vector (m_dist.at (i), 0.0, 0.0));
439  Ptr<LteUeNetDevice> lteUeDev = ueDevs.Get (i)->GetObject<LteUeNetDevice> ();
440  Ptr<LteUePhy> uePhy = lteUeDev->GetPhy ();
441  uePhy->SetAttribute ("TxPower", DoubleValue (23.0));
442  uePhy->SetAttribute ("NoiseFigure", DoubleValue (9.0));
443  }
444 
445  double statsStartTime = 0.300; // need to allow for RRC connection establishment + SRS
446  double statsDuration = 0.4;
447  double tolerance = 0.1;
448  Simulator::Stop (Seconds (statsStartTime + statsDuration - 0.000001));
449 
450  lteHelper->EnableRlcTraces ();
451  Ptr<RadioBearerStatsCalculator> rlcStats = lteHelper->GetRlcStats ();
452  rlcStats->SetAttribute ("StartTime", TimeValue (Seconds (statsStartTime)));
453  rlcStats->SetAttribute ("EpochDuration", TimeValue (Seconds (statsDuration)));
454 
455 
456  Simulator::Run ();
457 
458  NS_LOG_INFO ("DL - Test with " << m_nUser << " user(s)");
459  std::vector <uint64_t> dlDataRxed;
460  double totalData = 0;
461  double totalEstThrPf = 0;
462  for (int i = 0; i < m_nUser; i++)
463  {
464  // get the imsi
465  uint64_t imsi = ueDevs.Get (i)->GetObject<LteUeNetDevice> ()->GetImsi ();
466  // get the lcId
467  uint8_t lcId = 3;
468  dlDataRxed.push_back (rlcStats->GetDlRxData (imsi, lcId));
469  totalData += (double)dlDataRxed.at (i);
470  NS_LOG_INFO ("\tUser " << i << " dist " << m_dist.at (i) << " imsi " << imsi << " bytes rxed " << (double)dlDataRxed.at (i) << " thr " << (double)dlDataRxed.at (i) / statsDuration);
471  totalEstThrPf += m_estThrPfDl.at (i);
472  }
473 
479  for (int i = 0; i < m_nUser; i++)
480  {
481  double thrRatio = (double)dlDataRxed.at (i) / totalData;
482  double estThrRatio = (double)m_estThrPfDl.at (i) / totalEstThrPf;
483  NS_LOG_INFO ("\tUser " << i << " thrRatio " << thrRatio << " estThrRatio " << estThrRatio);
484  NS_TEST_ASSERT_MSG_EQ_TOL (estThrRatio, thrRatio, tolerance, " Unfair Throughput!");
485  }
486 
491  NS_LOG_INFO ("UL - Test with " << m_nUser);
492  std::vector <uint64_t> ulDataRxed;
493  for (int i = 0; i < m_nUser; i++)
494  {
495  // get the imsi
496  uint64_t imsi = ueDevs.Get (i)->GetObject<LteUeNetDevice> ()->GetImsi ();
497  // get the lcId
498  uint8_t lcId = 3;
499  ulDataRxed.push_back (rlcStats->GetUlRxData (imsi, lcId));
500  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));
501  NS_TEST_ASSERT_MSG_EQ_TOL ((double)ulDataRxed.at (i) / statsDuration, (double)m_estThrPfUl.at (i), (double)m_estThrPfUl.at (i) * tolerance, " Unfair Throughput!");
502  }
503  Simulator::Destroy ();
504 
505 }
#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:34
NetDeviceContainer InstallEnbDevice(NodeContainer c)
Create a set of eNodeB devices.
Definition: lte-helper.cc:382
Ptr< T > GetObject(void) const
Get a pointer to the requested aggregated Object.
Definition: object.h:462
Hold variables of type string.
Definition: string.h:41
Ptr< NetDevice > Get(uint32_t i) const
Get the Ptr stored in this container at a given index.
A suite of tests to run.
Definition: test.h:1333
Ptr< LteEnbPhy > GetPhy(void) const
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:716
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:201
void EnableRlcTraces(void)
Enable trace sinks for RLC layer.
Definition: lte-helper.cc:1102
#define NS_LOG_INFO(msg)
Use NS_LOG to output a message of level LOG_INFO.
Definition: log.h:244
static LenaTestPfFfMacSchedulerSuite lenaTestPfFfMacSchedulerSuite
encapsulates test code
Definition: test.h:1147
void ActivateDataRadioBearer(NetDeviceContainer ueDevices, EpsBearer bearer)
Activate a Data Radio Bearer on a given UE devices (for LTE-only simulation).
Definition: lte-helper.cc:1046
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:225
LenaPfFfMacSchedulerTestCase1(uint16_t nUser, uint16_t dist, double thrRefDl, double thrRefUl, bool errorModelEnabled)
This class contains the specification of EPS Bearers.
Definition: eps-bearer.h:71
void Install(Ptr< Node > node) const
"Layout" a single node according to the current position allocator type.
tuple mobility
Definition: third.py:101
void AddTestCase(TestCase *testCase, enum TestDuration duration)
Add an individual child TestCase to this test suite.
Definition: test.cc:298
AttributeValue implementation for Time.
Definition: nstime.h:957
uint64_t GetDlRxData(uint64_t imsi, uint8_t lcid)
Gets the number of received downlink data bytes.
holds a vector of ns3::NetDevice pointers
LenaPfFfMacSchedulerTestCase2(std::vector< uint16_t > dist, std::vector< uint32_t > estThrPfDl, std::vector< uint32_t > estThrPfUl, bool errorModelEnabled)
#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:373
static std::string BuildNameString(uint16_t nUser, std::vector< uint16_t > dist)
Every class exported by the ns3 library is enclosed in the ns3 namespace.
keep track of a set of node pointers.
void SetMobilityModel(std::string type, std::string n1="", const AttributeValue &v1=EmptyAttributeValue(), std::string n2="", const AttributeValue &v2=EmptyAttributeValue(), std::string n3="", const AttributeValue &v3=EmptyAttributeValue(), std::string n4="", const AttributeValue &v4=EmptyAttributeValue(), std::string n5="", const AttributeValue &v5=EmptyAttributeValue(), std::string n6="", const AttributeValue &v6=EmptyAttributeValue(), std::string n7="", const AttributeValue &v7=EmptyAttributeValue(), std::string n8="", const AttributeValue &v8=EmptyAttributeValue(), std::string n9="", const AttributeValue &v9=EmptyAttributeValue())
void SetPosition(const Vector &position)
Ptr< RadioBearerStatsCalculator > GetRlcStats(void)
Definition: lte-helper.cc:1233
NetDeviceContainer InstallUeDevice(NodeContainer c)
Create a set of UE devices.
Definition: lte-helper.cc:397
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.
static std::string BuildNameString(uint16_t nUser, uint16_t dist)
virtual void DoRun(void)
Implementation to actually run this TestCase.
Ptr< Node > Get(uint32_t i) const
Get the Ptr stored in this container at a given index.
Time Seconds(double value)
Construct a Time in the indicated unit.
Definition: nstime.h:895
void SetDefault(std::string name, const AttributeValue &value)
Definition: config.cc:774
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:1190
Ptr< LteUePhy > GetPhy(void) const
This class can be used to hold variables of floating point type such as 'double' or 'float'...
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:191
The eNodeB device implementation.
Qci
QoS Class Indicator.
Definition: eps-bearer.h:77
This system test program creates different test cases with a single eNB and several UEs...
The LteUeNetDevice class implements the UE net device.