A Discrete-Event Network Simulator
API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
lte-test-pss-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/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 ("LenaTestPssFfMacCheduler");
62 
63 namespace ns3 {
64 
66  : TestSuite ("lte-pss-ff-mac-scheduler", SYSTEM)
67 {
68  NS_LOG_INFO ("creating LenaTestPssFfMacSchedulerSuite");
69 
70  // General config
71  // Traffic: UDP traffic with fixed rate
72  // Token generation rate = traffic rate
73  // RLC header length = 2 bytes, PDCP header = 2 bytes
74  // Simulation time = 1.0 sec
75  // Throughput in this file is calculated in RLC layer
76 
77  //Test Case 1: homogeneous flow test in PSS (same distance)
78 
79  // DOWNLINK -> DISTANCE 0 -> MCS 28 -> Itbs 26 (from table 7.1.7.2.1-1 of 36.2 13)
80  // Traffic info
81  // UDP traffic: payload size = 200 bytes, interval = 1 ms
82  // UDP rate in scheduler: (payload + RLC header + PDCP header + IP header + UDP header) * 1000 byte/sec -> 232000 byte/rate
83  // Totol bandwidth: 24 PRB at Itbs 26 -> 2196 -> 2196000 byte/sec
84  // 1 user -> 232000 * 1 = 232000 < 2196000 -> throughput = 232000 byte/sec
85  // 3 user -> 232000 * 3 = 696000 < 2196000 -> througphut = 232000 byte/sec
86  // 6 user -> 232000 * 6 = 139200 < 2196000 -> throughput = 232000 byte/sec
87  // 12 user -> 232000 * 12 = 2784000 > 2196000 -> throughput = 2196000 / 12 = 183000 byte/sec
88  // UPLINK -> DISTANCE 0 -> MCS 28 -> Itbs 26 (from table 7.1.7.2.1-1 of 36.2 13)
89  // 1 user -> 25 PRB at Itbs 26 -> 2292 -> 2292000 > 232000 -> throughput = 232000 bytes/sec
90  // 3 users -> 8 PRB at Itbs 26 -> 749 -> 749000 > 232000 -> throughput = 232000 bytes/sec
91  // 6 users -> 4 PRB at Itbs 26 -> 373 -> 373000 > 232000 -> throughput = 232000 bytes/sec
92  // 12 users -> 2 PRB at Itbs 26 -> 185 -> 185000 < 232000 -> throughput = 185000 bytes/sec
93  AddTestCase (new LenaPssFfMacSchedulerTestCase1 (1,0,0,232000,232000,200,1));
94  AddTestCase (new LenaPssFfMacSchedulerTestCase1 (3,0,0,232000,232000,200,1));
95  AddTestCase (new LenaPssFfMacSchedulerTestCase1 (6,0,0,232000,232000,200,1));
96  AddTestCase (new LenaPssFfMacSchedulerTestCase1 (12,0,0,183000,185000,200,1));
97 
98  // DOWNLINK - DISTANCE 3000 -> MCS 24 -> Itbs 20 (from table 7.1.7.2.1-1 of 36.213)
99  // DOWNLINK -> DISTANCE 0 -> MCS 28 -> Itbs 26 (from table 7.1.7.2.1-1 of 36.2 13)
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 -> 232000 * 1 = 232000 < 1383000 -> throughput = 232000 byte/sec
105  // 3 user -> 232000 * 3 = 696000 < 1383000 -> througphut = 232000 byte/sec
106  // 6 user -> 232000 * 6 = 139200 > 1383000 -> throughput = 1383000 / 6 = 230500 byte/sec
107  // 12 user -> 232000 * 12 = 2784000 > 1383000 -> throughput = 1383000 / 12 = 115250 byte/sec
108  // UPLINK - DISTANCE 3000 -> MCS 20 -> Itbs 18 (from table 7.1.7.2.1-1 of 36.213)
109  // 1 user -> 25 PRB at Itbs 18 -> 1239 -> 1239000 > 232000 -> throughput = 232000 bytes/sec
110  // 3 users -> 8 PRB at Itbs 18 -> 389 -> 389000 > 232000 -> throughput = 232000 bytes/sec
111  // 6 users -> 4 PRB at Itbs 18 -> 193 -> 193000 < 232000 -> throughput = 193000 bytes/sec
112  // 12 users -> 2 PRB at Itbs 18 -> 97 -> 97000 < 232000 -> throughput = 97000 bytes/sec
113  AddTestCase (new LenaPssFfMacSchedulerTestCase1 (1,0,3000,232000,232000,200,1));
114  AddTestCase (new LenaPssFfMacSchedulerTestCase1 (3,0,3000,232000,232000,200,1));
115  AddTestCase (new LenaPssFfMacSchedulerTestCase1 (6,0,3000,230500,193000,200,1));
116  AddTestCase (new LenaPssFfMacSchedulerTestCase1 (12,0,3000,115250,97000,200,1));
117 
118  // DOWNLINK - DISTANCE 6000 -> MCS 16 -> Itbs 15 (from table 7.1.7.2.1-1 of 36.213)
119  // Traffic info
120  // UDP traffic: payload size = 200 bytes, interval = 1 ms
121  // UDP rate in scheduler: (payload + RLC header + PDCP header + IP header + UDP header) * 1000 byte/sec -> 232000 byte/rate
122  // Totol bandwidth: 24 PRB at Itbs 15 -> 903 -> 903000 byte/sec
123  // 1 user -> 232000 * 1 = 232000 < 903000 -> throughput = 232000 byte/sec
124  // 3 user -> 232000 * 3 = 696000 < 903000 -> througphut = 232000 byte/sec
125  // 6 user -> 232000 * 6 = 139200 > 903000 -> throughput = 903000 / 6 = 150500 byte/sec
126  // 12 user -> 232000 * 12 = 2784000 > 903000 -> throughput = 903000 / 12 = 75250 byte/sec
127  // UPLINK - DISTANCE 6000 -> MCS 12 -> Itbs 11 (from table 7.1.7.2.1-1 of 36.213)
128  // 1 user -> 25 PRB at Itbs 11 -> 621 -> 621000 > 232000 -> throughput = 232000 bytes/sec
129  // 3 users -> 8 PRB at Itbs 11 -> 201 -> 201000 < 232000 -> throughput = 201000 bytes/sec
130  // 6 users -> 4 PRB at Itbs 11 -> 97 -> 97000 < 232000 -> throughput = 97000 bytes/sec
131  // 12 users -> 2 PRB at Itbs 11 -> 47 -> 47000 < 232000 -> throughput = 47000 bytes/sec
132  AddTestCase (new LenaPssFfMacSchedulerTestCase1 (1,0,6000,232000,232000,200,1));
133  AddTestCase (new LenaPssFfMacSchedulerTestCase1 (3,0,6000,232000,201000,200,1));
134  AddTestCase (new LenaPssFfMacSchedulerTestCase1 (6,0,6000,150500,97000,200,1));
135  AddTestCase (new LenaPssFfMacSchedulerTestCase1 (12,0,6000,75250,47000,200,1));
136 
137  // DOWNLINK - DISTANCE 9000 -> MCS 12 -> Itbs 11 (from table 7.1.7.2.1-1 of 36.213)
138  // Traffic info
139  // UDP traffic: payload size = 200 bytes, interval = 1 ms
140  // UDP rate in scheduler: (payload + RLC header + PDCP header + IP header + UDP header) * 1000 byte/sec -> 232000 byte/rate
141  // Totol bandwidth: 24 PRB at Itbs 11 -> 597 -> 597000 byte/sec
142  // 1 user -> 232000 * 1 = 232000 < 597000 -> throughput = 232000 byte/sec
143  // 3 user -> 232000 * 3 = 696000 > 597000 -> througphut = 597000 / 3 = 199000byte/sec
144  // 6 user -> 232000 * 6 = 139200 > 597000 -> throughput = 597000 / 6 = 99500 byte/sec
145  // 12 user -> 232000 * 12 = 2784000 > 597000 -> throughput = 597000 / 12 = 49750 byte/sec
146  // UPLINK - DISTANCE 9000 -> MCS 8 -> Itbs 8 (from table 7.1.7.2.1-1 of 36.213)
147  // 1 user -> 24 PRB at Itbs 8 -> 437 -> 437000 > 232000 -> throughput = 232000 bytes/sec
148  // 3 users -> 8 PRB at Itbs 8 -> 137 -> 137000 < 232000 -> throughput = 137000 bytes/sec
149  // 6 users -> 4 PRB at Itbs 8 -> 67 -> 67000 < 232000 -> throughput = 67000 bytes/sec
150  // 12 users -> 2 PRB at Itbs 8 -> 32 -> 32000 < 232000 -> throughput = 32000 bytes/sec
151  AddTestCase (new LenaPssFfMacSchedulerTestCase1 (1,0,9000,232000,232000,200,1));
152  AddTestCase (new LenaPssFfMacSchedulerTestCase1 (3,0,9000,199000,137000,200,1));
153  AddTestCase (new LenaPssFfMacSchedulerTestCase1 (6,0,9000,99500,67000,200,1));
154  AddTestCase (new LenaPssFfMacSchedulerTestCase1 (12,0,9000,49750,32000,200,1));
155 
156  // DONWLINK - DISTANCE 15000 -> MCS 6 -> Itbs 6 (from table 7.1.7.2.1-1 of 36.213)
157  // Traffic info
158  // UDP traffic: payload size = 200 bytes, interval = 1 ms
159  // UDP rate in scheduler: (payload + RLC header + PDCP header + IP header + UDP header) * 1000 byte/sec -> 232000 byte/rate
160  // Totol bandwidth: 24 PRB at Itbs 6 -> 309 -> 309000 byte/sec
161  // 1 user -> 232000 * 1 = 232000 < 309000 -> throughput = 232000 byte/sec
162  // 3 user -> 232000 * 3 = 696000 > 309000 -> througphut = 309000 / 3 = 103000byte/sec
163  // 6 user -> 232000 * 6 = 139200 > 309000 -> throughput = 309000 / 6 = 51500 byte/sec
164  // 12 user -> 232000 * 12 = 2784000 > 309000 -> throughput = 309000 / 12 = 25750 byte/sec
165  // UPLINK - DISTANCE 15000 -> MCS 6 -> Itbs 6 (from table 7.1.7.2.1-1 of 36.213)
166  // 1 user -> 25 PRB at Itbs 6 -> 233 -> 233000 > 232000 -> throughput = 232000 bytes/sec
167  // 3 users -> 8 PRB at Itbs 6 -> 69 -> 69000 < 232000 -> throughput = 69000 bytes/sec
168  // 6 users -> 4 PRB at Itbs 6 -> 32 -> 32000 < 232000 -> throughput = 32000 bytes/sec
169  // 12 users -> 2 PRB at Itbs 6 -> 15 -> 15000 < 232000 -> throughput = 15000 bytes/sec
170  AddTestCase (new LenaPssFfMacSchedulerTestCase1 (1,0,15000,232000,232000,200,1));
171  AddTestCase (new LenaPssFfMacSchedulerTestCase1 (3,0,15000,103000,69000,200,1));
172  AddTestCase (new LenaPssFfMacSchedulerTestCase1 (6,0,15000,51500,32000,200,1));
173  AddTestCase (new LenaPssFfMacSchedulerTestCase1 (12,0,15000,25750,15000,200,1));
174 
175  // Test Case 2: homogeneous flow test in PSS (different distance)
176  // Traffic1 info
177  // UDP traffic: payload size = 100 bytes, interval = 1 ms
178  // UDP rate in scheduler: (payload + RLC header + PDCP header + IP header + UDP header) * 1000 byte/sec -> 132000 byte/rate
179  // Maximum throughput = 5 / ( 1/2196000 + 1/1383000 + 1/903000 + 1/597000 + 1/309000) = 694720 byte/s
180  // 132000 * 5 = 660000 < 694720 -> estimated throughput in downlink = 694720/5 = 132000 bytes/sec
181  std::vector<uint16_t> dist1;
182  dist1.push_back (0); // User 0 distance --> MCS 28
183  dist1.push_back (3000); // User 1 distance --> MCS 24
184  dist1.push_back (6000); // User 2 distance --> MCS 16
185  dist1.push_back (9000); // User 3 distance --> MCS 12
186  dist1.push_back (15000); // User 4 distance --> MCS 6
187  std::vector<uint16_t> packetSize1;
188  packetSize1.push_back (100);
189  packetSize1.push_back (100);
190  packetSize1.push_back (100);
191  packetSize1.push_back (100);
192  packetSize1.push_back (100);
193  std::vector<uint32_t> estThrPssDl1;
194  estThrPssDl1.push_back (132000);
195  estThrPssDl1.push_back (132000);
196  estThrPssDl1.push_back (132000);
197  estThrPssDl1.push_back (132000);
198  estThrPssDl1.push_back (132000);
199  AddTestCase (new LenaPssFfMacSchedulerTestCase2 (dist1,estThrPssDl1,packetSize1,1));
200 
201  // Traffic2 info
202  // UDP traffic: payload size = 200 bytes, interval = 1 ms
203  // UDP rate in scheduler: (payload + RLC header + PDCP header + IP header + UDP header) * 1000 byte/sec -> 132000 byte/rate
204  // Maximum throughput = 5 / ( 1/2196000 + 1/1383000 + 1/903000 + 1/597000 + 1/309000) = 694720 byte/s
205  // 232000 * 5 = 1160000 > 694720 -> estimated throughput in downlink = 694720/5 = 138944 bytes/sec
206  std::vector<uint16_t> dist2;
207  dist2.push_back (0); // User 0 distance --> MCS 28
208  dist2.push_back (3000); // User 1 distance --> MCS 24
209  dist2.push_back (6000); // User 2 distance --> MCS 16
210  dist2.push_back (9000); // User 3 distance --> MCS 12
211  dist2.push_back (15000); // User 4 distance --> MCS 6
212  std::vector<uint16_t> packetSize2;
213  packetSize2.push_back (200);
214  packetSize2.push_back (200);
215  packetSize2.push_back (200);
216  packetSize2.push_back (200);
217  packetSize2.push_back (200);
218  std::vector<uint32_t> estThrPssDl2;
219  estThrPssDl2.push_back (138944);
220  estThrPssDl2.push_back (138944);
221  estThrPssDl2.push_back (138944);
222  estThrPssDl2.push_back (138944);
223  estThrPssDl2.push_back (138944);
224  AddTestCase (new LenaPssFfMacSchedulerTestCase2 (dist2,estThrPssDl2,packetSize2,1));
225 
226  // Test Case 3: : heterogeneous flow test in PSS (same distance)
227  // Traffic3 info:
228  // UDP traffic: payload size = [100, 200,300,400,500] bytes, interval = 1 ms
229  // UDP rate in scheduler: (payload + RLC header + PDCP header + IP header + UDP header) * 1000 byte/sec -> 232000 byte/rate
230  // Maximum throughput = 2196000 byte/sec
231  // 132000 + 232000 + 332000 + 432000 + 532000 = 1660000 < 2196000 -> estimated throughput in downlink = [132000, 232000,332000, 432000, 53200] bytes/sec
232  std::vector<uint16_t> dist3;
233  dist3.push_back (0); // User 0 distance --> MCS 28
234  dist3.push_back (0); // User 1 distance --> MCS 24
235  dist3.push_back (0); // User 2 distance --> MCS 16
236  dist3.push_back (0); // User 3 distance --> MCS 12
237  dist3.push_back (0); // User 4 distance --> MCS 6
238  std::vector<uint16_t> packetSize3;
239  packetSize3.push_back (100);
240  packetSize3.push_back (200);
241  packetSize3.push_back (300);
242  packetSize3.push_back (400);
243  packetSize3.push_back (500);
244  std::vector<uint32_t> estThrPssDl3;
245  estThrPssDl3.push_back (132000);
246  estThrPssDl3.push_back (232000);
247  estThrPssDl3.push_back (332000);
248  estThrPssDl3.push_back (432000);
249  estThrPssDl3.push_back (532000);
250  AddTestCase (new LenaPssFfMacSchedulerTestCase2 (dist3,estThrPssDl3,packetSize3,1));
251 
252 
253  // Test Case 4: heterogeneous flow test in PSS (different distance)
254  // Traffic4 info
255  // UDP traffic: payload size = [100,200,300] bytes, interval = 1 ms
256  // UDP rate in scheduler: (payload + RLC header + PDCP header + IP header + UDP header) * 1000 byte/sec -> [132000, 232000, 332000] byte/rate
257  // Maximum throughput = 5 / ( 1/2196000 + 1/1383000 + 1/903000 ) = 1312417 byte/s
258  // 132000 + 232000 + 332000 = 696000 < 1312417 -> estimated throughput in downlink = [132000, 232000, 332000] byte/sec
259  std::vector<uint16_t> dist4;
260  dist4.push_back (0); // User 0 distance --> MCS 28
261  dist4.push_back (3000); // User 1 distance --> MCS 24
262  dist4.push_back (6000); // User 2 distance --> MCS 16
263  std::vector<uint16_t> packetSize4;
264  packetSize4.push_back (100);
265  packetSize4.push_back (200);
266  packetSize4.push_back (300);
267  std::vector<uint32_t> estThrPssDl4;
268  estThrPssDl4.push_back (132000); // User 0 estimated TTI throughput from PSS
269  estThrPssDl4.push_back (232000); // User 1 estimated TTI throughput from PSS
270  estThrPssDl4.push_back (332000); // User 2 estimated TTI throughput from PSS
271  AddTestCase (new LenaPssFfMacSchedulerTestCase2 (dist4,estThrPssDl4,packetSize4,1));
272 }
273 
275 
276 // --------------- T E S T - C A S E # 1 ------------------------------
277 
278 
279 std::string
280 LenaPssFfMacSchedulerTestCase1::BuildNameString (uint16_t nUser, uint16_t dist)
281 {
282  std::ostringstream oss;
283  oss << nUser << " UEs, distance " << dist << " m";
284  return oss.str ();
285 }
286 
287 
288 LenaPssFfMacSchedulerTestCase1::LenaPssFfMacSchedulerTestCase1 (uint16_t nUser, uint16_t nLc, uint16_t dist, double thrRefDl, double thrRefUl, uint16_t packetSize, uint16_t interval)
289  : TestCase (BuildNameString (nUser, dist)),
290  m_nUser (nUser),
291  m_nLc (nLc),
292  m_dist (dist),
293  m_packetSize (packetSize),
294  m_interval (interval),
295  m_thrRefDl (thrRefDl),
296  m_thrRefUl (thrRefUl)
297 {
298 }
299 
301 {
302 }
303 
304 void
306 {
307  Ptr<LteHelper> lteHelper = CreateObject<LteHelper> ();
308  Ptr<EpcHelper> epcHelper = CreateObject<EpcHelper> ();
309  lteHelper->SetEpcHelper (epcHelper);
310 
311  Ptr<Node> pgw = epcHelper->GetPgwNode ();
312 
313  // Create a single RemoteHost
314  NodeContainer remoteHostContainer;
315  remoteHostContainer.Create (1);
316  Ptr<Node> remoteHost = remoteHostContainer.Get (0);
317  InternetStackHelper internet;
318  internet.Install (remoteHostContainer);
319 
320  // Create the Internet
321  PointToPointHelper p2ph;
322  p2ph.SetDeviceAttribute ("DataRate", DataRateValue (DataRate ("100Gb/s")));
323  p2ph.SetDeviceAttribute ("Mtu", UintegerValue (1500));
324  p2ph.SetChannelAttribute ("Delay", TimeValue (Seconds (0.001)));
325  NetDeviceContainer internetDevices = p2ph.Install (pgw, remoteHost);
326  Ipv4AddressHelper ipv4h;
327  ipv4h.SetBase ("1.0.0.0", "255.0.0.0");
328  Ipv4InterfaceContainer internetIpIfaces = ipv4h.Assign (internetDevices);
329  // interface 0 is localhost, 1 is the p2p device
330  Ipv4Address remoteHostAddr = internetIpIfaces.GetAddress (1);
331 
332  Ipv4StaticRoutingHelper ipv4RoutingHelper;
333  Ptr<Ipv4StaticRouting> remoteHostStaticRouting = ipv4RoutingHelper.GetStaticRouting (remoteHost->GetObject<Ipv4> ());
334  remoteHostStaticRouting->AddNetworkRouteTo (Ipv4Address ("7.0.0.0"), Ipv4Mask ("255.0.0.0"), 1);
335 
336  Config::SetDefault ("ns3::LteAmc::AmcModel", EnumValue (LteAmc::PiroEW2010));
337  Config::SetDefault ("ns3::LteAmc::Ber", DoubleValue (0.00005));
338  Config::SetDefault ("ns3::LteSpectrumPhy::CtrlErrorModelEnabled", BooleanValue (false));
339  Config::SetDefault ("ns3::LteSpectrumPhy::DataErrorModelEnabled", BooleanValue (false));
340 
341  lteHelper->SetAttribute ("EpsBearerToRlcMapping", EnumValue (LteHelper::RLC_UM_ALWAYS));
342 
344  //LogComponentEnable ("LenaTestPssFfMacCheduler", LOG_LEVEL_ALL);
345 
346  lteHelper->SetAttribute ("PathlossModel", StringValue ("ns3::FriisSpectrumPropagationLossModel"));
347 
348  // Create Nodes: eNodeB and UE
349  NodeContainer enbNodes;
350  NodeContainer ueNodes;
351  enbNodes.Create (1);
352  ueNodes.Create (m_nUser);
353 
354  // Install Mobility Model
355  MobilityHelper mobility;
356  mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel");
357  mobility.Install (enbNodes);
358  mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel");
359  mobility.Install (ueNodes);
360 
361  // Create Devices and install them in the Nodes (eNB and UE)
362  NetDeviceContainer enbDevs;
363  NetDeviceContainer ueDevs;
364  lteHelper->SetSchedulerType ("ns3::PssFfMacScheduler");
365  lteHelper->SetSchedulerAttribute("PssFdSchedulerType", StringValue("PFsch"));
366  enbDevs = lteHelper->InstallEnbDevice (enbNodes);
367  ueDevs = lteHelper->InstallUeDevice (ueNodes);
368 
369  // Attach a UE to a eNB
370  lteHelper->Attach (ueDevs, enbDevs.Get (0));
371 
372  Ptr<LteEnbNetDevice> lteEnbDev = enbDevs.Get (0)->GetObject<LteEnbNetDevice> ();
373  Ptr<LteEnbPhy> enbPhy = lteEnbDev->GetPhy ();
374  enbPhy->SetAttribute ("TxPower", DoubleValue (30.0));
375  enbPhy->SetAttribute ("NoiseFigure", DoubleValue (5.0));
376 
377  // Set UEs' position and power
378  for (int i = 0; i < m_nUser; i++)
379  {
381  mm->SetPosition (Vector (m_dist, 0.0, 0.0));
382  Ptr<LteUeNetDevice> lteUeDev = ueDevs.Get (i)->GetObject<LteUeNetDevice> ();
383  Ptr<LteUePhy> uePhy = lteUeDev->GetPhy ();
384  uePhy->SetAttribute ("TxPower", DoubleValue (23.0));
385  uePhy->SetAttribute ("NoiseFigure", DoubleValue (9.0));
386  }
387 
388  // Install the IP stack on the UEs
389  internet.Install (ueNodes);
390  Ipv4InterfaceContainer ueIpIface;
391  ueIpIface = epcHelper->AssignUeIpv4Address (NetDeviceContainer (ueDevs));
392  // Assign IP address to UEs, and install applications
393  for (uint32_t u = 0; u < ueNodes.GetN (); ++u)
394  {
395  Ptr<Node> ueNode = ueNodes.Get (u);
396  // Set the default gateway for the UE
397  Ptr<Ipv4StaticRouting> ueStaticRouting = ipv4RoutingHelper.GetStaticRouting (ueNode->GetObject<Ipv4> ());
398  ueStaticRouting->SetDefaultRoute (epcHelper->GetUeDefaultGatewayAddress (), 1);
399 
400  // Activate an EPS bearer
401  Ptr<NetDevice> ueDevice = ueDevs.Get (u);
402  GbrQosInformation qos;
403  qos.gbrDl = (m_packetSize + 32) * (1000 / m_interval) * 8 * 1; // bit/
404  qos.gbrUl = (m_packetSize + 32) * (1000 / m_interval) * 8 * 1;
405  qos.mbrDl = 0;
406  qos.mbrUl = 0;
407 
409  EpsBearer bearer (q, qos);
410  lteHelper->ActivateEpsBearer (ueDevice, bearer, EpcTft::Default ());
411  }
412 
413  lteHelper->EnableRlcTraces ();
414 
415  // Install downlind and uplink applications
416  uint16_t dlPort = 1234;
417  uint16_t ulPort = 2000;
418  PacketSinkHelper dlPacketSinkHelper ("ns3::UdpSocketFactory", InetSocketAddress (Ipv4Address::GetAny (), dlPort));
419  PacketSinkHelper ulPacketSinkHelper ("ns3::UdpSocketFactory", InetSocketAddress (Ipv4Address::GetAny (), ulPort));
420  ApplicationContainer clientApps;
421  ApplicationContainer serverApps;
422  for (uint32_t u = 0; u < ueNodes.GetN (); ++u)
423  {
424  ++ulPort;
425  serverApps.Add (dlPacketSinkHelper.Install (ueNodes.Get (u))); // receive packets from remotehost
426  serverApps.Add (ulPacketSinkHelper.Install (remoteHost)); // receive packets from UEs
427 
428  UdpClientHelper dlClient (ueIpIface.GetAddress (u), dlPort); // uplink packets generator
429  dlClient.SetAttribute ("Interval", TimeValue (MilliSeconds (m_interval)));
430  dlClient.SetAttribute ("MaxPackets", UintegerValue (1000000));
431  dlClient.SetAttribute ("PacketSize", UintegerValue (m_packetSize));
432 
433  UdpClientHelper ulClient (remoteHostAddr, ulPort); // downlink packets generator
434  ulClient.SetAttribute ("Interval", TimeValue (MilliSeconds (m_interval)));
435  ulClient.SetAttribute ("MaxPackets", UintegerValue (1000000));
436  ulClient.SetAttribute ("PacketSize", UintegerValue (m_packetSize));
437 
438  clientApps.Add (dlClient.Install (remoteHost));
439  clientApps.Add (ulClient.Install (ueNodes.Get (u)));
440  }
441 
442  serverApps.Start (Seconds (0.001));
443  clientApps.Start (Seconds (0.001));
444 
445  double simulationTime = 2.0;
446  double tolerance = 0.1;
447  Simulator::Stop (Seconds (simulationTime));
448 
449  Ptr<RadioBearerStatsCalculator> rlcStats = lteHelper->GetRlcStats ();
450  rlcStats->SetAttribute ("EpochDuration", TimeValue (Seconds (simulationTime)));
451 
452  Simulator::Run ();
453 
458  NS_LOG_INFO ("DL - Test with " << m_nUser << " user(s) at distance " << m_dist);
459  std::vector <uint64_t> dlDataRxed;
460  for (int i = 0; i < m_nUser; i++)
461  {
462  // get the imsi
463  uint64_t imsi = ueDevs.Get (i)->GetObject<LteUeNetDevice> ()->GetImsi ();
464  // get the lcId
465  uint8_t lcId = ueDevs.Get (i)->GetObject<LteUeNetDevice> ()->GetRrc ()->GetLcIdVector ().at (0);
466  uint64_t data = rlcStats->GetDlRxData (imsi, lcId);
467  dlDataRxed.push_back (data);
468  NS_LOG_INFO ("\tUser " << i << " imsi " << imsi << " bytes rxed " << (double)dlDataRxed.at (i) << " thr " << (double)dlDataRxed.at (i) / simulationTime << " ref " << m_thrRefDl);
469  }
470 
471  for (int i = 0; i < m_nUser; i++)
472  {
473  NS_TEST_ASSERT_MSG_EQ_TOL ((double)dlDataRxed.at (i) / simulationTime, m_thrRefDl, m_thrRefDl * tolerance, " Unfair Throughput!");
474  }
475 
480  NS_LOG_INFO ("UL - Test with " << m_nUser << " user(s) at distance " << m_dist);
481  std::vector <uint64_t> ulDataRxed;
482  for (int i = 0; i < m_nUser; i++)
483  {
484  // get the imsi
485  uint64_t imsi = ueDevs.Get (i)->GetObject<LteUeNetDevice> ()->GetImsi ();
486  // get the lcId
487  uint8_t lcId = ueDevs.Get (i)->GetObject<LteUeNetDevice> ()->GetRrc ()->GetLcIdVector ().at (0);
488  ulDataRxed.push_back (rlcStats->GetUlRxData (imsi, lcId));
489  NS_LOG_INFO ("\tUser " << i << " imsi " << imsi << " bytes rxed " << (double)ulDataRxed.at (i) << " thr " << (double)ulDataRxed.at (i) / simulationTime << " ref " << m_thrRefUl);
490  }
491 
492  for (int i = 0; i < m_nUser; i++)
493  {
494  NS_TEST_ASSERT_MSG_EQ_TOL ((double)ulDataRxed.at (i) / simulationTime, m_thrRefUl, m_thrRefUl * tolerance, " Unfair Throughput!");
495  }
497 
498 }
499 
500 
501 
502 // --------------- T E S T - C A S E # 2 ------------------------------
503 
504 
505 std::string
506 LenaPssFfMacSchedulerTestCase2::BuildNameString (uint16_t nUser, std::vector<uint16_t> dist)
507 {
508  std::ostringstream oss;
509  oss << "distances (m) = [ " ;
510  for (std::vector<uint16_t>::iterator it = dist.begin (); it != dist.end (); ++it)
511  {
512  oss << *it << " ";
513  }
514  oss << "]";
515  return oss.str ();
516 }
517 
518 
519 LenaPssFfMacSchedulerTestCase2::LenaPssFfMacSchedulerTestCase2 (std::vector<uint16_t> dist, std::vector<uint32_t> estThrPssDl, std::vector<uint16_t> packetSize, uint16_t interval)
520  : TestCase (BuildNameString (dist.size (), dist)),
521  m_nUser (dist.size ()),
522  m_dist (dist),
523  m_packetSize (packetSize),
524  m_interval (interval),
525  m_estThrPssDl (estThrPssDl)
526 {
527 }
528 
530 {
531 }
532 
533 void
535 {
536  Ptr<LteHelper> lteHelper = CreateObject<LteHelper> ();
537  Ptr<EpcHelper> epcHelper = CreateObject<EpcHelper> ();
538  lteHelper->SetEpcHelper (epcHelper);
539 
540  Ptr<Node> pgw = epcHelper->GetPgwNode ();
541 
542  // Create a single RemoteHost
543  NodeContainer remoteHostContainer;
544  remoteHostContainer.Create (1);
545  Ptr<Node> remoteHost = remoteHostContainer.Get (0);
546  InternetStackHelper internet;
547  internet.Install (remoteHostContainer);
548 
549  // Create the Internet
550  PointToPointHelper p2ph;
551  p2ph.SetDeviceAttribute ("DataRate", DataRateValue (DataRate ("100Gb/s")));
552  p2ph.SetDeviceAttribute ("Mtu", UintegerValue (1500));
553  p2ph.SetChannelAttribute ("Delay", TimeValue (Seconds (0.001)));
554  NetDeviceContainer internetDevices = p2ph.Install (pgw, remoteHost);
555  Ipv4AddressHelper ipv4h;
556  ipv4h.SetBase ("1.0.0.0", "255.0.0.0");
557  Ipv4InterfaceContainer internetIpIfaces = ipv4h.Assign (internetDevices);
558  // interface 0 is localhost, 1 is the p2p device
559  Ipv4Address remoteHostAddr = internetIpIfaces.GetAddress (1);
560 
561  Ipv4StaticRoutingHelper ipv4RoutingHelper;
562  Ptr<Ipv4StaticRouting> remoteHostStaticRouting = ipv4RoutingHelper.GetStaticRouting (remoteHost->GetObject<Ipv4> ());
563  remoteHostStaticRouting->AddNetworkRouteTo (Ipv4Address ("7.0.0.0"), Ipv4Mask ("255.0.0.0"), 1);
564 
565  Config::SetDefault ("ns3::LteAmc::AmcModel", EnumValue (LteAmc::PiroEW2010));
566  Config::SetDefault ("ns3::LteAmc::Ber", DoubleValue (0.00005));
567  Config::SetDefault ("ns3::LteSpectrumPhy::CtrlErrorModelEnabled", BooleanValue (false));
568  Config::SetDefault ("ns3::LteSpectrumPhy::DataErrorModelEnabled", BooleanValue (false));
569 
570  lteHelper->SetAttribute ("EpsBearerToRlcMapping", EnumValue (LteHelper::RLC_UM_ALWAYS));
571 
573  //LogComponentEnable ("LenaTestPssFfMacCheduler", LOG_LEVEL_ALL);
574 
575  lteHelper->SetAttribute ("PathlossModel", StringValue ("ns3::FriisSpectrumPropagationLossModel"));
576 
577  // Create Nodes: eNodeB and UE
578  NodeContainer enbNodes;
579  NodeContainer ueNodes;
580  enbNodes.Create (1);
581  ueNodes.Create (m_nUser);
582 
583  // Install Mobility Model
584  MobilityHelper mobility;
585  mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel");
586  mobility.Install (enbNodes);
587  mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel");
588  mobility.Install (ueNodes);
589 
590  // Create Devices and install them in the Nodes (eNB and UE)
591  NetDeviceContainer enbDevs;
592  NetDeviceContainer ueDevs;
593  lteHelper->SetSchedulerType ("ns3::PssFfMacScheduler");
594  lteHelper->SetSchedulerAttribute ("PssFdSchedulerType", StringValue ("PFsch"));
595  enbDevs = lteHelper->InstallEnbDevice (enbNodes);
596  ueDevs = lteHelper->InstallUeDevice (ueNodes);
597 
598  // Attach a UE to a eNB
599  lteHelper->Attach (ueDevs, enbDevs.Get (0));
600 
601  Ptr<LteEnbNetDevice> lteEnbDev = enbDevs.Get (0)->GetObject<LteEnbNetDevice> ();
602  Ptr<LteEnbPhy> enbPhy = lteEnbDev->GetPhy ();
603  enbPhy->SetAttribute ("TxPower", DoubleValue (30.0));
604  enbPhy->SetAttribute ("NoiseFigure", DoubleValue (5.0));
605 
606  // Set UEs' position and power
607  for (int i = 0; i < m_nUser; i++)
608  {
610  mm->SetPosition (Vector (m_dist.at (i), 0.0, 0.0));
611  Ptr<LteUeNetDevice> lteUeDev = ueDevs.Get (i)->GetObject<LteUeNetDevice> ();
612  Ptr<LteUePhy> uePhy = lteUeDev->GetPhy ();
613  uePhy->SetAttribute ("TxPower", DoubleValue (23.0));
614  uePhy->SetAttribute ("NoiseFigure", DoubleValue (9.0));
615  }
616 
617  // Install the IP stack on the UEs
618  internet.Install (ueNodes);
619  Ipv4InterfaceContainer ueIpIface;
620  ueIpIface = epcHelper->AssignUeIpv4Address (NetDeviceContainer (ueDevs));
621  // Assign IP address to UEs, and install applications
622  for (uint32_t u = 0; u < ueNodes.GetN (); ++u)
623  {
624  Ptr<Node> ueNode = ueNodes.Get (u);
625  // Set the default gateway for the UE
626  Ptr<Ipv4StaticRouting> ueStaticRouting = ipv4RoutingHelper.GetStaticRouting (ueNode->GetObject<Ipv4> ());
627  ueStaticRouting->SetDefaultRoute (epcHelper->GetUeDefaultGatewayAddress (), 1);
628 
629  // Activate an EPS bearer
630  Ptr<NetDevice> ueDevice = ueDevs.Get (u);
631  GbrQosInformation qos;
632  qos.gbrDl = (m_packetSize.at (u) + 32) * (1000 / m_interval) * 8 * 1; // bit/s, = Target Bit Rate(TBR)
633  qos.gbrUl = (m_packetSize.at (u) + 32) * (1000 / m_interval) * 8 * 1;
634  qos.mbrDl = qos.gbrDl;
635  qos.mbrUl = qos.gbrUl;
636 
638  EpsBearer bearer (q, qos);
639  lteHelper->ActivateEpsBearer (ueDevice, bearer, EpcTft::Default ());
640 
641  }
642 
643  lteHelper->EnableRlcTraces ();
644 
645  // Install downlind and uplink applications
646  uint16_t dlPort = 1234;
647  uint16_t ulPort = 2000;
648  PacketSinkHelper dlPacketSinkHelper ("ns3::UdpSocketFactory", InetSocketAddress (Ipv4Address::GetAny (), dlPort));
649  PacketSinkHelper ulPacketSinkHelper ("ns3::UdpSocketFactory", InetSocketAddress (Ipv4Address::GetAny (), ulPort));
650  ApplicationContainer clientApps;
651  ApplicationContainer serverApps;
652  for (uint32_t u = 0; u < ueNodes.GetN (); ++u)
653  {
654  ++ulPort;
655  serverApps.Add (dlPacketSinkHelper.Install (ueNodes.Get (u))); // receive packets from remotehost
656  serverApps.Add (ulPacketSinkHelper.Install (remoteHost)); // receive packets from UEs
657 
658  UdpClientHelper dlClient (ueIpIface.GetAddress (u), dlPort); // uplink packets generator
659  dlClient.SetAttribute ("Interval", TimeValue (MilliSeconds (m_interval)));
660  dlClient.SetAttribute ("MaxPackets", UintegerValue (1000000));
661  dlClient.SetAttribute ("PacketSize", UintegerValue (m_packetSize.at (u)));
662 
663  UdpClientHelper ulClient (remoteHostAddr, ulPort); // downlink packets generator
664  ulClient.SetAttribute ("Interval", TimeValue (MilliSeconds (m_interval)));
665  ulClient.SetAttribute ("MaxPackets", UintegerValue (1000000));
666  ulClient.SetAttribute ("PacketSize", UintegerValue (m_packetSize.at (u)));
667 
668  clientApps.Add (dlClient.Install (remoteHost));
669  clientApps.Add (ulClient.Install (ueNodes.Get (u)));
670  }
671 
672  serverApps.Start (Seconds (0.001));
673  clientApps.Start (Seconds (0.001));
674 
675  double simulationTime = 1.0;
676  double tolerance = 0.1;
677  Simulator::Stop (Seconds (simulationTime));
678 
679  Ptr<RadioBearerStatsCalculator> rlcStats = lteHelper->GetRlcStats ();
680  rlcStats->SetAttribute ("EpochDuration", TimeValue (Seconds (simulationTime)));
681 
682  Simulator::Run ();
683 
688  NS_LOG_INFO ("DL - Test with " << m_nUser << " user(s)");
689  std::vector <uint64_t> dlDataRxed;
690  for (int i = 0; i < m_nUser; i++)
691  {
692  // get the imsi
693  uint64_t imsi = ueDevs.Get (i)->GetObject<LteUeNetDevice> ()->GetImsi ();
694  // get the lcId
695  uint8_t lcId = ueDevs.Get (i)->GetObject<LteUeNetDevice> ()->GetRrc ()->GetLcIdVector ().at (0);
696  dlDataRxed.push_back (rlcStats->GetDlRxData (imsi, lcId));
697  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);
698  }
699 
700  for (int i = 0; i < m_nUser; i++)
701  {
702  NS_TEST_ASSERT_MSG_EQ_TOL ((double)dlDataRxed.at (i) / simulationTime, m_estThrPssDl.at (i), m_estThrPssDl.at (i) * tolerance, " Unfair Throughput!");
703  }
704 
706 
707 }
708 
709 
710 } // namespace ns3
711 
712 
713 
714