A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
lte-test-tta-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("LenaTestTtaFfMacScheduler");
57
59 : TestSuite("lte-tta-ff-mac-scheduler", Type::SYSTEM)
60{
61 NS_LOG_INFO("creating LenaTestTtaFfMacSchedulerSuite");
62
63 bool errorModel = false;
64
65 // Test Case : AMC works in TTA
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 LenaTtaFfMacSchedulerTestCase(1, 0, 2196000, 2292000, errorModel),
80 TestCase::Duration::EXTENSIVE);
81 AddTestCase(new LenaTtaFfMacSchedulerTestCase(3, 0, 2196000, 749000, errorModel),
82 TestCase::Duration::QUICK);
83 AddTestCase(new LenaTtaFfMacSchedulerTestCase(6, 0, 2196000, 373000, errorModel),
84 TestCase::Duration::EXTENSIVE);
85 AddTestCase(new LenaTtaFfMacSchedulerTestCase(12, 0, 2196000, 184670, errorModel),
86 TestCase::Duration::EXTENSIVE);
87 AddTestCase(new LenaTtaFfMacSchedulerTestCase(15, 0, 2196000, 147730, errorModel),
88 TestCase::Duration::EXTENSIVE);
89
90 // DOWNLINK - DISTANCE 4800 -> MCS 22 -> Itbs 20 (from table 7.1.7.2.1-1 of 36.213)
91 // 1 user -> 24 PRB at Itbs 15 -> 1383 -> 1383000 bytes/sec for one UE; 0 bytes/sec for other
92 // UEs 3 users -> 1383000 among 3 users -> 1383000 bytes/sec for one UE; 0 bytes/sec for other
93 // UEs 6 users -> 1383000 among 6 users -> 1383000 bytes/sec for one UE; 0 bytes/sec for other
94 // UEs 12 users -> 1383000 among 12 users -> 1383000 bytes/sec for one UE; 0 bytes/sec for other
95 // UEs UPLINK - DISTANCE 4800 -> MCS 14 -> Itbs 13 (from table 7.1.7.2.1-1 of 36.213) 1 user ->
96 // 25 PRB at Itbs 13 -> 807 -> 807000 bytes/sec 3 users -> 8 PRB at Itbs 13 -> 253 -> 253000
97 // bytes/sec 6 users -> 4 PRB at Itbs 13 -> 125 -> 125000 bytes/sec after the patch enforcing
98 // min 3 PRBs per UE: 12 users -> 3 PRB at Itbs 13 -> 93 bytes * 8/12 UE/TTI -> 62000
99 // bytes/sec
100 AddTestCase(new LenaTtaFfMacSchedulerTestCase(1, 4800, 1383000, 807000, errorModel),
101 TestCase::Duration::EXTENSIVE);
102 AddTestCase(new LenaTtaFfMacSchedulerTestCase(3, 4800, 1383000, 253000, errorModel),
103 TestCase::Duration::EXTENSIVE);
104 AddTestCase(new LenaTtaFfMacSchedulerTestCase(6, 4800, 1383000, 125000, errorModel),
105 TestCase::Duration::EXTENSIVE);
106 AddTestCase(new LenaTtaFfMacSchedulerTestCase(12, 4800, 1383000, 62000, errorModel),
107 TestCase::Duration::EXTENSIVE);
108
109 // DOWNLINK - DISTANCE 6000 -> MCS 20 -> Itbs 18 (from table 7.1.7.2.1-1 of 36.213)
110 // 1 user -> 24 PRB at Itbs 15 -> 1191 -> 1191000 bytes/sec for one UE; 0 bytes/sec for other
111 // UEs 3 users -> 1191000 among 3 users -> 1191000 bytes/sec for one UE; 0 bytes/sec for other
112 // UEs 6 users -> 1191000 among 6 users -> 1191000 bytes/sec for one UE; 0 bytes/sec for other
113 // UEs 12 users ->1191000 among 12 users -> 1191000 bytes/sec for one UE; 0 bytes/sec for other
114 // UEs UPLINK - DISTANCE 6000 -> MCS 12 -> Itbs 11 (from table 7.1.7.2.1-1 of 36.213) 1 user ->
115 // 25 PRB at Itbs 11 -> 621 -> 621000 bytes/sec 3 users -> 8 PRB at Itbs 11 -> 201 -> 201000
116 // bytes/sec 6 users -> 4 PRB at Itbs 11 -> 97 -> 97000 bytes/sec after the patch enforcing min
117 // 3 PRBs per UE: 12 users -> 3 PRB at Itbs 11 -> 73 bytes * 8/12 UE/TTI -> 48667 bytes/sec
118 AddTestCase(new LenaTtaFfMacSchedulerTestCase(1, 6000, 1191000, 621000, errorModel),
119 TestCase::Duration::EXTENSIVE);
120 AddTestCase(new LenaTtaFfMacSchedulerTestCase(3, 6000, 1191000, 201000, errorModel),
121 TestCase::Duration::EXTENSIVE);
122 AddTestCase(new LenaTtaFfMacSchedulerTestCase(6, 6000, 1191000, 97000, errorModel),
123 TestCase::Duration::EXTENSIVE);
124 AddTestCase(new LenaTtaFfMacSchedulerTestCase(12, 6000, 1191000, 48667, errorModel),
125 TestCase::Duration::EXTENSIVE);
126
127 // DOWNLINK - DISTANCE 10000 -> MCS 14 -> Itbs 13 (from table 7.1.7.2.1-1 of 36.213)
128 // 1 user -> 24 PRB at Itbs 8 -> 775 -> 775000 bytes/sec for one UE; 0 bytes/sec for other UEs
129 // 3 users -> 775000 among 3 users -> 775000 bytes/sec for one UE; 0 bytes/sec for other UEs
130 // 6 users -> 775000 among 6 users -> 775000 bytes/sec for one UE; 0 bytes/sec for other UEs
131 // 12 users -> 775000 among 12 users -> 775000 bytes/sec for one UE; 0 bytes/sec for other UEs
132 // UPLINK - DISTANCE 10000 -> MCS 8 -> Itbs 8 (from table 7.1.7.2.1-1 of 36.213)
133 // 1 user -> 24 PRB at Itbs 8 -> 437 -> 437000 bytes/sec
134 // 3 users -> 8 PRB at Itbs 8 -> 137 -> 137000 bytes/sec
135 // 6 users -> 4 PRB at Itbs 8 -> 67 -> 67000 bytes/sec
136 // after the patch enforcing min 3 PRBs per UE:
137 // 12 users -> 3 PRB at Itbs 8 -> 49 bytes * 8/12 UE/TTI -> 32667 bytes/sec
138 AddTestCase(new LenaTtaFfMacSchedulerTestCase(1, 10000, 775000, 437000, errorModel),
139 TestCase::Duration::EXTENSIVE);
140 AddTestCase(new LenaTtaFfMacSchedulerTestCase(3, 10000, 775000, 137000, errorModel),
141 TestCase::Duration::EXTENSIVE);
142 AddTestCase(new LenaTtaFfMacSchedulerTestCase(6, 10000, 775000, 67000, errorModel),
143 TestCase::Duration::EXTENSIVE);
144 AddTestCase(new LenaTtaFfMacSchedulerTestCase(12, 10000, 775000, 32667, errorModel),
145 TestCase::Duration::EXTENSIVE);
146
147 // DONWLINK - DISTANCE 20000 -> MCS 8 -> Itbs 8 (from table 7.1.7.2.1-1 of 36.213)
148 // 1 user -> 24 PRB at Itbs 8 -> 421 -> 421000 bytes/sec for one UE; 0 bytes/sec for other UEs
149 // 3 users -> 421000 among 3 users -> 421000 bytes/sec for one UE; 0 bytes/sec for other UEs
150 // 6 users -> 421000 among 6 users -> 421000 bytes/sec for one UE; 0 bytes/sec for other UEs
151 // 12 users -> 421000 among 12 users -> 421000 bytes/sec for one UE; 0 bytes/sec for other UEs
152 // UPLINK - DISTANCE 20000 -> MCS 2 -> Itbs 2 (from table 7.1.7.2.1-1 of 36.213)
153 // 1 user -> 25 PRB at Itbs 2 -> 233 -> 137000 bytes/sec
154 // 3 users -> 8 PRB at Itbs 2 -> 69 -> 41000 bytes/sec
155 // 6 users -> 4 PRB at Itbs 2 -> 32 -> 22000 bytes/sec
156 // after the patch enforcing min 3 PRBs per UE:
157 // 12 users -> 3 PRB at Itbs 2 -> 26 bytes * 8/12 UE/TTI -> 12000 bytes/sec
158 AddTestCase(new LenaTtaFfMacSchedulerTestCase(1, 20000, 421000, 137000, errorModel),
159 TestCase::Duration::EXTENSIVE);
160 AddTestCase(new LenaTtaFfMacSchedulerTestCase(3, 20000, 421000, 41000, errorModel),
161 TestCase::Duration::EXTENSIVE);
162 AddTestCase(new LenaTtaFfMacSchedulerTestCase(6, 20000, 421000, 22000, errorModel),
163 TestCase::Duration::EXTENSIVE);
164 AddTestCase(new LenaTtaFfMacSchedulerTestCase(12, 20000, 421000, 12000, errorModel),
165 TestCase::Duration::EXTENSIVE);
166
167 // DOWNLINK - DISTANCE 100000 -> CQI == 0 -> out of range -> 0 bytes/sec
168 // UPLINK - DISTANCE 100000 -> CQI == 0 -> out of range -> 0 bytes/sec
169 AddTestCase(new LenaTtaFfMacSchedulerTestCase(1, 100000, 0, 0, errorModel),
170 TestCase::Duration::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
228 // Disable Uplink Power Control
229 Config::SetDefault("ns3::LteUePhy::EnableUplinkPowerControl", BooleanValue(false));
230
235 Ptr<LteHelper> lteHelper = CreateObject<LteHelper>();
236 lteHelper->SetAttribute("PathlossModel", StringValue("ns3::FriisSpectrumPropagationLossModel"));
237
238 // Create Nodes: eNodeB and UE
239 NodeContainer enbNodes;
240 NodeContainer ueNodes;
241 enbNodes.Create(1);
242 ueNodes.Create(m_nUser);
243
244 // Install Mobility Model
245 MobilityHelper mobility;
246 mobility.SetMobilityModel("ns3::ConstantPositionMobilityModel");
247 mobility.Install(enbNodes);
248 mobility.SetMobilityModel("ns3::ConstantPositionMobilityModel");
249 mobility.Install(ueNodes);
250
251 // Create Devices and install them in the Nodes (eNB and UE)
252 NetDeviceContainer enbDevs;
253 NetDeviceContainer ueDevs;
254 lteHelper->SetSchedulerType("ns3::TtaFfMacScheduler");
255 lteHelper->SetSchedulerAttribute("UlCqiFilter", EnumValue(FfMacScheduler::SRS_UL_CQI));
256 enbDevs = lteHelper->InstallEnbDevice(enbNodes);
257 ueDevs = lteHelper->InstallUeDevice(ueNodes);
258
259 // Attach a UE to a eNB
260 lteHelper->Attach(ueDevs, enbDevs.Get(0));
261
262 // Activate an EPS bearer
264 EpsBearer bearer(q);
265 lteHelper->ActivateDataRadioBearer(ueDevs, bearer);
266
267 Ptr<LteEnbNetDevice> lteEnbDev = enbDevs.Get(0)->GetObject<LteEnbNetDevice>();
268 Ptr<LteEnbPhy> enbPhy = lteEnbDev->GetPhy();
269 enbPhy->SetAttribute("TxPower", DoubleValue(30.0));
270 enbPhy->SetAttribute("NoiseFigure", DoubleValue(5.0));
271
272 // Set UEs' position and power
273 for (int i = 0; i < m_nUser; i++)
274 {
277 mm->SetPosition(Vector(m_dist, 0.0, 0.0));
278 Ptr<LteUeNetDevice> lteUeDev = ueDevs.Get(i)->GetObject<LteUeNetDevice>();
279 Ptr<LteUePhy> uePhy = lteUeDev->GetPhy();
280 uePhy->SetAttribute("TxPower", DoubleValue(23.0));
281 uePhy->SetAttribute("NoiseFigure", DoubleValue(9.0));
282 }
283
284 double statsStartTime = 0.300; // need to allow for RRC connection establishment + SRS
285 double statsDuration = 0.6;
286 double tolerance = 0.1;
287 Simulator::Stop(Seconds(statsStartTime + statsDuration - 0.000001));
288
289 lteHelper->EnableMacTraces();
290 lteHelper->EnableRlcTraces();
291 Ptr<RadioBearerStatsCalculator> rlcStats = lteHelper->GetRlcStats();
292 rlcStats->SetAttribute("StartTime", TimeValue(Seconds(statsStartTime)));
293 rlcStats->SetAttribute("EpochDuration", TimeValue(Seconds(statsDuration)));
294
296
300 NS_LOG_INFO("DL - Test with " << m_nUser << " user(s) at distance " << m_dist);
301 std::vector<uint64_t> dlDataRxed;
302 for (int i = 0; i < m_nUser; i++)
303 {
304 // get the imsi
305 uint64_t imsi = ueDevs.Get(i)->GetObject<LteUeNetDevice>()->GetImsi();
306 uint8_t lcId = 3;
307 dlDataRxed.push_back(rlcStats->GetDlRxData(imsi, lcId));
308 NS_LOG_INFO("\tUser " << i << " imsi " << imsi << " bytes rxed " << (double)dlDataRxed.at(i)
309 << " thr " << (double)dlDataRxed.at(i) / statsDuration << " ref "
310 << m_thrRefDl);
311 }
312
318 uint8_t found = 0;
319 for (int i = 0; i < m_nUser; i++)
320 {
321 double throughput = (double)dlDataRxed.at(i) / statsDuration;
322 if (throughput != 0 && found == 0)
323 {
326 m_thrRefDl * tolerance,
327 " Unfair Throughput!");
328 found = 1;
329 }
330 else if (throughput != 0 && found == 1)
331 {
332 NS_TEST_ASSERT_MSG_EQ_TOL(0, m_thrRefDl, m_thrRefDl * tolerance, " Unfair Throughput!");
333 }
334 else
335 {
336 NS_TEST_ASSERT_MSG_EQ_TOL(throughput, 0, 0, " Unfair Throughput!");
337 }
338 }
339
343 NS_LOG_INFO("UL - Test with " << m_nUser << " user(s) at distance " << m_dist);
344 std::vector<uint64_t> ulDataRxed;
345 for (int i = 0; i < m_nUser; i++)
346 {
347 // get the imsi
348 uint64_t imsi = ueDevs.Get(i)->GetObject<LteUeNetDevice>()->GetImsi();
349 // get the lcId
350 uint8_t lcId = 3;
351 ulDataRxed.push_back(rlcStats->GetUlRxData(imsi, lcId));
352 NS_LOG_INFO("\tUser " << i << " imsi " << imsi << " bytes rxed " << (double)ulDataRxed.at(i)
353 << " thr " << (double)ulDataRxed.at(i) / statsDuration << " ref "
354 << m_thrRefUl);
355 }
362 for (int i = 0; i < m_nUser; i++)
363 {
364 NS_TEST_ASSERT_MSG_EQ_TOL((double)ulDataRxed.at(i) / statsDuration,
366 m_thrRefUl * tolerance,
367 " Unfair Throughput!");
368 }
370}
Lena Test Tta Ff Mac Scheduler Suite.
This system test program creates different test cases with a single eNB and several UEs,...
double m_dist
the distance between nodes
double m_thrRefUl
the UL throughput reference
LenaTtaFfMacSchedulerTestCase(uint16_t nUser, double dist, double thrRefDl, double thrRefUl, bool errorModelEnabled)
Constructor.
bool m_errorModelEnabled
is error model enabled?
void DoRun() override
Implementation to actually run this TestCase.
static std::string BuildNameString(uint16_t nUser, double dist)
Build name string.
double m_thrRefDl
the DL throughput reference
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:62
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:522
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:77
static void Destroy()
Execute the events scheduled with ScheduleDestroy().
Definition: simulator.cc:142
static void Run()
Run the simulation.
Definition: simulator.cc:178
static void Stop()
Tell the Simulator the calling event should be the last one executed.
Definition: simulator.cc:186
Hold variables of type string.
Definition: string.h:56
encapsulates test code
Definition: test.h:1061
void AddTestCase(TestCase *testCase, Duration duration=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:1268
Type
Type of test.
Definition: test.h:1275
AttributeValue implementation for Time.
Definition: nstime.h:1413
void SetDefault(std::string name, const AttributeValue &value)
Definition: config.cc:894
#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 LenaTestTtaFfMacSchedulerSuite lenaTestTtaFfMacSchedulerSuite
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:338
Time Seconds(double value)
Construct a Time in the indicated unit.
Definition: nstime.h:1326
Every class exported by the ns3 library is enclosed in the ns3 namespace.
std::ofstream throughput