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