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 * SPDX-License-Identifier: GPL-2.0-only
5 *
6 * Author: Marco Miozzo <marco.miozzo@cttc.es>,
7 * Nicola Baldo <nbaldo@cttc.es>
8 * Dizhi Zhou <dizhi.zhou@gmail.com>
9 */
10
12
13#include "ns3/double.h"
14#include "ns3/internet-module.h"
15#include "ns3/ipv4-global-routing-helper.h"
16#include "ns3/network-module.h"
17#include "ns3/packet-sink-helper.h"
18#include "ns3/point-to-point-epc-helper.h"
19#include "ns3/point-to-point-helper.h"
20#include "ns3/radio-bearer-stats-calculator.h"
21#include "ns3/string.h"
22#include "ns3/udp-client-server-helper.h"
23#include <ns3/boolean.h>
24#include <ns3/constant-position-mobility-model.h>
25#include <ns3/enum.h>
26#include <ns3/eps-bearer.h>
27#include <ns3/ff-mac-scheduler.h>
28#include <ns3/log.h>
29#include <ns3/lte-enb-net-device.h>
30#include <ns3/lte-enb-phy.h>
31#include <ns3/lte-helper.h>
32#include <ns3/lte-ue-net-device.h>
33#include <ns3/lte-ue-phy.h>
34#include <ns3/lte-ue-rrc.h>
35#include <ns3/mobility-helper.h>
36#include <ns3/net-device-container.h>
37#include <ns3/node-container.h>
38#include <ns3/object.h>
39#include <ns3/packet.h>
40#include <ns3/ptr.h>
41#include <ns3/simulator.h>
42#include <ns3/spectrum-error-model.h>
43#include <ns3/spectrum-interference.h>
44#include <ns3/test.h>
45
46#include <iostream>
47#include <sstream>
48#include <string>
49
50using namespace ns3;
51
52NS_LOG_COMPONENT_DEFINE("LenaTestPssFfMacScheduler");
53
55 : TestSuite("lte-pss-ff-mac-scheduler", Type::SYSTEM)
56{
57 NS_LOG_INFO("creating LenaTestPssFfMacSchedulerSuite");
58
59 bool errorModel = false;
60
61 // General config
62 // Traffic: UDP traffic with fixed rate
63 // Token generation rate = traffic rate
64 // RLC header length = 2 bytes, PDCP header = 2 bytes
65 // Simulation time = 1.0 sec
66 // Throughput in this file is calculated in RLC layer
67
68 // Test Case 1: homogeneous flow test in PSS (same distance)
69 // DOWNLINK -> DISTANCE 0 -> MCS 28 -> Itbs 26 (from table 7.1.7.2.1-1 of 36.2 13)
70 // Traffic info
71 // UDP traffic: payload size = 200 bytes, interval = 1 ms
72 // UDP rate in scheduler: (payload + RLC header + PDCP header + IP header + UDP header) *
73 // 1000 byte/sec -> 232000 byte/rate
74 // Total bandwidth: 24 PRB at Itbs 26 -> 2196 -> 2196000 byte/sec
75 // 1 user -> 232000 * 1 = 232000 < 2196000 -> throughput = 232000 byte/sec
76 // 3 user -> 232000 * 3 = 696000 < 2196000 -> througphut = 232000 byte/sec
77 // 6 user -> 232000 * 6 = 139200 < 2196000 -> throughput = 232000 byte/sec
78 // 12 user -> 232000 * 12 = 2784000 > 2196000 -> throughput = 2196000 / 12 = 183000 byte/sec
79 // UPLINK -> DISTANCE 0 -> MCS 28 -> Itbs 26 (from table 7.1.7.2.1-1 of 36.2 13)
80 // 1 user -> 25 PRB at Itbs 26 -> 2292 -> 2292000 > 232000 -> throughput = 232000 bytes/sec
81 // 3 users -> 8 PRB at Itbs 26 -> 749 -> 749000 > 232000 -> throughput = 232000 bytes/sec
82 // 6 users -> 4 PRB at Itbs 26 -> 373 -> 373000 > 232000 -> throughput = 232000 bytes/sec
83 // 12 users -> 2 PRB at Itbs 26 -> 185 -> 185000 < 232000 -> throughput = 185000 bytes/sec
84 AddTestCase(new LenaPssFfMacSchedulerTestCase1(1, 0, 232000, 232000, 200, 1, errorModel),
85 TestCase::Duration::EXTENSIVE);
86 AddTestCase(new LenaPssFfMacSchedulerTestCase1(3, 0, 232000, 232000, 200, 1, errorModel),
87 TestCase::Duration::EXTENSIVE);
88 AddTestCase(new LenaPssFfMacSchedulerTestCase1(6, 0, 232000, 232000, 200, 1, errorModel),
89 TestCase::Duration::EXTENSIVE);
90
91 // AddTestCase (new LenaPssFfMacSchedulerTestCase1 (12,0,183000,185000,200,1,errorModel));//
92 // simulation time = 1.5, otherwise, ul test will fail
93
94 // DOWNLINK - DISTANCE 4800 -> MCS 22 -> Itbs 20 (from table 7.1.7.2.1-1 of 36.213)
95 // Traffic info
96 // UDP traffic: payload size = 200 bytes, interval = 1 ms
97 // UDP rate in scheduler: (payload + RLC header + PDCP header + IP header + UDP header) * 1000
98 // byte/sec -> 232000 byte/rate
99 // Total bandwidth: 24 PRB at Itbs 20 -> 1383 -> 1383000 byte/sec
100 // 1 user -> 903000 * 1 = 232000 < 1383000 -> throughput = 232000 byte/sec
101 // 3 user -> 232000 * 3 = 696000 < 1383000 -> througphut = 232000 byte/sec
102 // 6 user -> 232000 * 6 = 139200 > 1383000 -> throughput = 1383000 / 6 = 230500 byte/sec
103 // 12 user -> 232000 * 12 = 2784000 > 1383000 -> throughput = 1383000 / 12 = 115250 byte/sec
104 // UPLINK - DISTANCE 4800 -> MCS 14 -> Itbs 13 (from table 7.1.7.2.1-1 of 36.213)
105 // 1 user -> 25 PRB at Itbs 13 -> 807 -> 807000 > 232000 -> throughput = 232000 bytes/sec
106 // 3 users -> 8 PRB at Itbs 13 -> 253 -> 253000 > 232000 -> throughput = 232000 bytes/sec
107 // 6 users -> 4 PRB at Itbs 13 -> 125 -> 125000 < 232000 -> throughput = 125000 bytes/sec
108 // after the patch enforcing min 3 PRBs per UE:
109 // 12 users -> 3 PRB at Itbs 13 -> 93 bytes * 8/12 UE/TTI -> 62000 < 232000 -> throughput =
110 // 62000 bytes/sec
111 AddTestCase(new LenaPssFfMacSchedulerTestCase1(1, 4800, 232000, 232000, 200, 1, errorModel),
112 TestCase::Duration::EXTENSIVE);
113 AddTestCase(new LenaPssFfMacSchedulerTestCase1(3, 4800, 232000, 232000, 200, 1, errorModel),
114 TestCase::Duration::EXTENSIVE);
115 AddTestCase(new LenaPssFfMacSchedulerTestCase1(6, 4800, 230500, 125000, 200, 1, errorModel),
116 TestCase::Duration::EXTENSIVE);
117 // AddTestCase (new LenaPssFfMacSchedulerTestCase1 (12,4800,115250,62000,200,1,errorModel)); //
118 // simulation time = 1.5, otherwise, ul test will fail
119
120 // DOWNLINK - DISTANCE 6000 -> MCS 20 -> Itbs 18 (from table 7.1.7.2.1-1 of 36.213)
121 // Traffic info
122 // UDP traffic: payload size = 200 bytes, interval = 1 ms
123 // UDP rate in scheduler: (payload + RLC header + PDCP header + IP header + UDP header) * 1000
124 // byte/sec -> 232000 byte/rate
125 // Total bandwidth: 24 PRB at Itbs 18 -> 1191 -> 1191000 byte/sec
126 // 1 user -> 903000 * 1 = 232000 < 1191000 -> throughput = 232000 byte/sec
127 // 3 user -> 232000 * 3 = 696000 < 1191000 -> througphut = 232000 byte/sec
128 // 6 user -> 232000 * 6 = 1392000 > 1191000 -> throughput = 1191000 / 6 = 198500 byte/sec
129 // 12 user -> 232000 * 12 = 2784000 > 1191000 -> throughput = 1191000 / 12 = 99250 byte/sec
130
131 // UPLINK - DISTANCE 6000 -> MCS 12 -> Itbs 11 (from table 7.1.7.2.1-1 of 36.213)
132 // 1 user -> 25 PRB at Itbs 11 -> 621 -> 621000 > 232000 -> throughput = 232000 bytes/sec
133 // 3 users -> 8 PRB at Itbs 11 -> 201 -> 201000 < 232000 -> throughput = 201000 bytes/sec
134 // 6 users -> 4 PRB at Itbs 11 -> 97 -> 97000 < 232000 -> throughput = 97000 bytes/sec
135 // after the patch enforcing min 3 PRBs per UE:
136 // 12 users -> 3 PRB at Itbs 11 -> 73 bytes * 8/12 UE/TTI -> 48667 < 232000 -> throughput =
137 // 48667 bytes/sec
138 AddTestCase(new LenaPssFfMacSchedulerTestCase1(1, 6000, 232000, 232000, 200, 1, errorModel),
139 TestCase::Duration::EXTENSIVE);
140 AddTestCase(new LenaPssFfMacSchedulerTestCase1(3, 6000, 232000, 201000, 200, 1, errorModel),
141 TestCase::Duration::EXTENSIVE);
142 AddTestCase(new LenaPssFfMacSchedulerTestCase1(6, 6000, 198500, 97000, 200, 1, errorModel),
143 TestCase::Duration::EXTENSIVE);
144 // AddTestCase (new LenaPssFfMacSchedulerTestCase1 (12,6000,99250,48667,200,1, errorModel)); //
145 // simulation time = 1.5, otherwise, ul test will fail
146
147 // DOWNLINK - DISTANCE 10000 -> MCS 14 -> Itbs 13 (from table 7.1.7.2.1-1 of 36.213)
148 // Traffic info
149 // UDP traffic: payload size = 200 bytes, interval = 1 ms
150 // UDP rate in scheduler: (payload + RLC header + PDCP header + IP header + UDP header) * 1000
151 // byte/sec -> 232000 byte/rate
152 // Total bandwidth: 24 PRB at Itbs 13 -> 775 -> 775000 byte/sec
153 // 1 user -> 903000 * 1 = 232000 < 775000 -> throughput = 232000 byte/sec
154 // 3 user -> 232000 * 3 = 696000 > 775000 -> througphut = 232000 byte/sec
155 // 6 user -> 232000 * 6 = 139200 > 775000 -> throughput = 775000 / 6 = 129166 byte/sec
156 // 12 user -> 232000 * 12 = 2784000 > 775000 -> throughput = 775000 / 12 = 64583 byte/sec
157 // UPLINK - DISTANCE 10000 -> MCS 8 -> Itbs 8 (from table 7.1.7.2.1-1 of 36.213)
158 // 1 user -> 24 PRB at Itbs 8 -> 437 -> 437000 > 232000 -> throughput = 232000 bytes/sec
159 // 3 users -> 8 PRB at Itbs 8 -> 137 -> 137000 < 232000 -> throughput = 137000 bytes/sec
160 // 6 users -> 4 PRB at Itbs 8 -> 67 -> 67000 < 232000 -> throughput = 67000 bytes/sec
161 // after the patch enforcing min 3 PRBs per UE:
162 // 12 users -> 3 PRB at Itbs 8 -> 49 bytes * 8/12 UE/TTI -> 32667 < 232000 -> throughput = 32667
163 // bytes/sec
164 AddTestCase(new LenaPssFfMacSchedulerTestCase1(1, 10000, 232000, 232000, 200, 1, errorModel),
165 TestCase::Duration::EXTENSIVE);
166 AddTestCase(new LenaPssFfMacSchedulerTestCase1(3, 10000, 232000, 137000, 200, 1, errorModel),
167 TestCase::Duration::EXTENSIVE);
168 AddTestCase(new LenaPssFfMacSchedulerTestCase1(6, 10000, 129166, 67000, 200, 1, errorModel),
169 TestCase::Duration::EXTENSIVE);
170 // AddTestCase (new LenaPssFfMacSchedulerTestCase1 (12,10000,64583,32667,200,1,errorModel));//
171 // simulation time = 1.5, otherwise, ul test will fail
172
173 // DOWNLINK - DISTANCE 100000 -> CQI == 0 -> out of range -> 0 bytes/sec
174 // UPLINK - DISTANCE 100000 -> CQI == 0 -> out of range -> 0 bytes/sec
175 AddTestCase(new LenaPssFfMacSchedulerTestCase1(1, 100000, 0, 0, 200, 1, errorModel),
176 TestCase::Duration::QUICK);
177
178 // Test Case 2: homogeneous flow test in PSS (different distance)
179 // Traffic1 info
180 // UDP traffic: payload size = 100 bytes, interval = 1 ms
181 // UDP rate in scheduler: (payload + RLC header + PDCP header + IP header + UDP header) * 1000
182 // byte/sec -> 132000 byte/rate
183 // Maximum throughput = 4 / ( 1/2196000 + 1/1191000 + 1/1383000 + 1/775000 ) = 1209046 byte/s
184 // 132000 * 4 = 528000 < 1209046 -> estimated throughput in downlink = 132000 byte/sec
185 std::vector<double> dist1;
186 dist1.push_back(0); // User 0 distance --> MCS 28
187 dist1.push_back(4800); // User 1 distance --> MCS 22
188 dist1.push_back(6000); // User 2 distance --> MCS 20
189 dist1.push_back(10000); // User 3 distance --> MCS 14
190 std::vector<uint16_t> packetSize1;
191 packetSize1.push_back(100);
192 packetSize1.push_back(100);
193 packetSize1.push_back(100);
194 packetSize1.push_back(100);
195 std::vector<uint32_t> estThrPssDl1;
196 estThrPssDl1.push_back(132000); // User 0 estimated TTI throughput from PSS
197 estThrPssDl1.push_back(132000); // User 1 estimated TTI throughput from PSS
198 estThrPssDl1.push_back(132000); // User 2 estimated TTI throughput from PSS
199 estThrPssDl1.push_back(132000); // User 3 estimated TTI throughput from PSS
200 AddTestCase(new LenaPssFfMacSchedulerTestCase2(dist1, estThrPssDl1, packetSize1, 1, errorModel),
201 TestCase::Duration::QUICK);
202
203 // Traffic2 info
204 // UDP traffic: payload size = 200 bytes, interval = 1 ms
205 // UDP rate in scheduler: (payload + RLC header + PDCP header + IP header + UDP header) * 1000
206 // byte/sec -> 232000 byte/rate
207 // Maximum throughput = 4 / ( 1/2196000 + 1/1191000 + 1/1383000 + 1/775000 ) = 1209046 byte/s
208 // 232000 * 4 = 928000 < 1209046 -> estimated throughput in downlink = 928000 / 4 = 230000
209 // byte/sec
210 std::vector<double> dist2;
211 dist2.push_back(0); // User 0 distance --> MCS 28
212 dist2.push_back(4800); // User 1 distance --> MCS 22
213 dist2.push_back(6000); // User 2 distance --> MCS 20
214 dist2.push_back(10000); // User 3 distance --> MCS 14
215 std::vector<uint16_t> packetSize2;
216 packetSize2.push_back(200);
217 packetSize2.push_back(200);
218 packetSize2.push_back(200);
219 packetSize2.push_back(200);
220 std::vector<uint32_t> estThrPssDl2;
221 estThrPssDl2.push_back(230000); // User 0 estimated TTI throughput from PSS
222 estThrPssDl2.push_back(230000); // User 1 estimated TTI throughput from PSS
223 estThrPssDl2.push_back(230000); // User 2 estimated TTI throughput from PSS
224 estThrPssDl2.push_back(230000); // User 3 estimated TTI throughput from PSS
225 AddTestCase(new LenaPssFfMacSchedulerTestCase2(dist2, estThrPssDl2, packetSize2, 1, errorModel),
226 TestCase::Duration::QUICK);
227
228 // Test Case 3: heterogeneous flow test in PSS
229 // UDP traffic: payload size = [100,200,300] bytes, interval = 1 ms
230 // UDP rate in scheduler: (payload + RLC header + PDCP header + IP header + UDP header) * 1000
231 // byte/sec -> [132000, 232000, 332000] byte/rate
232 // Maximum throughput = 3 / ( 1/2196000 + 1/1191000 + 1/1383000) = 1486569 byte/s
233 // 132000 + 232000 + 332000 = 696000 < 1486569 -> estimated throughput in downlink = [132000,
234 // 232000, 332000] byte/sec
235 std::vector<double> dist3;
236 dist3.push_back(0); // User 0 distance --> MCS 28
237 dist3.push_back(4800); // User 1 distance --> MCS 22
238 dist3.push_back(6000); // User 2 distance --> MCS 20
239 std::vector<uint16_t> packetSize3;
240 packetSize3.push_back(100);
241 packetSize3.push_back(200);
242 packetSize3.push_back(300);
243 std::vector<uint32_t> estThrPssDl3;
244 estThrPssDl3.push_back(132000); // User 0 estimated TTI throughput from PSS
245 estThrPssDl3.push_back(232000); // User 1 estimated TTI throughput from PSS
246 estThrPssDl3.push_back(332000); // User 2 estimated TTI throughput from PSS
247 AddTestCase(new LenaPssFfMacSchedulerTestCase2(dist3, estThrPssDl3, packetSize3, 1, errorModel),
248 TestCase::Duration::QUICK);
249}
250
251/**
252 * @ingroup lte-test
253 * Static variable for test initialization
254 */
256
257// --------------- T E S T - C A S E # 1 ------------------------------
258
259std::string
261{
262 std::ostringstream oss;
263 oss << nUser << " UEs, distance " << dist << " m";
264 return oss.str();
265}
266
268 double dist,
269 double thrRefDl,
270 double thrRefUl,
271 uint16_t packetSize,
272 uint16_t interval,
273 bool errorModelEnabled)
274 : TestCase(BuildNameString(nUser, dist)),
275 m_nUser(nUser),
276 m_dist(dist),
277 m_packetSize(packetSize),
278 m_interval(interval),
279 m_thrRefDl(thrRefDl),
280 m_thrRefUl(thrRefUl),
281 m_errorModelEnabled(errorModelEnabled)
282{
283}
284
288
289void
291{
292 NS_LOG_FUNCTION(this << GetName());
293
295 {
296 Config::SetDefault("ns3::LteSpectrumPhy::CtrlErrorModelEnabled", BooleanValue(false));
297 Config::SetDefault("ns3::LteSpectrumPhy::DataErrorModelEnabled", BooleanValue(false));
298 }
299
300 Config::SetDefault("ns3::LteHelper::UseIdealRrc", BooleanValue(true));
301 Config::SetDefault("ns3::MacStatsCalculator::DlOutputFilename",
302 StringValue(CreateTempDirFilename("DlMacStats.txt")));
303 Config::SetDefault("ns3::MacStatsCalculator::UlOutputFilename",
304 StringValue(CreateTempDirFilename("UlMacStats.txt")));
305 Config::SetDefault("ns3::RadioBearerStatsCalculator::DlRlcOutputFilename",
306 StringValue(CreateTempDirFilename("DlRlcStats.txt")));
307 Config::SetDefault("ns3::RadioBearerStatsCalculator::UlRlcOutputFilename",
308 StringValue(CreateTempDirFilename("UlRlcStats.txt")));
309
312 lteHelper->SetEpcHelper(epcHelper);
313
314 // LogComponentEnable ("PssFfMacScheduler", LOG_DEBUG);
315
316 Ptr<Node> pgw = epcHelper->GetPgwNode();
317
318 // Create a single RemoteHost
319 NodeContainer remoteHostContainer;
320 remoteHostContainer.Create(1);
321 Ptr<Node> remoteHost = remoteHostContainer.Get(0);
322 InternetStackHelper internet;
323 internet.Install(remoteHostContainer);
324
325 // Create the Internet
327 p2ph.SetDeviceAttribute("DataRate", DataRateValue(DataRate("100Gb/s")));
328 p2ph.SetDeviceAttribute("Mtu", UintegerValue(1500));
329 p2ph.SetChannelAttribute("Delay", TimeValue(Seconds(0.001)));
330 NetDeviceContainer internetDevices = p2ph.Install(pgw, remoteHost);
331 Ipv4AddressHelper ipv4h;
332 ipv4h.SetBase("1.0.0.0", "255.0.0.0");
333 Ipv4InterfaceContainer internetIpIfaces = ipv4h.Assign(internetDevices);
334 // interface 0 is localhost, 1 is the p2p device
335 Ipv4Address remoteHostAddr = internetIpIfaces.GetAddress(1);
336
337 Ipv4StaticRoutingHelper ipv4RoutingHelper;
338 Ptr<Ipv4StaticRouting> remoteHostStaticRouting =
339 ipv4RoutingHelper.GetStaticRouting(remoteHost->GetObject<Ipv4>());
340 remoteHostStaticRouting->AddNetworkRouteTo(Ipv4Address("7.0.0.0"), Ipv4Mask("255.0.0.0"), 1);
341
342 // Config::SetDefault ("ns3::LteAmc::AmcModel", EnumValue (LteAmc::PiroEW2010));
343 // Config::SetDefault ("ns3::LteAmc::Ber", DoubleValue (0.00005));
344 // Config::SetDefault ("ns3::LteSpectrumPhy::CtrlErrorModelEnabled", BooleanValue (false));
345 // Config::SetDefault ("ns3::LteSpectrumPhy::DataErrorModelEnabled", BooleanValue (false));
346
347 // Config::SetDefault ("ns3::LteEnbRrc::EpsBearerToRlcMapping", EnumValue
348 // (LteHelper::RLC_UM_ALWAYS));
349
350 // LogComponentDisableAll (LOG_LEVEL_ALL);
351 // LogComponentEnable ("LenaTestPssFfMacScheduler", LOG_LEVEL_ALL);
352
353 lteHelper->SetAttribute("PathlossModel", StringValue("ns3::FriisSpectrumPropagationLossModel"));
354
355 // Create Nodes: eNodeB and UE
356 NodeContainer enbNodes;
357 NodeContainer ueNodes;
358 enbNodes.Create(1);
359 ueNodes.Create(m_nUser);
360
361 // Install Mobility Model
362 MobilityHelper mobility;
363 mobility.SetMobilityModel("ns3::ConstantPositionMobilityModel");
364 mobility.Install(enbNodes);
365 mobility.SetMobilityModel("ns3::ConstantPositionMobilityModel");
366 mobility.Install(ueNodes);
367
368 // Create Devices and install them in the Nodes (eNB and UE)
369 NetDeviceContainer enbDevs;
370 NetDeviceContainer ueDevs;
371 lteHelper->SetSchedulerType("ns3::PssFfMacScheduler");
372 lteHelper->SetSchedulerAttribute("UlCqiFilter", EnumValue(FfMacScheduler::SRS_UL_CQI));
373 enbDevs = lteHelper->InstallEnbDevice(enbNodes);
374 ueDevs = lteHelper->InstallUeDevice(ueNodes);
375
376 Ptr<LteEnbNetDevice> lteEnbDev = enbDevs.Get(0)->GetObject<LteEnbNetDevice>();
377 Ptr<LteEnbPhy> enbPhy = lteEnbDev->GetPhy();
378 enbPhy->SetAttribute("TxPower", DoubleValue(30.0));
379 enbPhy->SetAttribute("NoiseFigure", DoubleValue(5.0));
380
381 // Set UEs' position and power
382 for (int i = 0; i < m_nUser; i++)
383 {
386 mm->SetPosition(Vector(m_dist, 0.0, 0.0));
387 Ptr<LteUeNetDevice> lteUeDev = ueDevs.Get(i)->GetObject<LteUeNetDevice>();
388 Ptr<LteUePhy> uePhy = lteUeDev->GetPhy();
389 uePhy->SetAttribute("TxPower", DoubleValue(23.0));
390 uePhy->SetAttribute("NoiseFigure", DoubleValue(9.0));
391 }
392
393 // Install the IP stack on the UEs
394 internet.Install(ueNodes);
395 Ipv4InterfaceContainer ueIpIface;
396 ueIpIface = epcHelper->AssignUeIpv4Address(NetDeviceContainer(ueDevs));
397
398 // Assign IP address to UEs
399 for (uint32_t u = 0; u < ueNodes.GetN(); ++u)
400 {
401 Ptr<Node> ueNode = ueNodes.Get(u);
402 // Set the default gateway for the UE
403 Ptr<Ipv4StaticRouting> ueStaticRouting =
404 ipv4RoutingHelper.GetStaticRouting(ueNode->GetObject<Ipv4>());
405 ueStaticRouting->SetDefaultRoute(epcHelper->GetUeDefaultGatewayAddress(), 1);
406 }
407
408 // Attach a UE to a eNB
409 lteHelper->Attach(ueDevs, enbDevs.Get(0));
410
411 // Activate an EPS bearer on all UEs
412 for (uint32_t u = 0; u < ueNodes.GetN(); ++u)
413 {
414 Ptr<NetDevice> ueDevice = ueDevs.Get(u);
416 qos.gbrDl = (m_packetSize + 32) * (1000 / m_interval) *
417 8; // bit/s, considering IP, UDP, RLC, PDCP header size
418 qos.gbrUl = (m_packetSize + 32) * (1000 / m_interval) * 8;
419 qos.mbrDl = 0;
420 qos.mbrUl = 0;
421
423 EpsBearer bearer(q, qos);
424 lteHelper->ActivateDedicatedEpsBearer(ueDevice, bearer, EpcTft::Default());
425 }
426
427 // Install downlink and uplink applications
428 uint16_t dlPort = 1234;
429 uint16_t ulPort = 2000;
430 ApplicationContainer clientApps;
431 ApplicationContainer serverApps;
432 PacketSinkHelper dlPacketSinkHelper("ns3::UdpSocketFactory",
434
435 for (uint32_t u = 0; u < ueNodes.GetN(); ++u)
436 {
437 ++ulPort;
438 PacketSinkHelper ulPacketSinkHelper("ns3::UdpSocketFactory",
440 serverApps.Add(ulPacketSinkHelper.Install(remoteHost)); // receive packets from UEs
441 serverApps.Add(
442 dlPacketSinkHelper.Install(ueNodes.Get(u))); // receive packets from remotehost
443
444 UdpClientHelper dlClient(ueIpIface.GetAddress(u), dlPort); // downlink packets generator
445 dlClient.SetAttribute("Interval", TimeValue(MilliSeconds(m_interval)));
446 dlClient.SetAttribute("MaxPackets", UintegerValue(1000000));
447 dlClient.SetAttribute("PacketSize", UintegerValue(m_packetSize));
448
449 UdpClientHelper ulClient(remoteHostAddr, ulPort); // uplink packets generator
450 ulClient.SetAttribute("Interval", TimeValue(MilliSeconds(m_interval)));
451 ulClient.SetAttribute("MaxPackets", UintegerValue(1000000));
452 ulClient.SetAttribute("PacketSize", UintegerValue(m_packetSize));
453
454 clientApps.Add(dlClient.Install(remoteHost));
455 clientApps.Add(ulClient.Install(ueNodes.Get(u)));
456 }
457
458 serverApps.Start(Seconds(0.030));
459 clientApps.Start(Seconds(0.030));
460
461 double statsStartTime = 0.300; // need to allow for RRC connection establishment + SRS
462 double statsDuration = 0.6;
463 double tolerance = 0.1;
464 Simulator::Stop(Seconds(statsStartTime + statsDuration - 0.0001));
465
466 lteHelper->EnableRlcTraces();
467 lteHelper->EnableMacTraces();
468 Ptr<RadioBearerStatsCalculator> rlcStats = lteHelper->GetRlcStats();
469 rlcStats->SetAttribute("StartTime", TimeValue(Seconds(statsStartTime)));
470 rlcStats->SetAttribute("EpochDuration", TimeValue(Seconds(statsDuration)));
471
473
474 /**
475 * Check that the downlink assignment is done in a "token bank fair queue" manner
476 */
477
478 NS_LOG_INFO("DL - Test with " << m_nUser << " user(s) at distance " << m_dist);
479 std::vector<uint64_t> dlDataRxed;
480 for (int i = 0; i < m_nUser; i++)
481 {
482 // get the imsi
483 uint64_t imsi = ueDevs.Get(i)->GetObject<LteUeNetDevice>()->GetImsi();
484 // get the lcId
485 uint8_t lcId = 4;
486 uint64_t data = rlcStats->GetDlRxData(imsi, lcId);
487 dlDataRxed.push_back(data);
488 NS_LOG_INFO("\tUser " << i << " imsi " << imsi << " bytes rxed " << (double)dlDataRxed.at(i)
489 << " thr " << (double)dlDataRxed.at(i) / statsDuration << " ref "
490 << m_thrRefDl);
491 }
492
493 for (int i = 0; i < m_nUser; i++)
494 {
495 NS_TEST_ASSERT_MSG_EQ_TOL((double)dlDataRxed.at(i) / statsDuration,
497 m_thrRefDl * tolerance,
498 " Unfair Throughput!");
499 }
500
501 /**
502 * Check that the uplink assignment is done in a "round robin" manner
503 */
504
505 NS_LOG_INFO("UL - Test with " << m_nUser << " user(s) at distance " << m_dist);
506 std::vector<uint64_t> ulDataRxed;
507 for (int i = 0; i < m_nUser; i++)
508 {
509 // get the imsi
510 uint64_t imsi = ueDevs.Get(i)->GetObject<LteUeNetDevice>()->GetImsi();
511 // get the lcId
512 uint8_t lcId = 4;
513 ulDataRxed.push_back(rlcStats->GetUlRxData(imsi, lcId));
514 NS_LOG_INFO("\tUser " << i << " imsi " << imsi << " bytes rxed " << (double)ulDataRxed.at(i)
515 << " thr " << (double)ulDataRxed.at(i) / statsDuration << " ref "
516 << m_thrRefUl);
517 }
518
519 for (int i = 0; i < m_nUser; i++)
520 {
521 NS_TEST_ASSERT_MSG_EQ_TOL((double)ulDataRxed.at(i) / statsDuration,
523 m_thrRefUl * tolerance,
524 " Unfair Throughput!");
525 }
527}
528
529// --------------- T E S T - C A S E # 2 ------------------------------
530
531std::string
532LenaPssFfMacSchedulerTestCase2::BuildNameString(uint16_t nUser, std::vector<double> dist)
533{
534 std::ostringstream oss;
535 oss << "distances (m) = [ ";
536 for (auto it = dist.begin(); it != dist.end(); ++it)
537 {
538 oss << *it << " ";
539 }
540 oss << "]";
541 return oss.str();
542}
543
545 std::vector<uint32_t> estThrPssDl,
546 std::vector<uint16_t> packetSize,
547 uint16_t interval,
548 bool errorModelEnabled)
549 : TestCase(BuildNameString(dist.size(), dist)),
550 m_nUser(dist.size()),
551 m_dist(dist),
552 m_packetSize(packetSize),
553 m_interval(interval),
554 m_estThrPssDl(estThrPssDl),
555 m_errorModelEnabled(errorModelEnabled)
556{
557}
558
562
563void
565{
567 {
568 Config::SetDefault("ns3::LteSpectrumPhy::CtrlErrorModelEnabled", BooleanValue(false));
569 Config::SetDefault("ns3::LteSpectrumPhy::DataErrorModelEnabled", BooleanValue(false));
570 }
571
572 Config::SetDefault("ns3::LteHelper::UseIdealRrc", BooleanValue(true));
573 Config::SetDefault("ns3::MacStatsCalculator::DlOutputFilename",
574 StringValue(CreateTempDirFilename("DlMacStats.txt")));
575 Config::SetDefault("ns3::MacStatsCalculator::UlOutputFilename",
576 StringValue(CreateTempDirFilename("UlMacStats.txt")));
577 Config::SetDefault("ns3::RadioBearerStatsCalculator::DlRlcOutputFilename",
578 StringValue(CreateTempDirFilename("DlRlcStats.txt")));
579 Config::SetDefault("ns3::RadioBearerStatsCalculator::UlRlcOutputFilename",
580 StringValue(CreateTempDirFilename("UlRlcStats.txt")));
581
584 lteHelper->SetEpcHelper(epcHelper);
585
586 Ptr<Node> pgw = epcHelper->GetPgwNode();
587
588 // Create a single RemoteHost
589 NodeContainer remoteHostContainer;
590 remoteHostContainer.Create(1);
591 Ptr<Node> remoteHost = remoteHostContainer.Get(0);
592 InternetStackHelper internet;
593 internet.Install(remoteHostContainer);
594
595 // Create the Internet
597 p2ph.SetDeviceAttribute("DataRate", DataRateValue(DataRate("100Gb/s")));
598 p2ph.SetDeviceAttribute("Mtu", UintegerValue(1500));
599 p2ph.SetChannelAttribute("Delay", TimeValue(Seconds(0.001)));
600 NetDeviceContainer internetDevices = p2ph.Install(pgw, remoteHost);
601 Ipv4AddressHelper ipv4h;
602 ipv4h.SetBase("1.0.0.0", "255.0.0.0");
603 Ipv4InterfaceContainer internetIpIfaces = ipv4h.Assign(internetDevices);
604 // interface 0 is localhost, 1 is the p2p device
605 Ipv4Address remoteHostAddr = internetIpIfaces.GetAddress(1);
606
607 Ipv4StaticRoutingHelper ipv4RoutingHelper;
608 Ptr<Ipv4StaticRouting> remoteHostStaticRouting =
609 ipv4RoutingHelper.GetStaticRouting(remoteHost->GetObject<Ipv4>());
610 remoteHostStaticRouting->AddNetworkRouteTo(Ipv4Address("7.0.0.0"), Ipv4Mask("255.0.0.0"), 1);
611
612 // LogComponentDisableAll (LOG_LEVEL_ALL);
613 // LogComponentEnable ("LenaTestPssFfMacScheduler", LOG_LEVEL_ALL);
614
615 lteHelper->SetAttribute("PathlossModel", StringValue("ns3::FriisSpectrumPropagationLossModel"));
616
617 // Create Nodes: eNodeB and UE
618 NodeContainer enbNodes;
619 NodeContainer ueNodes;
620 enbNodes.Create(1);
621 ueNodes.Create(m_nUser);
622
623 // Install Mobility Model
624 MobilityHelper mobility;
625 mobility.SetMobilityModel("ns3::ConstantPositionMobilityModel");
626 mobility.Install(enbNodes);
627 mobility.SetMobilityModel("ns3::ConstantPositionMobilityModel");
628 mobility.Install(ueNodes);
629
630 // Create Devices and install them in the Nodes (eNB and UE)
631 NetDeviceContainer enbDevs;
632 NetDeviceContainer ueDevs;
633 lteHelper->SetSchedulerType("ns3::PssFfMacScheduler");
634 lteHelper->SetSchedulerAttribute("UlCqiFilter", EnumValue(FfMacScheduler::SRS_UL_CQI));
635 enbDevs = lteHelper->InstallEnbDevice(enbNodes);
636 ueDevs = lteHelper->InstallUeDevice(ueNodes);
637
638 Ptr<LteEnbNetDevice> lteEnbDev = enbDevs.Get(0)->GetObject<LteEnbNetDevice>();
639 Ptr<LteEnbPhy> enbPhy = lteEnbDev->GetPhy();
640 enbPhy->SetAttribute("TxPower", DoubleValue(30.0));
641 enbPhy->SetAttribute("NoiseFigure", DoubleValue(5.0));
642
643 // Set UEs' position and power
644 for (int i = 0; i < m_nUser; i++)
645 {
648 mm->SetPosition(Vector(m_dist.at(i), 0.0, 0.0));
649 Ptr<LteUeNetDevice> lteUeDev = ueDevs.Get(i)->GetObject<LteUeNetDevice>();
650 Ptr<LteUePhy> uePhy = lteUeDev->GetPhy();
651 uePhy->SetAttribute("TxPower", DoubleValue(23.0));
652 uePhy->SetAttribute("NoiseFigure", DoubleValue(9.0));
653 }
654
655 // Install the IP stack on the UEs
656 internet.Install(ueNodes);
657 Ipv4InterfaceContainer ueIpIface;
658 ueIpIface = epcHelper->AssignUeIpv4Address(NetDeviceContainer(ueDevs));
659
660 // Assign IP address to UEs
661 for (uint32_t u = 0; u < ueNodes.GetN(); ++u)
662 {
663 Ptr<Node> ueNode = ueNodes.Get(u);
664 // Set the default gateway for the UE
665 Ptr<Ipv4StaticRouting> ueStaticRouting =
666 ipv4RoutingHelper.GetStaticRouting(ueNode->GetObject<Ipv4>());
667 ueStaticRouting->SetDefaultRoute(epcHelper->GetUeDefaultGatewayAddress(), 1);
668 }
669
670 // Attach a UE to a eNB
671 lteHelper->Attach(ueDevs, enbDevs.Get(0));
672
673 // Activate an EPS bearer on all UEs
674
675 for (uint32_t u = 0; u < ueNodes.GetN(); ++u)
676 {
677 Ptr<NetDevice> ueDevice = ueDevs.Get(u);
679 qos.gbrDl = (m_packetSize.at(u) + 32) * (1000 / m_interval) *
680 8; // bit/s, considering IP, UDP, RLC, PDCP header size
681 qos.gbrUl = (m_packetSize.at(u) + 32) * (1000 / m_interval) * 8;
682 qos.mbrDl = qos.gbrDl;
683 qos.mbrUl = qos.gbrUl;
684
686 EpsBearer bearer(q, qos);
687 lteHelper->ActivateDedicatedEpsBearer(ueDevice, bearer, EpcTft::Default());
688 }
689
690 // Install downlink and uplink applications
691 uint16_t dlPort = 1234;
692 uint16_t ulPort = 2000;
693 ApplicationContainer clientApps;
694 ApplicationContainer serverApps;
695 PacketSinkHelper dlPacketSinkHelper("ns3::UdpSocketFactory",
697
698 for (uint32_t u = 0; u < ueNodes.GetN(); ++u)
699 {
700 ++ulPort;
701 PacketSinkHelper ulPacketSinkHelper("ns3::UdpSocketFactory",
703 serverApps.Add(ulPacketSinkHelper.Install(remoteHost)); // receive packets from UEs
704 serverApps.Add(
705 dlPacketSinkHelper.Install(ueNodes.Get(u))); // receive packets from remotehost
706
707 UdpClientHelper dlClient(ueIpIface.GetAddress(u), dlPort); // downlink packets generator
708 dlClient.SetAttribute("Interval", TimeValue(MilliSeconds(m_interval)));
709 dlClient.SetAttribute("MaxPackets", UintegerValue(1000000));
710 dlClient.SetAttribute("PacketSize", UintegerValue(m_packetSize.at(u)));
711
712 UdpClientHelper ulClient(remoteHostAddr, ulPort); // uplink packets generator
713 ulClient.SetAttribute("Interval", TimeValue(MilliSeconds(m_interval)));
714 ulClient.SetAttribute("MaxPackets", UintegerValue(1000000));
715 ulClient.SetAttribute("PacketSize", UintegerValue(m_packetSize.at(u)));
716
717 clientApps.Add(dlClient.Install(remoteHost));
718 clientApps.Add(ulClient.Install(ueNodes.Get(u)));
719 }
720
721 serverApps.Start(Seconds(0.030));
722 clientApps.Start(Seconds(0.030));
723
724 double statsStartTime = 0.04; // need to allow for RRC connection establishment + SRS
725 double statsDuration = 0.5;
726 double tolerance = 0.1;
727 Simulator::Stop(Seconds(statsStartTime + statsDuration - 0.0001));
728
729 lteHelper->EnableRlcTraces();
730 Ptr<RadioBearerStatsCalculator> rlcStats = lteHelper->GetRlcStats();
731 rlcStats->SetAttribute("StartTime", TimeValue(Seconds(statsStartTime)));
732 rlcStats->SetAttribute("EpochDuration", TimeValue(Seconds(statsDuration)));
733
735
736 /**
737 * Check that the downlink assignment is done in a "token bank fair queue" manner
738 */
739
740 NS_LOG_INFO("DL - Test with " << m_nUser << " user(s)");
741 std::vector<uint64_t> dlDataRxed;
742 for (int i = 0; i < m_nUser; i++)
743 {
744 // get the imsi
745 uint64_t imsi = ueDevs.Get(i)->GetObject<LteUeNetDevice>()->GetImsi();
746 // get the lcId
747 uint8_t lcId = 4;
748 dlDataRxed.push_back(rlcStats->GetDlRxData(imsi, lcId));
749 NS_LOG_INFO("\tUser " << i << " dist " << m_dist.at(i) << " imsi " << imsi << " bytes rxed "
750 << (double)dlDataRxed.at(i) << " thr "
751 << (double)dlDataRxed.at(i) / statsDuration << " ref "
752 << m_estThrPssDl.at(i));
753 }
754
755 for (int i = 0; i < m_nUser; i++)
756 {
757 NS_TEST_ASSERT_MSG_EQ_TOL((double)dlDataRxed.at(i) / statsDuration,
758 m_estThrPssDl.at(i),
759 m_estThrPssDl.at(i) * tolerance,
760 " Unfair Throughput!");
761 }
762
764}
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.
ApplicationContainer Install(NodeContainer c)
Install an application on each node of the input container configured with all the attributes set wit...
void SetAttribute(const std::string &name, const AttributeValue &value)
Helper function used to set the underlying application attributes.
AttributeValue implementation for Boolean.
Definition boolean.h:26
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:78
AttributeValue implementation for DataRate.
Definition data-rate.h:285
This class can be used to hold variables of floating point type such as 'double' or 'float'.
Definition double.h:31
Hold variables of type enum.
Definition enum.h:52
static Ptr< EpcTft > Default()
creates a TFT matching any traffic
Definition epc-tft.cc:218
This class contains the specification of EPS Bearers.
Definition eps-bearer.h:80
Qci
QoS Class Indicator.
Definition eps-bearer.h:95
@ GBR_CONV_VOICE
GBR Conversational Voice.
Definition eps-bearer.h:96
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.
static Ipv4Address GetAny()
Access to the IPv4 forwarding table, interfaces, and configuration.
Definition ipv4.h:69
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
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:511
A helper to make it easier to instantiate an ns3::PacketSinkApplication on a set of nodes.
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.
static void Destroy()
Execute the events scheduled with ScheduleDestroy().
Definition simulator.cc:131
static void Run()
Run the simulation.
Definition simulator.cc:167
static void Stop()
Tell the Simulator the calling event should be the last one executed.
Definition simulator.cc:175
Hold variables of type string.
Definition string.h:45
encapsulates test code
Definition test.h:1050
void AddTestCase(TestCase *testCase, Duration duration=Duration::QUICK)
Add an individual child TestCase to this test suite.
Definition test.cc:292
std::string CreateTempDirFilename(std::string filename)
Construct the full path to a file in a temporary directory.
Definition test.cc:432
std::string GetName() const
Definition test.cc:367
A suite of tests to run.
Definition test.h:1267
Type
Type of test.
Definition test.h:1274
AttributeValue implementation for Time.
Definition nstime.h:1431
Create a client application which sends UDP packets carrying a 32bit sequence number and a 64 bit tim...
Hold an unsigned integer type.
Definition uinteger.h:34
void SetDefault(std::string name, const AttributeValue &value)
Definition config.cc:883
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition log.h:191
#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:264
static LenaTestPssFfMacSchedulerSuite lenaTestPssFfMacSchedulerSuite
Static variable for test initialization.
Ptr< T > CreateObject(Args &&... args)
Create an object by type, with varying number of constructor parameters.
Definition object.h:619
#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:327
Time Seconds(double value)
Construct a Time in the indicated unit.
Definition nstime.h:1344
Time MilliSeconds(uint64_t value)
Construct a Time in the indicated unit.
Definition nstime.h:1356
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:25
uint64_t gbrDl
Guaranteed Bit Rate (bit/s) in downlink.
Definition eps-bearer.h:31
uint64_t gbrUl
Guaranteed Bit Rate (bit/s) in uplink.
Definition eps-bearer.h:32
uint64_t mbrDl
Maximum Bit Rate (bit/s) in downlink.
Definition eps-bearer.h:33
uint64_t mbrUl
Maximum Bit Rate (bit/s) in uplink.
Definition eps-bearer.h:34
static const uint32_t packetSize
Packet size generated at the AP.