A Discrete-Event Network Simulator
API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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/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 NS_LOG_COMPONENT_DEFINE ("LenaTestTdBetFfMacCheduler");
55 
56 namespace ns3 {
57 
59  : TestSuite ("lte-tdbet-ff-mac-scheduler", SYSTEM)
60 {
61  NS_LOG_INFO ("creating LenaTestTdBetFfMacSchedulerSuite");
62 
63  //Test Case 1: AMC works in TDBET
64 
65  // DOWNLINK - DISTANCE 0 -> MCS 28 -> Itbs 26 (from table 7.1.7.2.1-1 of 36.213)
66  // 1 user -> 24 PRB at Itbs 26 -> 2196 -> 2196000 bytes/sec
67  // 3 users -> 2196000 among 3 users -> 732000 bytes/sec
68  // 6 users -> 2196000 among 6 users -> 366000 bytes/sec
69  // 12 users -> 2196000 among 12 users -> 183000 bytes/sec
70  // 15 users -> 2196000 among 15 users -> 146400 bytes/sec
71  // UPLINK- DISTANCE 0 -> MCS 28 -> Itbs 26 (from table 7.1.7.2.1-1 of 36.213)
72  // 1 user -> 25 PRB at Itbs 26 -> 2292 -> 2292000 bytes/sec
73  // 3 users -> 8 PRB at Itbs 26 -> 749 -> 749000 bytes/sec
74  // 6 users -> 4 PRB at Itbs 26 -> 373 -> 373000 bytes/sec
75  // 12 users -> 2 PRB at Itbs 26 -> 185 -> 185000 bytes/sec
76  // 15 users -> 1 PRB at Itbs 26 -> 89 -> 89000 bytes/sec
77  AddTestCase (new LenaTdBetFfMacSchedulerTestCase1 (1,0,0,2196000,2292000));
78  AddTestCase (new LenaTdBetFfMacSchedulerTestCase1 (3,0,0,732000,749000));
79  AddTestCase (new LenaTdBetFfMacSchedulerTestCase1 (6,0,0,366000,373000));
80  AddTestCase (new LenaTdBetFfMacSchedulerTestCase1 (12,0,0,183000,185000));
81  AddTestCase (new LenaTdBetFfMacSchedulerTestCase1 (15,0,0,146400,89000));
82 
83  // DOWNLINK - DISTANCE 3000 -> MCS 24 -> Itbs 30 (from table 7.1.7.2.1-1 of 36.213)
84  // 1 user -> 24 PRB at Itbs 20 -> 1383 -> 1383000 bytes/sec
85  // 3 users -> 1383000 among 3 users -> 461000 bytes/sec
86  // 6 users -> 1383000 among 6 users -> 230500 bytes/sec
87  // 12 users -> 1383000 among 12 users -> 115250 bytes/sec
88  // 15 users -> 1383000 among 15 users -> 92200 bytes/sec
89  // UPLINK - DISTANCE 3000 -> MCS 20 -> Itbs 18 (from table 7.1.7.2.1-1 of 36.213)
90  // 1 user -> 25 PRB at Itbs 18 -> 1239 -> 1239000 bytes/sec
91  // 3 users -> 8 PRB at Itbs 18 -> 389 -> 389000 bytes/sec
92  // 6 users -> 4 PRB at Itbs 18 -> 193 -> 193000 bytes/sec
93  // 12 users -> 2 PRB at Itbs 18 -> 97 -> 97000 bytes/sec
94  // 15 users -> 1 PRB at Itbs 18 -> 47 -> 47000 bytes/sec
95  AddTestCase (new LenaTdBetFfMacSchedulerTestCase1 (1,0,3000,1383000,1239000));
96  AddTestCase (new LenaTdBetFfMacSchedulerTestCase1 (3,0,3000,461000,389000));
97  AddTestCase (new LenaTdBetFfMacSchedulerTestCase1 (6,0,3000,230500,193000));
98  AddTestCase (new LenaTdBetFfMacSchedulerTestCase1 (12,0,3000,115250,97000));
99  AddTestCase (new LenaTdBetFfMacSchedulerTestCase1 (15,0,3000,92200,47000));
100 
101  // DOWNLINK - DISTANCE 6000 -> MCS 16 -> Itbs 15 (from table 7.1.7.2.1-1 of 36.213)
102  // 1 user -> 24 PRB at Itbs 15 -> 903 -> 903000 bytes/sec
103  // 3 users -> 903000 among 3 users -> 301000 bytes/sec
104  // 6 users -> 903000 among 6 users -> 150500 bytes/sec
105  // 12 users -> 903000 among 12 users -> 75250 bytes/sec
106  // 15 users -> 903000 among 15 users -> 60200 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 -> 2 PRB at Itbs 11 -> 47 -> 47000 bytes/sec
112  // 15 users -> 1 PRB at Itbs 11 -> 22 -> 22000 bytes/sec
113  AddTestCase (new LenaTdBetFfMacSchedulerTestCase1 (1,0,6000,903000,621000));
114  AddTestCase (new LenaTdBetFfMacSchedulerTestCase1 (3,0,6000,301000,201000));
115  AddTestCase (new LenaTdBetFfMacSchedulerTestCase1 (6,0,6000,150500,97000));
116  AddTestCase (new LenaTdBetFfMacSchedulerTestCase1 (12,0,6000,75250,47000));
117  AddTestCase (new LenaTdBetFfMacSchedulerTestCase1 (15,0,6000,60200,22000));
118 
119  // DOWNLINK - DISTANCE 9000 -> MCS 12 -> Itbs 11 (from table 7.1.7.2.1-1 of 36.213)
120  // 1 user -> 24 PRB at Itbs 11 -> 597 -> 597000 bytes/sec
121  // 3 users -> 597000 among 3 users -> 199000 bytes/sec
122  // 6 users -> 597000 among 6 users -> 99500 bytes/sec
123  // 12 users -> 597000 among 12 users -> 49750 bytes/sec
124  // 15 users -> 597000 among 15 users -> 39800 bytes/sec
125  // UPLINK - DISTANCE 9000 -> MCS 8 -> Itbs 8 (from table 7.1.7.2.1-1 of 36.213)
126  // 1 user -> 24 PRB at Itbs 8 -> 437 -> 437000 bytes/sec
127  // 3 users -> 8 PRB at Itbs 8 -> 137 -> 137000 bytes/sec
128  // 6 users -> 4 PRB at Itbs 8 -> 67 -> 67000 bytes/sec
129  // 12 users -> 2 PRB at Itbs 8 -> 32 -> 32000 bytes/sec
130  // 15 users -> 1 PRB at Itbs 8 -> 15 -> 15000 bytes/sec
131  AddTestCase (new LenaTdBetFfMacSchedulerTestCase1 (1,0,9000,597000,437000));
132  AddTestCase (new LenaTdBetFfMacSchedulerTestCase1 (3,0,9000,199000,137000));
133  AddTestCase (new LenaTdBetFfMacSchedulerTestCase1 (6,0,9000,99500,67000));
134  AddTestCase (new LenaTdBetFfMacSchedulerTestCase1 (12,0,9000,49750,32000));
135  AddTestCase (new LenaTdBetFfMacSchedulerTestCase1 (15,0,9000,39800,15000));
136 
137  // DONWLINK - DISTANCE 15000 -> MCS 6 -> Itbs 6 (from table 7.1.7.2.1-1 of 36.213)
138  // 1 user -> 24 PRB at Itbs 6 -> 309 -> 309000 bytes/sec
139  // 3 users -> 309000 among 3 users -> 103000 bytes/sec
140  // 6 users -> 309000 among 6 users -> 51500 bytes/sec
141  // 12 users -> 309000 among 12 users -> 25750 bytes/sec
142  // 15 users -> 309000 among 15 users -> 20600 bytes/sec
143  // UPLINK - DISTANCE 15000 -> MCS 6 -> Itbs 6 (from table 7.1.7.2.1-1 of 36.213)
144  // 1 user -> 25 PRB at Itbs 6 -> 233 -> 233000 bytes/sec
145  // 3 users -> 8 PRB at Itbs 6 -> 69 -> 69000 bytes/sec
146  // 6 users -> 4 PRB at Itbs 6 -> 32 -> 32000 bytes/sec
147  // 12 users -> 2 PRB at Itbs 6 -> 15 -> 15000 bytes/sec
148  // 15 users -> 1 PRB at Itbs 6 -> 7 -> 7000 bytes/sec
149  AddTestCase (new LenaTdBetFfMacSchedulerTestCase1 (1,0,15000,309000,233000));
150  AddTestCase (new LenaTdBetFfMacSchedulerTestCase1 (3,0,15000,103000,69000));
151  AddTestCase (new LenaTdBetFfMacSchedulerTestCase1 (6,0,15000,51500,32000));
152  AddTestCase (new LenaTdBetFfMacSchedulerTestCase1 (12,0,15000,25750,15000));
153  AddTestCase (new LenaTdBetFfMacSchedulerTestCase1 (15,0,15000,20600,7000));
154 
155  // Test Case 2: fairness check
156 
157  std::vector<uint16_t> dist;
158  dist.push_back (0); // User 0 distance --> MCS 28
159  dist.push_back (3000); // User 1 distance --> MCS 24
160  dist.push_back (6000); // User 2 distance --> MCS 16
161  dist.push_back (9000); // User 3 distance --> MCS 12
162  dist.push_back (15000); // User 4 distance --> MCS 6
163  std::vector<uint32_t> estAchievableRateDl;
164  estAchievableRateDl.push_back (2196000);
165  estAchievableRateDl.push_back (1383000);
166  estAchievableRateDl.push_back (903000);
167  estAchievableRateDl.push_back (597000);
168  estAchievableRateDl.push_back (309000);
169  std::vector<uint32_t> estThrTdBetUl;
170  estThrTdBetUl.push_back (469000); // User 0 estimated TTI throughput from TDBET
171  estThrTdBetUl.push_back (249000); // User 1 estimated TTI throughput from TDBET
172  estThrTdBetUl.push_back (125000); // User 2 estimated TTI throughput from TDBET
173  estThrTdBetUl.push_back (85000); // User 3 estimated TTI throughput from TDBET
174  estThrTdBetUl.push_back (41000); // User 4 estimated TTI throughput from TDBET
175  AddTestCase (new LenaTdBetFfMacSchedulerTestCase2 (dist, estAchievableRateDl, estThrTdBetUl));
176 
177 
178 }
179 
181 
182 
183 // --------------- T E S T - C A S E # 1 ------------------------------
184 
185 
186 std::string
188 {
189  std::ostringstream oss;
190  oss << nUser << " UEs, distance " << dist << " m";
191  return oss.str ();
192 }
193 
194 LenaTdBetFfMacSchedulerTestCase1::LenaTdBetFfMacSchedulerTestCase1 (uint16_t nUser, uint16_t nLc, uint16_t dist, double thrRefDl, double thrRefUl)
195  : TestCase (BuildNameString (nUser, dist)),
196  m_nUser (nUser),
197  m_nLc (nLc),
198  m_dist (dist),
199  m_thrRefDl (thrRefDl),
200  m_thrRefUl (thrRefUl)
201 {
202 }
203 
205 {
206 }
207 
208 void
210 {
211  Config::SetDefault ("ns3::LteAmc::AmcModel", EnumValue (LteAmc::PiroEW2010));
212  Config::SetDefault ("ns3::LteAmc::Ber", DoubleValue (0.00005));
213  Config::SetDefault ("ns3::LteSpectrumPhy::CtrlErrorModelEnabled", BooleanValue (false));
214  Config::SetDefault ("ns3::LteSpectrumPhy::DataErrorModelEnabled", BooleanValue (false));
215 
217  //LogComponentEnable ("LenaTestTdBetFfMacCheduler", LOG_LEVEL_ALL);
218 
223  Ptr<LteHelper> lteHelper = CreateObject<LteHelper> ();
224 
225  lteHelper->SetAttribute ("PathlossModel", StringValue ("ns3::FriisSpectrumPropagationLossModel"));
226 
227  // Create Nodes: eNodeB and UE
228  NodeContainer enbNodes;
229  NodeContainer ueNodes;
230  enbNodes.Create (1);
231  ueNodes.Create (m_nUser);
232 
233  // Install Mobility Model
234  MobilityHelper mobility;
235  mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel");
236  mobility.Install (enbNodes);
237  mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel");
238  mobility.Install (ueNodes);
239 
240  // Create Devices and install them in the Nodes (eNB and UE)
241  NetDeviceContainer enbDevs;
242  NetDeviceContainer ueDevs;
243  lteHelper->SetSchedulerType ("ns3::TdBetFfMacScheduler");
244  enbDevs = lteHelper->InstallEnbDevice (enbNodes);
245  ueDevs = lteHelper->InstallUeDevice (ueNodes);
246 
247  // Attach a UE to a eNB
248  lteHelper->Attach (ueDevs, enbDevs.Get (0));
249 
250  // Activate an EPS bearer
252  EpsBearer bearer (q);
253  lteHelper->ActivateEpsBearer (ueDevs, bearer, EpcTft::Default ());
254 
255  Ptr<LteEnbNetDevice> lteEnbDev = enbDevs.Get (0)->GetObject<LteEnbNetDevice> ();
256  Ptr<LteEnbPhy> enbPhy = lteEnbDev->GetPhy ();
257  enbPhy->SetAttribute ("TxPower", DoubleValue (30.0));
258  enbPhy->SetAttribute ("NoiseFigure", DoubleValue (5.0));
259 
260  // Set UEs' position and power
261  for (int i = 0; i < m_nUser; i++)
262  {
264  mm->SetPosition (Vector (m_dist, 0.0, 0.0));
265  Ptr<LteUeNetDevice> lteUeDev = ueDevs.Get (i)->GetObject<LteUeNetDevice> ();
266  Ptr<LteUePhy> uePhy = lteUeDev->GetPhy ();
267  uePhy->SetAttribute ("TxPower", DoubleValue (23.0));
268  uePhy->SetAttribute ("NoiseFigure", DoubleValue (9.0));
269  }
270 
271  lteHelper->EnableRlcTraces ();
272 
273  double simulationTime = 1.0;
274  double tolerance = 0.1;
275  Simulator::Stop (Seconds (simulationTime));
276 
277  Ptr<RadioBearerStatsCalculator> rlcStats = lteHelper->GetRlcStats ();
278  rlcStats->SetAttribute ("EpochDuration", TimeValue (Seconds (simulationTime)));
279 
280  Simulator::Run ();
281 
285  NS_LOG_INFO ("DL - Test with " << m_nUser << " user(s) at distance " << m_dist);
286  std::vector <uint64_t> dlDataRxed;
287  for (int i = 0; i < m_nUser; i++)
288  {
289  // get the imsi
290  uint64_t imsi = ueDevs.Get (i)->GetObject<LteUeNetDevice> ()->GetImsi ();
291  // get the lcId
292  uint8_t lcId = ueDevs.Get (i)->GetObject<LteUeNetDevice> ()->GetRrc ()->GetLcIdVector ().at (0);
293  dlDataRxed.push_back (rlcStats->GetDlRxData (imsi, lcId));
294  NS_LOG_INFO ("\tUser " << i << " imsi " << imsi << " bytes rxed " << (double)dlDataRxed.at (i) << " thr " << (double)dlDataRxed.at (i) / simulationTime << " ref " << m_thrRefDl);
295  }
302  for (int i = 0; i < m_nUser; i++)
303  {
304  NS_TEST_ASSERT_MSG_EQ_TOL ((double)dlDataRxed.at (i) / simulationTime, m_thrRefDl, m_thrRefDl * tolerance, " Unfair Throughput!");
305  }
306 
310  NS_LOG_INFO ("UL - Test with " << m_nUser << " user(s) at distance " << m_dist);
311  std::vector <uint64_t> ulDataRxed;
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  // get the lcId
317  uint8_t lcId = ueDevs.Get (i)->GetObject<LteUeNetDevice> ()->GetRrc ()->GetLcIdVector ().at (0);
318  ulDataRxed.push_back (rlcStats->GetUlRxData (imsi, lcId));
319  NS_LOG_INFO ("\tUser " << i << " imsi " << imsi << " bytes rxed " << (double)ulDataRxed.at (i) << " thr " << (double)ulDataRxed.at (i) / simulationTime << " ref " << m_thrRefUl);
320  }
327  for (int i = 0; i < m_nUser; i++)
328  {
329  NS_TEST_ASSERT_MSG_EQ_TOL ((double)ulDataRxed.at (i) / simulationTime, m_thrRefUl, m_thrRefUl * tolerance, " Unfair Throughput!");
330  }
332 
333 }
334 
335 
336 
337 // --------------- T E S T - C A S E # 2 ------------------------------
338 
339 
340 std::string
341 LenaTdBetFfMacSchedulerTestCase2::BuildNameString (uint16_t nUser, std::vector<uint16_t> dist)
342 {
343  std::ostringstream oss;
344  oss << "distances (m) = [ " ;
345  for (std::vector<uint16_t>::iterator it = dist.begin (); it != dist.end (); ++it)
346  {
347  oss << *it << " ";
348  }
349  oss << "]";
350  return oss.str ();
351 }
352 
353 
354 LenaTdBetFfMacSchedulerTestCase2::LenaTdBetFfMacSchedulerTestCase2 (std::vector<uint16_t> dist, std::vector<uint32_t> estAchievableRateDl, std::vector<uint32_t> estThrTdBetUl)
355  : TestCase (BuildNameString (dist.size (), dist)),
356  m_nUser (dist.size ()),
357  m_dist (dist),
358  m_achievableRateDl (estAchievableRateDl),
359  m_estThrTdBetUl (estThrTdBetUl)
360 {
361 }
362 
364 {
365 }
366 
367 void
369 {
371  //LogComponentEnable ("LenaTestTdBetFfMacCheduler", LOG_LEVEL_ALL);
372 
377  Ptr<LteHelper> lteHelper = CreateObject<LteHelper> ();
378 
379  lteHelper->SetAttribute ("PathlossModel", StringValue ("ns3::FriisSpectrumPropagationLossModel"));
380 
381  // Create Nodes: eNodeB and UE
382  NodeContainer enbNodes;
383  NodeContainer ueNodes;
384  enbNodes.Create (1);
385  ueNodes.Create (m_nUser);
386 
387  // Install Mobility Model
388  MobilityHelper mobility;
389  mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel");
390  mobility.Install (enbNodes);
391  mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel");
392  mobility.Install (ueNodes);
393 
394  // Create Devices and install them in the Nodes (eNB and UE)
395  NetDeviceContainer enbDevs;
396  NetDeviceContainer ueDevs;
397  lteHelper->SetSchedulerType ("ns3::TdBetFfMacScheduler");
398  enbDevs = lteHelper->InstallEnbDevice (enbNodes);
399  ueDevs = lteHelper->InstallUeDevice (ueNodes);
400 
401  // Attach a UE to a eNB
402  lteHelper->Attach (ueDevs, enbDevs.Get (0));
403 
404  // Activate an EPS bearer
406  EpsBearer bearer (q);
407  lteHelper->ActivateEpsBearer (ueDevs, bearer, EpcTft::Default ());
408 
409  Ptr<LteEnbNetDevice> lteEnbDev = enbDevs.Get (0)->GetObject<LteEnbNetDevice> ();
410  Ptr<LteEnbPhy> enbPhy = lteEnbDev->GetPhy ();
411  enbPhy->SetAttribute ("TxPower", DoubleValue (30.0));
412  enbPhy->SetAttribute ("NoiseFigure", DoubleValue (5.0));
413 
414  // Set UEs' position and power
415  for (int i = 0; i < m_nUser; i++)
416  {
418  mm->SetPosition (Vector (m_dist.at (i), 0.0, 0.0));
419  Ptr<LteUeNetDevice> lteUeDev = ueDevs.Get (i)->GetObject<LteUeNetDevice> ();
420  Ptr<LteUePhy> uePhy = lteUeDev->GetPhy ();
421  uePhy->SetAttribute ("TxPower", DoubleValue (23.0));
422  uePhy->SetAttribute ("NoiseFigure", DoubleValue (9.0));
423  }
424 
425  lteHelper->EnableRlcTraces ();
426 
427  double simulationTime = 1;
428  double tolerance = 0.1;
429  Simulator::Stop (Seconds (simulationTime));
430 
431  Ptr<RadioBearerStatsCalculator> rlcStats = lteHelper->GetRlcStats ();
432  rlcStats->SetAttribute ("EpochDuration", TimeValue (Seconds (simulationTime)));
433 
434  Simulator::Run ();
435 
436  NS_LOG_INFO ("DL - Test with " << m_nUser << " user(s)");
437  std::vector <uint64_t> dlDataRxed;
438  double totalData = 0;
439  double estTotalThr = 0;
440  double estUeThr = 0;
441  for (int i = 0; i < m_nUser; i++)
442  {
443  // get the imsi
444  uint64_t imsi = ueDevs.Get (i)->GetObject<LteUeNetDevice> ()->GetImsi ();
445  // get the lcId
446  uint8_t lcId = ueDevs.Get (i)->GetObject<LteUeNetDevice> ()->GetRrc ()->GetLcIdVector ().at (0);
447  dlDataRxed.push_back (rlcStats->GetDlRxData (imsi, lcId));
448  totalData += (double)dlDataRxed.at (i);
449  estTotalThr += 1 / m_achievableRateDl.at (i);
450  //NS_LOG_INFO ("\tUser " << i << " dist " << m_dist.at (i) << " imsi " << imsi << " bytes rxed " << (double)dlDataRxed.at (i) << " thr " << (double)dlDataRxed.at (i) / simulationTime << " ref " << m_nUser);
451  }
452 
453  estTotalThr = m_nUser * (1 / estTotalThr);
454  estUeThr = estTotalThr / m_nUser;
455 
460  for (int i = 0; i < m_nUser; i++)
461  {
462  double thrRatio = (double) 1 / m_nUser;
463  double estThrRatio = (double)dlDataRxed.at (i) / totalData;
464  NS_LOG_INFO ("\tUser " << i << " thrRatio " << thrRatio << " estThrRatio " << estThrRatio);
465  NS_TEST_ASSERT_MSG_EQ_TOL (estThrRatio, thrRatio, tolerance, " Unfair Throughput!");
466  NS_TEST_ASSERT_MSG_EQ_TOL ((double)dlDataRxed.at (i) / simulationTime, estUeThr, estUeThr * tolerance, " Unfair Throughput!");
467  }
468 
473  NS_LOG_INFO ("UL - Test with " << m_nUser);
474  std::vector <uint64_t> ulDataRxed;
475  for (int i = 0; i < m_nUser; i++)
476  {
477  // get the imsi
478  uint64_t imsi = ueDevs.Get (i)->GetObject<LteUeNetDevice> ()->GetImsi ();
479  // get the lcId
480  uint8_t lcId = ueDevs.Get (i)->GetObject<LteUeNetDevice> ()->GetRrc ()->GetLcIdVector ().at (0);
481  ulDataRxed.push_back (rlcStats->GetUlRxData (imsi, lcId));
482  NS_LOG_INFO ("\tUser " << i << " dist " << m_dist.at (i) << " bytes rxed " << (double)ulDataRxed.at (i) << " thr " << (double)ulDataRxed.at (i) / simulationTime << " ref " << (double)m_estThrTdBetUl.at (i));
483  NS_TEST_ASSERT_MSG_EQ_TOL ((double)ulDataRxed.at (i) / simulationTime, (double)m_estThrTdBetUl.at (i), (double)m_estThrTdBetUl.at (i) * tolerance, " Unfair Throughput!");
484  }
486 
487 }
488 
489 
490 } // namespace ns3
491 
492 
493 
494