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