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", 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),
81 AddTestCase(new LenaTtaFfMacSchedulerTestCase(3, 0, 2196000, 749000, errorModel),
83 AddTestCase(new LenaTtaFfMacSchedulerTestCase(6, 0, 2196000, 373000, errorModel),
85 AddTestCase(new LenaTtaFfMacSchedulerTestCase(12, 0, 2196000, 184670, errorModel),
87 AddTestCase(new LenaTtaFfMacSchedulerTestCase(15, 0, 2196000, 147730, errorModel),
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),
102 AddTestCase(new LenaTtaFfMacSchedulerTestCase(3, 4800, 1383000, 253000, errorModel),
104 AddTestCase(new LenaTtaFfMacSchedulerTestCase(6, 4800, 1383000, 125000, errorModel),
106 AddTestCase(new LenaTtaFfMacSchedulerTestCase(12, 4800, 1383000, 62000, errorModel),
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),
120 AddTestCase(new LenaTtaFfMacSchedulerTestCase(3, 6000, 1191000, 201000, errorModel),
122 AddTestCase(new LenaTtaFfMacSchedulerTestCase(6, 6000, 1191000, 97000, errorModel),
124 AddTestCase(new LenaTtaFfMacSchedulerTestCase(12, 6000, 1191000, 48667, errorModel),
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),
140 AddTestCase(new LenaTtaFfMacSchedulerTestCase(3, 10000, 775000, 137000, errorModel),
142 AddTestCase(new LenaTtaFfMacSchedulerTestCase(6, 10000, 775000, 67000, errorModel),
144 AddTestCase(new LenaTtaFfMacSchedulerTestCase(12, 10000, 775000, 32667, errorModel),
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),
160 AddTestCase(new LenaTtaFfMacSchedulerTestCase(3, 20000, 421000, 41000, errorModel),
162 AddTestCase(new LenaTtaFfMacSchedulerTestCase(6, 20000, 421000, 22000, errorModel),
164 AddTestCase(new LenaTtaFfMacSchedulerTestCase(12, 20000, 421000, 12000, errorModel),
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), TestCase::QUICK);
170}
171
177
178// --------------- T E S T - C A S E ------------------------------
179
180std::string
182{
183 std::ostringstream oss;
184 oss << nUser << " UEs, distance " << dist << " m";
185 return oss.str();
186}
187
189 double dist,
190 double thrRefDl,
191 double thrRefUl,
192 bool errorModelEnabled)
193 : TestCase(BuildNameString(nUser, dist)),
194 m_nUser(nUser),
195 m_dist(dist),
196 m_thrRefDl(thrRefDl),
197 m_thrRefUl(thrRefUl),
198 m_errorModelEnabled(errorModelEnabled)
199{
200}
201
203{
204}
205
206void
208{
209 NS_LOG_FUNCTION(this << m_nUser << m_dist);
210
212 {
213 Config::SetDefault("ns3::LteSpectrumPhy::CtrlErrorModelEnabled", BooleanValue(false));
214 Config::SetDefault("ns3::LteSpectrumPhy::DataErrorModelEnabled", BooleanValue(false));
215 }
216
217 Config::SetDefault("ns3::LteHelper::UseIdealRrc", BooleanValue(true));
218 Config::SetDefault("ns3::MacStatsCalculator::DlOutputFilename",
219 StringValue(CreateTempDirFilename("DlMacStats.txt")));
220 Config::SetDefault("ns3::MacStatsCalculator::UlOutputFilename",
221 StringValue(CreateTempDirFilename("UlMacStats.txt")));
222 Config::SetDefault("ns3::RadioBearerStatsCalculator::DlRlcOutputFilename",
223 StringValue(CreateTempDirFilename("DlRlcStats.txt")));
224 Config::SetDefault("ns3::RadioBearerStatsCalculator::UlRlcOutputFilename",
225 StringValue(CreateTempDirFilename("UlRlcStats.txt")));
226
227 // Disable Uplink Power Control
228 Config::SetDefault("ns3::LteUePhy::EnableUplinkPowerControl", BooleanValue(false));
229
234 Ptr<LteHelper> lteHelper = CreateObject<LteHelper>();
235 lteHelper->SetAttribute("PathlossModel", StringValue("ns3::FriisSpectrumPropagationLossModel"));
236
237 // Create Nodes: eNodeB and UE
238 NodeContainer enbNodes;
239 NodeContainer ueNodes;
240 enbNodes.Create(1);
241 ueNodes.Create(m_nUser);
242
243 // Install Mobility Model
244 MobilityHelper mobility;
245 mobility.SetMobilityModel("ns3::ConstantPositionMobilityModel");
246 mobility.Install(enbNodes);
247 mobility.SetMobilityModel("ns3::ConstantPositionMobilityModel");
248 mobility.Install(ueNodes);
249
250 // Create Devices and install them in the Nodes (eNB and UE)
251 NetDeviceContainer enbDevs;
252 NetDeviceContainer ueDevs;
253 lteHelper->SetSchedulerType("ns3::TtaFfMacScheduler");
254 lteHelper->SetSchedulerAttribute("UlCqiFilter", EnumValue(FfMacScheduler::SRS_UL_CQI));
255 enbDevs = lteHelper->InstallEnbDevice(enbNodes);
256 ueDevs = lteHelper->InstallUeDevice(ueNodes);
257
258 // Attach a UE to a eNB
259 lteHelper->Attach(ueDevs, enbDevs.Get(0));
260
261 // Activate an EPS bearer
263 EpsBearer bearer(q);
264 lteHelper->ActivateDataRadioBearer(ueDevs, bearer);
265
266 Ptr<LteEnbNetDevice> lteEnbDev = enbDevs.Get(0)->GetObject<LteEnbNetDevice>();
267 Ptr<LteEnbPhy> enbPhy = lteEnbDev->GetPhy();
268 enbPhy->SetAttribute("TxPower", DoubleValue(30.0));
269 enbPhy->SetAttribute("NoiseFigure", DoubleValue(5.0));
270
271 // Set UEs' position and power
272 for (int i = 0; i < m_nUser; i++)
273 {
276 mm->SetPosition(Vector(m_dist, 0.0, 0.0));
277 Ptr<LteUeNetDevice> lteUeDev = ueDevs.Get(i)->GetObject<LteUeNetDevice>();
278 Ptr<LteUePhy> uePhy = lteUeDev->GetPhy();
279 uePhy->SetAttribute("TxPower", DoubleValue(23.0));
280 uePhy->SetAttribute("NoiseFigure", DoubleValue(9.0));
281 }
282
283 double statsStartTime = 0.300; // need to allow for RRC connection establishment + SRS
284 double statsDuration = 0.6;
285 double tolerance = 0.1;
286 Simulator::Stop(Seconds(statsStartTime + statsDuration - 0.000001));
287
288 lteHelper->EnableMacTraces();
289 lteHelper->EnableRlcTraces();
290 Ptr<RadioBearerStatsCalculator> rlcStats = lteHelper->GetRlcStats();
291 rlcStats->SetAttribute("StartTime", TimeValue(Seconds(statsStartTime)));
292 rlcStats->SetAttribute("EpochDuration", TimeValue(Seconds(statsDuration)));
293
295
299 NS_LOG_INFO("DL - Test with " << m_nUser << " user(s) at distance " << m_dist);
300 std::vector<uint64_t> dlDataRxed;
301 for (int i = 0; i < m_nUser; i++)
302 {
303 // get the imsi
304 uint64_t imsi = ueDevs.Get(i)->GetObject<LteUeNetDevice>()->GetImsi();
305 uint8_t lcId = 3;
306 dlDataRxed.push_back(rlcStats->GetDlRxData(imsi, lcId));
307 NS_LOG_INFO("\tUser " << i << " imsi " << imsi << " bytes rxed " << (double)dlDataRxed.at(i)
308 << " thr " << (double)dlDataRxed.at(i) / statsDuration << " ref "
309 << m_thrRefDl);
310 }
311
317 uint8_t found = 0;
318 for (int i = 0; i < m_nUser; i++)
319 {
320 double throughput = (double)dlDataRxed.at(i) / statsDuration;
321 if (throughput != 0 && found == 0)
322 {
323 NS_TEST_ASSERT_MSG_EQ_TOL(throughput,
325 m_thrRefDl * tolerance,
326 " Unfair Throughput!");
327 found = 1;
328 }
329 else if (throughput != 0 && found == 1)
330 {
331 NS_TEST_ASSERT_MSG_EQ_TOL(0, m_thrRefDl, m_thrRefDl * tolerance, " Unfair Throughput!");
332 }
333 else
334 {
335 NS_TEST_ASSERT_MSG_EQ_TOL(throughput, 0, 0, " Unfair Throughput!");
336 }
337 }
338
342 NS_LOG_INFO("UL - Test with " << m_nUser << " user(s) at distance " << m_dist);
343 std::vector<uint64_t> ulDataRxed;
344 for (int i = 0; i < m_nUser; i++)
345 {
346 // get the imsi
347 uint64_t imsi = ueDevs.Get(i)->GetObject<LteUeNetDevice>()->GetImsi();
348 // get the lcId
349 uint8_t lcId = 3;
350 ulDataRxed.push_back(rlcStats->GetUlRxData(imsi, lcId));
351 NS_LOG_INFO("\tUser " << i << " imsi " << imsi << " bytes rxed " << (double)ulDataRxed.at(i)
352 << " thr " << (double)ulDataRxed.at(i) / statsDuration << " ref "
353 << m_thrRefUl);
354 }
361 for (int i = 0; i < m_nUser; i++)
362 {
363 NS_TEST_ASSERT_MSG_EQ_TOL((double)ulDataRxed.at(i) / statsDuration,
365 m_thrRefUl * tolerance,
366 " Unfair Throughput!");
367 }
369}
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: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 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: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.