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-stats-calculator.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: Jaume Nin <jnin@cttc.es>
19
*/
20
21
#include "
lte-stats-calculator.h
"
22
23
#include <ns3/log.h>
24
#include <ns3/config.h>
25
#include <ns3/lte-enb-rrc.h>
26
#include <ns3/lte-ue-rrc.h>
27
#include <ns3/lte-enb-net-device.h>
28
#include <ns3/lte-ue-net-device.h>
29
30
namespace
ns3 {
31
32
NS_LOG_COMPONENT_DEFINE
(
"LteStatsCalculator"
);
33
34
LteStatsCalculator::LteStatsCalculator
()
35
: m_dlOutputFilename (
""
),
36
m_ulOutputFilename (
""
)
37
{
38
// Nothing to do here
39
40
}
41
42
LteStatsCalculator::~LteStatsCalculator
()
43
{
44
// Nothing to do here
45
}
46
47
48
TypeId
49
LteStatsCalculator::GetTypeId
(
void
)
50
{
51
static
TypeId
tid =
TypeId
(
"ns3::LteStatsCalculator"
)
52
.
SetParent
<
Object
> ()
53
.AddConstructor<LteStatsCalculator> ()
54
;
55
return
tid;
56
}
57
58
59
void
60
LteStatsCalculator::SetUlOutputFilename
(std::string outputFilename)
61
{
62
m_ulOutputFilename
= outputFilename;
63
}
64
65
std::string
66
LteStatsCalculator::GetUlOutputFilename
(
void
)
67
{
68
return
m_ulOutputFilename
;
69
}
70
71
void
72
LteStatsCalculator::SetDlOutputFilename
(std::string outputFilename)
73
{
74
m_dlOutputFilename
= outputFilename;
75
}
76
77
std::string
78
LteStatsCalculator::GetDlOutputFilename
(
void
)
79
{
80
return
m_dlOutputFilename
;
81
}
82
83
84
bool
85
LteStatsCalculator::ExistsImsiPath
(std::string path)
86
{
87
if
(
m_pathImsiMap
.find (path) ==
m_pathImsiMap
.end () )
88
{
89
return
false
;
90
}
91
else
92
{
93
return
true
;
94
}
95
}
96
97
void
98
LteStatsCalculator::SetImsiPath
(std::string path, uint64_t imsi)
99
{
100
NS_LOG_FUNCTION
(
this
<< path << imsi);
101
m_pathImsiMap
[path] = imsi;
102
}
103
104
uint64_t
105
LteStatsCalculator::GetImsiPath
(std::string path)
106
{
107
return
m_pathImsiMap
.find (path)->second;
108
}
109
110
bool
111
LteStatsCalculator::ExistsCellIdPath
(std::string path)
112
{
113
if
(
m_pathCellIdMap
.find (path) ==
m_pathCellIdMap
.end () )
114
{
115
return
false
;
116
}
117
else
118
{
119
return
true
;
120
}
121
}
122
123
void
124
LteStatsCalculator::SetCellIdPath
(std::string path, uint16_t cellId)
125
{
126
NS_LOG_FUNCTION
(
this
<< path << cellId);
127
m_pathCellIdMap
[path] = cellId;
128
}
129
130
uint16_t
131
LteStatsCalculator::GetCellIdPath
(std::string path)
132
{
133
return
m_pathCellIdMap
.find (path)->second;
134
}
135
136
137
uint64_t
138
LteStatsCalculator::FindImsiFromEnbRlcPath
(std::string path)
139
{
140
NS_LOG_FUNCTION
(path);
141
// Sample path input:
142
// /NodeList/#NodeId/DeviceList/#DeviceId/LteEnbRrc/UeMap/#C-RNTI/DataRadioBearerMap/#LCID/LteRlc/RxPDU
143
144
// We retrieve the UeManager associated to the C-RNTI and perform the IMSI lookup
145
std::string ueMapPath = path.substr (0, path.find (
"/DataRadioBearerMap"
));
146
Config::MatchContainer
match =
Config::LookupMatches
(ueMapPath);
147
148
if
(match.
GetN
() != 0)
149
{
150
Ptr<Object>
ueInfo = match.
Get
(0);
151
NS_LOG_LOGIC
(
"FindImsiFromEnbRlcPath: "
<< path <<
", "
<< ueInfo->
GetObject
<
UeManager
> ()->
GetImsi
());
152
return
ueInfo->
GetObject
<
UeManager
> ()->GetImsi ();
153
}
154
else
155
{
156
NS_FATAL_ERROR
(
"Lookup "
<< ueMapPath <<
" got no matches"
);
157
}
158
}
159
160
uint64_t
161
LteStatsCalculator::FindImsiFromUePhy
(std::string path)
162
{
163
NS_LOG_FUNCTION
(path);
164
// Sample path input:
165
// /NodeList/#NodeId/DeviceList/#DeviceId/LteUePhy
166
167
// We retrieve the UeInfo associated to the C-RNTI and perform the IMSI lookup
168
std::string ueRlcPath = path.substr (0, path.find (
"/LteUePhy"
));
169
ueRlcPath +=
"/LteUeRrc"
;
170
Config::MatchContainer
match =
Config::LookupMatches
(ueRlcPath);
171
172
if
(match.
GetN
() != 0)
173
{
174
Ptr<Object>
ueRrc = match.
Get
(0);
175
return
ueRrc->
GetObject
<
LteUeRrc
> ()->GetImsi ();
176
}
177
else
178
{
179
NS_FATAL_ERROR
(
"Lookup "
<< ueRlcPath <<
" got no matches"
);
180
}
181
return
0;
182
}
183
184
185
uint64_t
186
LteStatsCalculator::FindImsiFromLteNetDevice
(std::string path)
187
{
188
NS_LOG_FUNCTION
(path);
189
// Sample path input:
190
// /NodeList/#NodeId/DeviceList/#DeviceId/
191
192
// We retrieve the Imsi associated to the LteUeNetDevice
193
Config::MatchContainer
match =
Config::LookupMatches
(path);
194
195
if
(match.
GetN
() != 0)
196
{
197
Ptr<Object>
ueNetDevice = match.
Get
(0);
198
NS_LOG_LOGIC
(
"FindImsiFromLteNetDevice: "
<< path <<
", "
<< ueNetDevice->
GetObject
<
LteUeNetDevice
> ()->
GetImsi
());
199
return
ueNetDevice->
GetObject
<
LteUeNetDevice
> ()->GetImsi ();
200
}
201
else
202
{
203
NS_FATAL_ERROR
(
"Lookup "
<< path <<
" got no matches"
);
204
}
205
}
206
207
uint16_t
208
LteStatsCalculator::FindCellIdFromEnbRlcPath
(std::string path)
209
{
210
NS_LOG_FUNCTION
(path);
211
// Sample path input:
212
// /NodeList/#NodeId/DeviceList/#DeviceId/LteEnbRrc/UeMap/#C-RNTI/DataRadioBearerMap/#LCID/LteRlc/RxPDU
213
214
// We retrieve the CellId associated to the Enb
215
std::string enbNetDevicePath = path.substr (0, path.find (
"/LteEnbRrc"
));
216
Config::MatchContainer
match =
Config::LookupMatches
(enbNetDevicePath);
217
if
(match.
GetN
() != 0)
218
{
219
Ptr<Object>
enbNetDevice = match.
Get
(0);
220
NS_LOG_LOGIC
(
"FindCellIdFromEnbRlcPath: "
<< path <<
", "
<< enbNetDevice->
GetObject
<
LteEnbNetDevice
> ()->
GetCellId
());
221
return
enbNetDevice->
GetObject
<
LteEnbNetDevice
> ()->GetCellId ();
222
}
223
else
224
{
225
NS_FATAL_ERROR
(
"Lookup "
<< enbNetDevicePath <<
" got no matches"
);
226
}
227
}
228
229
uint64_t
230
LteStatsCalculator::FindImsiFromEnbMac
(std::string path, uint16_t rnti)
231
{
232
NS_LOG_FUNCTION
(path << rnti);
233
234
// /NodeList/#NodeId/DeviceList/#DeviceId/LteEnbMac/DlScheduling
235
std::ostringstream oss;
236
std::string p = path.substr (0, path.find (
"/LteEnbMac"
));
237
oss << rnti;
238
p +=
"/LteEnbRrc/UeMap/"
+ oss.str ();
239
uint64_t imsi =
FindImsiFromEnbRlcPath
(p);
240
NS_LOG_LOGIC
(
"FindImsiFromEnbMac: "
<< path <<
", "
<< rnti <<
", "
<< imsi);
241
return
imsi;
242
}
243
244
uint16_t
245
LteStatsCalculator::FindCellIdFromEnbMac
(std::string path, uint16_t rnti)
246
{
247
NS_LOG_FUNCTION
(path << rnti);
248
// /NodeList/#NodeId/DeviceList/#DeviceId/LteEnbMac/DlScheduling
249
std::ostringstream oss;
250
std::string p = path.substr (0, path.find (
"/LteEnbMac"
));
251
oss << rnti;
252
p +=
"/LteEnbRrc/UeMap/"
+ oss.str ();
253
uint16_t cellId =
FindCellIdFromEnbRlcPath
(p);
254
NS_LOG_LOGIC
(
"FindCellIdFromEnbMac: "
<< path <<
", "
<< rnti <<
", "
<< cellId);
255
return
cellId;
256
}
257
258
259
uint64_t
260
LteStatsCalculator::FindImsiForEnb
(std::string path, uint16_t rnti)
261
{
262
NS_LOG_FUNCTION
(path << rnti);
263
uint64_t imsi = 0;
264
if
(path.find (
"/DlPhyTransmission"
))
265
{
266
// /NodeList/0/DeviceList/0/LteEnbPhy/DlPhyTransmission/LteEnbRrc/UeMap/1
267
std::ostringstream oss;
268
std::string p = path.substr (0, path.find (
"/LteEnbPhy"
));
269
oss << rnti;
270
p +=
"/LteEnbRrc/UeMap/"
+ oss.str ();
271
imsi =
FindImsiFromEnbRlcPath
(p);
272
NS_LOG_LOGIC
(
"FindImsiForEnb[Tx]: "
<< path <<
", "
<< rnti <<
", "
<< imsi);
273
}
274
else
if
(path.find (
"/UlPhyReception"
))
275
{
276
std::string p = path.substr (0, path.find (
"/LteUePhy"
));
277
imsi =
FindImsiFromLteNetDevice
(p);
278
NS_LOG_LOGIC
(
"FindImsiForEnb[Rx]: "
<< path <<
", "
<< rnti <<
", "
<< imsi);
279
}
280
return
imsi;
281
}
282
283
284
uint64_t
285
LteStatsCalculator::FindImsiForUe
(std::string path, uint16_t rnti)
286
{
287
NS_LOG_FUNCTION
(path << rnti);
288
uint64_t imsi = 0;
289
if
(path.find (
"/UlPhyTransmission"
))
290
{
291
std::string p = path.substr (0, path.find (
"/LteUePhy"
));
292
imsi =
FindImsiFromLteNetDevice
(p);
293
NS_LOG_LOGIC
(
"FindImsiForUe[Tx]: "
<< path <<
", "
<< rnti <<
", "
<< imsi);
294
}
295
else
if
(path.find (
"/DlPhyReception"
))
296
{
297
// /NodeList/0/DeviceList/0/LteEnbPhy/LteSpectrumPhy
298
std::ostringstream oss;
299
std::string p = path.substr (0, path.find (
"/LteEnbPhy"
));
300
oss << rnti;
301
p +=
"/LteEnbRrc/UeMap/"
+ oss.str ();
302
imsi =
FindImsiFromEnbRlcPath
(p);
303
NS_LOG_LOGIC
(
"FindImsiForUe[Rx]: "
<< path <<
", "
<< rnti <<
", "
<< imsi);
304
}
305
return
imsi;
306
}
307
308
309
}
// namespace ns3
src
lte
helper
lte-stats-calculator.cc
Generated on Fri Aug 30 2013 01:42:53 for ns-3 by
1.8.1.2