A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
lte-test-fdmt-ff-mac-scheduler.cc
Go to the documentation of this file.
1/*
2 * Copyright (c) 2011 Centre Tecnologic de Telecomunicacions de Catalunya (CTTC)
3 *
4 * SPDX-License-Identifier: GPL-2.0-only
5 *
6 * Author: Marco Miozzo <marco.miozzo@cttc.es>,
7 * Nicola Baldo <nbaldo@cttc.es>
8 * Dizhi Zhou <dizhi.zhou@gmail.com>
9 */
10
12
13#include "ns3/double.h"
14#include "ns3/radio-bearer-stats-calculator.h"
15#include "ns3/string.h"
16#include <ns3/boolean.h>
17#include <ns3/constant-position-mobility-model.h>
18#include <ns3/enum.h>
19#include <ns3/eps-bearer.h>
20#include <ns3/ff-mac-scheduler.h>
21#include <ns3/log.h>
22#include <ns3/lte-enb-net-device.h>
23#include <ns3/lte-enb-phy.h>
24#include <ns3/lte-helper.h>
25#include <ns3/lte-ue-net-device.h>
26#include <ns3/lte-ue-phy.h>
27#include <ns3/lte-ue-rrc.h>
28#include <ns3/mobility-helper.h>
29#include <ns3/net-device-container.h>
30#include <ns3/node-container.h>
31#include <ns3/object.h>
32#include <ns3/packet.h>
33#include <ns3/ptr.h>
34#include <ns3/simulator.h>
35#include <ns3/spectrum-error-model.h>
36#include <ns3/spectrum-interference.h>
37#include <ns3/test.h>
38
39#include <iostream>
40#include <sstream>
41#include <string>
42
43using namespace ns3;
44
45NS_LOG_COMPONENT_DEFINE("LenaTestFdMtFfMacScheduler");
46
48 : TestSuite("lte-fdmt-ff-mac-scheduler", Type::SYSTEM)
49{
50 NS_LOG_INFO("creating LenaTestFdMtFfMacSchedulerSuite");
51
52 bool errorModel = false;
53
54 // Test Case : AMC works in FDMT
55
56 // Note: here the MCS is calculated by the narrowband CQI
57
58 // DOWNLINK - DISTANCE 0 -> MCS 28 -> Itbs 26 (from table 7.1.7.2.1-1 of 36.213)
59 // 1 user -> 24 PRB at Itbs 26 -> 2196 -> 2196000 bytes/sec for one UE; 0 bytes/sec for other
60 // UEs 3 users -> 2196000 among 3 users -> 2196000 bytes/sec for one UE; 0 bytes/sec for other
61 // UEs 6 users -> 2196000 among 6 users -> 2196000 bytes/sec for one UE; 0 bytes/sec for other
62 // UEs 12 users -> 2196000 among 12 users -> 2196000 bytes/sec for one UE; 0 bytes/sec for other
63 // UEs UPLINK- DISTANCE 0 -> MCS 28 -> Itbs 26 (from table 7.1.7.2.1-1 of 36.213) 1 user -> 25
64 // PRB at Itbs 26 -> 2292 -> 2292000 bytes/sec 3 users -> 8 PRB at Itbs 26 -> 749 -> 749000
65 // bytes/sec 6 users -> 4 PRB at Itbs 26 -> 373 -> 373000 bytes/sec after the patch enforcing
66 // min 3 PRBs per UE: 12 users -> 3 PRB at Itbs 26 -> 277 bytes * 8/12 UE/TTI -> 184670
67 // bytes/sec
68 AddTestCase(new LenaFdMtFfMacSchedulerTestCase(1, 0, 2196000, 2292000, errorModel),
69 TestCase::Duration::EXTENSIVE);
70 AddTestCase(new LenaFdMtFfMacSchedulerTestCase(3, 0, 2196000, 749000, errorModel),
71 TestCase::Duration::QUICK);
72 AddTestCase(new LenaFdMtFfMacSchedulerTestCase(6, 0, 2196000, 373000, errorModel),
73 TestCase::Duration::EXTENSIVE);
74 AddTestCase(new LenaFdMtFfMacSchedulerTestCase(12, 0, 2196000, 184670, errorModel),
75 TestCase::Duration::EXTENSIVE);
76
77 // DOWNLINK - DISTANCE 4800 -> MCS 22 -> Itbs 20 (from table 7.1.7.2.1-1 of 36.213)
78 // 1 user -> 24 PRB at Itbs 20 -> 1383 -> 1383000 byte/secfor one UE; 0 bytes/sec for other UEs
79 // 3 users -> 1383000 among 3 users -> 1383000 bytes/sec for one UE; 0 bytes/sec for other UEs
80 // 6 users -> 1383000 among 6 users -> 1383000 bytes/sec for one UE; 0 bytes/sec for other UEs
81 // 12 users -> 1383000 among 12 users -> 1383000 bytes/sec for one UE; 0 bytes/sec for other UEs
82 // UPLINK - DISTANCE 4800 -> MCS 14 -> Itbs 13 (from table 7.1.7.2.1-1 of 36.213)
83 // 1 user -> 25 PRB at Itbs 13 -> 807 -> 807000 bytes/sec
84 // 3 users -> 8 PRB at Itbs 13 -> 253 -> 253000 bytes/sec
85 // 6 users -> 4 PRB at Itbs 13 -> 125 -> 125000 bytes/sec
86 // after the patch enforcing min 3 PRBs per UE:
87 // 12 users -> 3 PRB at Itbs 13 -> 93 bytes * 8/12 UE/TTI -> 62000 bytes/sec
88 AddTestCase(new LenaFdMtFfMacSchedulerTestCase(1, 4800, 1383000, 807000, errorModel),
89 TestCase::Duration::EXTENSIVE);
90 AddTestCase(new LenaFdMtFfMacSchedulerTestCase(3, 4800, 1383000, 253000, errorModel),
91 TestCase::Duration::EXTENSIVE);
92 AddTestCase(new LenaFdMtFfMacSchedulerTestCase(6, 4800, 1383000, 125000, errorModel),
93 TestCase::Duration::EXTENSIVE);
94 AddTestCase(new LenaFdMtFfMacSchedulerTestCase(12, 4800, 1383000, 62000, errorModel),
95 TestCase::Duration::EXTENSIVE);
96
97 // DOWNLINK - DISTANCE 6000 -> MCS 20 -> Itbs 18 (from table 7.1.7.2.1-1 of 36.213)
98 // 1 user -> 24 PRB at Itbs 18 -> 1191 -> 1191000 byte/sec for one UE; 0 bytes/sec for other UEs
99 // 3 users -> 1191000 among 3 users -> 1191000 bytes/sec for one UE; 0 bytes/sec for other UEs
100 // 6 users -> 1191000 among 6 users -> 1191000 bytes/sec for one UE; 0 bytes/sec for other UEs
101 // 12 users ->1191000 among 12 users -> 1191000 bytes/sec for one UE; 0 bytes/sec for other UEs
102 // UPLINK - DISTANCE 6000 -> MCS 12 -> Itbs 11 (from table 7.1.7.2.1-1 of 36.213)
103 // 1 user -> 25 PRB at Itbs 11 -> 621 -> 621000 bytes/sec
104 // 3 users -> 8 PRB at Itbs 11 -> 201 -> 201000 bytes/sec
105 // 6 users -> 4 PRB at Itbs 11 -> 97 -> 97000 bytes/sec
106 // after the patch enforcing min 3 PRBs per UE:
107 // 12 users -> 3 PRB at Itbs 11 -> 73 bytes * 8/12 UE/TTI -> 48667 bytes/sec
108 AddTestCase(new LenaFdMtFfMacSchedulerTestCase(1, 6000, 1191000, 621000, errorModel),
109 TestCase::Duration::EXTENSIVE);
110 AddTestCase(new LenaFdMtFfMacSchedulerTestCase(3, 6000, 1191000, 201000, errorModel),
111 TestCase::Duration::EXTENSIVE);
112 AddTestCase(new LenaFdMtFfMacSchedulerTestCase(6, 6000, 1191000, 97000, errorModel),
113 TestCase::Duration::EXTENSIVE);
114 AddTestCase(new LenaFdMtFfMacSchedulerTestCase(12, 6000, 1191000, 48667, errorModel),
115 TestCase::Duration::EXTENSIVE);
116
117 // DOWNLINK - DISTANCE 10000 -> MCS 14 -> Itbs 13 (from table 7.1.7.2.1-1 of 36.213)
118 // 1 user -> 24 PRB at Itbs 13 -> 775 -> 775000 byte/sec for one UE; 0 bytes/sec for other UEs
119 // 3 users -> 775000 among 3 users -> 775000 bytes/sec for one UE; 0 bytes/sec for other UEs
120 // 6 users -> 775000 among 6 users -> 775000 bytes/sec for one UE; 0 bytes/sec for other UEs
121 // 12 users -> 775000 among 12 users -> 775000 bytes/sec for one UE; 0 bytes/sec for other UEs
122 // UPLINK - DISTANCE 10000 -> MCS 8 -> Itbs 8 (from table 7.1.7.2.1-1 of 36.213)
123 // 1 user -> 24 PRB at Itbs 8 -> 437 -> 437000 bytes/sec
124 // 3 users -> 8 PRB at Itbs 8 -> 137 -> 137000 bytes/sec
125 // 6 users -> 4 PRB at Itbs 8 -> 67 -> 67000 bytes/sec
126 // after the patch enforcing min 3 PRBs per UE:
127 // 12 users -> 3 PRB at Itbs 8 -> 49 bytes * 8/12 UE/TTI -> 32667 bytes/sec
128 AddTestCase(new LenaFdMtFfMacSchedulerTestCase(1, 10000, 775000, 437000, errorModel),
129 TestCase::Duration::EXTENSIVE);
130 AddTestCase(new LenaFdMtFfMacSchedulerTestCase(3, 10000, 775000, 137000, errorModel),
131 TestCase::Duration::EXTENSIVE);
132 AddTestCase(new LenaFdMtFfMacSchedulerTestCase(6, 10000, 775000, 67000, errorModel),
133 TestCase::Duration::EXTENSIVE);
134 AddTestCase(new LenaFdMtFfMacSchedulerTestCase(12, 10000, 775000, 32667, errorModel),
135 TestCase::Duration::EXTENSIVE);
136
137 // DONWLINK - DISTANCE 20000 -> MCS 8 -> Itbs 8 (from table 7.1.7.2.1-1 of 36.213)
138 // 1 user -> 24 PRB at Itbs 8 -> 421 -> 421000 bytes/sec for one UE; 0 bytes/sec for other UEs
139 // 3 users -> 421000 among 3 users -> 421000 bytes/sec for one UE; 0 bytes/sec for other UEs
140 // 6 users -> 421000 among 6 users -> 421000 bytes/sec for one UE; 0 bytes/sec for other UEs
141 // 12 users -> 421000 among 12 users -> 421000 bytes/sec for one UE; 0 bytes/sec for other UEs
142 // UPLINK - DISTANCE 20000 -> MCS 2 -> Itbs 2 (from table 7.1.7.2.1-1 of 36.213)
143 // 1 user -> 25 PRB at Itbs 2 -> 233 -> 137000 bytes/sec
144 // 3 users -> 8 PRB at Itbs 2 -> 69 -> 41000 bytes/sec
145 // 6 users -> 4 PRB at Itbs 2 -> 32 -> 22000 bytes/sec
146 // after the patch enforcing min 3 PRBs per UE:
147 // 12 users -> 3 PRB at Itbs 2 -> 26 bytes * 8/12 UE/TTI -> 12000 bytes/sec
148 AddTestCase(new LenaFdMtFfMacSchedulerTestCase(1, 20000, 421000, 137000, errorModel),
149 TestCase::Duration::EXTENSIVE);
150 AddTestCase(new LenaFdMtFfMacSchedulerTestCase(3, 20000, 421000, 41000, errorModel),
151 TestCase::Duration::EXTENSIVE);
152 AddTestCase(new LenaFdMtFfMacSchedulerTestCase(6, 20000, 421000, 22000, errorModel),
153 TestCase::Duration::EXTENSIVE);
154 AddTestCase(new LenaFdMtFfMacSchedulerTestCase(12, 20000, 421000, 12000, errorModel),
155 TestCase::Duration::EXTENSIVE);
156
157 // DOWNLINK - DISTANCE 100000 -> CQI == 0 -> out of range -> 0 bytes/sec
158 // UPLINK - DISTANCE 100000 -> CQI == 0 -> out of range -> 0 bytes/sec
159 AddTestCase(new LenaFdMtFfMacSchedulerTestCase(1, 100000, 0, 0, errorModel),
160 TestCase::Duration::QUICK);
161}
162
163/**
164 * \ingroup lte-test
165 * Static variable for test initialization
166 */
168
169// --------------- T E S T - C A S E ------------------------------
170
171std::string
173{
174 std::ostringstream oss;
175 oss << nUser << " UEs, distance " << dist << " m";
176 return oss.str();
177}
178
180 double dist,
181 double thrRefDl,
182 double thrRefUl,
183 bool errorModelEnabled)
184 : TestCase(BuildNameString(nUser, dist)),
185 m_nUser(nUser),
186 m_dist(dist),
187 m_thrRefDl(thrRefDl),
188 m_thrRefUl(thrRefUl),
189 m_errorModelEnabled(errorModelEnabled)
190{
191}
192
196
197void
199{
200 NS_LOG_FUNCTION(this << m_nUser << m_dist);
201
203 {
204 Config::SetDefault("ns3::LteSpectrumPhy::CtrlErrorModelEnabled", BooleanValue(false));
205 Config::SetDefault("ns3::LteSpectrumPhy::DataErrorModelEnabled", BooleanValue(false));
206 }
207
208 Config::SetDefault("ns3::LteHelper::UseIdealRrc", BooleanValue(true));
209 Config::SetDefault("ns3::MacStatsCalculator::DlOutputFilename",
210 StringValue(CreateTempDirFilename("DlMacStats.txt")));
211 Config::SetDefault("ns3::MacStatsCalculator::UlOutputFilename",
212 StringValue(CreateTempDirFilename("UlMacStats.txt")));
213 Config::SetDefault("ns3::RadioBearerStatsCalculator::DlRlcOutputFilename",
214 StringValue(CreateTempDirFilename("DlRlcStats.txt")));
215 Config::SetDefault("ns3::RadioBearerStatsCalculator::UlRlcOutputFilename",
216 StringValue(CreateTempDirFilename("UlRlcStats.txt")));
217
218 /**
219 * Initialize Simulation Scenario: 1 eNB and m_nUser UEs
220 */
221
223 lteHelper->SetAttribute("PathlossModel", StringValue("ns3::FriisSpectrumPropagationLossModel"));
224
225 // Create Nodes: eNodeB and UE
226 NodeContainer enbNodes;
227 NodeContainer ueNodes;
228 enbNodes.Create(1);
229 ueNodes.Create(m_nUser);
230
231 // Install Mobility Model
232 MobilityHelper mobility;
233 mobility.SetMobilityModel("ns3::ConstantPositionMobilityModel");
234 mobility.Install(enbNodes);
235 mobility.SetMobilityModel("ns3::ConstantPositionMobilityModel");
236 mobility.Install(ueNodes);
237
238 // Create Devices and install them in the Nodes (eNB and UE)
239 NetDeviceContainer enbDevs;
240 NetDeviceContainer ueDevs;
241 lteHelper->SetSchedulerType("ns3::FdMtFfMacScheduler");
242 lteHelper->SetSchedulerAttribute("UlCqiFilter", EnumValue(FfMacScheduler::SRS_UL_CQI));
243 enbDevs = lteHelper->InstallEnbDevice(enbNodes);
244 ueDevs = lteHelper->InstallUeDevice(ueNodes);
245
246 // Attach a UE to a eNB
247 lteHelper->Attach(ueDevs, enbDevs.Get(0));
248
249 // Activate an EPS bearer
251 EpsBearer bearer(q);
252 lteHelper->ActivateDataRadioBearer(ueDevs, bearer);
253
254 Ptr<LteEnbNetDevice> lteEnbDev = enbDevs.Get(0)->GetObject<LteEnbNetDevice>();
255 Ptr<LteEnbPhy> enbPhy = lteEnbDev->GetPhy();
256 enbPhy->SetAttribute("TxPower", DoubleValue(30.0));
257 enbPhy->SetAttribute("NoiseFigure", DoubleValue(5.0));
258
259 // Set UEs' position and power
260 for (int i = 0; i < m_nUser; i++)
261 {
264 mm->SetPosition(Vector(m_dist, 0.0, 0.0));
265 Ptr<LteUeNetDevice> lteUeDev = ueDevs.Get(i)->GetObject<LteUeNetDevice>();
266 Ptr<LteUePhy> uePhy = lteUeDev->GetPhy();
267 uePhy->SetAttribute("TxPower", DoubleValue(23.0));
268 uePhy->SetAttribute("NoiseFigure", DoubleValue(9.0));
269 }
270
271 double statsStartTime = 0.300; // need to allow for RRC connection establishment + SRS
272 double statsDuration = 0.6;
273 double tolerance = 0.1;
274 Simulator::Stop(Seconds(statsStartTime + statsDuration - 0.000001));
275
276 lteHelper->EnableMacTraces();
277 lteHelper->EnableRlcTraces();
278 Ptr<RadioBearerStatsCalculator> rlcStats = lteHelper->GetRlcStats();
279 rlcStats->SetAttribute("StartTime", TimeValue(Seconds(statsStartTime)));
280 rlcStats->SetAttribute("EpochDuration", TimeValue(Seconds(statsDuration)));
281
283
284 /**
285 * Check that the downlink assignment is done in a "frequency domain maximum throughput" manner
286 */
287 NS_LOG_INFO("DL - Test with " << m_nUser << " user(s) at distance " << m_dist);
288 std::vector<uint64_t> dlDataRxed;
289 for (int i = 0; i < m_nUser; i++)
290 {
291 // get the imsi
292 uint64_t imsi = ueDevs.Get(i)->GetObject<LteUeNetDevice>()->GetImsi();
293 uint8_t lcId = 3;
294 dlDataRxed.push_back(rlcStats->GetDlRxData(imsi, lcId));
295 NS_LOG_INFO("\tUser " << i << " imsi " << imsi << " bytes rxed " << (double)dlDataRxed.at(i)
296 << " thr " << (double)dlDataRxed.at(i) / statsDuration << " ref "
297 << m_thrRefDl);
298 }
299
300 /**
301 * Check that the assignment is done in a "frequency domain maximum throughput" manner among
302 * users with maximum SINRs: without fading, current FD MT always assign all resources to one UE
303 */
304
305 uint8_t found = 0;
306 for (int i = 0; i < m_nUser; i++)
307 {
308 double throughput = (double)dlDataRxed.at(i) / statsDuration;
309 if (throughput != 0 && found == 0)
310 {
313 m_thrRefDl * tolerance,
314 " Unfair Throughput!");
315 found = 1;
316 }
317 else if (throughput != 0 && found == 1)
318 {
319 NS_TEST_ASSERT_MSG_EQ_TOL(0, m_thrRefDl, m_thrRefDl * tolerance, " Unfair Throughput!");
320 }
321 else
322 {
323 NS_TEST_ASSERT_MSG_EQ_TOL(throughput, 0, 0, " Unfair Throughput!");
324 }
325 }
326
327 /**
328 * Check that the uplink assignment is done in a "proportional fair" manner
329 */
330 NS_LOG_INFO("UL - Test with " << m_nUser << " user(s) at distance " << m_dist);
331 std::vector<uint64_t> ulDataRxed;
332 for (int i = 0; i < m_nUser; i++)
333 {
334 // get the imsi
335 uint64_t imsi = ueDevs.Get(i)->GetObject<LteUeNetDevice>()->GetImsi();
336 // get the lcId
337 uint8_t lcId = 3;
338 ulDataRxed.push_back(rlcStats->GetUlRxData(imsi, lcId));
339 NS_LOG_INFO("\tUser " << i << " imsi " << imsi << " bytes rxed " << (double)ulDataRxed.at(i)
340 << " thr " << (double)ulDataRxed.at(i) / statsDuration << " ref "
341 << m_thrRefUl);
342 }
343 /**
344 * Check that the assignment is done in a "proportional fair" manner among users
345 * with equal SINRs: the bandwidth should be distributed according to the
346 * ratio of the estimated throughput per TTI of each user; therefore equally
347 * partitioning the whole bandwidth achievable from a single users in a TTI
348 */
349 for (int i = 0; i < m_nUser; i++)
350 {
351 NS_TEST_ASSERT_MSG_EQ_TOL((double)ulDataRxed.at(i) / statsDuration,
353 m_thrRefUl * tolerance,
354 " Unfair Throughput!");
355 }
357}
This system test program creates different test cases with a single eNB and several UEs,...
double m_thrRefDl
DL throughput reference.
LenaFdMtFfMacSchedulerTestCase(uint16_t nUser, double dist, double thrRefDl, double thrRefUl, bool errorModelEnabled)
Constructor.
void DoRun() override
Implementation to actually run this TestCase.
static std::string BuildNameString(uint16_t nUser, double dist)
Builds the test name string based on provided parameter values.
double m_dist
distance between the nodes
double m_thrRefUl
UL throughput reference.
Test suite for LenaFdMtFfMacSchedulerTestCase test case.
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 LenaTestFdMtFfMacSchedulerSuite lenaTestFdMtFfMacSchedulerSuite
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.
std::ofstream throughput