A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
lte-test-rr-ff-mac-scheduler.cc
Go to the documentation of this file.
1/*
2 * Copyright (c) 2011, 2012 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 */
9
11
12#include "ns3/double.h"
13#include "ns3/radio-bearer-stats-calculator.h"
14#include "ns3/string.h"
15#include <ns3/boolean.h>
16#include <ns3/constant-position-mobility-model.h>
17#include <ns3/enum.h>
18#include <ns3/eps-bearer.h>
19#include <ns3/ff-mac-scheduler.h>
20#include <ns3/log.h>
21#include <ns3/lte-enb-net-device.h>
22#include <ns3/lte-enb-phy.h>
23#include <ns3/lte-helper.h>
24#include <ns3/lte-ue-net-device.h>
25#include <ns3/lte-ue-phy.h>
26#include <ns3/lte-ue-rrc.h>
27#include <ns3/mobility-helper.h>
28#include <ns3/net-device-container.h>
29#include <ns3/node-container.h>
30#include <ns3/object.h>
31#include <ns3/packet.h>
32#include <ns3/ptr.h>
33#include <ns3/simulator.h>
34#include <ns3/spectrum-error-model.h>
35#include <ns3/spectrum-interference.h>
36#include <ns3/test.h>
37
38#include <iostream>
39
40using namespace ns3;
41
42NS_LOG_COMPONENT_DEFINE("LenaTestRrFfMacScheduler");
43
45 : TestSuite("lte-rr-ff-mac-scheduler", Type::SYSTEM)
46{
47 NS_LOG_INFO("creating LenaRrFfMacSchedulerTestCase");
48
49 bool errorModel = true;
50
51 // DOWNLINK- DISTANCE 0 -> MCS 28 -> Itbs 26 (from table 7.1.7.2.1-1 of 36.213)
52 // 1 user -> 24 PRB at Itbs 26 -> 2196 -> 2196000 bytes/sec
53 // 3 users -> 8 PRB at Itbs 26 -> 749 -> 749000 bytes/sec
54 // 6 users -> 4 PRB at Itbs 26 -> 373 -> 373000 bytes/sec
55 // 9 user -> 2 PRB at Itbs 26 -> 185 -> 185000 bytes/sec
56 // 12 users -> 2 PRB at Itbs 26 -> 185 -> 185000 bytes/sec
57 // 15 users -> 2 PRB at Itbs 26 * 0.8 -> 148 -> 148000 bytes/sec
58 // UPLINK- DISTANCE 0 -> MCS 28 -> Itbs 26 (from table 7.1.7.2.1-1 of 36.213)
59 // 1 user -> 25 PRB at Itbs 26 -> 2292 -> 2292000 bytes/sec
60 // 3 users -> 8 PRB at Itbs 26 -> 749 -> 749000 bytes/sec
61 // 6 users -> 4 PRB at Itbs 26 -> 373 -> 373000 bytes/sec
62 // after the patch enforcing min 3 PRBs per UE:
63 // 9 users -> 3 PRB at Itbs 26 -> 277 bytes * 8/9 UE/TTI -> 246220 bytes/sec
64 // 12 users -> 3 PRB at Itbs 26 -> 277 bytes * 8/12 UE/TTI -> 184670 bytes/sec
65 // 15 users -> 3 PRB at Itbs 26 -> 277 bytes * 8/15 UE/TTI -> 147730 bytes/sec
66 AddTestCase(new LenaRrFfMacSchedulerTestCase(1, 0, 2196000, 2292000, errorModel),
67 TestCase::Duration::EXTENSIVE);
68 AddTestCase(new LenaRrFfMacSchedulerTestCase(3, 0, 749000, 749000, errorModel),
69 TestCase::Duration::QUICK);
70 AddTestCase(new LenaRrFfMacSchedulerTestCase(6, 0, 373000, 373000, errorModel),
71 TestCase::Duration::EXTENSIVE);
72 AddTestCase(new LenaRrFfMacSchedulerTestCase(9, 0, 185000, 246220, errorModel),
73 TestCase::Duration::EXTENSIVE);
74 AddTestCase(new LenaRrFfMacSchedulerTestCase(12, 0, 185000, 184670, errorModel),
75 TestCase::Duration::EXTENSIVE);
76 AddTestCase(new LenaRrFfMacSchedulerTestCase(15, 0, 148000, 147730, errorModel),
77 TestCase::Duration::EXTENSIVE);
78
79 // DOWNLINK - DISTANCE 4800 -> MCS 22 -> Itbs 20 (from table 7.1.7.2.1-1 of 36.213)
80 // 1 user -> 24 PRB at Itbs 20 -> 1383 -> 1383000 bytes/sec
81 // 3 users -> 8 PRB at Itbs 20 -> 469 -> 469000 bytes/sec
82 // 6 users -> 4 PRB at Itbs 20 -> 233 -> 233000 bytes/sec
83 // 9 user -> 2 PRB at Itbs 20 -> 113 -> 113000 bytes/sec
84 // 12 users -> 2 PRB at Itbs 20 -> 113 -> 113000 bytes/sec
85 // 15 users -> 2 PRB at Itbs 20 * 0.8 -> 90.4 -> 90400 bytes/sec
86 // UPLINK - DISTANCE 4800 -> MCS 14 -> Itbs 13 (from table 7.1.7.2.1-1 of 36.213)
87 // 1 user -> 25 PRB at Itbs 13 -> 807 -> 807000 bytes/sec
88 // 3 users -> 8 PRB at Itbs 13 -> 253 -> 253000 bytes/sec
89 // 6 users -> 4 PRB at Itbs 13 -> 125 -> 125000 bytes/sec
90 // after the patch enforcing min 3 PRBs per UE:
91 // 9 users -> 3 PRB at Itbs 13 -> 93 bytes * 8/9 UE/TTI -> 82667 bytes/sec
92 // 12 users -> 3 PRB at Itbs 13 -> 93 bytes * 8/12 UE/TTI -> 62000 bytes/sec
93 // 15 users -> 3 PRB at Itbs 13 -> 93 bytes * 8/15 UE/TTI -> 49600 bytes/sec
94 AddTestCase(new LenaRrFfMacSchedulerTestCase(1, 4800, 1383000, 807000, errorModel),
95 TestCase::Duration::EXTENSIVE);
96 AddTestCase(new LenaRrFfMacSchedulerTestCase(3, 4800, 469000, 253000, errorModel),
97 TestCase::Duration::EXTENSIVE);
98 AddTestCase(new LenaRrFfMacSchedulerTestCase(6, 4800, 233000, 125000, errorModel),
99 TestCase::Duration::EXTENSIVE);
100 AddTestCase(new LenaRrFfMacSchedulerTestCase(9, 4800, 113000, 82667, errorModel),
101 TestCase::Duration::EXTENSIVE);
102 AddTestCase(new LenaRrFfMacSchedulerTestCase(12, 4800, 113000, 62000, errorModel),
103 TestCase::Duration::EXTENSIVE);
104 AddTestCase(new LenaRrFfMacSchedulerTestCase(15, 4800, 90400, 49600, errorModel),
105 TestCase::Duration::EXTENSIVE);
106
107 // DOWNLINK - DISTANCE 6000 -> MCS 20 -> Itbs 18 (from table 7.1.7.2.1-1 of 36.213)
108 // 1 user -> 24 PRB at Itbs 15 -> 1191 -> 1191000 bytes/sec
109 // 3 users -> 8 PRB at Itbs 15 -> 389 -> 389000 bytes/sec
110 // 6 users -> 4 PRB at Itbs 15 -> 193 -> 193000 bytes/sec
111 // 9 user -> 2 PRB at Itbs 15 -> 97 -> 97000 bytes/sec
112 // 12 users -> 2 PRB at Itbs 15 -> 97 -> 97000 bytes/sec
113 // 15 users -> 2 PRB at Itbs 15 * 0.8 -> 77.6 -> 77600 bytes/sec
114 // UPLINK - DISTANCE 6000 -> MCS 12 -> Itbs 11 (from table 7.1.7.2.1-1 of 36.213)
115 // 1 user -> 25 PRB at Itbs 11 -> 621 -> 621000 bytes/sec
116 // 3 users -> 8 PRB at Itbs 11 -> 201 -> 201000 bytes/sec
117 // 6 users -> 4 PRB at Itbs 11 -> 97 -> 97000 bytes/sec
118 // 9 users -> 3 PRB at Itbs 11 -> 73 bytes * 8/9 UE/TTI -> 64889 bytes/sec
119 // 12 users -> 3 PRB at Itbs 11 -> 73 bytes * 8/12 UE/TTI -> 48667 bytes/sec
120 // 15 users -> 3 PRB at Itbs 11 -> 73 bytes * 8/15 UE/TTI -> 38993 bytes/sec
121 AddTestCase(new LenaRrFfMacSchedulerTestCase(1, 6000, 1191000, 621000, errorModel),
122 TestCase::Duration::EXTENSIVE);
123 AddTestCase(new LenaRrFfMacSchedulerTestCase(3, 6000, 389000, 201000, errorModel),
124 TestCase::Duration::EXTENSIVE);
125 AddTestCase(new LenaRrFfMacSchedulerTestCase(6, 6000, 193000, 97000, errorModel),
126 TestCase::Duration::EXTENSIVE);
127 AddTestCase(new LenaRrFfMacSchedulerTestCase(9, 6000, 97000, 64889, errorModel),
128 TestCase::Duration::EXTENSIVE);
129 AddTestCase(new LenaRrFfMacSchedulerTestCase(12, 6000, 97000, 48667, errorModel),
130 TestCase::Duration::EXTENSIVE);
131 AddTestCase(new LenaRrFfMacSchedulerTestCase(15, 6000, 77600, 38993, errorModel),
132 TestCase::Duration::EXTENSIVE);
133
134 // DOWNLINK - DISTANCE 20000 -> MCS 8 -> Itbs 8 (from table 7.1.7.2.1-1 of 36.213)
135 // 1 user -> 24 PRB at Itbs 8 -> 421 -> 421000 bytes/sec
136 // 3 users -> 8 PRB at Itbs 8 -> 137 -> 137000 bytes/sec
137 // 6 users -> 4 PRB at Itbs 8 -> 67 -> 67000 bytes/sec
138 // 9 user -> 2 PRB at Itbs 8 -> 32 -> 32000 bytes/sec
139 // 12 users -> 2 PRB at Itbs 8 -> 32 -> 32000 bytes/sec
140 // 15 users -> 2 PRB at Itbs 8 * 0.8 -> 25.6 -> 25600 bytes/sec
141 // UPLINK - DISTANCE 20000 -> MCS 2 -> Itbs 2 (from table 7.1.7.2.1-1 of 36.213)
142 // 1 user -> 25 PRB at Itbs 2 -> 137 -> 137000 bytes/sec
143 // 3 users -> 8 PRB at Itbs 2 -> 41 -> 41000 bytes/sec
144 // 6 users -> 4 PRB at Itbs 2 -> 22 -> 22000 bytes/sec
145 // after the patch enforcing min 3 PRBs per UE:
146 // 9 users -> 3 PRB at Itbs 2 -> 18 bytes * 8/9 UE/TTI -> 16000 bytes/sec
147 // 12 users -> 3 PRB at Itbs 2 -> 18 bytes * 8/12 UE/TTI -> 12000 bytes/sec
148 // 15 users -> 3 PRB at Itbs 2 -> 18 bytes * 8/15 UE/TTI -> 9600 bytes/sec
149 AddTestCase(new LenaRrFfMacSchedulerTestCase(1, 20000, 421000, 137000, errorModel),
150 TestCase::Duration::EXTENSIVE);
151 AddTestCase(new LenaRrFfMacSchedulerTestCase(3, 20000, 137000, 41000, errorModel),
152 TestCase::Duration::EXTENSIVE);
153 AddTestCase(new LenaRrFfMacSchedulerTestCase(6, 20000, 67000, 22000, errorModel),
154 TestCase::Duration::EXTENSIVE);
155 AddTestCase(new LenaRrFfMacSchedulerTestCase(9, 20000, 32000, 16000, errorModel),
156 TestCase::Duration::EXTENSIVE);
157 AddTestCase(new LenaRrFfMacSchedulerTestCase(12, 20000, 32000, 12000, errorModel),
158 TestCase::Duration::EXTENSIVE);
159 AddTestCase(new LenaRrFfMacSchedulerTestCase(15, 20000, 25600, 9600, errorModel),
160 TestCase::Duration::EXTENSIVE);
161
162 // DOWNLINK - DISTANCE 100000 -> CQI == 0 -> out of range -> 0 bytes/sec
163 // UPLINK - DISTANCE 100000 -> CQI == 0 -> out of range -> 0 bytes/sec
164 AddTestCase(new LenaRrFfMacSchedulerTestCase(1, 100000, 0, 0, errorModel),
165 TestCase::Duration::QUICK);
166}
167
168/**
169 * \ingroup lte-test
170 * Static variable for test initialization
171 */
173
174std::string
176{
177 std::ostringstream oss;
178 oss << nUser << " UEs, distance " << dist << " m";
179 return oss.str();
180}
181
183 double dist,
184 double thrRefDl,
185 double thrRefUl,
186 bool errorModelEnabled)
187 : TestCase(BuildNameString(nUser, dist)),
188 m_nUser(nUser),
189 m_dist(dist),
190 m_thrRefDl(thrRefDl),
191 m_thrRefUl(thrRefUl),
192 m_errorModelEnabled(errorModelEnabled)
193{
194}
195
199
200void
202{
203 NS_LOG_FUNCTION(this << m_nUser << m_dist);
205 {
206 Config::SetDefault("ns3::LteSpectrumPhy::CtrlErrorModelEnabled", BooleanValue(false));
207 Config::SetDefault("ns3::LteSpectrumPhy::DataErrorModelEnabled", BooleanValue(false));
208 }
209 Config::SetDefault("ns3::LteHelper::UseIdealRrc", BooleanValue(false));
210 Config::SetDefault("ns3::MacStatsCalculator::DlOutputFilename",
211 StringValue(CreateTempDirFilename("DlMacStats.txt")));
212 Config::SetDefault("ns3::MacStatsCalculator::UlOutputFilename",
213 StringValue(CreateTempDirFilename("UlMacStats.txt")));
214 Config::SetDefault("ns3::RadioBearerStatsCalculator::DlRlcOutputFilename",
215 StringValue(CreateTempDirFilename("DlRlcStats.txt")));
216 Config::SetDefault("ns3::RadioBearerStatsCalculator::UlRlcOutputFilename",
217 StringValue(CreateTempDirFilename("UlRlcStats.txt")));
218
219 // This is needed as the RR scheduler does not allocate resources properly for retransmission
220 Config::SetDefault("ns3::LteRlcAm::TxOpportunityForRetxAlwaysBigEnough", BooleanValue(true));
221
222 // Disable Uplink Power Control
223 Config::SetDefault("ns3::LteUePhy::EnableUplinkPowerControl", BooleanValue(false));
224
225 /**
226 * Initialize Simulation Scenario: 1 eNB and m_nUser UEs
227 */
228
230
231 lteHelper->SetAttribute("PathlossModel", StringValue("ns3::FriisSpectrumPropagationLossModel"));
232
233 // Create Nodes: eNodeB and UE
234 NodeContainer enbNodes;
235 NodeContainer ueNodes;
236 enbNodes.Create(1);
237 ueNodes.Create(m_nUser);
238
239 // Install Mobility Model
240 MobilityHelper mobility;
241 mobility.SetMobilityModel("ns3::ConstantPositionMobilityModel");
242 mobility.Install(enbNodes);
243 mobility.SetMobilityModel("ns3::ConstantPositionMobilityModel");
244 mobility.Install(ueNodes);
245
246 // Create Devices and install them in the Nodes (eNB and UE)
247 NetDeviceContainer enbDevs;
248 NetDeviceContainer ueDevs;
249 lteHelper->SetSchedulerType("ns3::RrFfMacScheduler");
250 lteHelper->SetSchedulerAttribute("UlCqiFilter", EnumValue(FfMacScheduler::SRS_UL_CQI));
251 enbDevs = lteHelper->InstallEnbDevice(enbNodes);
252 ueDevs = lteHelper->InstallUeDevice(ueNodes);
253
254 // Attach a UE to a eNB
255 lteHelper->Attach(ueDevs, enbDevs.Get(0));
256
257 // Activate an EPS bearer
259 EpsBearer bearer(q);
260 lteHelper->ActivateDataRadioBearer(ueDevs, bearer);
261
262 Ptr<LteEnbNetDevice> lteEnbDev = enbDevs.Get(0)->GetObject<LteEnbNetDevice>();
263 Ptr<LteEnbPhy> enbPhy = lteEnbDev->GetPhy();
264 enbPhy->SetAttribute("TxPower", DoubleValue(30.0));
265 enbPhy->SetAttribute("NoiseFigure", DoubleValue(5.0));
266
267 // Set UEs' position and power
268 for (int i = 0; i < m_nUser; i++)
269 {
272 mm->SetPosition(Vector(m_dist, 0.0, 0.0));
273 Ptr<LteUeNetDevice> lteUeDev = ueDevs.Get(i)->GetObject<LteUeNetDevice>();
274 Ptr<LteUePhy> uePhy = lteUeDev->GetPhy();
275 uePhy->SetAttribute("TxPower", DoubleValue(23.0));
276 uePhy->SetAttribute("NoiseFigure", DoubleValue(9.0));
277 }
278
279 double statsStartTime = 0.300; // need to allow for RRC connection establishment + SRS
280 double statsDuration = 0.4;
281 double tolerance = 0.1;
282 Simulator::Stop(Seconds(statsStartTime + statsDuration - 0.0001));
283
284 lteHelper->EnableRlcTraces();
285 Ptr<RadioBearerStatsCalculator> rlcStats = lteHelper->GetRlcStats();
286 rlcStats->SetAttribute("StartTime", TimeValue(Seconds(statsStartTime)));
287 rlcStats->SetAttribute("EpochDuration", TimeValue(Seconds(statsDuration)));
288
290
291 /**
292 * Check that the assignment is done in a RR fashion
293 */
294 NS_LOG_INFO("DL - Test with " << m_nUser << " user(s) at distance " << m_dist);
295 std::vector<uint64_t> dlDataRxed;
297 {
298 m_thrRefDl *= 0.95; // for counting the Vienna AMC behavior: BLER between 0% and 10%
299 }
300 for (int i = 0; i < m_nUser; i++)
301 {
302 // get the imsi
303 uint64_t imsi = ueDevs.Get(i)->GetObject<LteUeNetDevice>()->GetImsi();
304 uint8_t lcId = 3;
305 dlDataRxed.push_back(rlcStats->GetDlRxData(imsi, lcId));
306 NS_LOG_INFO("\tUser " << i << " imsi " << imsi << " lcid " << (uint16_t)lcId
307 << " bytes rxed " << (double)dlDataRxed.at(i) << " thr "
308 << (double)dlDataRxed.at(i) / statsDuration << " ref " << m_thrRefDl);
309 NS_TEST_ASSERT_MSG_EQ_TOL((double)dlDataRxed.at(i) / statsDuration,
311 m_thrRefDl * tolerance,
312 " Unfair Throughput!");
313 }
314
315 NS_LOG_INFO("UL - Test with " << m_nUser << " user(s) at distance " << m_dist);
316 std::vector<uint64_t> ulDataRxed;
318 {
319 m_thrRefUl *= 0.95; // for counting the Vienna AMC behavior: BLER between 0% and 10%
320 }
321 for (int i = 0; i < m_nUser; i++)
322 {
323 // get the imsi
324 uint64_t imsi = ueDevs.Get(i)->GetObject<LteUeNetDevice>()->GetImsi();
325 // get the lcId
326 uint8_t lcId = 3;
327 ulDataRxed.push_back(rlcStats->GetUlRxData(imsi, lcId));
328 NS_LOG_INFO("\tUser " << i << " imsi " << imsi << " lcid " << (uint16_t)lcId
329 << " bytes rxed " << (double)ulDataRxed.at(i) << " thr "
330 << (double)ulDataRxed.at(i) / statsDuration << " ref " << m_thrRefUl
331 << " txed " << rlcStats->GetUlTxData(imsi, lcId) / statsDuration);
332 NS_TEST_ASSERT_MSG_EQ_TOL((double)ulDataRxed.at(i) / statsDuration,
334 m_thrRefUl * tolerance,
335 " Unfair Throughput!");
336 }
337
339}
This system test program creates different test cases with a single eNB and This system test program ...
double m_thrRefDl
the DL throughput reference
void DoRun() override
Implementation to actually run this TestCase.
double m_thrRefUl
the UL throughput reference
bool m_errorModelEnabled
indicates whether the error model is enabled
static std::string BuildNameString(uint16_t nUser, double dist)
Builds the test name string based on provided parameter values.
double m_dist
the distance between nodes
LenaRrFfMacSchedulerTestCase(uint16_t nUser, double dist, double thrRefDl, double thrRefUl, bool errorModelEnabled)
Constructor.
Test suite for RrFfMacScheduler test.
Mobility model for which the current position does not change once it has been set and until it is se...
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
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
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.
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
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
A suite of tests to run.
Definition test.h:1267
Type
Type of test.
Definition test.h:1274
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 LenaTestRrFfMacSchedulerSuite lenaTestRrFfMacSchedulerSuite
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
Every class exported by the ns3 library is enclosed in the ns3 namespace.