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-phy-error-model.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 <ns3/radio-bearer-stats-calculator.h>
31
#include <ns3/buildings-mobility-model.h>
32
#include <ns3/hybrid-buildings-propagation-loss-model.h>
33
#include <ns3/eps-bearer.h>
34
#include <ns3/node-container.h>
35
#include <ns3/mobility-helper.h>
36
#include <ns3/net-device-container.h>
37
#include <ns3/lte-ue-net-device.h>
38
#include <ns3/lte-enb-net-device.h>
39
#include <ns3/lte-ue-rrc.h>
40
#include <ns3/lte-helper.h>
41
#include <ns3/string.h>
42
#include <ns3/double.h>
43
#include <ns3/lte-enb-phy.h>
44
#include <ns3/lte-ue-phy.h>
45
#include <ns3/config.h>
46
#include <ns3/boolean.h>
47
#include <ns3/enum.h>
48
#include <ns3/unused.h>
49
50
#include "
lte-test-phy-error-model.h
"
51
52
NS_LOG_COMPONENT_DEFINE
(
"LenaTestPhyErrorModel"
);
53
54
namespace
ns3 {
55
56
57
LenaTestPhyErrorModelrSuite::LenaTestPhyErrorModelrSuite
()
58
:
TestSuite
(
"lte-phy-error-model"
, SYSTEM)
59
{
60
NS_LOG_INFO
(
"creating LenaTestPhyErrorModelTestCase"
);
61
62
// MCS 2 TB size of 256 bits BER 0.33 SINR -5.51
63
AddTestCase
(
new
LenaPhyErrorModelTestCase
(4, 1800, 32, 0.35, 50));
64
// MCS 2 TB size of 528 bits BER 0.11 SINR -5.51
65
AddTestCase
(
new
LenaPhyErrorModelTestCase
(2, 1800, 66, 0.11, 34));
66
// MCS 2 TB size of 1088 bits BER 0.02 SINR -5.51
67
AddTestCase
(
new
LenaPhyErrorModelTestCase
(1, 1800, 136, 0.02, 16));
68
// MCS 12 TB size of 4800 bits BER 0.3 SINR 4.43
69
AddTestCase
(
new
LenaPhyErrorModelTestCase
(1, 600, 600, 0.3, 48));
70
// MCS 12 TB size of 1632 bits BER 0.55 SINR 4.43
71
AddTestCase
(
new
LenaPhyErrorModelTestCase
(3, 600, 204, 0.55, 52));
72
// MCS 16 TB size of 7272 bits (3648 x 3584) BER 0.14 SINR 8.48
73
// BER 0.14 = 1 - ((1-0.075)*(1-0.075))
74
AddTestCase
(
new
LenaPhyErrorModelTestCase
(1, 470, 781, 0.14, 29));
75
76
77
78
}
79
80
static
LenaTestPhyErrorModelrSuite
lenaTestPhyErrorModelrSuite
;
81
82
std::string
83
LenaPhyErrorModelTestCase::BuildNameString
(uint16_t nUser, uint16_t dist)
84
{
85
std::ostringstream oss;
86
oss << nUser <<
" UEs, distance "
<< dist <<
" m"
;
87
return
oss.str ();
88
}
89
90
LenaPhyErrorModelTestCase::LenaPhyErrorModelTestCase
(uint16_t nUser, uint16_t dist, uint16_t tbSize,
double
berRef, uint16_t bernQuantile)
91
:
TestCase
(BuildNameString (nUser, dist)),
92
m_nUser (nUser),
93
m_dist (dist),
94
m_tbSize (tbSize),
95
m_berRef (berRef),
96
m_bernQuantile (bernQuantile)
97
{
98
}
99
100
LenaPhyErrorModelTestCase::~LenaPhyErrorModelTestCase
()
101
{
102
}
103
104
void
105
LenaPhyErrorModelTestCase::DoRun
(
void
)
106
{
107
108
double
ber = 0.03;
109
Config::SetDefault
(
"ns3::LteAmc::Ber"
,
DoubleValue
(ber));
110
Config::SetDefault
(
"ns3::LteAmc::AmcModel"
,
EnumValue
(
LteAmc::PiroEW2010
));
111
Config::SetDefault
(
"ns3::LteSpectrumPhy::PemEnabled"
,
BooleanValue
(
true
));
112
113
// LogComponentEnable ("LteEnbRrc", LOG_LEVEL_ALL);
114
// LogComponentEnable ("LteUeRrc", LOG_LEVEL_ALL);
115
// LogComponentEnable ("LteEnbMac", LOG_LEVEL_ALL);
116
// LogComponentEnable ("LteUeMac", LOG_LEVEL_ALL);
117
// LogComponentEnable ("LteRlc", LOG_LEVEL_ALL);
118
//
119
// LogComponentEnable ("LtePhy", LOG_LEVEL_ALL);
120
// LogComponentEnable ("LteEnbPhy", LOG_LEVEL_ALL);
121
// LogComponentEnable ("LteUePhy", LOG_LEVEL_ALL);
122
123
// LogComponentEnable ("LteSpectrumPhy", LOG_LEVEL_ALL);
124
// LogComponentEnable ("LteInterference", LOG_LEVEL_ALL);
125
// LogComponentEnable ("LteSinrChunkProcessor", LOG_LEVEL_ALL);
126
//
127
// LogComponentEnable ("LtePropagationLossModel", LOG_LEVEL_ALL);
128
// LogComponentEnable ("LossModel", LOG_LEVEL_ALL);
129
// LogComponentEnable ("ShadowingLossModel", LOG_LEVEL_ALL);
130
// LogComponentEnable ("PenetrationLossModel", LOG_LEVEL_ALL);
131
// LogComponentEnable ("MultipathLossModel", LOG_LEVEL_ALL);
132
// LogComponentEnable ("PathLossModel", LOG_LEVEL_ALL);
133
//
134
// LogComponentEnable ("LteNetDevice", LOG_LEVEL_ALL);
135
// LogComponentEnable ("LteUeNetDevice", LOG_LEVEL_ALL);
136
// LogComponentEnable ("LteEnbNetDevice", LOG_LEVEL_ALL);
137
138
// LogComponentEnable ("RrFfMacScheduler", LOG_LEVEL_ALL);
139
// LogComponentEnable ("LenaHelper", LOG_LEVEL_ALL);
140
// LogComponentEnable ("RlcStatsCalculator", LOG_LEVEL_ALL);
141
142
143
// LogComponentEnable ("LteSpectrumPhy", LOG_LEVEL_ALL);
144
// LogComponentEnable ("LteEnbMac", LOG_LEVEL_ALL);
145
// LogComponentEnable ("LteEnbPhy", LOG_LEVEL_ALL);
146
// LogComponentEnable ("LteUePhy", LOG_LEVEL_ALL);
147
// LogComponentEnable ("RrFfMacScheduler", LOG_LEVEL_ALL);
148
// LogComponentEnable ("LenaHelper", LOG_LEVEL_ALL);
149
// LogComponentEnable ("BuildingsPropagationLossModel", LOG_LEVEL_ALL);
150
// LogComponentEnable ("LteMiErrorModel", LOG_LEVEL_ALL);
151
// LogComponentEnable ("LteAmc", LOG_LEVEL_ALL);
152
//
153
LogComponentDisableAll
(
LOG_LEVEL_ALL
);
154
155
LogComponentEnable
(
"LenaTestPhyErrorModel"
,
LOG_LEVEL_ALL
);
156
157
162
Ptr<LteHelper>
lena = CreateObject<LteHelper> ();
163
164
// Create Nodes: eNodeB and UE
165
NodeContainer
enbNodes;
166
NodeContainer
ueNodes;
167
enbNodes.
Create
(1);
168
ueNodes.
Create
(
m_nUser
);
169
170
// Install Mobility Model
171
MobilityHelper
mobility;
172
mobility.
SetMobilityModel
(
"ns3::BuildingsMobilityModel"
);
173
mobility.
Install
(enbNodes);
174
mobility.
SetMobilityModel
(
"ns3::BuildingsMobilityModel"
);
175
mobility.
Install
(ueNodes);
176
177
// remove random shadowing component
178
lena->
SetAttribute
(
"PathlossModel"
,
StringValue
(
"ns3::HybridBuildingsPropagationLossModel"
));
179
lena->
SetPathlossModelAttribute
(
"ShadowSigmaOutdoor"
,
DoubleValue
(0.0));
180
lena->
SetPathlossModelAttribute
(
"ShadowSigmaIndoor"
,
DoubleValue
(0.0));
181
lena->
SetPathlossModelAttribute
(
"ShadowSigmaExtWalls"
,
DoubleValue
(0.0));
182
183
// Create Devices and install them in the Nodes (eNB and UE)
184
NetDeviceContainer
enbDevs;
185
NetDeviceContainer
ueDevs;
186
lena->
SetSchedulerType
(
"ns3::RrFfMacScheduler"
);
187
188
enbDevs = lena->
InstallEnbDevice
(enbNodes);
189
ueDevs = lena->
InstallUeDevice
(ueNodes);
190
191
// Attach a UE to a eNB
192
lena->
Attach
(ueDevs, enbDevs.
Get
(0));
193
194
// Activate an EPS bearer
195
enum
EpsBearer::Qci
q =
EpsBearer::GBR_CONV_VOICE
;
196
EpsBearer
bearer (q);
197
lena->
ActivateEpsBearer
(ueDevs, bearer,
EpcTft::Default
());
198
199
200
Ptr<LteEnbNetDevice>
lteEnbDev = enbDevs.
Get
(0)->
GetObject
<
LteEnbNetDevice
> ();
201
Ptr<LteEnbPhy>
enbPhy = lteEnbDev->
GetPhy
();
202
enbPhy->
SetAttribute
(
"TxPower"
,
DoubleValue
(43.0));
203
enbPhy->SetAttribute (
"NoiseFigure"
,
DoubleValue
(5.0));
204
// place the HeNB over the default rooftop level (20 mt.)
205
Ptr<BuildingsMobilityModel>
mm = enbNodes.Get (0)->
GetObject
<
BuildingsMobilityModel
> ();
206
mm->
SetPosition
(
Vector
(0.0, 0.0, 30.0));
207
208
// Set UEs' position and power
209
for
(
int
i = 0; i <
m_nUser
; i++)
210
{
211
Ptr<BuildingsMobilityModel>
mm = ueNodes.
Get
(i)->
GetObject
<
BuildingsMobilityModel
> ();
212
mm->
SetPosition
(
Vector
(
m_dist
, 0.0, 1.0));
213
Ptr<LteUeNetDevice>
lteUeDev = ueDevs.
Get
(i)->
GetObject
<
LteUeNetDevice
> ();
214
Ptr<LteUePhy>
uePhy = lteUeDev->GetPhy ();
215
uePhy->SetAttribute (
"TxPower"
,
DoubleValue
(23.0));
216
uePhy->SetAttribute (
"NoiseFigure"
,
DoubleValue
(9.0));
217
}
218
219
lena->
EnableRlcTraces
();
220
double
simulationTime = 1.000;
221
Simulator::Stop
(
Seconds
(simulationTime));
222
223
Ptr<RadioBearerStatsCalculator>
rlcStats = lena->
GetRlcStats
();
224
rlcStats->
SetAttribute
(
"EpochDuration"
,
TimeValue
(
Seconds
(simulationTime)));
225
226
227
Simulator::Run
();
228
232
NS_LOG_INFO
(
"Test with "
<< m_nUser <<
" user(s) at distance "
<<
m_dist
<<
" expected BER "
<<
m_berRef
);
233
std::vector <uint64_t> dlDataRxed;
234
for
(
int
i = 0; i <
m_nUser
; i++)
235
{
236
// get the imsi
237
uint64_t imsi = ueDevs.
Get
(i)->
GetObject
<
LteUeNetDevice
> ()->GetImsi ();
238
// get the lcId
239
uint8_t lcId = ueDevs.
Get
(i)->
GetObject
<
LteUeNetDevice
> ()->GetRrc ()->GetLcIdVector ().at (0);
240
dlDataRxed.push_back (rlcStats->
GetDlRxData
(imsi, lcId));
241
double
txed = rlcStats->
GetDlTxData
(imsi, lcId);
242
int
n = txed /
m_tbSize
;
243
int
lambda = (double)dlDataRxed.at (i) /
m_tbSize
;
244
double
ber = 1.0 - ((double)dlDataRxed.at (i)/txed);
245
double
np = n-n*
m_berRef
;
246
NS_LOG_INFO
(
"\tUser "
<< i <<
" imsi "
<< imsi <<
" bytes rxed "
<< (
double
)dlDataRxed.at (i) <<
" txed "
<< txed
247
<<
" BER "
<< ber <<
" Err "
<< fabs (m_berRef - ber) <<
" lambda "
<< lambda
248
<<
" np "
<< np <<
" difference "
<< abs(lambda - np) <<
" quantile "
<<
m_bernQuantile
);
249
NS_UNUSED
(ber);
250
// the quantiles are evaluated offline according to a Bernoulli
251
// ditribution with n equal to the number of packet sent and p equal
252
// to the BER (see /reference/bernuolliDistribution.m for details)
253
NS_TEST_ASSERT_MSG_EQ_TOL
(lambda, np,
m_bernQuantile
,
" Unexpected BER distribution!"
);
254
}
255
256
257
Simulator::Destroy
();
258
}
259
260
}
// namespace ns3
261
262
src
lte
test
lte-test-phy-error-model.cc
Generated on Tue Oct 9 2012 16:45:41 for ns-3 by
1.8.1.2