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-harq.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 <ns3/object.h>
22
#include <ns3/spectrum-interference.h>
23
#include <ns3/spectrum-error-model.h>
24
#include <ns3/log.h>
25
#include <ns3/test.h>
26
#include <ns3/simulator.h>
27
#include <ns3/packet.h>
28
#include <ns3/ptr.h>
29
#include <iostream>
30
#include <cmath>
31
#include <ns3/radio-bearer-stats-calculator.h>
32
#include <ns3/mobility-building-info.h>
33
#include <ns3/hybrid-buildings-propagation-loss-model.h>
34
#include <ns3/eps-bearer.h>
35
#include <ns3/node-container.h>
36
#include <ns3/mobility-helper.h>
37
#include <ns3/net-device-container.h>
38
#include <ns3/lte-ue-net-device.h>
39
#include <ns3/lte-enb-net-device.h>
40
#include <ns3/lte-ue-rrc.h>
41
#include <ns3/lte-helper.h>
42
#include <ns3/string.h>
43
#include <ns3/double.h>
44
#include <ns3/lte-enb-phy.h>
45
#include <ns3/lte-ue-phy.h>
46
#include <ns3/config.h>
47
#include <ns3/boolean.h>
48
#include <ns3/enum.h>
49
#include <ns3/unused.h>
50
#include <ns3/ff-mac-scheduler.h>
51
#include <ns3/buildings-helper.h>
52
53
#include "
lte-test-harq.h
"
54
55
NS_LOG_COMPONENT_DEFINE
(
"LenaTestHarq"
);
56
57
namespace
ns3 {
58
59
60
LenaTestHarqSuite::LenaTestHarqSuite
()
61
:
TestSuite
(
"lte-harq"
, SYSTEM)
62
{
63
NS_LOG_INFO
(
"creating LenaTestHarqTestCase"
);
64
65
66
// Tests on DL/UL Data channels (PDSCH, PUSCH)
67
// MCS 0 TB size of 66 bytes SINR -9.91 dB expected throughput 31822 bytes/s
68
// TBLER 1st tx 1.0
69
// TBLER 2nd tx 0.074
70
AddTestCase
(
new
LenaHarqTestCase
(2, 2400, 66, 0.12, 31822),
TestCase::QUICK
);
71
72
// Tests on DL/UL Data channels (PDSCH, PUSCH)
73
// MCS 10 TB size of 472 bytes SINR 0.3 dB expected throughput 209964 bytes/s
74
// TBLER 1st tx 1.0
75
// TBLER 2nd tx 0.248
76
AddTestCase
(
new
LenaHarqTestCase
(1, 770, 472, 0.06, 209964),
TestCase::QUICK
);
77
78
79
80
}
81
82
static
LenaTestHarqSuite
lenaTestHarqSuite
;
83
84
std::string
85
LenaHarqTestCase::BuildNameString
(uint16_t nUser, uint16_t dist)
86
{
87
std::ostringstream oss;
88
oss << nUser <<
" UEs, distance "
<< dist <<
" m"
;
89
return
oss.str ();
90
}
91
92
LenaHarqTestCase::LenaHarqTestCase
(uint16_t nUser, uint16_t dist, uint16_t tbSize,
double
amcBer,
double
thrRef)
93
:
TestCase
(BuildNameString (nUser, dist)),
94
m_nUser (nUser),
95
m_dist (dist),
96
m_tbSize (tbSize),
97
m_amcBer (amcBer),
98
m_throughputRef (thrRef)
99
{
100
}
101
102
LenaHarqTestCase::~LenaHarqTestCase
()
103
{
104
}
105
106
void
107
LenaHarqTestCase::DoRun
(
void
)
108
{
109
110
Config::SetDefault
(
"ns3::LteAmc::Ber"
,
DoubleValue
(
m_amcBer
));
111
Config::SetDefault
(
"ns3::LteAmc::AmcModel"
,
EnumValue
(
LteAmc::PiroEW2010
));
112
Config::SetDefault
(
"ns3::LteSpectrumPhy::CtrlErrorModelEnabled"
,
BooleanValue
(
false
));
113
Config::SetDefault
(
"ns3::LteSpectrumPhy::DataErrorModelEnabled"
,
BooleanValue
(
true
));
114
Config::SetDefault
(
"ns3::LteHelper::UseIdealRrc"
,
BooleanValue
(
true
));
115
// Config::SetDefault ("ns3::RrFfMacScheduler::HarqEnabled", BooleanValue (false));
116
// LogComponentEnable ("LteEnbRrc", LOG_LEVEL_ALL);
117
// LogComponentEnable ("LteUeRrc", LOG_LEVEL_ALL);
118
// LogComponentEnable ("LteEnbMac", LOG_LEVEL_ALL);
119
// LogComponentEnable ("LteUeMac", LOG_LEVEL_ALL);
120
// LogComponentEnable ("LteRlc", LOG_LEVEL_ALL);
121
//
122
// LogComponentEnable ("LtePhy", LOG_LEVEL_ALL);
123
// LogComponentEnable ("LteEnbPhy", LOG_LEVEL_ALL);
124
// LogComponentEnable ("LteUePhy", LOG_LEVEL_ALL);
125
126
// LogComponentEnable ("LteSpectrumPhy", LOG_LEVEL_ALL);
127
// LogComponentEnable ("LteInterference", LOG_LEVEL_ALL);
128
// LogComponentEnable ("LteSinrChunkProcessor", LOG_LEVEL_ALL);
129
//
130
// LogComponentEnable ("LtePropagationLossModel", LOG_LEVEL_ALL);
131
// LogComponentEnable ("LossModel", LOG_LEVEL_ALL);
132
// LogComponentEnable ("ShadowingLossModel", LOG_LEVEL_ALL);
133
// LogComponentEnable ("PenetrationLossModel", LOG_LEVEL_ALL);
134
// LogComponentEnable ("MultipathLossModel", LOG_LEVEL_ALL);
135
// LogComponentEnable ("PathLossModel", LOG_LEVEL_ALL);
136
//
137
// LogComponentEnable ("LteNetDevice", LOG_LEVEL_ALL);
138
// LogComponentEnable ("LteUeNetDevice", LOG_LEVEL_ALL);
139
// LogComponentEnable ("LteEnbNetDevice", LOG_LEVEL_ALL);
140
141
// LogComponentEnable ("RrFfMacScheduler", LOG_LEVEL_ALL);
142
// LogComponentEnable ("LenaHelper", LOG_LEVEL_ALL);
143
// LogComponentEnable ("RlcStatsCalculator", LOG_LEVEL_ALL);
144
145
146
// LogComponentEnable ("LteSpectrumPhy", LOG_LEVEL_ALL);
147
// LogComponentEnable ("LteEnbMac", LOG_LEVEL_ALL);
148
// LogComponentEnable ("LteEnbPhy", LOG_LEVEL_ALL);
149
// LogComponentEnable ("LteUePhy", LOG_LEVEL_ALL);
150
// LogComponentEnable ("RrFfMacScheduler", LOG_LEVEL_ALL);
151
// LogComponentEnable ("LenaHelper", LOG_LEVEL_ALL);
152
// LogComponentEnable ("BuildingsPropagationLossModel", LOG_LEVEL_ALL);
153
// LogComponentEnable ("LteMiErrorModel", LOG_LEVEL_ALL);
154
// LogComponentEnable ("LteAmc", LOG_LEVEL_ALL);
155
//
156
// LogComponentDisableAll (LOG_LEVEL_ALL);
157
158
// LogComponentEnable ("LenaTestHarq", LOG_LEVEL_ALL);
159
160
165
Ptr<LteHelper>
lena = CreateObject<LteHelper> ();
166
167
// Create Nodes: eNodeB and UE
168
NodeContainer
enbNodes;
169
NodeContainer
ueNodes;
170
enbNodes.
Create
(1);
171
ueNodes.
Create
(
m_nUser
);
172
173
// Install Mobility Model
174
MobilityHelper
mobility;
175
mobility.
SetMobilityModel
(
"ns3::ConstantPositionMobilityModel"
);
176
mobility.
Install
(enbNodes);
177
BuildingsHelper::Install
(enbNodes);
178
179
mobility.
SetMobilityModel
(
"ns3::ConstantPositionMobilityModel"
);
180
mobility.
Install
(ueNodes);
181
BuildingsHelper::Install
(ueNodes);
182
183
// remove random shadowing component
184
lena->
SetAttribute
(
"PathlossModel"
,
StringValue
(
"ns3::HybridBuildingsPropagationLossModel"
));
185
lena->
SetPathlossModelAttribute
(
"ShadowSigmaOutdoor"
,
DoubleValue
(0.0));
186
lena->
SetPathlossModelAttribute
(
"ShadowSigmaIndoor"
,
DoubleValue
(0.0));
187
lena->
SetPathlossModelAttribute
(
"ShadowSigmaExtWalls"
,
DoubleValue
(0.0));
188
189
// Create Devices and install them in the Nodes (eNB and UE)
190
NetDeviceContainer
enbDevs;
191
NetDeviceContainer
ueDevs;
192
lena->
SetSchedulerType
(
"ns3::RrFfMacScheduler"
);
193
lena->
SetSchedulerAttribute
(
"UlCqiFilter"
,
EnumValue
(
FfMacScheduler::PUSCH_UL_CQI
));
194
195
enbDevs = lena->
InstallEnbDevice
(enbNodes);
196
ueDevs = lena->
InstallUeDevice
(ueNodes);
197
198
// Attach a UE to a eNB
199
lena->
Attach
(ueDevs, enbDevs.
Get
(0));
200
201
// Activate an EPS bearer
202
enum
EpsBearer::Qci
q =
EpsBearer::GBR_CONV_VOICE
;
203
EpsBearer
bearer (q);
204
lena->
ActivateDataRadioBearer
(ueDevs, bearer);
205
206
207
Ptr<LteEnbNetDevice>
lteEnbDev = enbDevs.
Get
(0)->
GetObject
<
LteEnbNetDevice
> ();
208
Ptr<LteEnbPhy>
enbPhy = lteEnbDev->
GetPhy
();
209
enbPhy->
SetAttribute
(
"TxPower"
,
DoubleValue
(43.0));
210
enbPhy->SetAttribute (
"NoiseFigure"
,
DoubleValue
(5.0));
211
// place the HeNB over the default rooftop level (20 mt.)
212
Ptr<MobilityModel>
mm = enbNodes.Get (0)->
GetObject
<
MobilityModel
> ();
213
mm->
SetPosition
(
Vector
(0.0, 0.0, 30.0));
214
215
// Set UEs' position and power
216
for
(
int
i = 0; i <
m_nUser
; i++)
217
{
218
Ptr<MobilityModel>
mm = ueNodes.
Get
(i)->
GetObject
<
MobilityModel
> ();
219
mm->
SetPosition
(
Vector
(
m_dist
, 0.0, 1.0));
220
Ptr<LteUeNetDevice>
lteUeDev = ueDevs.
Get
(i)->
GetObject
<
LteUeNetDevice
> ();
221
Ptr<LteUePhy>
uePhy = lteUeDev->GetPhy ();
222
uePhy->SetAttribute (
"TxPower"
,
DoubleValue
(23.0));
223
uePhy->SetAttribute (
"NoiseFigure"
,
DoubleValue
(9.0));
224
}
225
226
227
double
statsStartTime = 0.050;
// need to allow for RRC connection establishment + SRS
228
double
statsDuration = 2.0;
229
Simulator::Stop
(Seconds (statsStartTime + statsDuration - 0.0001));
230
231
lena->
EnableRlcTraces
();
232
Ptr<RadioBearerStatsCalculator>
rlcStats = lena->
GetRlcStats
();
233
rlcStats->
SetAttribute
(
"StartTime"
,
TimeValue
(Seconds (statsStartTime)));
234
rlcStats->
SetAttribute
(
"EpochDuration"
,
TimeValue
(Seconds (statsDuration)));
235
236
// for debugging purposes
237
lena->
EnableMacTraces
();
238
239
Simulator::Run
();
240
244
NS_LOG_INFO
(
"\tTest on downlink data shared channels (PDSCH)"
);
245
NS_LOG_INFO
(
"Test with "
<< m_nUser <<
" user(s) at distance "
<<
m_dist
<<
" expected Thr "
<<
m_throughputRef
);
246
for
(
int
i = 0; i <
m_nUser
; i++)
247
{
248
// get the imsi
249
uint64_t imsi = ueDevs.
Get
(i)->
GetObject
<
LteUeNetDevice
> ()->GetImsi ();
250
uint8_t lcId = 3;
251
double
txed = rlcStats->
GetDlTxData
(imsi, lcId);
252
double
rxed = rlcStats->
GetDlRxData
(imsi, lcId);
253
double
tolerance = 0.1;
254
255
NS_LOG_INFO
(
" User "
<< i <<
" imsi "
<< imsi <<
" bytes rxed/t "
<< rxed/statsDuration <<
" txed/t "
<< txed/statsDuration <<
" thr Ref "
<<
m_throughputRef
<<
" Err "
<< (abs (txed/statsDuration -
m_throughputRef
)) /
m_throughputRef
);
256
257
NS_TEST_ASSERT_MSG_EQ_TOL
(txed/statsDuration,
m_throughputRef
,
m_throughputRef
* tolerance,
" Unexpected Throughput!"
);
258
NS_TEST_ASSERT_MSG_EQ_TOL
(rxed/statsDuration,
m_throughputRef
,
m_throughputRef
* tolerance,
" Unexpected Throughput!"
);
259
}
260
261
262
Simulator::Destroy
();
263
}
264
265
266
}
// namespace
src
lte
test
lte-test-harq.cc
Generated on Fri Aug 30 2013 01:42:56 for ns-3 by
1.8.1.2