A Discrete-Event Network Simulator
API
lte-test-mimo.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 */
19
20#include "lte-test-mimo.h"
21
22#include "ns3/double.h"
23#include "ns3/radio-bearer-stats-calculator.h"
24#include "ns3/string.h"
25#include <ns3/boolean.h>
26#include <ns3/buildings-helper.h>
27#include <ns3/buildings-propagation-loss-model.h>
28#include <ns3/enum.h>
29#include <ns3/eps-bearer.h>
30#include <ns3/log.h>
31#include <ns3/lte-enb-net-device.h>
32#include <ns3/lte-enb-phy.h>
33#include <ns3/lte-helper.h>
34#include <ns3/lte-ue-net-device.h>
35#include <ns3/lte-ue-phy.h>
36#include <ns3/lte-ue-rrc.h>
37#include <ns3/mobility-building-info.h>
38#include <ns3/mobility-helper.h>
39#include <ns3/net-device-container.h>
40#include <ns3/node-container.h>
41#include <ns3/object.h>
42#include <ns3/packet.h>
43#include <ns3/pf-ff-mac-scheduler.h>
44#include <ns3/pointer.h>
45#include <ns3/ptr.h>
46#include <ns3/rr-ff-mac-scheduler.h>
47#include <ns3/simulator.h>
48#include <ns3/spectrum-error-model.h>
49#include <ns3/spectrum-interference.h>
50#include <ns3/test.h>
51
52#include <iostream>
53#include <sstream>
54#include <string>
55
56using namespace ns3;
57
58NS_LOG_COMPONENT_DEFINE("LteTestMimo");
59
61 : TestSuite("lte-mimo", SYSTEM)
62{
63 NS_LOG_INFO("creating LenaMimoTestCase");
64
65 // RR DOWNLINK- DISTANCE 300
66 // interval 1 : [0.1, 0.2) sec TxMode 0: MCS 20 -> TB size 1191 bytes
67 // interval 2 : [0.3, 0.4) sec TxMode 1: MCS 26 -> TB size 1836 bytes
68 // interval 3 : [0.5, 0.6) sec TxMode 2: MCS 18 -> TB size 967 bytes (x2 layers)
69 // -->
70 std::vector<uint32_t> estThrDl;
71 estThrDl.push_back(119100); // interval 1 : estimated throughput for TxMode 1
72 estThrDl.push_back(183600); // interval 2 : estimated throughput for TxMode 2
73 estThrDl.push_back(193400); // interval 3 : estimated throughput for TxMode 3
74 AddTestCase(new LenaMimoTestCase(300, estThrDl, "ns3::RrFfMacScheduler", true),
75 TestCase::QUICK);
76 AddTestCase(new LenaMimoTestCase(300, estThrDl, "ns3::PfFfMacScheduler", true),
77 TestCase::QUICK);
78 AddTestCase(new LenaMimoTestCase(300, estThrDl, "ns3::RrFfMacScheduler", false),
79 TestCase::QUICK);
80 AddTestCase(new LenaMimoTestCase(300, estThrDl, "ns3::PfFfMacScheduler", false),
81 TestCase::QUICK);
82}
83
85
86std::string
87LenaMimoTestCase::BuildNameString(uint16_t dist, std::string schedulerType, bool useIdealRrc)
88{
89 std::ostringstream oss;
90 oss << " UE distance " << dist << " m"
91 << " Scheduler " << schedulerType;
92 if (useIdealRrc)
93 {
94 oss << ", ideal RRC";
95 }
96 else
97 {
98 oss << ", real RRC";
99 }
100 return oss.str();
101}
102
104 std::vector<uint32_t> estThrDl,
105 std::string schedulerType,
106 bool useIdealRrc)
107 : TestCase(BuildNameString(dist, schedulerType, useIdealRrc)),
108 m_dist(dist),
109 m_estThrDl(estThrDl),
110 m_schedulerType(schedulerType),
111 m_useIdealRrc(useIdealRrc)
112{
113}
114
116{
117}
118
119void
121{
122 NS_LOG_FUNCTION(this << GetName());
123 Config::SetDefault("ns3::LteSpectrumPhy::DataErrorModelEnabled", BooleanValue(false));
124 Config::SetDefault("ns3::LteAmc::AmcModel", EnumValue(LteAmc::PiroEW2010));
125 Config::SetDefault("ns3::LteHelper::UseIdealRrc", BooleanValue(m_useIdealRrc));
126 Config::SetDefault("ns3::MacStatsCalculator::DlOutputFilename",
127 StringValue(CreateTempDirFilename("DlMacStats.txt")));
128 Config::SetDefault("ns3::MacStatsCalculator::UlOutputFilename",
129 StringValue(CreateTempDirFilename("UlMacStats.txt")));
130 Config::SetDefault("ns3::RadioBearerStatsCalculator::DlRlcOutputFilename",
131 StringValue(CreateTempDirFilename("DlRlcStats.txt")));
132 Config::SetDefault("ns3::RadioBearerStatsCalculator::UlRlcOutputFilename",
133 StringValue(CreateTempDirFilename("UlRlcStats.txt")));
134
135 // Disable Uplink Power Control
136 Config::SetDefault("ns3::LteUePhy::EnableUplinkPowerControl", BooleanValue(false));
137
142 Ptr<LteHelper> lteHelper = CreateObject<LteHelper>();
143 Config::SetDefault("ns3::RrFfMacScheduler::HarqEnabled", BooleanValue(false));
144 Config::SetDefault("ns3::PfFfMacScheduler::HarqEnabled", BooleanValue(false));
145
146 // lteHelper->SetSchedulerAttribute ("HarqEnabled", BooleanValue (false));
147
148 lteHelper->SetAttribute("PathlossModel",
149 StringValue("ns3::HybridBuildingsPropagationLossModel"));
150 lteHelper->SetPathlossModelAttribute("ShadowSigmaOutdoor", DoubleValue(0.0));
151 lteHelper->SetPathlossModelAttribute("ShadowSigmaIndoor", DoubleValue(0.0));
152 lteHelper->SetPathlossModelAttribute("ShadowSigmaExtWalls", DoubleValue(0.0));
153
154 // lteHelper->EnableLogComponents ();
155
156 // Create Nodes: eNodeB and UE
157 NodeContainer enbNodes;
158 NodeContainer ueNodes;
159 enbNodes.Create(1);
160 ueNodes.Create(1);
161
162 // Install Mobility Model
164 mobility.SetMobilityModel("ns3::ConstantPositionMobilityModel");
165 mobility.Install(enbNodes);
166 BuildingsHelper::Install(enbNodes);
167 mobility.SetMobilityModel("ns3::ConstantPositionMobilityModel");
168 mobility.Install(ueNodes);
169 BuildingsHelper::Install(ueNodes);
170
171 // Create Devices and install them in the Nodes (eNB and UE)
172 NetDeviceContainer enbDevs;
173 NetDeviceContainer ueDevs;
175 enbDevs = lteHelper->InstallEnbDevice(enbNodes);
176 ueDevs = lteHelper->InstallUeDevice(ueNodes);
177
178 // Attach a UE to a eNB
179 lteHelper->Attach(ueDevs, enbDevs.Get(0));
180
181 // Activate an EPS bearer
182 enum EpsBearer::Qci q = EpsBearer::GBR_CONV_VOICE;
183 EpsBearer bearer(q);
184 lteHelper->ActivateDataRadioBearer(ueDevs, bearer);
185
186 Ptr<LteEnbNetDevice> lteEnbDev = enbDevs.Get(0)->GetObject<LteEnbNetDevice>();
187 Ptr<LteEnbPhy> enbPhy = lteEnbDev->GetPhy();
188 enbPhy->SetAttribute("TxPower", DoubleValue(46.0));
189 enbPhy->SetAttribute("NoiseFigure", DoubleValue(5.0));
190 Ptr<MobilityModel> mmenb = enbNodes.Get(0)->GetObject<MobilityModel>();
191 mmenb->SetPosition(Vector(0.0, 0.0, 30.0));
192
193 // Set UE's position and power
194 Ptr<MobilityModel> mmue = ueNodes.Get(0)->GetObject<MobilityModel>();
195 mmue->SetPosition(Vector(m_dist, 0.0, 1.0));
196 Ptr<LteUeNetDevice> lteUeDev = ueDevs.Get(0)->GetObject<LteUeNetDevice>();
197 Ptr<LteUePhy> uePhy = lteUeDev->GetPhy();
198 uePhy->SetAttribute("TxPower", DoubleValue(23.0));
199 uePhy->SetAttribute("NoiseFigure", DoubleValue(9.0));
200
201 // need to allow for RRC connection establishment + SRS before enabling traces
202 lteHelper->EnableRlcTraces();
203 lteHelper->EnableMacTraces();
204 double simulationTime = 0.6;
205 double tolerance = 0.1;
206
207 uint8_t rnti = 1;
208 Ptr<LteEnbNetDevice> enbNetDev = enbDevs.Get(0)->GetObject<LteEnbNetDevice>();
209
210 PointerValue ptrval;
211 enbNetDev->GetCcMap()[0]->GetAttribute("FfMacScheduler", ptrval);
212 Ptr<PfFfMacScheduler> pfsched;
213 Ptr<RrFfMacScheduler> rrsched;
214 if (m_schedulerType == "ns3::RrFfMacScheduler")
215 {
216 rrsched = ptrval.Get<RrFfMacScheduler>();
217 if (!rrsched)
218 {
219 NS_FATAL_ERROR("No RR Scheduler available");
220 }
221 Simulator::Schedule(Seconds(0.2),
222 &RrFfMacScheduler::TransmissionModeConfigurationUpdate,
223 rrsched,
224 rnti,
225 1);
226 Simulator::Schedule(Seconds(0.4),
227 &RrFfMacScheduler::TransmissionModeConfigurationUpdate,
228 rrsched,
229 rnti,
230 2);
231 }
232 else if (m_schedulerType == "ns3::PfFfMacScheduler")
233 {
234 pfsched = ptrval.Get<PfFfMacScheduler>();
235 if (!pfsched)
236 {
237 NS_FATAL_ERROR("No Pf Scheduler available");
238 }
239
240 Simulator::Schedule(Seconds(0.2),
241 &PfFfMacScheduler::TransmissionModeConfigurationUpdate,
242 pfsched,
243 rnti,
244 1);
245 Simulator::Schedule(Seconds(0.4),
246 &PfFfMacScheduler::TransmissionModeConfigurationUpdate,
247 pfsched,
248 rnti,
249 2);
250 }
251 else
252 {
253 NS_FATAL_ERROR("Scheduler not supported by this test");
254 }
255
256 Ptr<RadioBearerStatsCalculator> rlcStats = lteHelper->GetRlcStats();
257 rlcStats->SetAttribute("EpochDuration", TimeValue(Seconds(0.1)));
258
259 NS_LOG_INFO(m_schedulerType << " MIMO test:");
260 double sampleTime = 0.199999; // at 0.2 RlcStats are reset
261 for (std::size_t j = 0; j < m_estThrDl.size(); j++)
262 {
263 NS_LOG_INFO("\t test with user at distance " << m_dist << " time " << sampleTime);
264 // get the imsi
265 uint64_t imsi = ueDevs.Get(0)->GetObject<LteUeNetDevice>()->GetImsi();
266 uint8_t lcId = 3;
267 Time t = Seconds(sampleTime);
268 Simulator::Schedule(t, &LenaMimoTestCase::GetRlcBufferSample, this, rlcStats, imsi, lcId);
269 sampleTime += 0.2;
270 }
271 Simulator::Stop(Seconds(simulationTime));
272 Simulator::Run();
273 Simulator::Destroy();
274
275 NS_LOG_INFO("Check consistency");
276 for (std::size_t i = 0; i < m_estThrDl.size(); i++)
277 {
278 NS_LOG_INFO("interval " << i + 1 << ": bytes rxed " << (double)m_dlDataRxed.at(i) << " ref "
279 << m_estThrDl.at(i));
281 m_estThrDl.at(i),
282 m_estThrDl.at(i) * tolerance,
283 " Unfair Throughput!");
284 }
285}
286
287void
289 uint64_t imsi,
290 uint8_t lcId)
291{
292 m_dlDataRxed.push_back(rlcStats->GetDlRxData(imsi, lcId));
293 NS_LOG_INFO(Simulator::Now() << "\t get bytes " << m_dlDataRxed.at(m_dlDataRxed.size() - 1));
294}
This system test program creates different test cases with a single eNB and single UE.
Definition: lte-test-mimo.h:43
void DoRun() override
Implementation to actually run this TestCase.
~LenaMimoTestCase() override
void GetRlcBufferSample(Ptr< RadioBearerStatsCalculator > rlcStats, uint64_t imsi, uint8_t rnti)
Get RLC buffer sample.
std::string m_schedulerType
the scheduler type
Definition: lte-test-mimo.h:80
LenaMimoTestCase(uint16_t dist, std::vector< uint32_t > estThrDl, std::string schedulerType, bool useIdealRrc)
Constructor.
bool m_useIdealRrc
whether to use the ideal RRC
Definition: lte-test-mimo.h:81
std::vector< uint64_t > m_dlDataRxed
DL data received.
Definition: lte-test-mimo.h:83
std::vector< uint32_t > m_estThrDl
estimated throughput DL
Definition: lte-test-mimo.h:79
uint16_t m_dist
the distance
Definition: lte-test-mimo.h:78
static std::string BuildNameString(uint16_t dist, std::string schedulerType, bool useIdealRrc)
Builds the test name string based on provided parameter values.
Lena Test Mimo Suite.
Definition: lte-test-mimo.h:94
AttributeValue implementation for Boolean.
Definition: boolean.h:37
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
The eNodeB device implementation.
std::map< uint8_t, Ptr< ComponentCarrierBaseStation > > GetCcMap() const
Ptr< LteEnbPhy > GetPhy() const
Ptr< RadioBearerStatsCalculator > GetRlcStats()
Definition: lte-helper.cc:1708
NetDeviceContainer InstallEnbDevice(NodeContainer c)
Create a set of eNodeB devices.
Definition: lte-helper.cc:482
void SetSchedulerType(std::string type)
Set the type of scheduler to be used by eNodeB devices.
Definition: lte-helper.cc:289
void Attach(NetDeviceContainer ueDevices)
Enables automatic attachment of a set of UE devices to a suitable cell using Idle mode initial cell s...
Definition: lte-helper.cc:1044
void SetPathlossModelAttribute(std::string n, const AttributeValue &v)
Set an attribute for the path loss models to be created.
Definition: lte-helper.cc:402
void EnableRlcTraces()
Enable trace sinks for RLC layer.
Definition: lte-helper.cc:1563
void ActivateDataRadioBearer(NetDeviceContainer ueDevices, EpsBearer bearer)
Activate a Data Radio Bearer on a given UE devices (for LTE-only simulation).
Definition: lte-helper.cc:1441
NetDeviceContainer InstallUeDevice(NodeContainer c)
Create a set of UE devices.
Definition: lte-helper.cc:497
void EnableMacTraces()
Enable trace sinks for MAC layer.
Definition: lte-helper.cc:1666
The LteUeNetDevice class implements the UE net device.
Helper class used to assign positions and mobility models to nodes.
Keep track of the current position and velocity of an object.
void SetPosition(const Vector &position)
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.
void SetAttribute(std::string name, const AttributeValue &value)
Set a single attribute, raising fatal errors if unsuccessful.
Definition: object-base.cc:258
Ptr< T > GetObject() const
Get a pointer to the requested aggregated Object.
Definition: object.h:471
Implements the SCHED SAP and CSCHED SAP for a Proportional Fair scheduler.
Hold objects of type Ptr<T>.
Definition: pointer.h:37
Implements the SCHED SAP and CSCHED SAP for a Round Robin scheduler.
Hold variables of type string.
Definition: string.h:42
encapsulates test code
Definition: test.h:1060
void AddTestCase(TestCase *testCase, TestDuration duration=QUICK)
Add an individual child TestCase to this test suite.
Definition: test.cc:305
std::string CreateTempDirFilename(std::string filename)
Construct the full path to a file in a temporary directory.
Definition: test.cc:442
std::string GetName() const
Definition: test.cc:377
A suite of tests to run.
Definition: test.h:1256
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:105
AttributeValue implementation for Time.
Definition: nstime.h:1425
void SetDefault(std::string name, const AttributeValue &value)
Definition: config.cc:891
#define NS_FATAL_ERROR(msg)
Report a fatal error with a message and terminate.
Definition: fatal-error.h:160
#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
Time Now()
create an ns3::Time instance which contains the current simulation time.
Definition: simulator.cc:296
#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:1338
static LenaTestMimoSuite lenaTestMimoSuite
Every class exported by the ns3 library is enclosed in the ns3 namespace.
mobility
Definition: third.py:96