A Discrete-Event Network Simulator
API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
lte-test-pf-ff-mac-scheduler.cc
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 
51 #include "lte-test-pf-ff-mac-scheduler.h"
52 
53 NS_LOG_COMPONENT_DEFINE ("LenaTestPfFfMacScheduler");
54 
55 namespace ns3 {
56 
57 LenaTestPfFfMacSchedulerSuite::LenaTestPfFfMacSchedulerSuite ()
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,0,2196000,2292000,errorModel), TestCase::EXTENSIVE);
81  AddTestCase (new LenaPfFfMacSchedulerTestCase1 (3,0,0,732000,749000,errorModel), TestCase::EXTENSIVE);
82  AddTestCase (new LenaPfFfMacSchedulerTestCase1 (6,0,0,366000,373000,errorModel), TestCase::EXTENSIVE);
83  AddTestCase (new LenaPfFfMacSchedulerTestCase1 (12,0,0,183000,184670,errorModel), TestCase::EXTENSIVE);
84  AddTestCase (new LenaPfFfMacSchedulerTestCase1 (15,0,0,146400,147730,errorModel), TestCase::EXTENSIVE);
85 
86 
87  // DOWNLINK - DISTANCE 4800 -> MCS 16 -> Itbs 20 (from table 7.1.7.2.1-1 of 36.213)
88  // 1 user -> 24 PRB at Itbs 20 -> 903 -> 903000 bytes/sec
89  // 3 users -> 903000 among 3 users -> 301000 bytes/sec
90  // 6 users -> 903000 among 6 users -> 150500 bytes/sec
91  // 12 users -> 903000 among 12 users -> 75250 bytes/sec
92  // 15 users -> 903000 among 15 users -> 60200 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,0,4800,903000,807000,errorModel), TestCase::EXTENSIVE);
101  AddTestCase (new LenaPfFfMacSchedulerTestCase1 (3,0,4800,301000,253000,errorModel), TestCase::EXTENSIVE);
102  AddTestCase (new LenaPfFfMacSchedulerTestCase1 (6,0,4800,150500,125000,errorModel), TestCase::EXTENSIVE);
103  AddTestCase (new LenaPfFfMacSchedulerTestCase1 (12,0,4800,75250,62000,errorModel), TestCase::EXTENSIVE);
104  AddTestCase (new LenaPfFfMacSchedulerTestCase1 (15,0,4800,60200,49600,errorModel), TestCase::EXTENSIVE);
105 
106  // DOWNLINK - DISTANCE 6000 -> MCS 14 -> Itbs 13 (from table 7.1.7.2.1-1 of 36.213)
107  // 1 user -> 24 PRB at Itbs 15 -> 775 -> 775000 bytes/sec
108  // 3 users -> 775000 among 3 users -> 258000 bytes/sec
109  // 6 users -> 775000 among 6 users -> 129200 bytes/sec
110  // 12 users -> 775000 among 12 users -> 64590 bytes/sec
111  // 15 users -> 775000 among 15 users -> 51700 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,0,6000,775000,621000,errorModel), TestCase::EXTENSIVE);
120  AddTestCase (new LenaPfFfMacSchedulerTestCase1 (3,0,6000,258000,201000,errorModel), TestCase::EXTENSIVE);
121  AddTestCase (new LenaPfFfMacSchedulerTestCase1 (6,0,6000,129200,97000,errorModel), TestCase::EXTENSIVE);
122  AddTestCase (new LenaPfFfMacSchedulerTestCase1 (12,0,6000,64590,48667,errorModel), TestCase::EXTENSIVE);
123  AddTestCase (new LenaPfFfMacSchedulerTestCase1 (15,0,6000,51700,38993,errorModel), TestCase::EXTENSIVE);
124 
125  // DOWNLINK - DISTANCE 10000 -> MCS 8 -> Itbs 8 (from table 7.1.7.2.1-1 of 36.213)
126  // 1 user -> 24 PRB at Itbs 8 -> 421 -> 421000 bytes/sec
127  // 3 users -> 421000 among 3 users -> 140333 bytes/sec
128  // 6 users -> 421000 among 6 users -> 70167 bytes/sec
129  // 12 users -> 421000 among 12 users -> 35083 bytes/sec
130  // 15 users -> 421000 among 15 users -> 28067 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,0,10000,421000,437000,errorModel), TestCase::EXTENSIVE);
139  AddTestCase (new LenaPfFfMacSchedulerTestCase1 (3,0,10000,140333,137000,errorModel), TestCase::EXTENSIVE);
140  AddTestCase (new LenaPfFfMacSchedulerTestCase1 (6,0,10000,70167,67000,errorModel), TestCase::EXTENSIVE);
141  AddTestCase (new LenaPfFfMacSchedulerTestCase1 (12,0,10000,35083,32667,errorModel), TestCase::EXTENSIVE);
142  AddTestCase (new LenaPfFfMacSchedulerTestCase1 (15,0,10000,28067,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,0,20000,421000,137000,errorModel), TestCase::EXTENSIVE);
158  AddTestCase (new LenaPfFfMacSchedulerTestCase1 (3,0,20000,140333,41000,errorModel), TestCase::EXTENSIVE);
159  AddTestCase (new LenaPfFfMacSchedulerTestCase1 (6,0,20000,70167,22000,errorModel), TestCase::EXTENSIVE);
160  AddTestCase (new LenaPfFfMacSchedulerTestCase1 (12,0,20000,35083,12000,errorModel), TestCase::EXTENSIVE);
161  AddTestCase (new LenaPfFfMacSchedulerTestCase1 (15,0,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 
189 static LenaTestPfFfMacSchedulerSuite lenaTestPfFfMacSchedulerSuite;
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 nLc, uint16_t dist, double thrRefDl, double thrRefUl, bool errorModelEnabled)
204  : TestCase (BuildNameString (nUser, dist)),
205  m_nUser (nUser),
206  m_nLc (nLc),
207  m_dist (dist),
208  m_thrRefDl (thrRefDl),
209  m_thrRefUl (thrRefUl),
210  m_errorModelEnabled (errorModelEnabled)
211 {
212 }
213 
214 LenaPfFfMacSchedulerTestCase1::~LenaPfFfMacSchedulerTestCase1 ()
215 {
216 }
217 
218 void
220 {
221  NS_LOG_FUNCTION (this << m_nUser << m_nLc << m_dist);
222 
223  if (!m_errorModelEnabled)
224  {
225  Config::SetDefault ("ns3::LteSpectrumPhy::CtrlErrorModelEnabled", BooleanValue (false));
226  Config::SetDefault ("ns3::LteSpectrumPhy::DataErrorModelEnabled", BooleanValue (false));
227  }
228  Config::SetDefault ("ns3::LteHelper::UseIdealRrc", BooleanValue (true));
229 
235  Ptr<LteHelper> lteHelper = CreateObject<LteHelper> ();
236  lteHelper->SetAttribute ("PathlossModel", StringValue ("ns3::FriisSpectrumPropagationLossModel"));
237 
238  // Create Nodes: eNodeB and UE
239  NodeContainer enbNodes;
240  NodeContainer ueNodes;
241  enbNodes.Create (1);
242  ueNodes.Create (m_nUser);
243 
244  // Install Mobility Model
245  MobilityHelper mobility;
246  mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel");
247  mobility.Install (enbNodes);
248  mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel");
249  mobility.Install (ueNodes);
250 
251  // Create Devices and install them in the Nodes (eNB and UE)
252  NetDeviceContainer enbDevs;
253  NetDeviceContainer ueDevs;
254  lteHelper->SetSchedulerType ("ns3::PfFfMacScheduler");
255  enbDevs = lteHelper->InstallEnbDevice (enbNodes);
256  ueDevs = lteHelper->InstallUeDevice (ueNodes);
257 
258  // Attach a UE to a eNB
259  lteHelper->Attach (ueDevs, enbDevs.Get (0));
260 
261  // Activate an EPS bearer
262  enum EpsBearer::Qci q = EpsBearer::GBR_CONV_VOICE;
263  EpsBearer bearer (q);
264  lteHelper->ActivateDataRadioBearer (ueDevs, bearer);
265 
266 
267  Ptr<LteEnbNetDevice> lteEnbDev = enbDevs.Get (0)->GetObject<LteEnbNetDevice> ();
268  Ptr<LteEnbPhy> enbPhy = lteEnbDev->GetPhy ();
269  enbPhy->SetAttribute ("TxPower", DoubleValue (30.0));
270  enbPhy->SetAttribute ("NoiseFigure", DoubleValue (5.0));
271 
272  // Set UEs' position and power
273  for (int i = 0; i < m_nUser; i++)
274  {
276  mm->SetPosition (Vector (m_dist, 0.0, 0.0));
277  Ptr<LteUeNetDevice> lteUeDev = ueDevs.Get (i)->GetObject<LteUeNetDevice> ();
278  Ptr<LteUePhy> uePhy = lteUeDev->GetPhy ();
279  uePhy->SetAttribute ("TxPower", DoubleValue (23.0));
280  uePhy->SetAttribute ("NoiseFigure", DoubleValue (9.0));
281  }
282 
283 
284  double statsStartTime = 0.300; // need to allow for RRC connection establishment + SRS
285  double statsDuration = 0.6;
286  double tolerance = 0.1;
287  Simulator::Stop (Seconds (statsStartTime + statsDuration - 0.000001));
288 
289  lteHelper->EnableMacTraces ();
290  lteHelper->EnableRlcTraces ();
291  Ptr<RadioBearerStatsCalculator> rlcStats = lteHelper->GetRlcStats ();
292  rlcStats->SetAttribute ("StartTime", TimeValue (Seconds (statsStartTime)));
293  rlcStats->SetAttribute ("EpochDuration", TimeValue (Seconds (statsDuration)));
294 
295 
296  Simulator::Run ();
297 
301  NS_LOG_INFO ("DL - Test with " << m_nUser << " user(s) at distance " << m_dist);
302  std::vector <uint64_t> dlDataRxed;
303  for (int i = 0; i < m_nUser; i++)
304  {
305  // get the imsi
306  uint64_t imsi = ueDevs.Get (i)->GetObject<LteUeNetDevice> ()->GetImsi ();
307  uint8_t lcId = 3;
308  dlDataRxed.push_back (rlcStats->GetDlRxData (imsi, lcId));
309  NS_LOG_INFO ("\tUser " << i << " imsi " << imsi << " bytes rxed " << (double)dlDataRxed.at (i) << " thr " << (double)dlDataRxed.at (i) / statsDuration << " ref " << m_thrRefDl);
310  }
317  for (int i = 0; i < m_nUser; i++)
318  {
319  NS_TEST_ASSERT_MSG_EQ_TOL ((double)dlDataRxed.at (i) / statsDuration, m_thrRefDl, m_thrRefDl * tolerance, " Unfair Throughput!");
320  }
321 
325  NS_LOG_INFO ("UL - Test with " << m_nUser << " user(s) at distance " << m_dist);
326  std::vector <uint64_t> ulDataRxed;
327  for (int i = 0; i < m_nUser; i++)
328  {
329  // get the imsi
330  uint64_t imsi = ueDevs.Get (i)->GetObject<LteUeNetDevice> ()->GetImsi ();
331  // get the lcId
332  uint8_t lcId = 3;
333  ulDataRxed.push_back (rlcStats->GetUlRxData (imsi, lcId));
334  NS_LOG_INFO ("\tUser " << i << " imsi " << imsi << " bytes rxed " << (double)ulDataRxed.at (i) << " thr " << (double)ulDataRxed.at (i) / statsDuration << " ref " << m_thrRefUl);
335  }
342  for (int i = 0; i < m_nUser; i++)
343  {
344  NS_TEST_ASSERT_MSG_EQ_TOL ((double)ulDataRxed.at (i) / statsDuration, m_thrRefUl, m_thrRefUl * tolerance, " Unfair Throughput!");
345  }
347 
348 }
349 
350 
351 
352 // --------------- T E S T - C A S E # 2 ------------------------------
353 
354 
355 std::string
356 LenaPfFfMacSchedulerTestCase2::BuildNameString (uint16_t nUser, std::vector<uint16_t> dist)
357 {
358  std::ostringstream oss;
359  oss << "distances (m) = [ " ;
360  for (std::vector<uint16_t>::iterator it = dist.begin (); it != dist.end (); ++it)
361  {
362  oss << *it << " ";
363  }
364  oss << "]";
365  return oss.str ();
366 }
367 
368 
369 LenaPfFfMacSchedulerTestCase2::LenaPfFfMacSchedulerTestCase2 (std::vector<uint16_t> dist, std::vector<uint32_t> estThrPfDl, std::vector<uint32_t> estThrPfUl, bool errorModelEnabled)
370  : TestCase (BuildNameString (dist.size (), dist)),
371  m_nUser (dist.size ()),
372  m_dist (dist),
373  m_estThrPfDl (estThrPfDl),
374  m_estThrPfUl (estThrPfUl),
375  m_errorModelEnabled (errorModelEnabled)
376 {
377 }
378 
379 LenaPfFfMacSchedulerTestCase2::~LenaPfFfMacSchedulerTestCase2 ()
380 {
381 }
382 
383 void
385 {
386  NS_LOG_FUNCTION (this);
387  if (!m_errorModelEnabled)
388  {
389  Config::SetDefault ("ns3::LteSpectrumPhy::CtrlErrorModelEnabled", BooleanValue (false));
390  Config::SetDefault ("ns3::LteSpectrumPhy::DataErrorModelEnabled", BooleanValue (false));
391  }
392  Config::SetDefault ("ns3::LteHelper::UseIdealRrc", BooleanValue (false));
393 
398  Ptr<LteHelper> lteHelper = CreateObject<LteHelper> ();
399 
400  lteHelper->SetAttribute ("PathlossModel", StringValue ("ns3::FriisSpectrumPropagationLossModel"));
401 
402  // Create Nodes: eNodeB and UE
403  NodeContainer enbNodes;
404  NodeContainer ueNodes;
405  enbNodes.Create (1);
406  ueNodes.Create (m_nUser);
407 
408  // Install Mobility Model
409  MobilityHelper mobility;
410  mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel");
411  mobility.Install (enbNodes);
412  mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel");
413  mobility.Install (ueNodes);
414 
415  // Create Devices and install them in the Nodes (eNB and UE)
416  NetDeviceContainer enbDevs;
417  NetDeviceContainer ueDevs;
418  lteHelper->SetSchedulerType ("ns3::PfFfMacScheduler");
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  double statsStartTime = 0.300; // need to allow for RRC connection establishment + SRS
447  double statsDuration = 0.4;
448  double tolerance = 0.1;
449  Simulator::Stop (Seconds (statsStartTime + statsDuration - 0.000001));
450 
451  lteHelper->EnableRlcTraces ();
452  Ptr<RadioBearerStatsCalculator> rlcStats = lteHelper->GetRlcStats ();
453  rlcStats->SetAttribute ("StartTime", TimeValue (Seconds (statsStartTime)));
454  rlcStats->SetAttribute ("EpochDuration", TimeValue (Seconds (statsDuration)));
455 
456 
457  Simulator::Run ();
458 
459  NS_LOG_INFO ("DL - Test with " << m_nUser << " user(s)");
460  std::vector <uint64_t> dlDataRxed;
461  double totalData = 0;
462  double totalEstThrPf = 0;
463  for (int i = 0; i < m_nUser; i++)
464  {
465  // get the imsi
466  uint64_t imsi = ueDevs.Get (i)->GetObject<LteUeNetDevice> ()->GetImsi ();
467  // get the lcId
468  uint8_t lcId = 3;
469  dlDataRxed.push_back (rlcStats->GetDlRxData (imsi, lcId));
470  totalData += (double)dlDataRxed.at (i);
471  NS_LOG_INFO ("\tUser " << i << " dist " << m_dist.at (i) << " imsi " << imsi << " bytes rxed " << (double)dlDataRxed.at (i) << " thr " << (double)dlDataRxed.at (i) / statsDuration);
472  totalEstThrPf += m_estThrPfDl.at (i);
473  }
474 
480  for (int i = 0; i < m_nUser; i++)
481  {
482  double thrRatio = (double)dlDataRxed.at (i) / totalData;
483  double estThrRatio = (double)m_estThrPfDl.at (i) / totalEstThrPf;
484  NS_LOG_INFO ("\tUser " << i << " thrRatio " << thrRatio << " estThrRatio " << estThrRatio);
485  NS_TEST_ASSERT_MSG_EQ_TOL (estThrRatio, thrRatio, tolerance, " Unfair Throughput!");
486  }
487 
492  NS_LOG_INFO ("UL - Test with " << m_nUser);
493  std::vector <uint64_t> ulDataRxed;
494  for (int i = 0; i < m_nUser; i++)
495  {
496  // get the imsi
497  uint64_t imsi = ueDevs.Get (i)->GetObject<LteUeNetDevice> ()->GetImsi ();
498  // get the lcId
499  uint8_t lcId = 3;
500  ulDataRxed.push_back (rlcStats->GetUlRxData (imsi, lcId));
501  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));
502  NS_TEST_ASSERT_MSG_EQ_TOL ((double)ulDataRxed.at (i) / statsDuration, (double)m_estThrPfUl.at (i), (double)m_estThrPfUl.at (i) * tolerance, " Unfair Throughput!");
503  }
505 
506 }
507 
508 
509 } // namespace ns3
510 
511 
512 
513 
smart pointer class similar to boost::intrusive_ptr
Definition: ptr.h:59
#define NS_LOG_FUNCTION(parameters)
Definition: log.h:311
Hold a bool native type.
Definition: boolean.h:38
hold variables of type string
Definition: string.h:19
Ptr< NetDevice > Get(uint32_t i) const
Get the Ptr<NetDevice> stored in this container at a given index.
Mobility model for which the current position does not change once it has been set and until it is se...
static void Run(void)
Definition: simulator.cc:157
#define NS_LOG_COMPONENT_DEFINE(name)
Definition: log.h:122
#define NS_LOG_INFO(msg)
Definition: log.h:264
a 3d vector
Definition: vector.h:31
void Install(Ptr< Node > node) const
"Layout" a single node according to the current position allocator type.
hold objects of type ns3::Time
Definition: nstime.h:700
Fast test.
Definition: test.h:843
holds a vector of ns3::NetDevice pointers
static void Destroy(void)
Definition: simulator.cc:121
void SetDefault(std::string name, const AttributeValue &value)
Definition: config.cc:667
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 AddTestCase(TestCase *testCase) NS_DEPRECATED
Add an individual test case to this test suite.
Definition: test.cc:172
virtual void DoRun(void)
Implementation to actually run this test case.
Helper class used to assign positions and mobility models to nodes.
Time Seconds(double seconds)
create ns3::Time instances in units of seconds.
Definition: nstime.h:586
static void Stop(void)
Definition: simulator.cc:164
Ptr< Node > Get(uint32_t i) const
Get the Ptr<Node> stored in this container at a given index.
void Create(uint32_t n)
Create n nodes and append pointers to them to the end of this NodeContainer.
Hold an floating point type.
Definition: double.h:41
Ptr< T > GetObject(void) const
Definition: object.h:332
virtual void DoRun(void)
Implementation to actually run this test case.