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 * 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: Marco Miozzo <marco.miozzo@cttc.es>,
18 * Nicola Baldo <nbaldo@cttc.es>
19 * Dizhi Zhou <dizhi.zhou@gmail.com>
20 */
21
23
24#include "ns3/double.h"
25#include "ns3/radio-bearer-stats-calculator.h"
26#include "ns3/string.h"
27#include <ns3/boolean.h>
28#include <ns3/constant-position-mobility-model.h>
29#include <ns3/enum.h>
30#include <ns3/eps-bearer.h>
31#include <ns3/ff-mac-scheduler.h>
32#include <ns3/log.h>
33#include <ns3/lte-enb-net-device.h>
34#include <ns3/lte-enb-phy.h>
35#include <ns3/lte-helper.h>
36#include <ns3/lte-ue-net-device.h>
37#include <ns3/lte-ue-phy.h>
38#include <ns3/lte-ue-rrc.h>
39#include <ns3/mobility-helper.h>
40#include <ns3/net-device-container.h>
41#include <ns3/node-container.h>
42#include <ns3/object.h>
43#include <ns3/packet.h>
44#include <ns3/ptr.h>
45#include <ns3/simulator.h>
46#include <ns3/spectrum-error-model.h>
47#include <ns3/spectrum-interference.h>
48#include <ns3/test.h>
49
50#include <iostream>
51#include <sstream>
52#include <string>
53
54using namespace ns3;
55
56NS_LOG_COMPONENT_DEFINE("LenaTestFdMtFfMacScheduler");
57
59 : TestSuite("lte-fdmt-ff-mac-scheduler", SYSTEM)
60{
61 NS_LOG_INFO("creating LenaTestFdMtFfMacSchedulerSuite");
62
63 bool errorModel = false;
64
65 // Test Case : AMC works in FDMT
66
67 // Note: here the MCS is calculated by the narrowband CQI
68
69 // DOWNLINK - DISTANCE 0 -> MCS 28 -> Itbs 26 (from table 7.1.7.2.1-1 of 36.213)
70 // 1 user -> 24 PRB at Itbs 26 -> 2196 -> 2196000 bytes/sec for one UE; 0 bytes/sec for other
71 // UEs 3 users -> 2196000 among 3 users -> 2196000 bytes/sec for one UE; 0 bytes/sec for other
72 // UEs 6 users -> 2196000 among 6 users -> 2196000 bytes/sec for one UE; 0 bytes/sec for other
73 // UEs 12 users -> 2196000 among 12 users -> 2196000 bytes/sec for one UE; 0 bytes/sec for other
74 // UEs UPLINK- DISTANCE 0 -> MCS 28 -> Itbs 26 (from table 7.1.7.2.1-1 of 36.213) 1 user -> 25
75 // PRB at Itbs 26 -> 2292 -> 2292000 bytes/sec 3 users -> 8 PRB at Itbs 26 -> 749 -> 749000
76 // bytes/sec 6 users -> 4 PRB at Itbs 26 -> 373 -> 373000 bytes/sec after the patch enforcing
77 // min 3 PRBs per UE: 12 users -> 3 PRB at Itbs 26 -> 277 bytes * 8/12 UE/TTI -> 184670
78 // bytes/sec
79 AddTestCase(new LenaFdMtFfMacSchedulerTestCase(1, 0, 2196000, 2292000, errorModel),
81 AddTestCase(new LenaFdMtFfMacSchedulerTestCase(3, 0, 2196000, 749000, errorModel),
83 AddTestCase(new LenaFdMtFfMacSchedulerTestCase(6, 0, 2196000, 373000, errorModel),
85 AddTestCase(new LenaFdMtFfMacSchedulerTestCase(12, 0, 2196000, 184670, errorModel),
87
88 // DOWNLINK - DISTANCE 4800 -> MCS 22 -> Itbs 20 (from table 7.1.7.2.1-1 of 36.213)
89 // 1 user -> 24 PRB at Itbs 20 -> 1383 -> 1383000 byte/secfor one UE; 0 bytes/sec for other UEs
90 // 3 users -> 1383000 among 3 users -> 1383000 bytes/sec for one UE; 0 bytes/sec for other UEs
91 // 6 users -> 1383000 among 6 users -> 1383000 bytes/sec for one UE; 0 bytes/sec for other UEs
92 // 12 users -> 1383000 among 12 users -> 1383000 bytes/sec for one UE; 0 bytes/sec for other UEs
93 // UPLINK - DISTANCE 4800 -> MCS 14 -> Itbs 13 (from table 7.1.7.2.1-1 of 36.213)
94 // 1 user -> 25 PRB at Itbs 13 -> 807 -> 807000 bytes/sec
95 // 3 users -> 8 PRB at Itbs 13 -> 253 -> 253000 bytes/sec
96 // 6 users -> 4 PRB at Itbs 13 -> 125 -> 125000 bytes/sec
97 // after the patch enforcing min 3 PRBs per UE:
98 // 12 users -> 3 PRB at Itbs 13 -> 93 bytes * 8/12 UE/TTI -> 62000 bytes/sec
99 AddTestCase(new LenaFdMtFfMacSchedulerTestCase(1, 4800, 1383000, 807000, errorModel),
101 AddTestCase(new LenaFdMtFfMacSchedulerTestCase(3, 4800, 1383000, 253000, errorModel),
103 AddTestCase(new LenaFdMtFfMacSchedulerTestCase(6, 4800, 1383000, 125000, errorModel),
105 AddTestCase(new LenaFdMtFfMacSchedulerTestCase(12, 4800, 1383000, 62000, errorModel),
107
108 // DOWNLINK - DISTANCE 6000 -> MCS 20 -> Itbs 18 (from table 7.1.7.2.1-1 of 36.213)
109 // 1 user -> 24 PRB at Itbs 18 -> 1191 -> 1191000 byte/sec for one UE; 0 bytes/sec for other UEs
110 // 3 users -> 1191000 among 3 users -> 1191000 bytes/sec for one UE; 0 bytes/sec for other UEs
111 // 6 users -> 1191000 among 6 users -> 1191000 bytes/sec for one UE; 0 bytes/sec for other UEs
112 // 12 users ->1191000 among 12 users -> 1191000 bytes/sec for one UE; 0 bytes/sec for other UEs
113 // UPLINK - DISTANCE 6000 -> MCS 12 -> Itbs 11 (from table 7.1.7.2.1-1 of 36.213)
114 // 1 user -> 25 PRB at Itbs 11 -> 621 -> 621000 bytes/sec
115 // 3 users -> 8 PRB at Itbs 11 -> 201 -> 201000 bytes/sec
116 // 6 users -> 4 PRB at Itbs 11 -> 97 -> 97000 bytes/sec
117 // after the patch enforcing min 3 PRBs per UE:
118 // 12 users -> 3 PRB at Itbs 11 -> 73 bytes * 8/12 UE/TTI -> 48667 bytes/sec
119 AddTestCase(new LenaFdMtFfMacSchedulerTestCase(1, 6000, 1191000, 621000, errorModel),
121 AddTestCase(new LenaFdMtFfMacSchedulerTestCase(3, 6000, 1191000, 201000, errorModel),
123 AddTestCase(new LenaFdMtFfMacSchedulerTestCase(6, 6000, 1191000, 97000, errorModel),
125 AddTestCase(new LenaFdMtFfMacSchedulerTestCase(12, 6000, 1191000, 48667, errorModel),
127
128 // DOWNLINK - DISTANCE 10000 -> MCS 14 -> Itbs 13 (from table 7.1.7.2.1-1 of 36.213)
129 // 1 user -> 24 PRB at Itbs 13 -> 775 -> 775000 byte/sec for one UE; 0 bytes/sec for other UEs
130 // 3 users -> 775000 among 3 users -> 775000 bytes/sec for one UE; 0 bytes/sec for other UEs
131 // 6 users -> 775000 among 6 users -> 775000 bytes/sec for one UE; 0 bytes/sec for other UEs
132 // 12 users -> 775000 among 12 users -> 775000 bytes/sec for one UE; 0 bytes/sec for other UEs
133 // UPLINK - DISTANCE 10000 -> MCS 8 -> Itbs 8 (from table 7.1.7.2.1-1 of 36.213)
134 // 1 user -> 24 PRB at Itbs 8 -> 437 -> 437000 bytes/sec
135 // 3 users -> 8 PRB at Itbs 8 -> 137 -> 137000 bytes/sec
136 // 6 users -> 4 PRB at Itbs 8 -> 67 -> 67000 bytes/sec
137 // after the patch enforcing min 3 PRBs per UE:
138 // 12 users -> 3 PRB at Itbs 8 -> 49 bytes * 8/12 UE/TTI -> 32667 bytes/sec
139 AddTestCase(new LenaFdMtFfMacSchedulerTestCase(1, 10000, 775000, 437000, errorModel),
141 AddTestCase(new LenaFdMtFfMacSchedulerTestCase(3, 10000, 775000, 137000, errorModel),
143 AddTestCase(new LenaFdMtFfMacSchedulerTestCase(6, 10000, 775000, 67000, errorModel),
145 AddTestCase(new LenaFdMtFfMacSchedulerTestCase(12, 10000, 775000, 32667, errorModel),
147
148 // DONWLINK - DISTANCE 20000 -> MCS 8 -> Itbs 8 (from table 7.1.7.2.1-1 of 36.213)
149 // 1 user -> 24 PRB at Itbs 8 -> 421 -> 421000 bytes/sec for one UE; 0 bytes/sec for other UEs
150 // 3 users -> 421000 among 3 users -> 421000 bytes/sec for one UE; 0 bytes/sec for other UEs
151 // 6 users -> 421000 among 6 users -> 421000 bytes/sec for one UE; 0 bytes/sec for other UEs
152 // 12 users -> 421000 among 12 users -> 421000 bytes/sec for one UE; 0 bytes/sec for other UEs
153 // UPLINK - DISTANCE 20000 -> MCS 2 -> Itbs 2 (from table 7.1.7.2.1-1 of 36.213)
154 // 1 user -> 25 PRB at Itbs 2 -> 233 -> 137000 bytes/sec
155 // 3 users -> 8 PRB at Itbs 2 -> 69 -> 41000 bytes/sec
156 // 6 users -> 4 PRB at Itbs 2 -> 32 -> 22000 bytes/sec
157 // after the patch enforcing min 3 PRBs per UE:
158 // 12 users -> 3 PRB at Itbs 2 -> 26 bytes * 8/12 UE/TTI -> 12000 bytes/sec
159 AddTestCase(new LenaFdMtFfMacSchedulerTestCase(1, 20000, 421000, 137000, errorModel),
161 AddTestCase(new LenaFdMtFfMacSchedulerTestCase(3, 20000, 421000, 41000, errorModel),
163 AddTestCase(new LenaFdMtFfMacSchedulerTestCase(6, 20000, 421000, 22000, errorModel),
165 AddTestCase(new LenaFdMtFfMacSchedulerTestCase(12, 20000, 421000, 12000, errorModel),
167
168 // DOWNLINK - DISTANCE 100000 -> CQI == 0 -> out of range -> 0 bytes/sec
169 // UPLINK - DISTANCE 100000 -> CQI == 0 -> out of range -> 0 bytes/sec
170 AddTestCase(new LenaFdMtFfMacSchedulerTestCase(1, 100000, 0, 0, errorModel), TestCase::QUICK);
171}
172
178
179// --------------- T E S T - C A S E ------------------------------
180
181std::string
183{
184 std::ostringstream oss;
185 oss << nUser << " UEs, distance " << dist << " m";
186 return oss.str();
187}
188
190 double dist,
191 double thrRefDl,
192 double thrRefUl,
193 bool errorModelEnabled)
194 : TestCase(BuildNameString(nUser, dist)),
195 m_nUser(nUser),
196 m_dist(dist),
197 m_thrRefDl(thrRefDl),
198 m_thrRefUl(thrRefUl),
199 m_errorModelEnabled(errorModelEnabled)
200{
201}
202
204{
205}
206
207void
209{
210 NS_LOG_FUNCTION(this << m_nUser << m_dist);
211
213 {
214 Config::SetDefault("ns3::LteSpectrumPhy::CtrlErrorModelEnabled", BooleanValue(false));
215 Config::SetDefault("ns3::LteSpectrumPhy::DataErrorModelEnabled", BooleanValue(false));
216 }
217
218 Config::SetDefault("ns3::LteHelper::UseIdealRrc", BooleanValue(true));
219 Config::SetDefault("ns3::MacStatsCalculator::DlOutputFilename",
220 StringValue(CreateTempDirFilename("DlMacStats.txt")));
221 Config::SetDefault("ns3::MacStatsCalculator::UlOutputFilename",
222 StringValue(CreateTempDirFilename("UlMacStats.txt")));
223 Config::SetDefault("ns3::RadioBearerStatsCalculator::DlRlcOutputFilename",
224 StringValue(CreateTempDirFilename("DlRlcStats.txt")));
225 Config::SetDefault("ns3::RadioBearerStatsCalculator::UlRlcOutputFilename",
226 StringValue(CreateTempDirFilename("UlRlcStats.txt")));
227
232 Ptr<LteHelper> lteHelper = CreateObject<LteHelper>();
233 lteHelper->SetAttribute("PathlossModel", StringValue("ns3::FriisSpectrumPropagationLossModel"));
234
235 // Create Nodes: eNodeB and UE
236 NodeContainer enbNodes;
237 NodeContainer ueNodes;
238 enbNodes.Create(1);
239 ueNodes.Create(m_nUser);
240
241 // Install Mobility Model
242 MobilityHelper mobility;
243 mobility.SetMobilityModel("ns3::ConstantPositionMobilityModel");
244 mobility.Install(enbNodes);
245 mobility.SetMobilityModel("ns3::ConstantPositionMobilityModel");
246 mobility.Install(ueNodes);
247
248 // Create Devices and install them in the Nodes (eNB and UE)
249 NetDeviceContainer enbDevs;
250 NetDeviceContainer ueDevs;
251 lteHelper->SetSchedulerType("ns3::FdMtFfMacScheduler");
252 lteHelper->SetSchedulerAttribute("UlCqiFilter", EnumValue(FfMacScheduler::SRS_UL_CQI));
253 enbDevs = lteHelper->InstallEnbDevice(enbNodes);
254 ueDevs = lteHelper->InstallUeDevice(ueNodes);
255
256 // Attach a UE to a eNB
257 lteHelper->Attach(ueDevs, enbDevs.Get(0));
258
259 // Activate an EPS bearer
261 EpsBearer bearer(q);
262 lteHelper->ActivateDataRadioBearer(ueDevs, bearer);
263
264 Ptr<LteEnbNetDevice> lteEnbDev = enbDevs.Get(0)->GetObject<LteEnbNetDevice>();
265 Ptr<LteEnbPhy> enbPhy = lteEnbDev->GetPhy();
266 enbPhy->SetAttribute("TxPower", DoubleValue(30.0));
267 enbPhy->SetAttribute("NoiseFigure", DoubleValue(5.0));
268
269 // Set UEs' position and power
270 for (int i = 0; i < m_nUser; i++)
271 {
274 mm->SetPosition(Vector(m_dist, 0.0, 0.0));
275 Ptr<LteUeNetDevice> lteUeDev = ueDevs.Get(i)->GetObject<LteUeNetDevice>();
276 Ptr<LteUePhy> uePhy = lteUeDev->GetPhy();
277 uePhy->SetAttribute("TxPower", DoubleValue(23.0));
278 uePhy->SetAttribute("NoiseFigure", DoubleValue(9.0));
279 }
280
281 double statsStartTime = 0.300; // need to allow for RRC connection establishment + SRS
282 double statsDuration = 0.6;
283 double tolerance = 0.1;
284 Simulator::Stop(Seconds(statsStartTime + statsDuration - 0.000001));
285
286 lteHelper->EnableMacTraces();
287 lteHelper->EnableRlcTraces();
288 Ptr<RadioBearerStatsCalculator> rlcStats = lteHelper->GetRlcStats();
289 rlcStats->SetAttribute("StartTime", TimeValue(Seconds(statsStartTime)));
290 rlcStats->SetAttribute("EpochDuration", TimeValue(Seconds(statsDuration)));
291
293
297 NS_LOG_INFO("DL - Test with " << m_nUser << " user(s) at distance " << m_dist);
298 std::vector<uint64_t> dlDataRxed;
299 for (int i = 0; i < m_nUser; i++)
300 {
301 // get the imsi
302 uint64_t imsi = ueDevs.Get(i)->GetObject<LteUeNetDevice>()->GetImsi();
303 uint8_t lcId = 3;
304 dlDataRxed.push_back(rlcStats->GetDlRxData(imsi, lcId));
305 NS_LOG_INFO("\tUser " << i << " imsi " << imsi << " bytes rxed " << (double)dlDataRxed.at(i)
306 << " thr " << (double)dlDataRxed.at(i) / statsDuration << " ref "
307 << m_thrRefDl);
308 }
309
315 uint8_t found = 0;
316 for (int i = 0; i < m_nUser; i++)
317 {
318 double throughput = (double)dlDataRxed.at(i) / statsDuration;
319 if (throughput != 0 && found == 0)
320 {
321 NS_TEST_ASSERT_MSG_EQ_TOL(throughput,
323 m_thrRefDl * tolerance,
324 " Unfair Throughput!");
325 found = 1;
326 }
327 else if (throughput != 0 && found == 1)
328 {
329 NS_TEST_ASSERT_MSG_EQ_TOL(0, m_thrRefDl, m_thrRefDl * tolerance, " Unfair Throughput!");
330 }
331 else
332 {
333 NS_TEST_ASSERT_MSG_EQ_TOL(throughput, 0, 0, " Unfair Throughput!");
334 }
335 }
336
340 NS_LOG_INFO("UL - Test with " << m_nUser << " user(s) at distance " << m_dist);
341 std::vector<uint64_t> ulDataRxed;
342 for (int i = 0; i < m_nUser; i++)
343 {
344 // get the imsi
345 uint64_t imsi = ueDevs.Get(i)->GetObject<LteUeNetDevice>()->GetImsi();
346 // get the lcId
347 uint8_t lcId = 3;
348 ulDataRxed.push_back(rlcStats->GetUlRxData(imsi, lcId));
349 NS_LOG_INFO("\tUser " << i << " imsi " << imsi << " bytes rxed " << (double)ulDataRxed.at(i)
350 << " thr " << (double)ulDataRxed.at(i) / statsDuration << " ref "
351 << m_thrRefUl);
352 }
359 for (int i = 0; i < m_nUser; i++)
360 {
361 NS_TEST_ASSERT_MSG_EQ_TOL((double)ulDataRxed.at(i) / statsDuration,
363 m_thrRefUl * tolerance,
364 " Unfair Throughput!");
365 }
367}
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.
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...
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
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
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:471
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
A suite of tests to run.
Definition: test.h:1256
AttributeValue implementation for Time.
Definition: nstime.h:1423
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 LenaTestFdMtFfMacSchedulerSuite lenaTestFdMtFfMacSchedulerSuite
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
Every class exported by the ns3 library is enclosed in the ns3 namespace.