A Discrete-Event Network Simulator
Home
Tutorials ▼
English
Portuguese
Docs ▼
Wiki
Manual
Models
Develop ▼
API
Bugs
API
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Properties
Friends
Macros
Groups
Pages
lte-test-mimo.cc
Go to the documentation of this file.
1
/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
2
/*
3
* Copyright (c) 2011 Centre Tecnologic de Telecomunicacions de Catalunya (CTTC)
4
*
5
* This program is free software; you can redistribute it and/or modify
6
* it under the terms of the GNU General Public License version 2 as
7
* published by the Free Software Foundation;
8
*
9
* This program is distributed in the hope that it will be useful,
10
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
* GNU General Public License for more details.
13
*
14
* You should have received a copy of the GNU General Public License
15
* along with this program; if not, write to the Free Software
16
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17
*
18
* Author: Marco Miozzo <marco.miozzo@cttc.es>
19
*/
20
21
#include <iostream>
22
#include <sstream>
23
#include <string>
24
25
#include <ns3/object.h>
26
#include <ns3/spectrum-interference.h>
27
#include <ns3/spectrum-error-model.h>
28
#include <ns3/log.h>
29
#include <ns3/test.h>
30
#include <ns3/simulator.h>
31
#include <ns3/packet.h>
32
#include <ns3/ptr.h>
33
#include <iostream>
34
#include "ns3/radio-bearer-stats-calculator.h"
35
#include <ns3/buildings-mobility-model.h>
36
#include <ns3/buildings-propagation-loss-model.h>
37
#include <ns3/eps-bearer.h>
38
#include <ns3/node-container.h>
39
#include <ns3/mobility-helper.h>
40
#include <ns3/net-device-container.h>
41
#include <ns3/lte-ue-net-device.h>
42
#include <ns3/lte-enb-net-device.h>
43
#include <ns3/lte-ue-rrc.h>
44
#include <ns3/lte-helper.h>
45
#include "ns3/string.h"
46
#include "ns3/double.h"
47
#include <ns3/lte-enb-phy.h>
48
#include <ns3/lte-ue-phy.h>
49
#include <ns3/boolean.h>
50
#include <ns3/rr-ff-mac-scheduler.h>
51
#include <ns3/pf-ff-mac-scheduler.h>
52
#include <ns3/pointer.h>
53
#include <ns3/enum.h>
54
55
#include "
lte-test-mimo.h
"
56
57
58
NS_LOG_COMPONENT_DEFINE
(
"LteTestMimo"
);
59
60
namespace
ns3 {
61
62
63
LenaTestMimoSuite::LenaTestMimoSuite
()
64
:
TestSuite
(
"lte-mimo"
, SYSTEM)
65
{
66
NS_LOG_INFO
(
"creating LenaMimoTestCase"
);
67
68
// RR DOWNLINK- DISTANCE 300
69
// interval 1 : [0.1, 0.2) sec TxMode 0: MCS 20 -> TB size 1191 bytes
70
// interval 2 : [0.3, 0.4) sec TxMode 1: MCS 26 -> TB size 1836 bytes
71
// interval 3 : [0.5, 0.6) sec TxMode 2: MCS 18 -> TB size 967 bytes (x2 layers)
72
// -->
73
std::vector<uint32_t> estThrDl;
74
estThrDl.push_back (119100);
// interval 1 : estimated throughput for TxMode 1
75
estThrDl.push_back (183600);
// interval 2 : estimated throughput for TxMode 2
76
estThrDl.push_back (193400);
// interval 3 : estimated throughput for TxMode 3
77
AddTestCase
(
new
LenaMimoTestCase
(300, estThrDl,
"ns3::RrFfMacScheduler"
,
true
),
TestCase::QUICK
);
78
AddTestCase
(
new
LenaMimoTestCase
(300, estThrDl,
"ns3::PfFfMacScheduler"
,
true
),
TestCase::QUICK
);
79
AddTestCase
(
new
LenaMimoTestCase
(300, estThrDl,
"ns3::RrFfMacScheduler"
,
false
),
TestCase::QUICK
);
80
AddTestCase
(
new
LenaMimoTestCase
(300, estThrDl,
"ns3::PfFfMacScheduler"
,
false
),
TestCase::QUICK
);
81
82
}
83
84
static
LenaTestMimoSuite
lenaTestMimoSuite
;
85
86
std::string
87
LenaMimoTestCase::BuildNameString
(uint16_t dist, std::string schedulerType,
bool
useIdealRrc)
88
{
89
std::ostringstream oss;
90
oss <<
" UE distance "
<< dist <<
" m"
<<
" Scheduler "
<< schedulerType;
91
if
(useIdealRrc)
92
{
93
oss <<
", ideal RRC"
;
94
}
95
else
96
{
97
oss <<
", real RRC"
;
98
}
99
return
oss.str ();
100
}
101
102
LenaMimoTestCase::LenaMimoTestCase
(uint16_t dist, std::vector<uint32_t> estThrDl, std::string schedulerType,
bool
useIdealRrc)
103
:
TestCase
(BuildNameString (dist, schedulerType, useIdealRrc)),
104
m_dist (dist),
105
m_estThrDl (estThrDl),
106
m_schedulerType (schedulerType),
107
m_useIdealRrc (useIdealRrc)
108
{
109
}
110
111
LenaMimoTestCase::~LenaMimoTestCase
()
112
{
113
}
114
115
void
116
LenaMimoTestCase::DoRun
(
void
)
117
{
118
NS_LOG_FUNCTION
(
this
<<
GetName
());
119
Config::SetDefault
(
"ns3::LteSpectrumPhy::DataErrorModelEnabled"
,
BooleanValue
(
false
));
120
Config::SetDefault
(
"ns3::LteAmc::AmcModel"
,
EnumValue
(
LteAmc::PiroEW2010
));
121
Config::SetDefault
(
"ns3::LteHelper::UseIdealRrc"
,
BooleanValue
(
m_useIdealRrc
));
122
128
Ptr<LteHelper>
lteHelper = CreateObject<LteHelper> ();
129
Config::SetDefault
(
"ns3::RrFfMacScheduler::HarqEnabled"
,
BooleanValue
(
false
));
130
Config::SetDefault
(
"ns3::PfFfMacScheduler::HarqEnabled"
,
BooleanValue
(
false
));
131
132
// lteHelper->SetSchedulerAttribute ("HarqEnabled", BooleanValue (false));
133
134
135
lteHelper->
SetAttribute
(
"PathlossModel"
,
StringValue
(
"ns3::HybridBuildingsPropagationLossModel"
));
136
lteHelper->
SetPathlossModelAttribute
(
"ShadowSigmaOutdoor"
,
DoubleValue
(0.0));
137
lteHelper->
SetPathlossModelAttribute
(
"ShadowSigmaIndoor"
,
DoubleValue
(0.0));
138
lteHelper->
SetPathlossModelAttribute
(
"ShadowSigmaExtWalls"
,
DoubleValue
(0.0));
139
140
// lteHelper->EnableLogComponents ();
141
142
// Create Nodes: eNodeB and UE
143
NodeContainer
enbNodes;
144
NodeContainer
ueNodes;
145
enbNodes.
Create
(1);
146
ueNodes.
Create
(1);
147
148
// Install Mobility Model
149
MobilityHelper
mobility;
150
mobility.
SetMobilityModel
(
"ns3::BuildingsMobilityModel"
);
151
mobility.
Install
(enbNodes);
152
mobility.
SetMobilityModel
(
"ns3::BuildingsMobilityModel"
);
153
mobility.
Install
(ueNodes);
154
155
// Create Devices and install them in the Nodes (eNB and UE)
156
NetDeviceContainer
enbDevs;
157
NetDeviceContainer
ueDevs;
158
lteHelper->
SetSchedulerType
(
m_schedulerType
);
159
enbDevs = lteHelper->
InstallEnbDevice
(enbNodes);
160
ueDevs = lteHelper->
InstallUeDevice
(ueNodes);
161
162
// Attach a UE to a eNB
163
lteHelper->
Attach
(ueDevs, enbDevs.
Get
(0));
164
165
// Activate an EPS bearer
166
enum
EpsBearer::Qci
q =
EpsBearer::GBR_CONV_VOICE
;
167
EpsBearer
bearer (q);
168
lteHelper->
ActivateDataRadioBearer
(ueDevs, bearer);
169
170
171
Ptr<LteEnbNetDevice>
lteEnbDev = enbDevs.
Get
(0)->
GetObject
<
LteEnbNetDevice
> ();
172
Ptr<LteEnbPhy>
enbPhy = lteEnbDev->
GetPhy
();
173
enbPhy->
SetAttribute
(
"TxPower"
,
DoubleValue
(46.0));
174
enbPhy->SetAttribute (
"NoiseFigure"
,
DoubleValue
(5.0));
175
Ptr<BuildingsMobilityModel>
mmenb = enbNodes.
Get
(0)->
GetObject
<
BuildingsMobilityModel
> ();
176
mmenb->
SetPosition
(
Vector
(0.0, 0.0, 30.0));
177
178
// Set UE's position and power
179
Ptr<BuildingsMobilityModel>
mmue = ueNodes.
Get
(0)->
GetObject
<
BuildingsMobilityModel
> ();
180
mmue->
SetPosition
(
Vector
(
m_dist
, 0.0, 1.0));
181
Ptr<LteUeNetDevice>
lteUeDev = ueDevs.
Get
(0)->
GetObject
<
LteUeNetDevice
> ();
182
Ptr<LteUePhy>
uePhy = lteUeDev->GetPhy ();
183
uePhy->SetAttribute (
"TxPower"
,
DoubleValue
(23.0));
184
uePhy->SetAttribute (
"NoiseFigure"
,
DoubleValue
(9.0));
185
186
// need to allow for RRC connection establishment + SRS before enabling traces
187
lteHelper->
EnableRlcTraces
();
188
lteHelper->
EnableMacTraces
();
189
double
simulationTime = 0.6;
190
double
tolerance = 0.1;
191
192
uint8_t rnti = 1;
193
Ptr<LteEnbNetDevice>
enbNetDev = enbDevs.
Get
(0)->
GetObject
<
LteEnbNetDevice
> ();
194
195
PointerValue
ptrval;
196
enbNetDev->
GetAttribute
(
"FfMacScheduler"
, ptrval);
197
Ptr<PfFfMacScheduler>
pfsched;
198
Ptr<RrFfMacScheduler>
rrsched;
199
if
(
m_schedulerType
.compare (
"ns3::RrFfMacScheduler"
) == 0)
200
{
201
rrsched = ptrval.Get<
RrFfMacScheduler
> ();
202
if
(rrsched == 0)
203
{
204
NS_FATAL_ERROR
(
"No RR Scheduler available"
);
205
}
206
Simulator::Schedule
(
Seconds
(0.2), &
RrFfMacScheduler::TransmissionModeConfigurationUpdate
, rrsched, rnti, 1);
207
Simulator::Schedule
(
Seconds
(0.4), &
RrFfMacScheduler::TransmissionModeConfigurationUpdate
, rrsched, rnti, 2);
208
}
209
else
if
(
m_schedulerType
.compare (
"ns3::PfFfMacScheduler"
) == 0)
210
{
211
pfsched = ptrval.Get<
PfFfMacScheduler
> ();
212
if
(pfsched == 0)
213
{
214
NS_FATAL_ERROR
(
"No Pf Scheduler available"
);
215
}
216
217
Simulator::Schedule
(
Seconds
(0.2), &
PfFfMacScheduler::TransmissionModeConfigurationUpdate
, pfsched, rnti, 1);
218
Simulator::Schedule
(
Seconds
(0.4), &
PfFfMacScheduler::TransmissionModeConfigurationUpdate
, pfsched, rnti, 2);
219
}
220
else
221
{
222
NS_FATAL_ERROR
(
"Scheduler not supported by this test"
);
223
}
224
225
226
Ptr<RadioBearerStatsCalculator>
rlcStats = lteHelper->
GetRlcStats
();
227
rlcStats->
SetAttribute
(
"EpochDuration"
,
TimeValue
(
Seconds
(0.1)));
228
229
NS_LOG_INFO
(
m_schedulerType
<<
" MIMO test:"
);
230
double
sampleTime = 0.199999;
// at 0.2 RlcStats are reset
231
for
(uint8_t j = 0; j <
m_estThrDl
.size (); j ++)
232
{
233
NS_LOG_INFO
(
"\t test with user at distance "
<<
m_dist
<<
" time "
<< sampleTime);
234
// get the imsi
235
uint64_t imsi = ueDevs.
Get
(0)->
GetObject
<
LteUeNetDevice
> ()->GetImsi ();
236
uint8_t lcId = 3;
237
Time
t =
Seconds
(sampleTime);
238
Simulator::Schedule
(t, &
LenaMimoTestCase::GetRlcBufferSample
,
this
, rlcStats, imsi, lcId);
239
sampleTime += 0.2;
240
}
241
Simulator::Stop
(
Seconds
(simulationTime));
242
Simulator::Run
();
243
Simulator::Destroy
();
244
245
NS_LOG_INFO
(
"Check consistency"
);
246
for
(uint8_t i = 0; i <
m_estThrDl
.size (); i++)
247
{
248
NS_LOG_INFO
(
"interval "
<< i + 1 <<
": bytes rxed "
<< (
double
)
m_dlDataRxed
.at (i) <<
" ref "
<<
m_estThrDl
.at (i));
249
NS_TEST_ASSERT_MSG_EQ_TOL
((
double
)
m_dlDataRxed
.at (i) ,
m_estThrDl
.at (i),
m_estThrDl
.at (i) * tolerance,
" Unfair Throughput!"
);
250
}
251
252
}
253
254
255
void
256
LenaMimoTestCase::GetRlcBufferSample
(
Ptr<RadioBearerStatsCalculator>
rlcStats, uint64_t imsi, uint8_t lcId)
257
{
258
m_dlDataRxed
.push_back (rlcStats->
GetDlRxData
(imsi, lcId));
259
NS_LOG_INFO
(
Simulator::Now
() <<
"\t get bytes "
<<
m_dlDataRxed
.at (
m_dlDataRxed
.size () - 1));
260
}
261
262
263
264
}
// namespace ns3
265
src
lte
test
lte-test-mimo.cc
Generated on Tue May 14 2013 11:08:27 for ns-3 by
1.8.1.2