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