-
Notifications
You must be signed in to change notification settings - Fork 0
/
radio-bearer-stats-calculator.h
454 lines (396 loc) · 13.2 KB
/
radio-bearer-stats-calculator.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
/*
* Copyright (c) 2011 Centre Tecnologic de Telecomunicacions de Catalunya (CTTC)
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation;
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* Author: Jaume Nin <jnin@cttc.es>
* Nicola Baldo <nbaldo@cttc.es>
*/
#ifndef RADIO_BEARER_STATS_CALCULATOR_H_
#define RADIO_BEARER_STATS_CALCULATOR_H_
#include "ns3/lte-stats-calculator.h"
#include "ns3/lte-common.h"
#include "ns3/uinteger.h"
#include "ns3/object.h"
#include "ns3/basic-data-calculators.h"
#include "ns3/lte-common.h"
#include <string>
#include <map>
#include <fstream>
namespace ns3
{
/// Container: (IMSI, LCID) pair, uint32_t
typedef std::map<ImsiLcidPair_t, uint32_t> Uint32Map;
/// Container: (IMSI, LCID) pair, uint64_t
typedef std::map<ImsiLcidPair_t, uint64_t> Uint64Map;
/// Container: (IMSI, LCID) pair, uint32_t calculator
typedef std::map<ImsiLcidPair_t, Ptr<MinMaxAvgTotalCalculator<uint32_t> > > Uint32StatsMap;
/// Container: (IMSI, LCID) pair, uint64_t calculator
typedef std::map<ImsiLcidPair_t, Ptr<MinMaxAvgTotalCalculator<uint64_t> > > Uint64StatsMap;
/// Container: (IMSI, LCID) pair, double
typedef std::map<ImsiLcidPair_t, double> DoubleMap;
/// Container: (IMSI, LCID) pair, LteFlowId_t
typedef std::map<ImsiLcidPair_t, LteFlowId_t> FlowIdMap;
/**
* \ingroup lte
*
* This class is an ns-3 trace sink that performs the calculation of
* PDU statistics for uplink and downlink. Statistics are generated
* on a per radio bearer basis. This class can be used for
* RLC PDU stats or PDCP PDU stats by connecting to the appropriate
* trace sources at the RLC or PDCP layer.
*
* The statistics are calculated at consecutive time windows and
* periodically written to a file. The calculated statistics are:
*
* - Number of transmitted PDUs
* - Number of received PDUs
* - Number of transmitted bytes
* - Number of received bytes
* - Average, min, max and standard deviation of PDU delay (delay is
* calculated from the generation of the PDU to its reception)
* - Average, min, max and standard deviation of PDU size
*/
class RadioBearerStatsCalculator : public LteStatsCalculator
{
public:
/**
* Class constructor
*/
RadioBearerStatsCalculator ();
/**
* Class constructor
*/
RadioBearerStatsCalculator (std::string protocolType);
/**
* Class destructor
*/
virtual
~RadioBearerStatsCalculator ();
// Inherited from ns3::Object
/**
* Register this type.
* \return The object TypeId.
*/
static TypeId GetTypeId (void);
void DoDispose ();
/**
* Get the name of the file where the uplink statistics will be stored.
* @return the name of the file where the uplink statistics will be stored
*/
std::string GetUlOutputFilename (void);
/**
* Get the name of the file where the downlink statistics will be stored.
* @return the name of the file where the downlink statistics will be stored
*/
std::string GetDlOutputFilename (void);
/**
* Set the name of the file where the uplink PDCP statistics will be stored.
*
* @param outputFilename string with the name of the file
*/
void SetUlPdcpOutputFilename (std::string outputFilename);
/**
* Get the name of the file where the uplink PDCP statistics will be stored.
* @return the name of the file where the uplink PDCP statistics will be stored
*/
std::string GetUlPdcpOutputFilename (void);
/**
* Set the name of the file where the downlink PDCP statistics will be stored.
*
* @param outputFilename string with the name of the file
*/
void SetDlPdcpOutputFilename (std::string outputFilename);
/**
* Get the name of the file where the downlink PDCP statistics will be stored.
* @return the name of the file where the downlink PDCP statistics will be stored
*/
std::string GetDlPdcpOutputFilename (void);
/**
*
* \param t the value of the StartTime attribute
*/
void SetStartTime (Time t);
/**
*
* \return the value of the StartTime attribute
*/
Time GetStartTime () const;
/**
*
* \param e the epoch duration
*/
void SetEpoch (Time e);
/**
*
* \return the epoch duration
*/
Time GetEpoch () const;
/**
* Notifies the stats calculator that an uplink transmission has occurred.
* @param cellId CellId of the attached Enb
* @param imsi IMSI of the UE who transmitted the PDU
* @param rnti C-RNTI of the UE who transmitted the PDU
* @param lcid LCID through which the PDU has been transmitted
* @param packetSize size of the PDU in bytes
*/
void
UlTxPdu (uint16_t cellId, uint64_t imsi, uint16_t rnti, uint8_t lcid, uint32_t packetSize);
/**
* Notifies the stats calculator that an uplink reception has occurred.
* @param cellId CellId of the attached Enb
* @param imsi IMSI of the UE who received the PDU
* @param rnti C-RNTI of the UE who received the PDU
* @param lcid LCID through which the PDU has been received
* @param packetSize size of the PDU in bytes
* @param delay RLC to RLC delay in nanoseconds
*/
void
UlRxPdu (uint16_t cellId, uint64_t imsi, uint16_t rnti, uint8_t lcid, uint32_t packetSize, uint64_t delay);
/**
* Notifies the stats calculator that an downlink transmission has occurred.
* @param cellId CellId of the attached Enb
* @param imsi IMSI of the UE who is receiving the PDU
* @param rnti C-RNTI of the UE who is receiving the PDU
* @param lcid LCID through which the PDU has been transmitted
* @param packetSize size of the PDU in bytes
*/
void
DlTxPdu (uint16_t cellId, uint64_t imsi, uint16_t rnti, uint8_t lcid, uint32_t packetSize);
/**
* Notifies the stats calculator that an downlink reception has occurred.
* @param cellId CellId of the attached Enb
* @param imsi IMSI of the UE who received the PDU
* @param rnti C-RNTI of the UE who received the PDU
* @param lcid LCID through which the PDU has been transmitted
* @param packetSize size of the PDU in bytes
* @param delay RLC to RLC delay in nanoseconds
*/
void
DlRxPdu (uint16_t cellId, uint64_t imsi, uint16_t rnti, uint8_t lcid, uint32_t packetSize, uint64_t delay);
/**
* Gets the number of transmitted uplink packets.
* @param imsi IMSI of the UE
* @param lcid LCID
* @return number of transmitted uplink packets
*/
uint32_t
GetUlTxPackets (uint64_t imsi, uint8_t lcid);
/**
* Gets the number of received uplink packets.
* @param imsi IMSI of the UE
* @param lcid LCID
* @return number of received uplink packets
*/
uint32_t
GetUlRxPackets (uint64_t imsi, uint8_t lcid);
/**
* Gets the number of transmitted uplink data bytes.
* @param imsi IMSI of the UE
* @param lcid LCID
* @return number of transmitted data bytes
*/
uint64_t
GetUlTxData (uint64_t imsi, uint8_t lcid);
/**
* Gets the number of received uplink data bytes.
* @param imsi IMSI of the UE
* @param lcid LCID
* @return number of received data bytes
*/
uint64_t
GetUlRxData (uint64_t imsi, uint8_t lcid);
/**
* Gets the attached Enb cellId.
* @param imsi IMSI of the UE
* @param lcid LCID
* @return Enb cellId
*/
uint32_t
GetUlCellId (uint64_t imsi, uint8_t lcid);
/**
* Gets the uplink RLC to RLC delay
* @param imsi IMSI of the UE
* @param lcid LCID
* @return RLC to RLC delay in seconds
*/
double
GetUlDelay (uint64_t imsi, uint8_t lcid);
/**
* Gets the uplink RLC to RLC statistics: average, min, max and standard deviation.
* @param imsi IMSI of the UE
* @param lcid LCID
* @return RLC to RLC delay statistics average, min, max and standard deviation in seconds
*/
std::vector<double>
GetUlDelayStats (uint64_t imsi, uint8_t lcid);
/**
* Gets the uplink PDU size statistics: average, min, max and standard deviation.
* @param imsi IMSI of the UE
* @param lcid LCID
* @return PDU size statistics average, min, max and standard deviation in seconds
*/
std::vector<double>
GetUlPduSizeStats (uint64_t imsi, uint8_t lcid);
/**
* Gets the number of transmitted downlink data bytes.
* @param imsi IMSI of the UE
* @param lcid LCID
* @return number of transmitted data bytes
*/
uint32_t
GetDlTxPackets (uint64_t imsi, uint8_t lcid);
/**
* Gets the number of received downlink data bytes.
* @param imsi IMSI of the UE
* @param lcid LCID
* @return number of received data bytes
*/
uint32_t
GetDlRxPackets (uint64_t imsi, uint8_t lcid);
/**
* Gets the number of transmitted downlink data bytes.
* @param imsi IMSI of the UE
* @param lcid LCID
* @return number of transmitted data bytes
*/
uint64_t
GetDlTxData (uint64_t imsi, uint8_t lcid);
/**
* Gets the number of received downlink data bytes.
* @param imsi IMSI of the UE
* @param lcid LCID
* @return number of received data bytes
*/
uint64_t
GetDlRxData (uint64_t imsi, uint8_t lcid);
/**
* Gets the attached Enb cellId.
* @param imsi IMSI of the UE
* @param lcid LCID
* @return Enb cellId
*/
uint32_t
GetDlCellId (uint64_t imsi, uint8_t lcid);
/**
* Gets the downlink RLC to RLC delay
* @param imsi IMSI of the UE
* @param lcid LCID
* @return RLC to RLC delay in seconds
*/
double
GetDlDelay (uint64_t imsi, uint8_t lcid);
/**
* Gets the downlink RLC to RLC statistics: average, min, max and standard deviation.
* @param imsi IMSI of the UE
* @param lcid LCID
* @return RLC to RLC delay statistics average, min, max and standard deviation in seconds
*/
std::vector<double>
GetDlDelayStats (uint64_t imsi, uint8_t lcid);
/**
* Gets the downlink PDU size statistics: average, min, max and standard deviation.
* @param imsi IMSI of the UE
* @param lcid LCID
* @return PDU size statistics average, min, max and standard deviation in seconds
*/
std::vector<double>
GetDlPduSizeStats (uint64_t imsi, uint8_t lcid);
private:
/**
* Called after each epoch to write collected
* statistics to output files. During first call
* it opens output files and write columns descriptions.
* During next calls it opens output files in append mode.
*/
void
ShowResults (void);
/**
* Writes collected statistics to UL output file and
* closes UL output file.
* @param outFile ofstream for UL statistics
*/
void
WriteUlResults (std::ofstream& outFile);
/**
* Writes collected statistics to DL output file and
* closes DL output file.
* @param outFile ofstream for DL statistics
*/
void
WriteDlResults (std::ofstream& outFile);
/**
* Erases collected statistics
*/
void
ResetResults (void);
/**
* Reschedules EndEpoch event. Usually used after
* execution of SetStartTime() or SetEpoch()
*/
void RescheduleEndEpoch ();
/**
* Function called in every endEpochEvent. It calls
* ShowResults() to write statistics to output files
* and ResetResults() to clear collected statistics.
*/
void EndEpoch (void);
EventId m_endEpochEvent; //!< Event id for next end epoch event
FlowIdMap m_flowId; //!< List of FlowIds, ie. (RNTI, LCID) by (IMSI, LCID) pair
Uint32Map m_dlCellId; //!< List of DL CellIds by (IMSI, LCID) pair
Uint32Map m_dlTxPackets; //!< Number of DL TX Packets by (IMSI, LCID) pair
Uint32Map m_dlRxPackets; //!< Number of DL RX Packets by (IMSI, LCID) pair
Uint64Map m_dlTxData; //!< Amount of DL TX Data by (IMSI, LCID) pair
Uint64Map m_dlRxData; //!< Amount of DL RX Data by (IMSI, LCID) pair
Uint64StatsMap m_dlDelay; //!< DL delay by (IMSI, LCID) pair
Uint32StatsMap m_dlPduSize; //!< DL PDU Size by (IMSI, LCID) pair
Uint32Map m_ulCellId; //!< List of UL CellIds by (IMSI, LCID) pair
Uint32Map m_ulTxPackets; //!< Number of UL TX Packets by (IMSI, LCID) pair
Uint32Map m_ulRxPackets; //!< Number of UL RX Packets by (IMSI, LCID) pair
Uint64Map m_ulTxData; //!< Amount of UL TX Data by (IMSI, LCID) pair
Uint64Map m_ulRxData; //!< Amount of UL RX Data by (IMSI, LCID) pair
Uint64StatsMap m_ulDelay; //!< UL delay by (IMSI, LCID) pair
Uint32StatsMap m_ulPduSize; //!< UL PDU Size by (IMSI, LCID) pair
/**
* Start time of the on going epoch
*/
Time m_startTime;
/**
* Epoch duration
*/
Time m_epochDuration;
/**
* true if output files have not been opened yet
*/
bool m_firstWrite;
/**
* true if any output is pending
*/
bool m_pendingOutput;
/**
* Protocol type, by default RLC
*/
std::string m_protocolType;
/**
* Name of the file where the downlink PDCP statistics will be saved
*/
std::string m_dlPdcpOutputFilename;
/**
* Name of the file where the uplink PDCP statistics will be saved
*/
std::string m_ulPdcpOutputFilename;
};
} // namespace ns3
#endif /* RADIO_BEARER_STATS_CALCULATOR_H_ */