A Discrete-Event Network Simulator
API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
lte-test-tdtbfq-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 
52 #include "ns3/point-to-point-epc-helper.h"
53 #include "ns3/network-module.h"
54 #include "ns3/ipv4-global-routing-helper.h"
55 #include "ns3/internet-module.h"
56 #include "ns3/applications-module.h"
57 #include "ns3/point-to-point-helper.h"
58 
60 
61 NS_LOG_COMPONENT_DEFINE ("LenaTestTdTbfqFfMacScheduler");
62 
63 namespace ns3 {
64 
66  : TestSuite ("lte-tdtbfq-ff-mac-scheduler", SYSTEM)
67 {
68  NS_LOG_INFO ("creating LenaTestTdTbfqFfMacSchedulerSuite");
69 
70  bool errorModel = false;
71 
72  // General config
73  // Traffic: UDP traffic with fixed rate
74  // Token generation rate = traffic rate
75  // RLC header length = 2 bytes, PDCP header = 2 bytes
76  // Simulation time = 1.0 sec
77  // Throughput in this file is calculated in RLC layer
78 
79  //Test Case 1: homogeneous flow test in TDTBFQ (same distance)
80  // DOWNLINK -> DISTANCE 0 -> MCS 28 -> Itbs 26 (from table 7.1.7.2.1-1 of 36.2 13)
81  // Traffic info
82  // UDP traffic: payload size = 200 bytes, interval = 1 ms
83  // UDP rate in scheduler: (payload + RLC header + PDCP header + IP header + UDP header) * 1000 byte/sec -> 232000 byte/rate
84  // Totol bandwidth: 24 PRB at Itbs 26 -> 2196 -> 2196000 byte/sec
85  // 1 user -> 232000 * 1 = 232000 < 2196000 -> throughput = 232000 byte/sec
86  // 3 user -> 232000 * 3 = 696000 < 2196000 -> througphut = 232000 byte/sec
87  // 6 user -> 232000 * 6 = 139200 < 2196000 -> throughput = 232000 byte/sec
88  // 12 user -> 232000 * 12 = 2784000 > 2196000 -> throughput = 2196000 / 12 = 183000 byte/sec
89  // UPLINK -> DISTANCE 0 -> MCS 28 -> Itbs 26 (from table 7.1.7.2.1-1 of 36.2 13)
90  // 1 user -> 25 PRB at Itbs 26 -> 2292 -> 2292000 > 232000 -> throughput = 232000 bytes/sec
91  // 3 users -> 8 PRB at Itbs 26 -> 749 -> 749000 > 232000 -> throughput = 232000 bytes/sec
92  // 6 users -> 4 PRB at Itbs 26 -> 373 -> 373000 > 232000 -> throughput = 232000 bytes/sec
93  // 12 users -> 2 PRB at Itbs 26 -> 185 -> 185000 < 232000 -> throughput = 185000 bytes/sec
94  AddTestCase (new LenaTdTbfqFfMacSchedulerTestCase1 (1,0,232000,232000,200,1,errorModel), TestCase::EXTENSIVE);
95  AddTestCase (new LenaTdTbfqFfMacSchedulerTestCase1 (3,0,232000,232000,200,1,errorModel), TestCase::EXTENSIVE);
96  AddTestCase (new LenaTdTbfqFfMacSchedulerTestCase1 (6,0,232000,232000,200,1,errorModel), TestCase::EXTENSIVE);
97  //AddTestCase (new LenaTdTbfqFfMacSchedulerTestCase1 (12,0,183000,185000,200,1,errorModel));// simulation time = 1.5, otherwise, ul test will fail
98 
99  // DOWNLINK - DISTANCE 4800 -> MCS 22 -> Itbs 20 (from table 7.1.7.2.1-1 of 36.213)
100  // Traffic info
101  // UDP traffic: payload size = 200 bytes, interval = 1 ms
102  // UDP rate in scheduler: (payload + RLC header + PDCP header + IP header + UDP header) * 1000 byte/sec -> 232000 byte/rate
103  // Totol bandwidth: 24 PRB at Itbs 20 -> 1383 -> 1383000 byte/sec
104  // 1 user -> 903000 * 1 = 232000 < 1383000 -> throughput = 232000 byte/sec
105  // 3 user -> 232000 * 3 = 696000 < 1383000 -> througphut = 232000 byte/sec
106  // 6 user -> 232000 * 6 = 1392000 > 1383000 -> throughput = 1383000 / 6 = 230500 byte/sec
107  // 12 user -> 232000 * 12 = 2784000 > 903000 -> throughput = 1383000 / 12 = 115250 byte/sec
108  // UPLINK - DISTANCE 4800 -> MCS 14 -> Itbs 13 (from table 7.1.7.2.1-1 of 36.213)
109  // 1 user -> 25 PRB at Itbs 13 -> 807 -> 807000 > 232000 -> throughput = 232000 bytes/sec
110  // 3 users -> 8 PRB at Itbs 13 -> 253 -> 253000 > 232000 -> throughput = 232000 bytes/sec
111  // 6 users -> 4 PRB at Itbs 13 -> 125 -> 125000 < 232000 -> throughput = 125000 bytes/sec
112  // after the patch enforcing min 3 PRBs per UE:
113  // 12 users -> 3 PRB at Itbs 13 -> 93 bytes * 8/12 UE/TTI -> 62000 < 232000 -> throughput = 62000 bytes/sec
114  AddTestCase (new LenaTdTbfqFfMacSchedulerTestCase1 (1,4800,232000,232000,200,1,errorModel), TestCase::EXTENSIVE);
115  AddTestCase (new LenaTdTbfqFfMacSchedulerTestCase1 (3,4800,232000,232000,200,1,errorModel), TestCase::EXTENSIVE);
116  AddTestCase (new LenaTdTbfqFfMacSchedulerTestCase1 (6,4800,230500,125000,200,1,errorModel), TestCase::EXTENSIVE);
117  //AddTestCase (new LenaTdTbfqFfMacSchedulerTestCase1 (12,4800,115250,62000,200,1,errorModel)); // simulation time = 1.5, otherwise, ul test will fail
118 
119  // DOWNLINK - DISTANCE 6000 -> MCS 20 -> Itbs 18 (from table 7.1.7.2.1-1 of 36.213)
120  // Traffic info
121  // UDP traffic: payload size = 200 bytes, interval = 1 ms
122  // UDP rate in scheduler: (payload + RLC header + PDCP header + IP header + UDP header) * 1000 byte/sec -> 232000 byte/rate
123  // Totol bandwidth: 24 PRB at Itbs 18 -> 1191 -> 1191000 byte/sec
124  // 1 user -> 903000 * 1 = 232000 < 1191000 -> throughput = 232000 byte/sec
125  // 3 user -> 232000 * 3 = 696000 < 1191000 -> througphut = 232000 byte/sec
126  // 6 user -> 232000 * 6 = 1392000 > 1191000 -> throughput = 1191000 / 6 = 198500 byte/sec
127  // 12 user -> 232000 * 12 = 2784000 > 1191000 -> throughput = 1191000 / 12 = 99250 byte/sec
128 
129  // UPLINK - DISTANCE 6000 -> MCS 12 -> Itbs 11 (from table 7.1.7.2.1-1 of 36.213)
130  // 1 user -> 25 PRB at Itbs 11 -> 621 -> 621000 > 232000 -> throughput = 232000 bytes/sec
131  // 3 users -> 8 PRB at Itbs 11 -> 201 -> 201000 < 232000 -> throughput = 201000 bytes/sec
132  // 6 users -> 4 PRB at Itbs 11 -> 97 -> 97000 < 232000 -> throughput = 97000 bytes/sec
133  // after the patch enforcing min 3 PRBs per UE:
134  // 12 users -> 3 PRB at Itbs 11 -> 73 bytes * 8/12 UE/TTI -> 48667 < 232000 -> throughput = 48667 bytes/sec
135  AddTestCase (new LenaTdTbfqFfMacSchedulerTestCase1 (1,6000,232000,232000,200,1,errorModel), TestCase::EXTENSIVE);
136  AddTestCase (new LenaTdTbfqFfMacSchedulerTestCase1 (3,6000,232000,201000,200,1,errorModel), TestCase::EXTENSIVE);
137  AddTestCase (new LenaTdTbfqFfMacSchedulerTestCase1 (6,6000,198500,97000,200,1,errorModel), TestCase::EXTENSIVE);
138  //AddTestCase (new LenaTdTbfqFfMacSchedulerTestCase1 (12,6000,99250,48667,200,1, errorModel)); // simulation time = 1.5, otherwise, ul test will fail
139 
140  // DOWNLINK - DISTANCE 10000 -> MCS 14 -> Itbs 13 (from table 7.1.7.2.1-1 of 36.213)
141  // Traffic info
142  // UDP traffic: payload size = 200 bytes, interval = 1 ms
143  // UDP rate in scheduler: (payload + RLC header + PDCP header + IP header + UDP header) * 1000 byte/sec -> 232000 byte/rate
144  // Totol bandwidth: 24 PRB at Itbs 13 -> 775 -> 775000 byte/sec
145  // 1 user -> 903000 * 1 = 232000 < 775000 -> throughput = 232000 byte/sec
146  // 3 user -> 232000 * 3 = 696000 < 775000 -> througphut = 232000 byte/sec
147  // 6 user -> 232000 * 6 = 1392000 > 775000 -> throughput = 775000 / 6 = 129166 byte/sec
148  // 12 user -> 232000 * 12 = 2784000 > 775000 -> throughput = 775000 / 12 = 64583 byte/sec
149  // UPLINK - DISTANCE 10000 -> MCS 8 -> Itbs 8 (from table 7.1.7.2.1-1 of 36.213)
150  // 1 user -> 24 PRB at Itbs 8 -> 437 -> 437000 > 232000 -> throughput = 232000 bytes/sec
151  // 3 users -> 8 PRB at Itbs 8 -> 137 -> 137000 < 232000 -> throughput = 137000 bytes/sec
152  // 6 users -> 4 PRB at Itbs 8 -> 67 -> 67000 < 232000 -> throughput = 67000 bytes/sec
153  // after the patch enforcing min 3 PRBs per UE:
154  // 12 users -> 3 PRB at Itbs 8 -> 49 bytes * 8/12 UE/TTI -> 32667 < 232000 -> throughput = 32667 bytes/sec
155  AddTestCase (new LenaTdTbfqFfMacSchedulerTestCase1 (1,10000,232000,232000,200,1,errorModel), TestCase::EXTENSIVE);
156  AddTestCase (new LenaTdTbfqFfMacSchedulerTestCase1 (3,10000,232000,137000,200,1,errorModel), TestCase::EXTENSIVE);
157  AddTestCase (new LenaTdTbfqFfMacSchedulerTestCase1 (6,10000,129166,67000,200,1,errorModel), TestCase::EXTENSIVE);
158  //AddTestCase (new LenaTdTbfqFfMacSchedulerTestCase1 (12,10000,64583,32667,200,1,errorModel));// simulation time = 1.5, otherwise, ul test will fail
159 
160  // Test Case 2: homogeneous flow test in TDTBFQ (different distance)
161  // Traffic1 info
162  // UDP traffic: payload size = 100 bytes, interval = 1 ms
163  // UDP rate in scheduler: (payload + RLC header + PDCP header + IP header + UDP header) * 1000 byte/sec -> 132000 byte/rate
164  // Maximum throughput = 4 / ( 1/2196000 + 1/1383000 + 1/1191000 + 1/775000 ) = 1209000 byte/s
165  // 132000 * 4 = 528000 < 1209000 -> estimated throughput in downlink = 132000 byte/sec
166  std::vector<uint16_t> dist1;
167  dist1.push_back (0); // User 0 distance --> MCS 28
168  dist1.push_back (4800); // User 1 distance --> MCS 22
169  dist1.push_back (6000); // User 2 distance --> MCS 20
170  dist1.push_back (10000); // User 3 distance --> MCS 14
171  std::vector<uint16_t> packetSize1;
172  packetSize1.push_back (100);
173  packetSize1.push_back (100);
174  packetSize1.push_back (100);
175  packetSize1.push_back (100);
176  std::vector<uint32_t> estThrTdTbfqDl1;
177  estThrTdTbfqDl1.push_back (132000); // User 0 estimated TTI throughput from TDTBFQ
178  estThrTdTbfqDl1.push_back (132000); // User 1 estimated TTI throughput from TDTBFQ
179  estThrTdTbfqDl1.push_back (132000); // User 2 estimated TTI throughput from TDTBFQ
180  estThrTdTbfqDl1.push_back (132000); // User 3 estimated TTI throughput from TDTBFQ
181  AddTestCase (new LenaTdTbfqFfMacSchedulerTestCase2 (dist1,estThrTdTbfqDl1,packetSize1,1,errorModel), TestCase::EXTENSIVE);
182 
183  // Traffic2 info
184  // UDP traffic: payload size = 300 bytes, interval = 1 ms
185  // UDP rate in scheduler: (payload + RLC header + PDCP header + IP header + UDP header) * 1000 byte/sec -> 332000 byte/rate
186  // Maximum throughput = 4 / ( 1/2196000 + 1/1383000 + 1/1191000 + 1/775000 ) = 1209000 byte/s
187  // 332000 * 4 = 1328000 > 1209000 -> estimated throughput in downlink = 1209000 / 4 = 302500 byte/sec
188  std::vector<uint16_t> dist2;
189  dist2.push_back (0); // User 0 distance --> MCS 28
190  dist2.push_back (4800); // User 1 distance --> MCS 22
191  dist2.push_back (6000); // User 2 distance --> MCS 20
192  dist2.push_back (10000); // User 3 distance --> MCS 14
193  std::vector<uint16_t> packetSize2;
194  packetSize2.push_back (300);
195  packetSize2.push_back (300);
196  packetSize2.push_back (300);
197  packetSize2.push_back (300);
198  std::vector<uint32_t> estThrTdTbfqDl2;
199  estThrTdTbfqDl2.push_back (302500); // User 0 estimated TTI throughput from TDTBFQ
200  estThrTdTbfqDl2.push_back (302500); // User 1 estimated TTI throughput from TDTBFQ
201  estThrTdTbfqDl2.push_back (302500); // User 2 estimated TTI throughput from TDTBFQ
202  estThrTdTbfqDl2.push_back (302500); // User 3 estimated TTI throughput from TDTBFQ
203  AddTestCase (new LenaTdTbfqFfMacSchedulerTestCase2 (dist2,estThrTdTbfqDl2,packetSize2,1,errorModel), TestCase::EXTENSIVE);
204 
205  // Test Case 3: heterogeneous flow test in TDTBFQ
206  // UDP traffic: payload size = [100,200,300] bytes, interval = 1 ms
207  // UDP rate in scheduler: (payload + RLC header + PDCP header + IP header + UDP header) * 1000 byte/sec -> [132000, 232000, 332000] byte/rate
208  // Maximum throughput = 3 / ( 1/2196000 + 1/1383000 + 1/1191000 ) = 1486666 byte/s
209  // 132000 + 232000 + 332000 = 696000 < 1486666 -> estimated throughput in downlink = [132000, 232000, 332000] byte/sec
210  std::vector<uint16_t> dist3;
211  dist3.push_back (0); // User 0 distance --> MCS 28
212  dist3.push_back (4800); // User 1 distance --> MCS 22
213  dist3.push_back (6000); // User 2 distance --> MCS 20
214  std::vector<uint16_t> packetSize3;
215  packetSize3.push_back (100);
216  packetSize3.push_back (200);
217  packetSize3.push_back (300);
218  std::vector<uint32_t> estThrTdTbfqDl3;
219  estThrTdTbfqDl3.push_back (132000); // User 0 estimated TTI throughput from TDTBFQ
220  estThrTdTbfqDl3.push_back (232000); // User 1 estimated TTI throughput from TDTBFQ
221  estThrTdTbfqDl3.push_back (332000); // User 2 estimated TTI throughput from TDTBFQ
222  AddTestCase (new LenaTdTbfqFfMacSchedulerTestCase2 (dist3,estThrTdTbfqDl3,packetSize3,1,errorModel), TestCase::QUICK);
223 
224 }
225 
227 
228 // --------------- T E S T - C A S E # 1 ------------------------------
229 
230 
231 std::string
233 {
234  std::ostringstream oss;
235  oss << nUser << " UEs, distance " << dist << " m";
236  return oss.str ();
237 }
238 
239 
240 LenaTdTbfqFfMacSchedulerTestCase1::LenaTdTbfqFfMacSchedulerTestCase1 (uint16_t nUser, uint16_t dist, double thrRefDl, double thrRefUl, uint16_t packetSize, uint16_t interval,bool errorModelEnabled)
241  : TestCase (BuildNameString (nUser, dist)),
242  m_nUser (nUser),
243  m_dist (dist),
244  m_packetSize (packetSize),
245  m_interval (interval),
246  m_thrRefDl (thrRefDl),
247  m_thrRefUl (thrRefUl),
248  m_errorModelEnabled (errorModelEnabled)
249 {
250 }
251 
253 {
254 }
255 
256 void
258 {
259  NS_LOG_FUNCTION (this << GetName ());
260 
261  if (!m_errorModelEnabled)
262  {
263  Config::SetDefault ("ns3::LteSpectrumPhy::CtrlErrorModelEnabled", BooleanValue (false));
264  Config::SetDefault ("ns3::LteSpectrumPhy::DataErrorModelEnabled", BooleanValue (false));
265  }
266 
267  Config::SetDefault ("ns3::LteHelper::UseIdealRrc", BooleanValue (true));
268 
269  Ptr<LteHelper> lteHelper = CreateObject<LteHelper> ();
270  Ptr<PointToPointEpcHelper> epcHelper = CreateObject<PointToPointEpcHelper> ();
271  lteHelper->SetEpcHelper (epcHelper);
272 
273  //LogComponentEnable ("TdTbfqFfMacScheduler", LOG_DEBUG);
274 
275  Ptr<Node> pgw = epcHelper->GetPgwNode ();
276 
277  // Create a single RemoteHost
278  NodeContainer remoteHostContainer;
279  remoteHostContainer.Create (1);
280  Ptr<Node> remoteHost = remoteHostContainer.Get (0);
281  InternetStackHelper internet;
282  internet.Install (remoteHostContainer);
283 
284  // Create the Internet
285  PointToPointHelper p2ph;
286  p2ph.SetDeviceAttribute ("DataRate", DataRateValue (DataRate ("100Gb/s")));
287  p2ph.SetDeviceAttribute ("Mtu", UintegerValue (1500));
288  p2ph.SetChannelAttribute ("Delay", TimeValue (Seconds (0.001)));
289  NetDeviceContainer internetDevices = p2ph.Install (pgw, remoteHost);
290  Ipv4AddressHelper ipv4h;
291  ipv4h.SetBase ("1.0.0.0", "255.0.0.0");
292  Ipv4InterfaceContainer internetIpIfaces = ipv4h.Assign (internetDevices);
293  // interface 0 is localhost, 1 is the p2p device
294  Ipv4Address remoteHostAddr = internetIpIfaces.GetAddress (1);
295 
296  Ipv4StaticRoutingHelper ipv4RoutingHelper;
297  Ptr<Ipv4StaticRouting> remoteHostStaticRouting = ipv4RoutingHelper.GetStaticRouting (remoteHost->GetObject<Ipv4> ());
298  remoteHostStaticRouting->AddNetworkRouteTo (Ipv4Address ("7.0.0.0"), Ipv4Mask ("255.0.0.0"), 1);
299 
300  //Config::SetDefault ("ns3::LteAmc::AmcModel", EnumValue (LteAmc::PiroEW2010));
301  //Config::SetDefault ("ns3::LteAmc::Ber", DoubleValue (0.00005));
302  //Config::SetDefault ("ns3::LteSpectrumPhy::CtrlErrorModelEnabled", BooleanValue (false));
303  //Config::SetDefault ("ns3::LteSpectrumPhy::DataErrorModelEnabled", BooleanValue (false));
304 
305  //Config::SetDefault ("ns3::LteEnbRrc::EpsBearerToRlcMapping", EnumValue (LteHelper::RLC_UM_ALWAYS));
306 
307 // LogComponentDisableAll (LOG_LEVEL_ALL);
308  //LogComponentEnable ("LenaTestTdTbfqFfMacCheduler", LOG_LEVEL_ALL);
309 
310  lteHelper->SetAttribute ("PathlossModel", StringValue ("ns3::FriisSpectrumPropagationLossModel"));
311 
312  // Create Nodes: eNodeB and UE
313  NodeContainer enbNodes;
314  NodeContainer ueNodes;
315  enbNodes.Create (1);
316  ueNodes.Create (m_nUser);
317 
318  // Install Mobility Model
319  MobilityHelper mobility;
320  mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel");
321  mobility.Install (enbNodes);
322  mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel");
323  mobility.Install (ueNodes);
324 
325  // Create Devices and install them in the Nodes (eNB and UE)
326  NetDeviceContainer enbDevs;
327  NetDeviceContainer ueDevs;
328  lteHelper->SetSchedulerType ("ns3::TdTbfqFfMacScheduler");
329  enbDevs = lteHelper->InstallEnbDevice (enbNodes);
330  ueDevs = lteHelper->InstallUeDevice (ueNodes);
331 
332 
333  Ptr<LteEnbNetDevice> lteEnbDev = enbDevs.Get (0)->GetObject<LteEnbNetDevice> ();
334  Ptr<LteEnbPhy> enbPhy = lteEnbDev->GetPhy ();
335  enbPhy->SetAttribute ("TxPower", DoubleValue (30.0));
336  enbPhy->SetAttribute ("NoiseFigure", DoubleValue (5.0));
337 
338  // Set UEs' position and power
339  for (int i = 0; i < m_nUser; i++)
340  {
342  mm->SetPosition (Vector (m_dist, 0.0, 0.0));
343  Ptr<LteUeNetDevice> lteUeDev = ueDevs.Get (i)->GetObject<LteUeNetDevice> ();
344  Ptr<LteUePhy> uePhy = lteUeDev->GetPhy ();
345  uePhy->SetAttribute ("TxPower", DoubleValue (23.0));
346  uePhy->SetAttribute ("NoiseFigure", DoubleValue (9.0));
347  }
348 
349  // Install the IP stack on the UEs
350  internet.Install (ueNodes);
351  Ipv4InterfaceContainer ueIpIface;
352  ueIpIface = epcHelper->AssignUeIpv4Address (NetDeviceContainer (ueDevs));
353 
354  // Assign IP address to UEs
355  for (uint32_t u = 0; u < ueNodes.GetN (); ++u)
356  {
357  Ptr<Node> ueNode = ueNodes.Get (u);
358  // Set the default gateway for the UE
359  Ptr<Ipv4StaticRouting> ueStaticRouting = ipv4RoutingHelper.GetStaticRouting (ueNode->GetObject<Ipv4> ());
360  ueStaticRouting->SetDefaultRoute (epcHelper->GetUeDefaultGatewayAddress (), 1);
361  }
362 
363  // Attach a UE to a eNB
364  lteHelper->Attach (ueDevs, enbDevs.Get (0));
365 
366  // Activate an EPS bearer on all UEs
367  for (uint32_t u = 0; u < ueNodes.GetN (); ++u)
368  {
369  Ptr<NetDevice> ueDevice = ueDevs.Get (u);
370  GbrQosInformation qos;
371  qos.gbrDl = (m_packetSize + 32) * (1000 / m_interval) * 8; // bit/s, considering IP, UDP, RLC, PDCP header size
372  qos.gbrUl = 0;
373  qos.mbrDl = qos.gbrDl;
374  qos.mbrUl = 0;
375 
377  EpsBearer bearer (q, qos);
378  lteHelper->ActivateDedicatedEpsBearer (ueDevice, bearer, EpcTft::Default ());
379  }
380 
381  // Install downlind and uplink applications
382  uint16_t dlPort = 1234;
383  uint16_t ulPort = 2000;
384  PacketSinkHelper dlPacketSinkHelper ("ns3::UdpSocketFactory", InetSocketAddress (Ipv4Address::GetAny (), dlPort));
385  PacketSinkHelper ulPacketSinkHelper ("ns3::UdpSocketFactory", InetSocketAddress (Ipv4Address::GetAny (), ulPort));
388  for (uint32_t u = 0; u < ueNodes.GetN (); ++u)
389  {
390  ++ulPort;
391  serverApps.Add (dlPacketSinkHelper.Install (ueNodes.Get (u))); // receive packets from remotehost
392  serverApps.Add (ulPacketSinkHelper.Install (remoteHost)); // receive packets from UEs
393 
394  UdpClientHelper dlClient (ueIpIface.GetAddress (u), dlPort); // uplink packets generator
395  dlClient.SetAttribute ("Interval", TimeValue (MilliSeconds (m_interval)));
396  dlClient.SetAttribute ("MaxPackets", UintegerValue (1000000));
397  dlClient.SetAttribute ("PacketSize", UintegerValue (m_packetSize));
398 
399  UdpClientHelper ulClient (remoteHostAddr, ulPort); // downlink packets generator
400  ulClient.SetAttribute ("Interval", TimeValue (MilliSeconds (m_interval)));
401  ulClient.SetAttribute ("MaxPackets", UintegerValue (1000000));
402  ulClient.SetAttribute ("PacketSize", UintegerValue (m_packetSize));
403 
404  clientApps.Add (dlClient.Install (remoteHost));
405  clientApps.Add (ulClient.Install (ueNodes.Get (u)));
406  }
407 
408  serverApps.Start (Seconds (0.001));
409  clientApps.Start (Seconds (0.001));
410 
411  double statsStartTime = 0.001; // need to allow for RRC connection establishment + SRS
412  double statsDuration = 1;
413  double tolerance = 0.1;
414  Simulator::Stop (Seconds (statsStartTime + statsDuration - 0.0001));
415 
416  lteHelper->EnableRlcTraces ();
417  lteHelper->EnableMacTraces ();
418  Ptr<RadioBearerStatsCalculator> rlcStats = lteHelper->GetRlcStats ();
419  rlcStats->SetAttribute ("StartTime", TimeValue (Seconds (statsStartTime)));
420  rlcStats->SetAttribute ("EpochDuration", TimeValue (Seconds (statsDuration)));
421 
422  Simulator::Run ();
423 
428  NS_LOG_INFO ("DL - Test with " << m_nUser << " user(s) at distance " << m_dist);
429  std::vector <uint64_t> dlDataRxed;
430  for (int i = 0; i < m_nUser; i++)
431  {
432  // get the imsi
433  uint64_t imsi = ueDevs.Get (i)->GetObject<LteUeNetDevice> ()->GetImsi ();
434  // get the lcId
435  uint8_t lcId = 4;
436  uint64_t data = rlcStats->GetDlRxData (imsi, lcId);
437  dlDataRxed.push_back (data);
438  NS_LOG_INFO ("\tUser " << i << " imsi " << imsi << " bytes rxed " << (double)dlDataRxed.at (i) << " thr " << (double)dlDataRxed.at (i) / statsDuration << " ref " << m_thrRefDl);
439  }
440 
441  for (int i = 0; i < m_nUser; i++)
442  {
443  NS_TEST_ASSERT_MSG_EQ_TOL ((double)dlDataRxed.at (i) / statsDuration, m_thrRefDl, m_thrRefDl * tolerance, " Unfair Throughput!");
444  }
445 
450  NS_LOG_INFO ("UL - Test with " << m_nUser << " user(s) at distance " << m_dist);
451  std::vector <uint64_t> ulDataRxed;
452  for (int i = 0; i < m_nUser; i++)
453  {
454  // get the imsi
455  uint64_t imsi = ueDevs.Get (i)->GetObject<LteUeNetDevice> ()->GetImsi ();
456  // get the lcId
457  uint8_t lcId = 4;
458  ulDataRxed.push_back (rlcStats->GetUlRxData (imsi, lcId));
459  NS_LOG_INFO ("\tUser " << i << " imsi " << imsi << " bytes rxed " << (double)ulDataRxed.at (i) << " thr " << (double)ulDataRxed.at (i) / statsDuration << " ref " << m_thrRefUl);
460  }
461 
462  for (int i = 0; i < m_nUser; i++)
463  {
464  NS_TEST_ASSERT_MSG_EQ_TOL ((double)ulDataRxed.at (i) / statsDuration, m_thrRefUl, m_thrRefUl * tolerance, " Unfair Throughput!");
465  }
467 
468 }
469 
470 
471 
472 // --------------- T E S T - C A S E # 2 ------------------------------
473 
474 
475 std::string
476 LenaTdTbfqFfMacSchedulerTestCase2::BuildNameString (uint16_t nUser, std::vector<uint16_t> dist)
477 {
478  std::ostringstream oss;
479  oss << "distances (m) = [ " ;
480  for (std::vector<uint16_t>::iterator it = dist.begin (); it != dist.end (); ++it)
481  {
482  oss << *it << " ";
483  }
484  oss << "]";
485  return oss.str ();
486 }
487 
488 
489 LenaTdTbfqFfMacSchedulerTestCase2::LenaTdTbfqFfMacSchedulerTestCase2 (std::vector<uint16_t> dist, std::vector<uint32_t> estThrTdTbfqDl, std::vector<uint16_t> packetSize, uint16_t interval,bool errorModelEnabled)
490  : TestCase (BuildNameString (dist.size (), dist)),
491  m_nUser (dist.size ()),
492  m_dist (dist),
493  m_packetSize (packetSize),
494  m_interval (interval),
495  m_estThrTdTbfqDl (estThrTdTbfqDl),
496  m_errorModelEnabled (errorModelEnabled)
497 {
498 }
499 
501 {
502 }
503 
504 void
506 {
507 
508  if (!m_errorModelEnabled)
509  {
510  Config::SetDefault ("ns3::LteSpectrumPhy::CtrlErrorModelEnabled", BooleanValue (false));
511  Config::SetDefault ("ns3::LteSpectrumPhy::DataErrorModelEnabled", BooleanValue (false));
512  }
513 
514  Config::SetDefault ("ns3::LteHelper::UseIdealRrc", BooleanValue (true));
515 
516 
517  Ptr<LteHelper> lteHelper = CreateObject<LteHelper> ();
518  Ptr<PointToPointEpcHelper> epcHelper = CreateObject<PointToPointEpcHelper> ();
519  lteHelper->SetEpcHelper (epcHelper);
520 
521  Ptr<Node> pgw = epcHelper->GetPgwNode ();
522 
523  // Create a single RemoteHost
524  NodeContainer remoteHostContainer;
525  remoteHostContainer.Create (1);
526  Ptr<Node> remoteHost = remoteHostContainer.Get (0);
527  InternetStackHelper internet;
528  internet.Install (remoteHostContainer);
529 
530  // Create the Internet
531  PointToPointHelper p2ph;
532  p2ph.SetDeviceAttribute ("DataRate", DataRateValue (DataRate ("100Gb/s")));
533  p2ph.SetDeviceAttribute ("Mtu", UintegerValue (1500));
534  p2ph.SetChannelAttribute ("Delay", TimeValue (Seconds (0.001)));
535  NetDeviceContainer internetDevices = p2ph.Install (pgw, remoteHost);
536  Ipv4AddressHelper ipv4h;
537  ipv4h.SetBase ("1.0.0.0", "255.0.0.0");
538  Ipv4InterfaceContainer internetIpIfaces = ipv4h.Assign (internetDevices);
539  // interface 0 is localhost, 1 is the p2p device
540  Ipv4Address remoteHostAddr = internetIpIfaces.GetAddress (1);
541 
542  Ipv4StaticRoutingHelper ipv4RoutingHelper;
543  Ptr<Ipv4StaticRouting> remoteHostStaticRouting = ipv4RoutingHelper.GetStaticRouting (remoteHost->GetObject<Ipv4> ());
544  remoteHostStaticRouting->AddNetworkRouteTo (Ipv4Address ("7.0.0.0"), Ipv4Mask ("255.0.0.0"), 1);
545 
546 
547 // LogComponentDisableAll (LOG_LEVEL_ALL);
548  //LogComponentEnable ("LenaTestTdTbfqFfMacCheduler", LOG_LEVEL_ALL);
549 
550  lteHelper->SetAttribute ("PathlossModel", StringValue ("ns3::FriisSpectrumPropagationLossModel"));
551 
552  // Create Nodes: eNodeB and UE
553  NodeContainer enbNodes;
554  NodeContainer ueNodes;
555  enbNodes.Create (1);
556  ueNodes.Create (m_nUser);
557 
558  // Install Mobility Model
559  MobilityHelper mobility;
560  mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel");
561  mobility.Install (enbNodes);
562  mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel");
563  mobility.Install (ueNodes);
564 
565  // Create Devices and install them in the Nodes (eNB and UE)
566  NetDeviceContainer enbDevs;
567  NetDeviceContainer ueDevs;
568  lteHelper->SetSchedulerType ("ns3::TdTbfqFfMacScheduler");
569  enbDevs = lteHelper->InstallEnbDevice (enbNodes);
570  ueDevs = lteHelper->InstallUeDevice (ueNodes);
571 
572  Ptr<LteEnbNetDevice> lteEnbDev = enbDevs.Get (0)->GetObject<LteEnbNetDevice> ();
573  Ptr<LteEnbPhy> enbPhy = lteEnbDev->GetPhy ();
574  enbPhy->SetAttribute ("TxPower", DoubleValue (30.0));
575  enbPhy->SetAttribute ("NoiseFigure", DoubleValue (5.0));
576 
577  // Set UEs' position and power
578  for (int i = 0; i < m_nUser; i++)
579  {
581  mm->SetPosition (Vector (m_dist.at (i), 0.0, 0.0));
582  Ptr<LteUeNetDevice> lteUeDev = ueDevs.Get (i)->GetObject<LteUeNetDevice> ();
583  Ptr<LteUePhy> uePhy = lteUeDev->GetPhy ();
584  uePhy->SetAttribute ("TxPower", DoubleValue (23.0));
585  uePhy->SetAttribute ("NoiseFigure", DoubleValue (9.0));
586  }
587 
588  // Install the IP stack on the UEs
589  internet.Install (ueNodes);
590  Ipv4InterfaceContainer ueIpIface;
591  ueIpIface = epcHelper->AssignUeIpv4Address (NetDeviceContainer (ueDevs));
592 
593  // Assign IP address to UEs
594  for (uint32_t u = 0; u < ueNodes.GetN (); ++u)
595  {
596  Ptr<Node> ueNode = ueNodes.Get (u);
597  // Set the default gateway for the UE
598  Ptr<Ipv4StaticRouting> ueStaticRouting = ipv4RoutingHelper.GetStaticRouting (ueNode->GetObject<Ipv4> ());
599  ueStaticRouting->SetDefaultRoute (epcHelper->GetUeDefaultGatewayAddress (), 1);
600  }
601 
602  // Attach a UE to a eNB
603  lteHelper->Attach (ueDevs, enbDevs.Get (0));
604 
605  // Activate an EPS bearer on all UEs
606 
607  uint16_t mbrDl = 0;
608  for (uint32_t u = 0; u < ueNodes.GetN (); ++u)
609  {
610  mbrDl = mbrDl + m_packetSize.at (u);
611  }
612  mbrDl = mbrDl / ueNodes.GetN ();
613 
614  for (uint32_t u = 0; u < ueNodes.GetN (); ++u)
615  {
616  Ptr<NetDevice> ueDevice = ueDevs.Get (u);
617  GbrQosInformation qos;
618  qos.gbrDl = (mbrDl + 32) * (1000 / m_interval) * 8; // bit/s, considering IP, UDP, RLC, PDCP header size
619  qos.gbrUl = 0;
620  qos.mbrDl = qos.gbrDl;
621  qos.mbrUl = 0;
622 
624  EpsBearer bearer (q, qos);
625  lteHelper->ActivateDedicatedEpsBearer (ueDevice, bearer, EpcTft::Default ());
626  }
627 
628 
629  // Install downlind and uplink applications
630  uint16_t dlPort = 1234;
631  uint16_t ulPort = 2000;
632  PacketSinkHelper dlPacketSinkHelper ("ns3::UdpSocketFactory", InetSocketAddress (Ipv4Address::GetAny (), dlPort));
633  PacketSinkHelper ulPacketSinkHelper ("ns3::UdpSocketFactory", InetSocketAddress (Ipv4Address::GetAny (), ulPort));
636  for (uint32_t u = 0; u < ueNodes.GetN (); ++u)
637  {
638  ++ulPort;
639  serverApps.Add (dlPacketSinkHelper.Install (ueNodes.Get (u))); // receive packets from remotehost
640  serverApps.Add (ulPacketSinkHelper.Install (remoteHost)); // receive packets from UEs
641 
642  UdpClientHelper dlClient (ueIpIface.GetAddress (u), dlPort); // uplink packets generator
643  dlClient.SetAttribute ("Interval", TimeValue (MilliSeconds (m_interval)));
644  dlClient.SetAttribute ("MaxPackets", UintegerValue (1000000));
645  dlClient.SetAttribute ("PacketSize", UintegerValue (m_packetSize.at (u)));
646 
647  UdpClientHelper ulClient (remoteHostAddr, ulPort); // downlink packets generator
648  ulClient.SetAttribute ("Interval", TimeValue (MilliSeconds (m_interval)));
649  ulClient.SetAttribute ("MaxPackets", UintegerValue (1000000));
650  ulClient.SetAttribute ("PacketSize", UintegerValue (m_packetSize.at (u)));
651 
652  clientApps.Add (dlClient.Install (remoteHost));
653  clientApps.Add (ulClient.Install (ueNodes.Get (u)));
654  }
655 
656  serverApps.Start (Seconds (0.001));
657  clientApps.Start (Seconds (0.001));
658 
659  double statsStartTime = 0.001; // need to allow for RRC connection establishment + SRS
660  double statsDuration = 1.0;
661  double tolerance = 0.1;
662  Simulator::Stop (Seconds (statsStartTime + statsDuration - 0.0001));
663 
664  lteHelper->EnableRlcTraces ();
665  Ptr<RadioBearerStatsCalculator> rlcStats = lteHelper->GetRlcStats ();
666  rlcStats->SetAttribute ("StartTime", TimeValue (Seconds (statsStartTime)));
667  rlcStats->SetAttribute ("EpochDuration", TimeValue (Seconds (statsDuration)));
668 
669 
670  Simulator::Run ();
671 
676  NS_LOG_INFO ("DL - Test with " << m_nUser << " user(s)");
677  std::vector <uint64_t> dlDataRxed;
678  for (int i = 0; i < m_nUser; i++)
679  {
680  // get the imsi
681  uint64_t imsi = ueDevs.Get (i)->GetObject<LteUeNetDevice> ()->GetImsi ();
682  // get the lcId
683  uint8_t lcId = 4;
684  dlDataRxed.push_back (rlcStats->GetDlRxData (imsi, lcId));
685  NS_LOG_INFO ("\tUser " << i << " dist " << m_dist.at (i) << " imsi " << imsi << " bytes rxed " << (double)dlDataRxed.at (i) << " thr " << (double)dlDataRxed.at (i) / statsDuration << " ref " << m_estThrTdTbfqDl.at (i));
686  }
687 
688  for (int i = 0; i < m_nUser; i++)
689  {
690  NS_TEST_ASSERT_MSG_EQ_TOL ((double)dlDataRxed.at (i) / statsDuration, m_estThrTdTbfqDl.at (i), m_estThrTdTbfqDl.at (i) * tolerance, " Unfair Throughput!");
691  }
692 
694 
695 }
696 
697 
698 } // namespace ns3
699 
700 
701 
702 
holds a vector of ns3::Application pointers.
an Inet address class
static Ipv4Address GetAny(void)
smart pointer class similar to boost::intrusive_ptr
Definition: ptr.h:59
#define NS_LOG_FUNCTION(parameters)
Definition: log.h:345
Hold a bool native type.
Definition: boolean.h:38
holds a vector of std::pair of Ptr and interface index.
hold variables of type string
Definition: string.h:19
Ptr< NetDevice > Get(uint32_t i) const
Get the Ptr stored in this container at a given index.
NetDeviceContainer Install(NodeContainer c)
#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:326
a class to represent an Ipv4 address mask
Definition: ipv4-address.h:210
void Add(ApplicationContainer other)
Append the contents of another ApplicationContainer to the end of this container. ...
A suite of tests to run.
Definition: test.h:1025
Mobility model for which the current position does not change once it has been set and until it is se...
static Ptr< EpcTft > Default()
creates a TFT matching any traffic
Definition: epc-tft.cc:142
static void Run(void)
Run the simulation until one of:
Definition: simulator.cc:157
aggregate IP/TCP/UDP functionality to existing Nodes.
static LenaTestTdTbfqFfMacSchedulerSuite lenaTestTdTbfqFfMacSchedulerSuite
#define NS_LOG_INFO(msg)
Definition: log.h:298
A helper to make it easier to instantiate an ns3::PacketSinkApplication on a set of nodes...
Build a set of PointToPointNetDevice objects.
encapsulates test code
Definition: test.h:849
void SetDeviceAttribute(std::string name, const AttributeValue &value)
Set an attribute value to be propagated to each NetDevice created by the helper.
NS_LOG_COMPONENT_DEFINE("LenaTestTdTbfqFfMacScheduler")
a 3d vector
Definition: vector.h:31
ApplicationContainer Install(NodeContainer c)
tuple clientApps
Definition: first.py:53
static std::string BuildNameString(uint16_t nUser, std::vector< uint16_t > dist)
uint32_t GetN(void) const
Get the number of Ptr stored in this container.
uint64_t gbrUl
Guaranteed Bit Rate (bit/s) in uplink.
Definition: eps-bearer.h:41
This system test program creates different test cases with a single eNB and several UEs...
Class for representing data rates.
Definition: data-rate.h:71
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.
Create a client application which sends UDP packets carrying a 32bit sequence number and a 64 bit tim...
hold objects of type ns3::Time
Definition: nstime.h:961
Hold an unsigned integer type.
Definition: uinteger.h:46
uint8_t data[writeSize]
Medium length test.
Definition: test.h:858
holds a vector of ns3::NetDevice pointers
static std::string BuildNameString(uint16_t nUser, uint16_t dist)
virtual void DoRun(void)
Implementation to actually run this TestCase.
uint64_t gbrDl
Guaranteed Bit Rate (bit/s) in downlink.
Definition: eps-bearer.h:40
LenaTdTbfqFfMacSchedulerTestCase1(uint16_t nUser, uint16_t dist, double thrRefDl, double thrRefUl, uint16_t packetSize, uint16_t interval, bool errorModelEnabled)
void Start(Time start)
Arrange for all of the Applications in this container to Start() at the Time given as a parameter...
static void Destroy(void)
Every event scheduled by the Simulator::insertAtDestroy method is invoked.
Definition: simulator.cc:121
tuple serverApps
Definition: first.py:44
Access to the Ipv4 forwarding table, interfaces, and configuration.
Definition: ipv4.h:75
void SetAttribute(std::string name, const AttributeValue &value)
Record an attribute to be set in each Application after it is is created.
void SetDefault(std::string name, const AttributeValue &value)
Definition: config.cc:667
keep track of a set of node pointers.
uint64_t mbrUl
Maximum Bit Rate (bit/s) in uplink.
Definition: eps-bearer.h:43
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 Install(std::string nodeName) const
Aggregate implementations of the ns3::Ipv4, ns3::Ipv6, ns3::Udp, and ns3::Tcp classes onto the provid...
void AddTestCase(TestCase *testCase) NS_DEPRECATED
Add an individual child TestCase case to this TestCase.
Definition: test.cc:173
LenaTdTbfqFfMacSchedulerTestCase2(std::vector< uint16_t > dist, std::vector< uint32_t > estThrTdTbfqDl, std::vector< uint16_t > packetSize, uint16_t interval, bool errorModelEnabled)
void SetChannelAttribute(std::string name, const AttributeValue &value)
Set an attribute value to be propagated to each Channel created by the helper.
Fast test.
Definition: test.h:857
Helper class used to assign positions and mobility models to nodes.
Ipv4 addresses are stored in host order in this class.
Definition: ipv4-address.h:38
Ipv4InterfaceContainer Assign(const NetDeviceContainer &c)
Assign IP addresses to the net devices specified in the container based on the current network prefix...
Ptr< Ipv4StaticRouting > GetStaticRouting(Ptr< Ipv4 > ipv4) const
Try and find the static routing protocol as either the main routing protocol or in the list of routin...
Helper class that adds ns3::Ipv4StaticRouting objects.
hold objects of type ns3::DataRate
static void Stop(void)
If an event invokes this method, it will be the last event scheduled by the Simulator::run method bef...
Definition: simulator.cc:165
Ptr< Node > Get(uint32_t i) const
Get the Ptr stored in this container at a given index.
virtual void DoRun(void)
Implementation to actually run this TestCase.
ApplicationContainer Install(NodeContainer c) const
Install an ns3::PacketSinkApplication on each node of the input container configured with all the att...
std::string GetName(void) const
Definition: test.cc:242
A helper class to make life easier while doing simple IPv4 address assignment in scripts.
void Create(uint32_t n)
Create n nodes and append pointers to them to the end of this NodeContainer.
uint64_t mbrDl
Maximum Bit Rate (bit/s) in downlink.
Definition: eps-bearer.h:42
3GPP TS 36.143 9.2.1.18 GBR QoS Information
Definition: eps-bearer.h:33
Hold a floating point type.
Definition: double.h:41
The eNodeB device implementation.
Ptr< T > GetObject(void) const
Definition: object.h:361
Qci
QoS Class Indicator.
Definition: eps-bearer.h:77
void SetBase(Ipv4Address network, Ipv4Mask mask, Ipv4Address base="0.0.0.1")
Set the base network number, network mask and base address.
Ipv4Address GetAddress(uint32_t i, uint32_t j=0) const
The LteUeNetDevice class implements the UE net device.