A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
lte-test-tdmt-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("LenaTestTdMtFfMacScheduler");
46
48 : TestSuite("lte-tdmt-ff-mac-scheduler", Type::SYSTEM)
49{
50 NS_LOG_INFO("creating LenaTestTdMtFfMacSchedulerSuite");
51
52 bool errorModel = false;
53
54 // Test Case : AMC works in TDMT
55
56 // Note: here the MCS is calculated by the wideband 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 LenaTdMtFfMacSchedulerTestCase(1, 0, 2196000, 2292000, errorModel),
69 TestCase::Duration::EXTENSIVE);
70 AddTestCase(new LenaTdMtFfMacSchedulerTestCase(3, 0, 2196000, 749000, errorModel),
71 TestCase::Duration::QUICK);
72 AddTestCase(new LenaTdMtFfMacSchedulerTestCase(6, 0, 2196000, 373000, errorModel),
73 TestCase::Duration::EXTENSIVE);
74 AddTestCase(new LenaTdMtFfMacSchedulerTestCase(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 bytes/sec for one UE; 0 bytes/sec for other
79 // UEs 3 users -> 1383000 among 3 users -> 1383000 bytes/sec for one UE; 0 bytes/sec for other
80 // UEs 6 users -> 1383000 among 6 users -> 1383000 bytes/sec for one UE; 0 bytes/sec for other
81 // UEs 12 users -> 1383000 among 12 users -> 1383000 bytes/sec for one UE; 0 bytes/sec for other
82 // UEs UPLINK - DISTANCE 4800 -> MCS 14 -> Itbs 13 (from table 7.1.7.2.1-1 of 36.213) 1 user ->
83 // 25 PRB at Itbs 13 -> 807 -> 807000 bytes/sec 3 users -> 8 PRB at Itbs 13 -> 253 -> 253000
84 // bytes/sec 6 users -> 4 PRB at Itbs 13 -> 125 -> 125000 bytes/sec after the patch enforcing
85 // min 3 PRBs per UE: 12 users -> 3 PRB at Itbs 13 -> 93 bytes * 8/12 UE/TTI -> 62000
86 // bytes/sec
87 AddTestCase(new LenaTdMtFfMacSchedulerTestCase(1, 4800, 1383000, 807000, errorModel),
88 TestCase::Duration::EXTENSIVE);
89 AddTestCase(new LenaTdMtFfMacSchedulerTestCase(3, 4800, 1383000, 253000, errorModel),
90 TestCase::Duration::EXTENSIVE);
91 AddTestCase(new LenaTdMtFfMacSchedulerTestCase(6, 4800, 1383000, 125000, errorModel),
92 TestCase::Duration::EXTENSIVE);
93 AddTestCase(new LenaTdMtFfMacSchedulerTestCase(12, 4800, 1383000, 62000, errorModel),
94 TestCase::Duration::EXTENSIVE);
95
96 // DOWNLINK - DISTANCE 6000 -> MCS 20 -> Itbs 18 (from table 7.1.7.2.1-1 of 36.213)
97 // 1 user -> 24 PRB at Itbs 18 -> 1191 -> 1191000 byte/sec for one UE; 0 bytes/sec for other UEs
98 // 3 users -> 1191000 among 3 users -> 1191000 bytes/sec for one UE; 0 bytes/sec for other UEs
99 // 6 users -> 1191000 among 6 users -> 1191000 bytes/sec for one UE; 0 bytes/sec for other UEs
100 // 12 users ->1191000 among 12 users -> 1191000 bytes/sec for one UE; 0 bytes/sec for other UEs
101 // UPLINK - DISTANCE 6000 -> MCS 12 -> Itbs 11 (from table 7.1.7.2.1-1 of 36.213)
102 // 1 user -> 25 PRB at Itbs 11 -> 621 -> 621000 bytes/sec
103 // 3 users -> 8 PRB at Itbs 11 -> 201 -> 201000 bytes/sec
104 // 6 users -> 4 PRB at Itbs 11 -> 97 -> 97000 bytes/sec
105 // after the patch enforcing min 3 PRBs per UE:
106 // 12 users -> 3 PRB at Itbs 11 -> 73 bytes * 8/12 UE/TTI -> 48667 bytes/sec
107 AddTestCase(new LenaTdMtFfMacSchedulerTestCase(1, 6000, 1191000, 621000, errorModel),
108 TestCase::Duration::EXTENSIVE);
109 AddTestCase(new LenaTdMtFfMacSchedulerTestCase(3, 6000, 1191000, 201000, errorModel),
110 TestCase::Duration::EXTENSIVE);
111 AddTestCase(new LenaTdMtFfMacSchedulerTestCase(6, 6000, 1191000, 97000, errorModel),
112 TestCase::Duration::EXTENSIVE);
113 AddTestCase(new LenaTdMtFfMacSchedulerTestCase(12, 6000, 1191000, 48667, errorModel),
114 TestCase::Duration::EXTENSIVE);
115
116 // DOWNLINK - DISTANCE 10000 -> MCS 14 -> Itbs 13 (from table 7.1.7.2.1-1 of 36.213)
117 // 1 user -> 24 PRB at Itbs 13 -> 775 -> 775000 byte/sec for one UE; 0 bytes/sec for other UEs
118 // 3 users -> 775000 among 3 users -> 775000 bytes/sec for one UE; 0 bytes/sec for other UEs
119 // 6 users -> 775000 among 6 users -> 775000 bytes/sec for one UE; 0 bytes/sec for other UEs
120 // 12 users -> 775000 among 12 users -> 775000 bytes/sec for one UE; 0 bytes/sec for other UEs
121 // UPLINK - DISTANCE 10000 -> MCS 8 -> Itbs 8 (from table 7.1.7.2.1-1 of 36.213)
122 // 1 user -> 24 PRB at Itbs 8 -> 437 -> 437000 bytes/sec
123 // 3 users -> 8 PRB at Itbs 8 -> 137 -> 137000 bytes/sec
124 // 6 users -> 4 PRB at Itbs 8 -> 67 -> 67000 bytes/sec
125 // after the patch enforcing min 3 PRBs per UE:
126 // 12 users -> 3 PRB at Itbs 8 -> 49 bytes * 8/12 UE/TTI -> 32667 bytes/sec
127 AddTestCase(new LenaTdMtFfMacSchedulerTestCase(1, 10000, 775000, 437000, errorModel),
128 TestCase::Duration::EXTENSIVE);
129 AddTestCase(new LenaTdMtFfMacSchedulerTestCase(3, 10000, 775000, 137000, errorModel),
130 TestCase::Duration::EXTENSIVE);
131 AddTestCase(new LenaTdMtFfMacSchedulerTestCase(6, 10000, 775000, 67000, errorModel),
132 TestCase::Duration::EXTENSIVE);
133 AddTestCase(new LenaTdMtFfMacSchedulerTestCase(12, 10000, 775000, 32667, errorModel),
134 TestCase::Duration::EXTENSIVE);
135
136 // DONWLINK - DISTANCE 20000 -> MCS 8 -> Itbs 8 (from table 7.1.7.2.1-1 of 36.213)
137 // 1 user -> 24 PRB at Itbs 8 -> 421 -> 421000 bytes/sec for one UE; 0 bytes/sec for other UEs
138 // 3 users -> 421000 among 3 users -> 421000 bytes/sec for one UE; 0 bytes/sec for other UEs
139 // 6 users -> 421000 among 6 users -> 421000 bytes/sec for one UE; 0 bytes/sec for other UEs
140 // 12 users -> 421000 among 12 users -> 421000 bytes/sec for one UE; 0 bytes/sec for other UEs
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 -> 233 -> 137000 bytes/sec
143 // 3 users -> 8 PRB at Itbs 2 -> 69 -> 41000 bytes/sec
144 // 6 users -> 4 PRB at Itbs 2 -> 32 -> 22000 bytes/sec
145 // after the patch enforcing min 3 PRBs per UE:
146 // 12 users -> 3 PRB at Itbs 2 -> 26 bytes * 8/12 UE/TTI -> 12000 bytes/sec
147 AddTestCase(new LenaTdMtFfMacSchedulerTestCase(1, 20000, 421000, 137000, errorModel),
148 TestCase::Duration::EXTENSIVE);
149 AddTestCase(new LenaTdMtFfMacSchedulerTestCase(3, 20000, 421000, 41000, errorModel),
150 TestCase::Duration::EXTENSIVE);
151 AddTestCase(new LenaTdMtFfMacSchedulerTestCase(6, 20000, 421000, 22000, errorModel),
152 TestCase::Duration::EXTENSIVE);
153 AddTestCase(new LenaTdMtFfMacSchedulerTestCase(12, 20000, 421000, 12000, errorModel),
154 TestCase::Duration::EXTENSIVE);
155
156 // DOWNLINK - DISTANCE 100000 -> CQI == 0 -> out of range -> 0 bytes/sec
157 // UPLINK - DISTANCE 100000 -> CQI == 0 -> out of range -> 0 bytes/sec
158 AddTestCase(new LenaTdMtFfMacSchedulerTestCase(1, 100000, 0, 0, errorModel),
159 TestCase::Duration::QUICK);
160}
161
162/**
163 * @ingroup lte-test
164 * Static variable for test initialization
165 */
167
168// --------------- T E S T - C A S E ------------------------------
169
170std::string
172{
173 std::ostringstream oss;
174 oss << nUser << " UEs, distance " << dist << " m";
175 return oss.str();
176}
177
179 double dist,
180 double thrRefDl,
181 double thrRefUl,
182 bool errorModelEnabled)
183 : TestCase(BuildNameString(nUser, dist)),
184 m_nUser(nUser),
185 m_dist(dist),
186 m_thrRefDl(thrRefDl),
187 m_thrRefUl(thrRefUl),
188 m_errorModelEnabled(errorModelEnabled)
189{
190}
191
195
196void
198{
199 NS_LOG_FUNCTION(this << m_nUser << m_dist);
200
202 {
203 Config::SetDefault("ns3::LteSpectrumPhy::CtrlErrorModelEnabled", BooleanValue(false));
204 Config::SetDefault("ns3::LteSpectrumPhy::DataErrorModelEnabled", BooleanValue(false));
205 }
206
207 Config::SetDefault("ns3::LteHelper::UseIdealRrc", BooleanValue(true));
208 Config::SetDefault("ns3::MacStatsCalculator::DlOutputFilename",
209 StringValue(CreateTempDirFilename("DlMacStats.txt")));
210 Config::SetDefault("ns3::MacStatsCalculator::UlOutputFilename",
211 StringValue(CreateTempDirFilename("UlMacStats.txt")));
212 Config::SetDefault("ns3::RadioBearerStatsCalculator::DlRlcOutputFilename",
213 StringValue(CreateTempDirFilename("DlRlcStats.txt")));
214 Config::SetDefault("ns3::RadioBearerStatsCalculator::UlRlcOutputFilename",
215 StringValue(CreateTempDirFilename("UlRlcStats.txt")));
216
217 // Disable Uplink Power Control
218 Config::SetDefault("ns3::LteUePhy::EnableUplinkPowerControl", BooleanValue(false));
219
220 /**
221 * Initialize Simulation Scenario: 1 eNB and m_nUser UEs
222 */
223
225 lteHelper->SetAttribute("PathlossModel", StringValue("ns3::FriisSpectrumPropagationLossModel"));
226
227 // Create Nodes: eNodeB and UE
228 NodeContainer enbNodes;
229 NodeContainer ueNodes;
230 enbNodes.Create(1);
231 ueNodes.Create(m_nUser);
232
233 // Install Mobility Model
234 MobilityHelper mobility;
235 mobility.SetMobilityModel("ns3::ConstantPositionMobilityModel");
236 mobility.Install(enbNodes);
237 mobility.SetMobilityModel("ns3::ConstantPositionMobilityModel");
238 mobility.Install(ueNodes);
239
240 // Create Devices and install them in the Nodes (eNB and UE)
241 NetDeviceContainer enbDevs;
242 NetDeviceContainer ueDevs;
243 lteHelper->SetSchedulerType("ns3::TdMtFfMacScheduler");
244 lteHelper->SetSchedulerAttribute("UlCqiFilter", EnumValue(FfMacScheduler::SRS_UL_CQI));
245 enbDevs = lteHelper->InstallEnbDevice(enbNodes);
246 ueDevs = lteHelper->InstallUeDevice(ueNodes);
247
248 // Attach a UE to a eNB
249 lteHelper->Attach(ueDevs, enbDevs.Get(0));
250
251 // Activate an EPS bearer
253 EpsBearer bearer(q);
254 lteHelper->ActivateDataRadioBearer(ueDevs, bearer);
255
256 Ptr<LteEnbNetDevice> lteEnbDev = enbDevs.Get(0)->GetObject<LteEnbNetDevice>();
257 Ptr<LteEnbPhy> enbPhy = lteEnbDev->GetPhy();
258 enbPhy->SetAttribute("TxPower", DoubleValue(30.0));
259 enbPhy->SetAttribute("NoiseFigure", DoubleValue(5.0));
260
261 // Set UEs' position and power
262 for (int i = 0; i < m_nUser; i++)
263 {
266 mm->SetPosition(Vector(m_dist, 0.0, 0.0));
267 Ptr<LteUeNetDevice> lteUeDev = ueDevs.Get(i)->GetObject<LteUeNetDevice>();
268 Ptr<LteUePhy> uePhy = lteUeDev->GetPhy();
269 uePhy->SetAttribute("TxPower", DoubleValue(23.0));
270 uePhy->SetAttribute("NoiseFigure", DoubleValue(9.0));
271 }
272
273 double statsStartTime = 0.300; // need to allow for RRC connection establishment + SRS
274 double statsDuration = 0.6;
275 double tolerance = 0.1;
276 Simulator::Stop(Seconds(statsStartTime + statsDuration - 0.000001));
277
278 lteHelper->EnableMacTraces();
279 lteHelper->EnableRlcTraces();
280 Ptr<RadioBearerStatsCalculator> rlcStats = lteHelper->GetRlcStats();
281 rlcStats->SetAttribute("StartTime", TimeValue(Seconds(statsStartTime)));
282 rlcStats->SetAttribute("EpochDuration", TimeValue(Seconds(statsDuration)));
283
285
286 /**
287 * Check that the downlink assignment is done in a "time domain maximum throughput" manner
288 */
289 NS_LOG_INFO("DL - Test with " << m_nUser << " user(s) at distance " << m_dist);
290 std::vector<uint64_t> dlDataRxed;
291 for (int i = 0; i < m_nUser; i++)
292 {
293 // get the imsi
294 uint64_t imsi = ueDevs.Get(i)->GetObject<LteUeNetDevice>()->GetImsi();
295 uint8_t lcId = 3;
296 dlDataRxed.push_back(rlcStats->GetDlRxData(imsi, lcId));
297 NS_LOG_INFO("\tUser " << i << " imsi " << imsi << " bytes rxed " << (double)dlDataRxed.at(i)
298 << " thr " << (double)dlDataRxed.at(i) / statsDuration << " ref "
299 << m_thrRefDl);
300 }
301
302 /**
303 * Check that the assignment is done in a "time domain maximum throughput" manner among users
304 * with maximum SINRs: without fading, current FD MT always assign all resources to one UE
305 */
306
307 uint8_t found = 0;
308 for (int i = 0; i < m_nUser; i++)
309 {
310 double throughput = (double)dlDataRxed.at(i) / statsDuration;
311 if (throughput != 0 && found == 0)
312 {
315 m_thrRefDl * tolerance,
316 " Unfair Throughput!");
317 found = 1;
318 }
319 else if (throughput != 0 && found == 1)
320 {
321 NS_TEST_ASSERT_MSG_EQ_TOL(0, m_thrRefDl, m_thrRefDl * tolerance, " Unfair Throughput!");
322 }
323 else
324 {
325 NS_TEST_ASSERT_MSG_EQ_TOL(throughput, 0, 0, " Unfair Throughput!");
326 }
327 }
328
329 /**
330 * Check that the uplink assignment is done in a "proportional fair" manner
331 */
332 NS_LOG_INFO("UL - Test with " << m_nUser << " user(s) at distance " << m_dist);
333 std::vector<uint64_t> ulDataRxed;
334 for (int i = 0; i < m_nUser; i++)
335 {
336 // get the imsi
337 uint64_t imsi = ueDevs.Get(i)->GetObject<LteUeNetDevice>()->GetImsi();
338 // get the lcId
339 uint8_t lcId = 3;
340 ulDataRxed.push_back(rlcStats->GetUlRxData(imsi, lcId));
341 NS_LOG_INFO("\tUser " << i << " imsi " << imsi << " bytes rxed " << (double)ulDataRxed.at(i)
342 << " thr " << (double)ulDataRxed.at(i) / statsDuration << " ref "
343 << m_thrRefUl);
344 }
345 /**
346 * Check that the assignment is done in a "proportional fair" manner among users
347 * with equal SINRs: the bandwidth should be distributed according to the
348 * ratio of the estimated throughput per TTI of each user; therefore equally
349 * partitioning the whole bandwidth achievable from a single users in a TTI
350 */
351 for (int i = 0; i < m_nUser; i++)
352 {
353 NS_TEST_ASSERT_MSG_EQ_TOL((double)ulDataRxed.at(i) / statsDuration,
355 m_thrRefUl * tolerance,
356 " Unfair Throughput!");
357 }
359}
This system test program creates different test cases with a single eNB and several UEs,...
double m_dist
the distance between nodes
void DoRun() override
Implementation to actually run this TestCase.
double m_thrRefUl
the UL throughput reference
double m_thrRefDl
the DL throughput reference
LenaTdMtFfMacSchedulerTestCase(uint16_t nUser, double dist, double thrRefDl, double thrRefUl, bool errorModelEnabled)
Constructor.
bool m_errorModelEnabled
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.
Test suite for TdMtFfMacScheduler tests.
AttributeValue implementation for Boolean.
Definition boolean.h:26
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
AttributeValue implementation for Time.
Definition nstime.h:1431
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 LenaTestTdMtFfMacSchedulerSuite lenaTestTdMtFfMacSchedulerSuite
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:1344
Every class exported by the ns3 library is enclosed in the ns3 namespace.
std::ofstream throughput