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