A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
lte-test-pss-ff-mac-scheduler.cc
Go to the documentation of this file.
1/*
2 * Copyright (c) 2011 Centre Tecnologic de Telecomunicacions de Catalunya (CTTC)
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation;
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program; if not, write to the Free Software
15 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16 *
17 * Author: Marco Miozzo <marco.miozzo@cttc.es>,
18 * Nicola Baldo <nbaldo@cttc.es>
19 * Dizhi Zhou <dizhi.zhou@gmail.com>
20 */
21
23
24#include "ns3/applications-module.h"
25#include "ns3/double.h"
26#include "ns3/internet-module.h"
27#include "ns3/ipv4-global-routing-helper.h"
28#include "ns3/network-module.h"
29#include "ns3/point-to-point-epc-helper.h"
30#include "ns3/point-to-point-helper.h"
31#include "ns3/radio-bearer-stats-calculator.h"
32#include "ns3/string.h"
33#include <ns3/boolean.h>
34#include <ns3/constant-position-mobility-model.h>
35#include <ns3/enum.h>
36#include <ns3/eps-bearer.h>
37#include <ns3/ff-mac-scheduler.h>
38#include <ns3/log.h>
39#include <ns3/lte-enb-net-device.h>
40#include <ns3/lte-enb-phy.h>
41#include <ns3/lte-helper.h>
42#include <ns3/lte-ue-net-device.h>
43#include <ns3/lte-ue-phy.h>
44#include <ns3/lte-ue-rrc.h>
45#include <ns3/mobility-helper.h>
46#include <ns3/net-device-container.h>
47#include <ns3/node-container.h>
48#include <ns3/object.h>
49#include <ns3/packet.h>
50#include <ns3/ptr.h>
51#include <ns3/simulator.h>
52#include <ns3/spectrum-error-model.h>
53#include <ns3/spectrum-interference.h>
54#include <ns3/test.h>
55
56#include <iostream>
57#include <sstream>
58#include <string>
59
60using namespace ns3;
61
62NS_LOG_COMPONENT_DEFINE("LenaTestPssFfMacScheduler");
63
65 : TestSuite("lte-pss-ff-mac-scheduler", SYSTEM)
66{
67 NS_LOG_INFO("creating LenaTestPssFfMacSchedulerSuite");
68
69 bool errorModel = false;
70
71 // General config
72 // Traffic: UDP traffic with fixed rate
73 // Token generation rate = traffic rate
74 // RLC header length = 2 bytes, PDCP header = 2 bytes
75 // Simulation time = 1.0 sec
76 // Throughput in this file is calculated in RLC layer
77
78 // Test Case 1: homogeneous flow test in PSS (same distance)
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) *
83 // 1000 byte/sec -> 232000 byte/rate
84 // Total 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 LenaPssFfMacSchedulerTestCase1(1, 0, 232000, 232000, 200, 1, errorModel),
96 AddTestCase(new LenaPssFfMacSchedulerTestCase1(3, 0, 232000, 232000, 200, 1, errorModel),
98 AddTestCase(new LenaPssFfMacSchedulerTestCase1(6, 0, 232000, 232000, 200, 1, errorModel),
100
101 // AddTestCase (new LenaPssFfMacSchedulerTestCase1 (12,0,183000,185000,200,1,errorModel));//
102 // simulation time = 1.5, otherwise, ul test will fail
103
104 // DOWNLINK - DISTANCE 4800 -> MCS 22 -> Itbs 20 (from table 7.1.7.2.1-1 of 36.213)
105 // Traffic info
106 // UDP traffic: payload size = 200 bytes, interval = 1 ms
107 // UDP rate in scheduler: (payload + RLC header + PDCP header + IP header + UDP header) * 1000
108 // byte/sec -> 232000 byte/rate
109 // Total bandwidth: 24 PRB at Itbs 20 -> 1383 -> 1383000 byte/sec
110 // 1 user -> 903000 * 1 = 232000 < 1383000 -> throughput = 232000 byte/sec
111 // 3 user -> 232000 * 3 = 696000 < 1383000 -> througphut = 232000 byte/sec
112 // 6 user -> 232000 * 6 = 139200 > 1383000 -> throughput = 1383000 / 6 = 230500 byte/sec
113 // 12 user -> 232000 * 12 = 2784000 > 1383000 -> throughput = 1383000 / 12 = 115250 byte/sec
114 // UPLINK - DISTANCE 4800 -> MCS 14 -> Itbs 13 (from table 7.1.7.2.1-1 of 36.213)
115 // 1 user -> 25 PRB at Itbs 13 -> 807 -> 807000 > 232000 -> throughput = 232000 bytes/sec
116 // 3 users -> 8 PRB at Itbs 13 -> 253 -> 253000 > 232000 -> throughput = 232000 bytes/sec
117 // 6 users -> 4 PRB at Itbs 13 -> 125 -> 125000 < 232000 -> throughput = 125000 bytes/sec
118 // after the patch enforcing min 3 PRBs per UE:
119 // 12 users -> 3 PRB at Itbs 13 -> 93 bytes * 8/12 UE/TTI -> 62000 < 232000 -> throughput =
120 // 62000 bytes/sec
121 AddTestCase(new LenaPssFfMacSchedulerTestCase1(1, 4800, 232000, 232000, 200, 1, errorModel),
123 AddTestCase(new LenaPssFfMacSchedulerTestCase1(3, 4800, 232000, 232000, 200, 1, errorModel),
125 AddTestCase(new LenaPssFfMacSchedulerTestCase1(6, 4800, 230500, 125000, 200, 1, errorModel),
127 // AddTestCase (new LenaPssFfMacSchedulerTestCase1 (12,4800,115250,62000,200,1,errorModel)); //
128 // simulation time = 1.5, otherwise, ul test will fail
129
130 // DOWNLINK - DISTANCE 6000 -> MCS 20 -> Itbs 18 (from table 7.1.7.2.1-1 of 36.213)
131 // Traffic info
132 // UDP traffic: payload size = 200 bytes, interval = 1 ms
133 // UDP rate in scheduler: (payload + RLC header + PDCP header + IP header + UDP header) * 1000
134 // byte/sec -> 232000 byte/rate
135 // Total bandwidth: 24 PRB at Itbs 18 -> 1191 -> 1191000 byte/sec
136 // 1 user -> 903000 * 1 = 232000 < 1191000 -> throughput = 232000 byte/sec
137 // 3 user -> 232000 * 3 = 696000 < 1191000 -> througphut = 232000 byte/sec
138 // 6 user -> 232000 * 6 = 1392000 > 1191000 -> throughput = 1191000 / 6 = 198500 byte/sec
139 // 12 user -> 232000 * 12 = 2784000 > 1191000 -> throughput = 1191000 / 12 = 99250 byte/sec
140
141 // UPLINK - DISTANCE 6000 -> MCS 12 -> Itbs 11 (from table 7.1.7.2.1-1 of 36.213)
142 // 1 user -> 25 PRB at Itbs 11 -> 621 -> 621000 > 232000 -> throughput = 232000 bytes/sec
143 // 3 users -> 8 PRB at Itbs 11 -> 201 -> 201000 < 232000 -> throughput = 201000 bytes/sec
144 // 6 users -> 4 PRB at Itbs 11 -> 97 -> 97000 < 232000 -> throughput = 97000 bytes/sec
145 // after the patch enforcing min 3 PRBs per UE:
146 // 12 users -> 3 PRB at Itbs 11 -> 73 bytes * 8/12 UE/TTI -> 48667 < 232000 -> throughput =
147 // 48667 bytes/sec
148 AddTestCase(new LenaPssFfMacSchedulerTestCase1(1, 6000, 232000, 232000, 200, 1, errorModel),
150 AddTestCase(new LenaPssFfMacSchedulerTestCase1(3, 6000, 232000, 201000, 200, 1, errorModel),
152 AddTestCase(new LenaPssFfMacSchedulerTestCase1(6, 6000, 198500, 97000, 200, 1, errorModel),
154 // AddTestCase (new LenaPssFfMacSchedulerTestCase1 (12,6000,99250,48667,200,1, errorModel)); //
155 // simulation time = 1.5, otherwise, ul test will fail
156
157 // DOWNLINK - DISTANCE 10000 -> MCS 14 -> Itbs 13 (from table 7.1.7.2.1-1 of 36.213)
158 // Traffic info
159 // UDP traffic: payload size = 200 bytes, interval = 1 ms
160 // UDP rate in scheduler: (payload + RLC header + PDCP header + IP header + UDP header) * 1000
161 // byte/sec -> 232000 byte/rate
162 // Total bandwidth: 24 PRB at Itbs 13 -> 775 -> 775000 byte/sec
163 // 1 user -> 903000 * 1 = 232000 < 775000 -> throughput = 232000 byte/sec
164 // 3 user -> 232000 * 3 = 696000 > 775000 -> througphut = 232000 byte/sec
165 // 6 user -> 232000 * 6 = 139200 > 775000 -> throughput = 775000 / 6 = 129166 byte/sec
166 // 12 user -> 232000 * 12 = 2784000 > 775000 -> throughput = 775000 / 12 = 64583 byte/sec
167 // UPLINK - DISTANCE 10000 -> MCS 8 -> Itbs 8 (from table 7.1.7.2.1-1 of 36.213)
168 // 1 user -> 24 PRB at Itbs 8 -> 437 -> 437000 > 232000 -> throughput = 232000 bytes/sec
169 // 3 users -> 8 PRB at Itbs 8 -> 137 -> 137000 < 232000 -> throughput = 137000 bytes/sec
170 // 6 users -> 4 PRB at Itbs 8 -> 67 -> 67000 < 232000 -> throughput = 67000 bytes/sec
171 // after the patch enforcing min 3 PRBs per UE:
172 // 12 users -> 3 PRB at Itbs 8 -> 49 bytes * 8/12 UE/TTI -> 32667 < 232000 -> throughput = 32667
173 // bytes/sec
174 AddTestCase(new LenaPssFfMacSchedulerTestCase1(1, 10000, 232000, 232000, 200, 1, errorModel),
176 AddTestCase(new LenaPssFfMacSchedulerTestCase1(3, 10000, 232000, 137000, 200, 1, errorModel),
178 AddTestCase(new LenaPssFfMacSchedulerTestCase1(6, 10000, 129166, 67000, 200, 1, errorModel),
180 // AddTestCase (new LenaPssFfMacSchedulerTestCase1 (12,10000,64583,32667,200,1,errorModel));//
181 // simulation time = 1.5, otherwise, ul test will fail
182
183 // DOWNLINK - DISTANCE 100000 -> CQI == 0 -> out of range -> 0 bytes/sec
184 // UPLINK - DISTANCE 100000 -> CQI == 0 -> out of range -> 0 bytes/sec
185 AddTestCase(new LenaPssFfMacSchedulerTestCase1(1, 100000, 0, 0, 200, 1, errorModel),
187
188 // Test Case 2: homogeneous flow test in PSS (different distance)
189 // Traffic1 info
190 // UDP traffic: payload size = 100 bytes, interval = 1 ms
191 // UDP rate in scheduler: (payload + RLC header + PDCP header + IP header + UDP header) * 1000
192 // byte/sec -> 132000 byte/rate
193 // Maximum throughput = 4 / ( 1/2196000 + 1/1191000 + 1/1383000 + 1/775000 ) = 1209046 byte/s
194 // 132000 * 4 = 528000 < 1209046 -> estimated throughput in downlink = 132000 byte/sec
195 std::vector<double> dist1;
196 dist1.push_back(0); // User 0 distance --> MCS 28
197 dist1.push_back(4800); // User 1 distance --> MCS 22
198 dist1.push_back(6000); // User 2 distance --> MCS 20
199 dist1.push_back(10000); // User 3 distance --> MCS 14
200 std::vector<uint16_t> packetSize1;
201 packetSize1.push_back(100);
202 packetSize1.push_back(100);
203 packetSize1.push_back(100);
204 packetSize1.push_back(100);
205 std::vector<uint32_t> estThrPssDl1;
206 estThrPssDl1.push_back(132000); // User 0 estimated TTI throughput from PSS
207 estThrPssDl1.push_back(132000); // User 1 estimated TTI throughput from PSS
208 estThrPssDl1.push_back(132000); // User 2 estimated TTI throughput from PSS
209 estThrPssDl1.push_back(132000); // User 3 estimated TTI throughput from PSS
210 AddTestCase(new LenaPssFfMacSchedulerTestCase2(dist1, estThrPssDl1, packetSize1, 1, errorModel),
212
213 // Traffic2 info
214 // UDP traffic: payload size = 200 bytes, interval = 1 ms
215 // UDP rate in scheduler: (payload + RLC header + PDCP header + IP header + UDP header) * 1000
216 // byte/sec -> 232000 byte/rate
217 // Maximum throughput = 4 / ( 1/2196000 + 1/1191000 + 1/1383000 + 1/775000 ) = 1209046 byte/s
218 // 232000 * 4 = 928000 < 1209046 -> estimated throughput in downlink = 928000 / 4 = 230000
219 // byte/sec
220 std::vector<double> dist2;
221 dist2.push_back(0); // User 0 distance --> MCS 28
222 dist2.push_back(4800); // User 1 distance --> MCS 22
223 dist2.push_back(6000); // User 2 distance --> MCS 20
224 dist2.push_back(10000); // User 3 distance --> MCS 14
225 std::vector<uint16_t> packetSize2;
226 packetSize2.push_back(200);
227 packetSize2.push_back(200);
228 packetSize2.push_back(200);
229 packetSize2.push_back(200);
230 std::vector<uint32_t> estThrPssDl2;
231 estThrPssDl2.push_back(230000); // User 0 estimated TTI throughput from PSS
232 estThrPssDl2.push_back(230000); // User 1 estimated TTI throughput from PSS
233 estThrPssDl2.push_back(230000); // User 2 estimated TTI throughput from PSS
234 estThrPssDl2.push_back(230000); // User 3 estimated TTI throughput from PSS
235 AddTestCase(new LenaPssFfMacSchedulerTestCase2(dist2, estThrPssDl2, packetSize2, 1, errorModel),
237
238 // Test Case 3: heterogeneous flow test in PSS
239 // UDP traffic: payload size = [100,200,300] bytes, interval = 1 ms
240 // UDP rate in scheduler: (payload + RLC header + PDCP header + IP header + UDP header) * 1000
241 // byte/sec -> [132000, 232000, 332000] byte/rate
242 // Maximum throughput = 3 / ( 1/2196000 + 1/1191000 + 1/1383000) = 1486569 byte/s
243 // 132000 + 232000 + 332000 = 696000 < 1486569 -> estimated throughput in downlink = [132000,
244 // 232000, 332000] byte/sec
245 std::vector<double> dist3;
246 dist3.push_back(0); // User 0 distance --> MCS 28
247 dist3.push_back(4800); // User 1 distance --> MCS 22
248 dist3.push_back(6000); // User 2 distance --> MCS 20
249 std::vector<uint16_t> packetSize3;
250 packetSize3.push_back(100);
251 packetSize3.push_back(200);
252 packetSize3.push_back(300);
253 std::vector<uint32_t> estThrPssDl3;
254 estThrPssDl3.push_back(132000); // User 0 estimated TTI throughput from PSS
255 estThrPssDl3.push_back(232000); // User 1 estimated TTI throughput from PSS
256 estThrPssDl3.push_back(332000); // User 2 estimated TTI throughput from PSS
257 AddTestCase(new LenaPssFfMacSchedulerTestCase2(dist3, estThrPssDl3, packetSize3, 1, errorModel),
259}
260
266
267// --------------- T E S T - C A S E # 1 ------------------------------
268
269std::string
271{
272 std::ostringstream oss;
273 oss << nUser << " UEs, distance " << dist << " m";
274 return oss.str();
275}
276
278 double dist,
279 double thrRefDl,
280 double thrRefUl,
281 uint16_t packetSize,
282 uint16_t interval,
283 bool errorModelEnabled)
284 : TestCase(BuildNameString(nUser, dist)),
285 m_nUser(nUser),
286 m_dist(dist),
287 m_packetSize(packetSize),
288 m_interval(interval),
289 m_thrRefDl(thrRefDl),
290 m_thrRefUl(thrRefUl),
291 m_errorModelEnabled(errorModelEnabled)
292{
293}
294
296{
297}
298
299void
301{
302 NS_LOG_FUNCTION(this << GetName());
303
305 {
306 Config::SetDefault("ns3::LteSpectrumPhy::CtrlErrorModelEnabled", BooleanValue(false));
307 Config::SetDefault("ns3::LteSpectrumPhy::DataErrorModelEnabled", BooleanValue(false));
308 }
309
310 Config::SetDefault("ns3::LteHelper::UseIdealRrc", BooleanValue(true));
311 Config::SetDefault("ns3::MacStatsCalculator::DlOutputFilename",
312 StringValue(CreateTempDirFilename("DlMacStats.txt")));
313 Config::SetDefault("ns3::MacStatsCalculator::UlOutputFilename",
314 StringValue(CreateTempDirFilename("UlMacStats.txt")));
315 Config::SetDefault("ns3::RadioBearerStatsCalculator::DlRlcOutputFilename",
316 StringValue(CreateTempDirFilename("DlRlcStats.txt")));
317 Config::SetDefault("ns3::RadioBearerStatsCalculator::UlRlcOutputFilename",
318 StringValue(CreateTempDirFilename("UlRlcStats.txt")));
319
320 Ptr<LteHelper> lteHelper = CreateObject<LteHelper>();
321 Ptr<PointToPointEpcHelper> epcHelper = CreateObject<PointToPointEpcHelper>();
322 lteHelper->SetEpcHelper(epcHelper);
323
324 // LogComponentEnable ("PssFfMacScheduler", LOG_DEBUG);
325
326 Ptr<Node> pgw = epcHelper->GetPgwNode();
327
328 // Create a single RemoteHost
329 NodeContainer remoteHostContainer;
330 remoteHostContainer.Create(1);
331 Ptr<Node> remoteHost = remoteHostContainer.Get(0);
332 InternetStackHelper internet;
333 internet.Install(remoteHostContainer);
334
335 // Create the Internet
337 p2ph.SetDeviceAttribute("DataRate", DataRateValue(DataRate("100Gb/s")));
338 p2ph.SetDeviceAttribute("Mtu", UintegerValue(1500));
339 p2ph.SetChannelAttribute("Delay", TimeValue(Seconds(0.001)));
340 NetDeviceContainer internetDevices = p2ph.Install(pgw, remoteHost);
341 Ipv4AddressHelper ipv4h;
342 ipv4h.SetBase("1.0.0.0", "255.0.0.0");
343 Ipv4InterfaceContainer internetIpIfaces = ipv4h.Assign(internetDevices);
344 // interface 0 is localhost, 1 is the p2p device
345 Ipv4Address remoteHostAddr = internetIpIfaces.GetAddress(1);
346
347 Ipv4StaticRoutingHelper ipv4RoutingHelper;
348 Ptr<Ipv4StaticRouting> remoteHostStaticRouting =
349 ipv4RoutingHelper.GetStaticRouting(remoteHost->GetObject<Ipv4>());
350 remoteHostStaticRouting->AddNetworkRouteTo(Ipv4Address("7.0.0.0"), Ipv4Mask("255.0.0.0"), 1);
351
352 // Config::SetDefault ("ns3::LteAmc::AmcModel", EnumValue (LteAmc::PiroEW2010));
353 // Config::SetDefault ("ns3::LteAmc::Ber", DoubleValue (0.00005));
354 // Config::SetDefault ("ns3::LteSpectrumPhy::CtrlErrorModelEnabled", BooleanValue (false));
355 // Config::SetDefault ("ns3::LteSpectrumPhy::DataErrorModelEnabled", BooleanValue (false));
356
357 // Config::SetDefault ("ns3::LteEnbRrc::EpsBearerToRlcMapping", EnumValue
358 // (LteHelper::RLC_UM_ALWAYS));
359
360 // LogComponentDisableAll (LOG_LEVEL_ALL);
361 // LogComponentEnable ("LenaTestPssFfMacScheduler", LOG_LEVEL_ALL);
362
363 lteHelper->SetAttribute("PathlossModel", StringValue("ns3::FriisSpectrumPropagationLossModel"));
364
365 // Create Nodes: eNodeB and UE
366 NodeContainer enbNodes;
367 NodeContainer ueNodes;
368 enbNodes.Create(1);
369 ueNodes.Create(m_nUser);
370
371 // Install Mobility Model
372 MobilityHelper mobility;
373 mobility.SetMobilityModel("ns3::ConstantPositionMobilityModel");
374 mobility.Install(enbNodes);
375 mobility.SetMobilityModel("ns3::ConstantPositionMobilityModel");
376 mobility.Install(ueNodes);
377
378 // Create Devices and install them in the Nodes (eNB and UE)
379 NetDeviceContainer enbDevs;
380 NetDeviceContainer ueDevs;
381 lteHelper->SetSchedulerType("ns3::PssFfMacScheduler");
382 lteHelper->SetSchedulerAttribute("UlCqiFilter", EnumValue(FfMacScheduler::SRS_UL_CQI));
383 enbDevs = lteHelper->InstallEnbDevice(enbNodes);
384 ueDevs = lteHelper->InstallUeDevice(ueNodes);
385
386 Ptr<LteEnbNetDevice> lteEnbDev = enbDevs.Get(0)->GetObject<LteEnbNetDevice>();
387 Ptr<LteEnbPhy> enbPhy = lteEnbDev->GetPhy();
388 enbPhy->SetAttribute("TxPower", DoubleValue(30.0));
389 enbPhy->SetAttribute("NoiseFigure", DoubleValue(5.0));
390
391 // Set UEs' position and power
392 for (int i = 0; i < m_nUser; i++)
393 {
396 mm->SetPosition(Vector(m_dist, 0.0, 0.0));
397 Ptr<LteUeNetDevice> lteUeDev = ueDevs.Get(i)->GetObject<LteUeNetDevice>();
398 Ptr<LteUePhy> uePhy = lteUeDev->GetPhy();
399 uePhy->SetAttribute("TxPower", DoubleValue(23.0));
400 uePhy->SetAttribute("NoiseFigure", DoubleValue(9.0));
401 }
402
403 // Install the IP stack on the UEs
404 internet.Install(ueNodes);
405 Ipv4InterfaceContainer ueIpIface;
406 ueIpIface = epcHelper->AssignUeIpv4Address(NetDeviceContainer(ueDevs));
407
408 // Assign IP address to UEs
409 for (uint32_t u = 0; u < ueNodes.GetN(); ++u)
410 {
411 Ptr<Node> ueNode = ueNodes.Get(u);
412 // Set the default gateway for the UE
413 Ptr<Ipv4StaticRouting> ueStaticRouting =
414 ipv4RoutingHelper.GetStaticRouting(ueNode->GetObject<Ipv4>());
415 ueStaticRouting->SetDefaultRoute(epcHelper->GetUeDefaultGatewayAddress(), 1);
416 }
417
418 // Attach a UE to a eNB
419 lteHelper->Attach(ueDevs, enbDevs.Get(0));
420
421 // Activate an EPS bearer on all UEs
422 for (uint32_t u = 0; u < ueNodes.GetN(); ++u)
423 {
424 Ptr<NetDevice> ueDevice = ueDevs.Get(u);
426 qos.gbrDl = (m_packetSize + 32) * (1000 / m_interval) *
427 8; // bit/s, considering IP, UDP, RLC, PDCP header size
428 qos.gbrUl = (m_packetSize + 32) * (1000 / m_interval) * 8;
429 qos.mbrDl = 0;
430 qos.mbrUl = 0;
431
433 EpsBearer bearer(q, qos);
434 lteHelper->ActivateDedicatedEpsBearer(ueDevice, bearer, EpcTft::Default());
435 }
436
437 // Install downlink and uplink applications
438 uint16_t dlPort = 1234;
439 uint16_t ulPort = 2000;
440 ApplicationContainer clientApps;
441 ApplicationContainer serverApps;
442 PacketSinkHelper dlPacketSinkHelper("ns3::UdpSocketFactory",
444
445 for (uint32_t u = 0; u < ueNodes.GetN(); ++u)
446 {
447 ++ulPort;
448 PacketSinkHelper ulPacketSinkHelper("ns3::UdpSocketFactory",
450 serverApps.Add(ulPacketSinkHelper.Install(remoteHost)); // receive packets from UEs
451 serverApps.Add(
452 dlPacketSinkHelper.Install(ueNodes.Get(u))); // receive packets from remotehost
453
454 UdpClientHelper dlClient(ueIpIface.GetAddress(u), dlPort); // downlink packets generator
455 dlClient.SetAttribute("Interval", TimeValue(MilliSeconds(m_interval)));
456 dlClient.SetAttribute("MaxPackets", UintegerValue(1000000));
457 dlClient.SetAttribute("PacketSize", UintegerValue(m_packetSize));
458
459 UdpClientHelper ulClient(remoteHostAddr, ulPort); // uplink packets generator
460 ulClient.SetAttribute("Interval", TimeValue(MilliSeconds(m_interval)));
461 ulClient.SetAttribute("MaxPackets", UintegerValue(1000000));
462 ulClient.SetAttribute("PacketSize", UintegerValue(m_packetSize));
463
464 clientApps.Add(dlClient.Install(remoteHost));
465 clientApps.Add(ulClient.Install(ueNodes.Get(u)));
466 }
467
468 serverApps.Start(Seconds(0.030));
469 clientApps.Start(Seconds(0.030));
470
471 double statsStartTime = 0.300; // need to allow for RRC connection establishment + SRS
472 double statsDuration = 0.6;
473 double tolerance = 0.1;
474 Simulator::Stop(Seconds(statsStartTime + statsDuration - 0.0001));
475
476 lteHelper->EnableRlcTraces();
477 lteHelper->EnableMacTraces();
478 Ptr<RadioBearerStatsCalculator> rlcStats = lteHelper->GetRlcStats();
479 rlcStats->SetAttribute("StartTime", TimeValue(Seconds(statsStartTime)));
480 rlcStats->SetAttribute("EpochDuration", TimeValue(Seconds(statsDuration)));
481
483
488 NS_LOG_INFO("DL - Test with " << m_nUser << " user(s) at distance " << m_dist);
489 std::vector<uint64_t> dlDataRxed;
490 for (int i = 0; i < m_nUser; i++)
491 {
492 // get the imsi
493 uint64_t imsi = ueDevs.Get(i)->GetObject<LteUeNetDevice>()->GetImsi();
494 // get the lcId
495 uint8_t lcId = 4;
496 uint64_t data = rlcStats->GetDlRxData(imsi, lcId);
497 dlDataRxed.push_back(data);
498 NS_LOG_INFO("\tUser " << i << " imsi " << imsi << " bytes rxed " << (double)dlDataRxed.at(i)
499 << " thr " << (double)dlDataRxed.at(i) / statsDuration << " ref "
500 << m_thrRefDl);
501 }
502
503 for (int i = 0; i < m_nUser; i++)
504 {
505 NS_TEST_ASSERT_MSG_EQ_TOL((double)dlDataRxed.at(i) / statsDuration,
507 m_thrRefDl * tolerance,
508 " Unfair Throughput!");
509 }
510
515 NS_LOG_INFO("UL - Test with " << m_nUser << " user(s) at distance " << m_dist);
516 std::vector<uint64_t> ulDataRxed;
517 for (int i = 0; i < m_nUser; i++)
518 {
519 // get the imsi
520 uint64_t imsi = ueDevs.Get(i)->GetObject<LteUeNetDevice>()->GetImsi();
521 // get the lcId
522 uint8_t lcId = 4;
523 ulDataRxed.push_back(rlcStats->GetUlRxData(imsi, lcId));
524 NS_LOG_INFO("\tUser " << i << " imsi " << imsi << " bytes rxed " << (double)ulDataRxed.at(i)
525 << " thr " << (double)ulDataRxed.at(i) / statsDuration << " ref "
526 << m_thrRefUl);
527 }
528
529 for (int i = 0; i < m_nUser; i++)
530 {
531 NS_TEST_ASSERT_MSG_EQ_TOL((double)ulDataRxed.at(i) / statsDuration,
533 m_thrRefUl * tolerance,
534 " Unfair Throughput!");
535 }
537}
538
539// --------------- T E S T - C A S E # 2 ------------------------------
540
541std::string
542LenaPssFfMacSchedulerTestCase2::BuildNameString(uint16_t nUser, std::vector<double> dist)
543{
544 std::ostringstream oss;
545 oss << "distances (m) = [ ";
546 for (std::vector<double>::iterator it = dist.begin(); it != dist.end(); ++it)
547 {
548 oss << *it << " ";
549 }
550 oss << "]";
551 return oss.str();
552}
553
555 std::vector<uint32_t> estThrPssDl,
556 std::vector<uint16_t> packetSize,
557 uint16_t interval,
558 bool errorModelEnabled)
559 : TestCase(BuildNameString(dist.size(), dist)),
560 m_nUser(dist.size()),
561 m_dist(dist),
562 m_packetSize(packetSize),
563 m_interval(interval),
564 m_estThrPssDl(estThrPssDl),
565 m_errorModelEnabled(errorModelEnabled)
566{
567}
568
570{
571}
572
573void
575{
577 {
578 Config::SetDefault("ns3::LteSpectrumPhy::CtrlErrorModelEnabled", BooleanValue(false));
579 Config::SetDefault("ns3::LteSpectrumPhy::DataErrorModelEnabled", BooleanValue(false));
580 }
581
582 Config::SetDefault("ns3::LteHelper::UseIdealRrc", BooleanValue(true));
583 Config::SetDefault("ns3::MacStatsCalculator::DlOutputFilename",
584 StringValue(CreateTempDirFilename("DlMacStats.txt")));
585 Config::SetDefault("ns3::MacStatsCalculator::UlOutputFilename",
586 StringValue(CreateTempDirFilename("UlMacStats.txt")));
587 Config::SetDefault("ns3::RadioBearerStatsCalculator::DlRlcOutputFilename",
588 StringValue(CreateTempDirFilename("DlRlcStats.txt")));
589 Config::SetDefault("ns3::RadioBearerStatsCalculator::UlRlcOutputFilename",
590 StringValue(CreateTempDirFilename("UlRlcStats.txt")));
591
592 Ptr<LteHelper> lteHelper = CreateObject<LteHelper>();
593 Ptr<PointToPointEpcHelper> epcHelper = CreateObject<PointToPointEpcHelper>();
594 lteHelper->SetEpcHelper(epcHelper);
595
596 Ptr<Node> pgw = epcHelper->GetPgwNode();
597
598 // Create a single RemoteHost
599 NodeContainer remoteHostContainer;
600 remoteHostContainer.Create(1);
601 Ptr<Node> remoteHost = remoteHostContainer.Get(0);
602 InternetStackHelper internet;
603 internet.Install(remoteHostContainer);
604
605 // Create the Internet
607 p2ph.SetDeviceAttribute("DataRate", DataRateValue(DataRate("100Gb/s")));
608 p2ph.SetDeviceAttribute("Mtu", UintegerValue(1500));
609 p2ph.SetChannelAttribute("Delay", TimeValue(Seconds(0.001)));
610 NetDeviceContainer internetDevices = p2ph.Install(pgw, remoteHost);
611 Ipv4AddressHelper ipv4h;
612 ipv4h.SetBase("1.0.0.0", "255.0.0.0");
613 Ipv4InterfaceContainer internetIpIfaces = ipv4h.Assign(internetDevices);
614 // interface 0 is localhost, 1 is the p2p device
615 Ipv4Address remoteHostAddr = internetIpIfaces.GetAddress(1);
616
617 Ipv4StaticRoutingHelper ipv4RoutingHelper;
618 Ptr<Ipv4StaticRouting> remoteHostStaticRouting =
619 ipv4RoutingHelper.GetStaticRouting(remoteHost->GetObject<Ipv4>());
620 remoteHostStaticRouting->AddNetworkRouteTo(Ipv4Address("7.0.0.0"), Ipv4Mask("255.0.0.0"), 1);
621
622 // LogComponentDisableAll (LOG_LEVEL_ALL);
623 // LogComponentEnable ("LenaTestPssFfMacScheduler", LOG_LEVEL_ALL);
624
625 lteHelper->SetAttribute("PathlossModel", StringValue("ns3::FriisSpectrumPropagationLossModel"));
626
627 // Create Nodes: eNodeB and UE
628 NodeContainer enbNodes;
629 NodeContainer ueNodes;
630 enbNodes.Create(1);
631 ueNodes.Create(m_nUser);
632
633 // Install Mobility Model
634 MobilityHelper mobility;
635 mobility.SetMobilityModel("ns3::ConstantPositionMobilityModel");
636 mobility.Install(enbNodes);
637 mobility.SetMobilityModel("ns3::ConstantPositionMobilityModel");
638 mobility.Install(ueNodes);
639
640 // Create Devices and install them in the Nodes (eNB and UE)
641 NetDeviceContainer enbDevs;
642 NetDeviceContainer ueDevs;
643 lteHelper->SetSchedulerType("ns3::PssFfMacScheduler");
644 lteHelper->SetSchedulerAttribute("UlCqiFilter", EnumValue(FfMacScheduler::SRS_UL_CQI));
645 enbDevs = lteHelper->InstallEnbDevice(enbNodes);
646 ueDevs = lteHelper->InstallUeDevice(ueNodes);
647
648 Ptr<LteEnbNetDevice> lteEnbDev = enbDevs.Get(0)->GetObject<LteEnbNetDevice>();
649 Ptr<LteEnbPhy> enbPhy = lteEnbDev->GetPhy();
650 enbPhy->SetAttribute("TxPower", DoubleValue(30.0));
651 enbPhy->SetAttribute("NoiseFigure", DoubleValue(5.0));
652
653 // Set UEs' position and power
654 for (int i = 0; i < m_nUser; i++)
655 {
658 mm->SetPosition(Vector(m_dist.at(i), 0.0, 0.0));
659 Ptr<LteUeNetDevice> lteUeDev = ueDevs.Get(i)->GetObject<LteUeNetDevice>();
660 Ptr<LteUePhy> uePhy = lteUeDev->GetPhy();
661 uePhy->SetAttribute("TxPower", DoubleValue(23.0));
662 uePhy->SetAttribute("NoiseFigure", DoubleValue(9.0));
663 }
664
665 // Install the IP stack on the UEs
666 internet.Install(ueNodes);
667 Ipv4InterfaceContainer ueIpIface;
668 ueIpIface = epcHelper->AssignUeIpv4Address(NetDeviceContainer(ueDevs));
669
670 // Assign IP address to UEs
671 for (uint32_t u = 0; u < ueNodes.GetN(); ++u)
672 {
673 Ptr<Node> ueNode = ueNodes.Get(u);
674 // Set the default gateway for the UE
675 Ptr<Ipv4StaticRouting> ueStaticRouting =
676 ipv4RoutingHelper.GetStaticRouting(ueNode->GetObject<Ipv4>());
677 ueStaticRouting->SetDefaultRoute(epcHelper->GetUeDefaultGatewayAddress(), 1);
678 }
679
680 // Attach a UE to a eNB
681 lteHelper->Attach(ueDevs, enbDevs.Get(0));
682
683 // Activate an EPS bearer on all UEs
684
685 for (uint32_t u = 0; u < ueNodes.GetN(); ++u)
686 {
687 Ptr<NetDevice> ueDevice = ueDevs.Get(u);
689 qos.gbrDl = (m_packetSize.at(u) + 32) * (1000 / m_interval) *
690 8; // bit/s, considering IP, UDP, RLC, PDCP header size
691 qos.gbrUl = (m_packetSize.at(u) + 32) * (1000 / m_interval) * 8;
692 qos.mbrDl = qos.gbrDl;
693 qos.mbrUl = qos.gbrUl;
694
696 EpsBearer bearer(q, qos);
697 lteHelper->ActivateDedicatedEpsBearer(ueDevice, bearer, EpcTft::Default());
698 }
699
700 // Install downlink and uplink applications
701 uint16_t dlPort = 1234;
702 uint16_t ulPort = 2000;
703 ApplicationContainer clientApps;
704 ApplicationContainer serverApps;
705 PacketSinkHelper dlPacketSinkHelper("ns3::UdpSocketFactory",
707
708 for (uint32_t u = 0; u < ueNodes.GetN(); ++u)
709 {
710 ++ulPort;
711 PacketSinkHelper ulPacketSinkHelper("ns3::UdpSocketFactory",
713 serverApps.Add(ulPacketSinkHelper.Install(remoteHost)); // receive packets from UEs
714 serverApps.Add(
715 dlPacketSinkHelper.Install(ueNodes.Get(u))); // receive packets from remotehost
716
717 UdpClientHelper dlClient(ueIpIface.GetAddress(u), dlPort); // downlink packets generator
718 dlClient.SetAttribute("Interval", TimeValue(MilliSeconds(m_interval)));
719 dlClient.SetAttribute("MaxPackets", UintegerValue(1000000));
720 dlClient.SetAttribute("PacketSize", UintegerValue(m_packetSize.at(u)));
721
722 UdpClientHelper ulClient(remoteHostAddr, ulPort); // uplink packets generator
723 ulClient.SetAttribute("Interval", TimeValue(MilliSeconds(m_interval)));
724 ulClient.SetAttribute("MaxPackets", UintegerValue(1000000));
725 ulClient.SetAttribute("PacketSize", UintegerValue(m_packetSize.at(u)));
726
727 clientApps.Add(dlClient.Install(remoteHost));
728 clientApps.Add(ulClient.Install(ueNodes.Get(u)));
729 }
730
731 serverApps.Start(Seconds(0.030));
732 clientApps.Start(Seconds(0.030));
733
734 double statsStartTime = 0.04; // need to allow for RRC connection establishment + SRS
735 double statsDuration = 0.5;
736 double tolerance = 0.1;
737 Simulator::Stop(Seconds(statsStartTime + statsDuration - 0.0001));
738
739 lteHelper->EnableRlcTraces();
740 Ptr<RadioBearerStatsCalculator> rlcStats = lteHelper->GetRlcStats();
741 rlcStats->SetAttribute("StartTime", TimeValue(Seconds(statsStartTime)));
742 rlcStats->SetAttribute("EpochDuration", TimeValue(Seconds(statsDuration)));
743
745
750 NS_LOG_INFO("DL - Test with " << m_nUser << " user(s)");
751 std::vector<uint64_t> dlDataRxed;
752 for (int i = 0; i < m_nUser; i++)
753 {
754 // get the imsi
755 uint64_t imsi = ueDevs.Get(i)->GetObject<LteUeNetDevice>()->GetImsi();
756 // get the lcId
757 uint8_t lcId = 4;
758 dlDataRxed.push_back(rlcStats->GetDlRxData(imsi, lcId));
759 NS_LOG_INFO("\tUser " << i << " dist " << m_dist.at(i) << " imsi " << imsi << " bytes rxed "
760 << (double)dlDataRxed.at(i) << " thr "
761 << (double)dlDataRxed.at(i) / statsDuration << " ref "
762 << m_estThrPssDl.at(i));
763 }
764
765 for (int i = 0; i < m_nUser; i++)
766 {
767 NS_TEST_ASSERT_MSG_EQ_TOL((double)dlDataRxed.at(i) / statsDuration,
768 m_estThrPssDl.at(i),
769 m_estThrPssDl.at(i) * tolerance,
770 " Unfair Throughput!");
771 }
772
774}
This system test program creates different test cases with a single eNB and several UEs,...
uint16_t m_interval
the interval time in ms
uint16_t m_packetSize
the packet size in bytes
bool m_errorModelEnabled
indicates whether the error model is enabled
double m_thrRefDl
the DL throughput reference value
static std::string BuildNameString(uint16_t nUser, double dist)
Builds the test name string based on provided parameter values.
double m_thrRefUl
the UL throughput reference value
double m_dist
the distance between nodes
LenaPssFfMacSchedulerTestCase1(uint16_t nUser, double dist, double thrRefDl, double thrRefUl, uint16_t packetSize, uint16_t interval, bool errorModelEnabled)
Constructor.
void DoRun() override
Implementation to actually run this TestCase.
Similar to the LenaPssFfMacSchedulerTestCase1 with the difference that UEs are places in such a way t...
bool m_errorModelEnabled
indicates whether the error model is enabled
std::vector< double > m_dist
the distance between nodes
uint16_t m_interval
the interval time in ms
std::vector< uint16_t > m_packetSize
the packet size in bytes
static std::string BuildNameString(uint16_t nUser, std::vector< double > dist)
Builds the test name string based on provided parameter values.
LenaPssFfMacSchedulerTestCase2(std::vector< double > dist, std::vector< uint32_t > estThrPssDl, std::vector< uint16_t > packetSize, uint16_t interval, bool errorModelEnabled)
Constructor.
void DoRun() override
Implementation to actually run this TestCase.
std::vector< uint32_t > m_estThrPssDl
the DL estimated throughput PSS
Lena Pss Ff Mac Scheduler Test Suite.
holds a vector of ns3::Application pointers.
AttributeValue implementation for Boolean.
Definition: boolean.h:37
Mobility model for which the current position does not change once it has been set and until it is se...
Class for representing data rates.
Definition: data-rate.h:89
AttributeValue implementation for DataRate.
This class can be used to hold variables of floating point type such as 'double' or 'float'.
Definition: double.h:42
Hold variables of type enum.
Definition: enum.h:56
static Ptr< EpcTft > Default()
creates a TFT matching any traffic
Definition: epc-tft.cc:229
This class contains the specification of EPS Bearers.
Definition: eps-bearer.h:91
Qci
QoS Class Indicator.
Definition: eps-bearer.h:106
@ GBR_CONV_VOICE
GBR Conversational Voice.
Definition: eps-bearer.h:107
an Inet address class
aggregate IP/TCP/UDP functionality to existing Nodes.
A helper class to make life easier while doing simple IPv4 address assignment in scripts.
void SetBase(Ipv4Address network, Ipv4Mask mask, Ipv4Address base="0.0.0.1")
Set the base network number, network mask and base address.
Ipv4InterfaceContainer Assign(const NetDeviceContainer &c)
Assign IP addresses to the net devices specified in the container based on the current network prefix...
Ipv4 addresses are stored in host order in this class.
Definition: ipv4-address.h:42
static Ipv4Address GetAny()
Access to the IPv4 forwarding table, interfaces, and configuration.
Definition: ipv4.h:79
holds a vector of std::pair of Ptr<Ipv4> and interface index.
Ipv4Address GetAddress(uint32_t i, uint32_t j=0) const
a class to represent an Ipv4 address mask
Definition: ipv4-address.h:257
Helper class that adds ns3::Ipv4StaticRouting objects.
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...
The eNodeB device implementation.
The LteUeNetDevice class implements the UE net device.
Helper class used to assign positions and mobility models to nodes.
holds a vector of ns3::NetDevice pointers
Ptr< NetDevice > Get(uint32_t i) const
Get the Ptr<NetDevice> stored in this container at a given index.
keep track of a set of node pointers.
uint32_t GetN() const
Get the number of Ptr<Node> stored in this container.
void Create(uint32_t n)
Create n nodes and append pointers to them to the end of this NodeContainer.
Ptr< Node > Get(uint32_t i) const
Get the Ptr<Node> stored in this container at a given index.
Ptr< T > GetObject() const
Get a pointer to the requested aggregated Object.
Definition: object.h:471
A helper to make it easier to instantiate an ns3::PacketSinkApplication on a set of nodes.
ApplicationContainer Install(NodeContainer c) const
Install an ns3::PacketSinkApplication on each node of the input container configured with all the att...
Build a set of PointToPointNetDevice objects.
void SetDeviceAttribute(std::string name, const AttributeValue &value)
Set an attribute value to be propagated to each NetDevice created by the helper.
void SetChannelAttribute(std::string name, const AttributeValue &value)
Set an attribute value to be propagated to each Channel created by the helper.
NetDeviceContainer Install(NodeContainer c)
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:78
static void Destroy()
Execute the events scheduled with ScheduleDestroy().
Definition: simulator.cc:140
static void Run()
Run the simulation.
Definition: simulator.cc:176
static void Stop()
Tell the Simulator the calling event should be the last one executed.
Definition: simulator.cc:184
Hold variables of type string.
Definition: string.h:56
encapsulates test code
Definition: test.h:1060
@ EXTENSIVE
Medium length test.
Definition: test.h:1066
@ QUICK
Fast test.
Definition: test.h:1065
void AddTestCase(TestCase *testCase, TestDuration duration=QUICK)
Add an individual child TestCase to this test suite.
Definition: test.cc:301
std::string CreateTempDirFilename(std::string filename)
Construct the full path to a file in a temporary directory.
Definition: test.cc:438
std::string GetName() const
Definition: test.cc:373
A suite of tests to run.
Definition: test.h:1256
AttributeValue implementation for Time.
Definition: nstime.h:1423
Create a client application which sends UDP packets carrying a 32bit sequence number and a 64 bit tim...
void SetAttribute(std::string name, const AttributeValue &value)
Record an attribute to be set in each Application after it is is created.
ApplicationContainer Install(NodeContainer c)
Hold an unsigned integer type.
Definition: uinteger.h:45
void SetDefault(std::string name, const AttributeValue &value)
Definition: config.cc:891
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:202
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by ",...
#define NS_LOG_INFO(msg)
Use NS_LOG to output a message of level LOG_INFO.
Definition: log.h:275
static LenaTestPssFfMacSchedulerSuite lenaTestPssFfMacSchedulerSuite
Static variable for test initialization.
#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:337
Time Seconds(double value)
Construct a Time in the indicated unit.
Definition: nstime.h:1336
Time MilliSeconds(uint64_t value)
Construct a Time in the indicated unit.
Definition: nstime.h:1348
Every class exported by the ns3 library is enclosed in the ns3 namespace.
uint8_t data[writeSize]
3GPP TS 36.413 9.2.1.18 GBR QoS Information
Definition: eps-bearer.h:36
uint64_t gbrDl
Guaranteed Bit Rate (bit/s) in downlink.
Definition: eps-bearer.h:42
uint64_t gbrUl
Guaranteed Bit Rate (bit/s) in uplink.
Definition: eps-bearer.h:43
uint64_t mbrDl
Maximum Bit Rate (bit/s) in downlink.
Definition: eps-bearer.h:44
uint64_t mbrUl
Maximum Bit Rate (bit/s) in uplink.
Definition: eps-bearer.h:45
static const uint32_t packetSize
Packet size generated at the AP.