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