A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
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", Type::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::Duration::QUICK);
76 AddTestCase(new LenaMimoTestCase(300, estThrDl, "ns3::PfFfMacScheduler", true),
77 TestCase::Duration::QUICK);
78 AddTestCase(new LenaMimoTestCase(300, estThrDl, "ns3::RrFfMacScheduler", false),
79 TestCase::Duration::QUICK);
80 AddTestCase(new LenaMimoTestCase(300, estThrDl, "ns3::PfFfMacScheduler", false),
81 TestCase::Duration::QUICK);
82}
83
89
90std::string
91LenaMimoTestCase::BuildNameString(uint16_t dist, std::string schedulerType, bool useIdealRrc)
92{
93 std::ostringstream oss;
94 oss << " UE distance " << dist << " m"
95 << " Scheduler " << schedulerType;
96 if (useIdealRrc)
97 {
98 oss << ", ideal RRC";
99 }
100 else
101 {
102 oss << ", real RRC";
103 }
104 return oss.str();
105}
106
108 std::vector<uint32_t> estThrDl,
109 std::string schedulerType,
110 bool useIdealRrc)
111 : TestCase(BuildNameString(dist, schedulerType, useIdealRrc)),
112 m_dist(dist),
113 m_estThrDl(estThrDl),
114 m_schedulerType(schedulerType),
115 m_useIdealRrc(useIdealRrc)
116{
117}
118
120{
121}
122
123void
125{
126 NS_LOG_FUNCTION(this << GetName());
127 Config::SetDefault("ns3::LteSpectrumPhy::DataErrorModelEnabled", BooleanValue(false));
128 Config::SetDefault("ns3::LteAmc::AmcModel", EnumValue(LteAmc::PiroEW2010));
129 Config::SetDefault("ns3::LteHelper::UseIdealRrc", BooleanValue(m_useIdealRrc));
130 Config::SetDefault("ns3::MacStatsCalculator::DlOutputFilename",
131 StringValue(CreateTempDirFilename("DlMacStats.txt")));
132 Config::SetDefault("ns3::MacStatsCalculator::UlOutputFilename",
133 StringValue(CreateTempDirFilename("UlMacStats.txt")));
134 Config::SetDefault("ns3::RadioBearerStatsCalculator::DlRlcOutputFilename",
135 StringValue(CreateTempDirFilename("DlRlcStats.txt")));
136 Config::SetDefault("ns3::RadioBearerStatsCalculator::UlRlcOutputFilename",
137 StringValue(CreateTempDirFilename("UlRlcStats.txt")));
138
139 // Disable Uplink Power Control
140 Config::SetDefault("ns3::LteUePhy::EnableUplinkPowerControl", BooleanValue(false));
141
146 Ptr<LteHelper> lteHelper = CreateObject<LteHelper>();
147 Config::SetDefault("ns3::RrFfMacScheduler::HarqEnabled", BooleanValue(false));
148 Config::SetDefault("ns3::PfFfMacScheduler::HarqEnabled", BooleanValue(false));
149
150 // lteHelper->SetSchedulerAttribute ("HarqEnabled", BooleanValue (false));
151
152 lteHelper->SetAttribute("PathlossModel",
153 StringValue("ns3::HybridBuildingsPropagationLossModel"));
154 lteHelper->SetPathlossModelAttribute("ShadowSigmaOutdoor", DoubleValue(0.0));
155 lteHelper->SetPathlossModelAttribute("ShadowSigmaIndoor", DoubleValue(0.0));
156 lteHelper->SetPathlossModelAttribute("ShadowSigmaExtWalls", DoubleValue(0.0));
157
158 // lteHelper->EnableLogComponents ();
159
160 // Create Nodes: eNodeB and UE
161 NodeContainer enbNodes;
162 NodeContainer ueNodes;
163 enbNodes.Create(1);
164 ueNodes.Create(1);
165
166 // Install Mobility Model
167 MobilityHelper mobility;
168 mobility.SetMobilityModel("ns3::ConstantPositionMobilityModel");
169 mobility.Install(enbNodes);
170 BuildingsHelper::Install(enbNodes);
171 mobility.SetMobilityModel("ns3::ConstantPositionMobilityModel");
172 mobility.Install(ueNodes);
174
175 // Create Devices and install them in the Nodes (eNB and UE)
176 NetDeviceContainer enbDevs;
177 NetDeviceContainer ueDevs;
178 lteHelper->SetSchedulerType(m_schedulerType);
179 enbDevs = lteHelper->InstallEnbDevice(enbNodes);
180 ueDevs = lteHelper->InstallUeDevice(ueNodes);
181
182 // Attach a UE to a eNB
183 lteHelper->Attach(ueDevs, enbDevs.Get(0));
184
185 // Activate an EPS bearer
187 EpsBearer bearer(q);
188 lteHelper->ActivateDataRadioBearer(ueDevs, bearer);
189
190 Ptr<LteEnbNetDevice> lteEnbDev = enbDevs.Get(0)->GetObject<LteEnbNetDevice>();
191 Ptr<LteEnbPhy> enbPhy = lteEnbDev->GetPhy();
192 enbPhy->SetAttribute("TxPower", DoubleValue(46.0));
193 enbPhy->SetAttribute("NoiseFigure", DoubleValue(5.0));
194 Ptr<MobilityModel> mmenb = enbNodes.Get(0)->GetObject<MobilityModel>();
195 mmenb->SetPosition(Vector(0.0, 0.0, 30.0));
196
197 // Set UE's position and power
198 Ptr<MobilityModel> mmue = ueNodes.Get(0)->GetObject<MobilityModel>();
199 mmue->SetPosition(Vector(m_dist, 0.0, 1.0));
200 Ptr<LteUeNetDevice> lteUeDev = ueDevs.Get(0)->GetObject<LteUeNetDevice>();
201 Ptr<LteUePhy> uePhy = lteUeDev->GetPhy();
202 uePhy->SetAttribute("TxPower", DoubleValue(23.0));
203 uePhy->SetAttribute("NoiseFigure", DoubleValue(9.0));
204
205 // need to allow for RRC connection establishment + SRS before enabling traces
206 lteHelper->EnableRlcTraces();
207 lteHelper->EnableMacTraces();
208 double simulationTime = 0.6;
209 double tolerance = 0.1;
210
211 uint8_t rnti = 1;
212 Ptr<LteEnbNetDevice> enbNetDev = enbDevs.Get(0)->GetObject<LteEnbNetDevice>();
213
214 PointerValue ptrval;
215 enbNetDev->GetCcMap()[0]->GetAttribute("FfMacScheduler", ptrval);
216 Ptr<PfFfMacScheduler> pfsched;
217 Ptr<RrFfMacScheduler> rrsched;
218 if (m_schedulerType == "ns3::RrFfMacScheduler")
219 {
220 rrsched = ptrval.Get<RrFfMacScheduler>();
221 if (!rrsched)
222 {
223 NS_FATAL_ERROR("No RR Scheduler available");
224 }
227 rrsched,
228 rnti,
229 1);
232 rrsched,
233 rnti,
234 2);
235 }
236 else if (m_schedulerType == "ns3::PfFfMacScheduler")
237 {
238 pfsched = ptrval.Get<PfFfMacScheduler>();
239 if (!pfsched)
240 {
241 NS_FATAL_ERROR("No Pf Scheduler available");
242 }
243
246 pfsched,
247 rnti,
248 1);
251 pfsched,
252 rnti,
253 2);
254 }
255 else
256 {
257 NS_FATAL_ERROR("Scheduler not supported by this test");
258 }
259
260 Ptr<RadioBearerStatsCalculator> rlcStats = lteHelper->GetRlcStats();
261 rlcStats->SetAttribute("EpochDuration", TimeValue(Seconds(0.1)));
262
263 NS_LOG_INFO(m_schedulerType << " MIMO test:");
264 double sampleTime = 0.199999; // at 0.2 RlcStats are reset
265 for (std::size_t j = 0; j < m_estThrDl.size(); j++)
266 {
267 NS_LOG_INFO("\t test with user at distance " << m_dist << " time " << sampleTime);
268 // get the imsi
269 uint64_t imsi = ueDevs.Get(0)->GetObject<LteUeNetDevice>()->GetImsi();
270 uint8_t lcId = 3;
271 Time t = Seconds(sampleTime);
272 Simulator::Schedule(t, &LenaMimoTestCase::GetRlcBufferSample, this, rlcStats, imsi, lcId);
273 sampleTime += 0.2;
274 }
275 Simulator::Stop(Seconds(simulationTime));
278
279 NS_LOG_INFO("Check consistency");
280 for (std::size_t i = 0; i < m_estThrDl.size(); i++)
281 {
282 NS_LOG_INFO("interval " << i + 1 << ": bytes rxed " << (double)m_dlDataRxed.at(i) << " ref "
283 << m_estThrDl.at(i));
285 m_estThrDl.at(i),
286 m_estThrDl.at(i) * tolerance,
287 " Unfair Throughput!");
288 }
289}
290
291void
293 uint64_t imsi,
294 uint8_t lcId)
295{
296 m_dlDataRxed.push_back(rlcStats->GetDlRxData(imsi, lcId));
297 NS_LOG_INFO(Simulator::Now() << "\t get bytes " << m_dlDataRxed.at(m_dlDataRxed.size() - 1));
298}
This system test program creates different test cases with a single eNB and single UE.
Definition: lte-test-mimo.h:42
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:79
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:80
std::vector< uint64_t > m_dlDataRxed
DL data received.
Definition: lte-test-mimo.h:82
std::vector< uint32_t > m_estThrDl
estimated throughput DL
Definition: lte-test-mimo.h:78
uint16_t m_dist
the distance
Definition: lte-test-mimo.h:77
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:92
AttributeValue implementation for Boolean.
Definition: boolean.h:37
static void Install(Ptr< Node > node)
Install the MobilityBuildingInfo to a node.
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
@ PiroEW2010
Definition: lte-amc.h:63
The eNodeB device implementation.
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.
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
Implements the SCHED SAP and CSCHED SAP for a Proportional Fair scheduler.
void TransmissionModeConfigurationUpdate(uint16_t rnti, uint8_t txMode)
transmission mode configuration update
AttributeValue implementation for Pointer.
Definition: pointer.h:48
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:77
Implements the SCHED SAP and CSCHED SAP for a Round Robin scheduler.
void TransmissionModeConfigurationUpdate(uint16_t rnti, uint8_t txMode)
Transmission mode configuration update function.
static EventId Schedule(const Time &delay, FUNC f, Ts &&... args)
Schedule an event to expire after delay.
Definition: simulator.h:571
static void Destroy()
Execute the events scheduled with ScheduleDestroy().
Definition: simulator.cc:142
static Time Now()
Return the current simulation virtual time.
Definition: simulator.cc:208
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
std::string GetName() const
Definition: test.cc:373
A suite of tests to run.
Definition: test.h:1268
Type
Type of test.
Definition: test.h:1275
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:105
AttributeValue implementation for Time.
Definition: nstime.h:1413
void SetDefault(std::string name, const AttributeValue &value)
Definition: config.cc:894
#define NS_FATAL_ERROR(msg)
Report a fatal error with a message and terminate.
Definition: fatal-error.h:179
#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 LenaTestMimoSuite lenaTestMimoSuite
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.