A Discrete-Event Network Simulator
API
radio-bearer-stats-calculator.h
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  * Nicola Baldo <nbaldo@cttc.es>
20  */
21 
22 #ifndef RADIO_BEARER_STATS_CALCULATOR_H_
23 #define RADIO_BEARER_STATS_CALCULATOR_H_
24 
25 #include "ns3/lte-stats-calculator.h"
26 #include "ns3/lte-common.h"
27 #include "ns3/uinteger.h"
28 #include "ns3/object.h"
29 #include "ns3/basic-data-calculators.h"
30 #include "ns3/lte-common.h"
31 #include <string>
32 #include <map>
33 #include <fstream>
34 
35 namespace ns3
36 {
38 typedef std::map<ImsiLcidPair_t, uint32_t> Uint32Map;
40 typedef std::map<ImsiLcidPair_t, uint64_t> Uint64Map;
42 typedef std::map<ImsiLcidPair_t, Ptr<MinMaxAvgTotalCalculator<uint32_t> > > Uint32StatsMap;
44 typedef std::map<ImsiLcidPair_t, Ptr<MinMaxAvgTotalCalculator<uint64_t> > > Uint64StatsMap;
46 typedef std::map<ImsiLcidPair_t, double> DoubleMap;
48 typedef std::map<ImsiLcidPair_t, LteFlowId_t> FlowIdMap;
49 
71 {
72 public:
77 
81  RadioBearerStatsCalculator (std::string protocolType);
82 
86  virtual
88 
89  // Inherited from ns3::Object
94  static TypeId GetTypeId (void);
95  void DoDispose ();
96 
101  std::string GetUlOutputFilename (void);
102 
107  std::string GetDlOutputFilename (void);
108 
114  void SetUlPdcpOutputFilename (std::string outputFilename);
115 
120  std::string GetUlPdcpOutputFilename (void);
121 
127  void SetDlPdcpOutputFilename (std::string outputFilename);
128 
133  std::string GetDlPdcpOutputFilename (void);
134 
135 
140  void SetStartTime (Time t);
141 
146  Time GetStartTime () const;
147 
152  void SetEpoch (Time e);
153 
158  Time GetEpoch () const;
159 
168  void
169  UlTxPdu (uint16_t cellId, uint64_t imsi, uint16_t rnti, uint8_t lcid, uint32_t packetSize);
170 
180  void
181  UlRxPdu (uint16_t cellId, uint64_t imsi, uint16_t rnti, uint8_t lcid, uint32_t packetSize, uint64_t delay);
182 
191  void
192  DlTxPdu (uint16_t cellId, uint64_t imsi, uint16_t rnti, uint8_t lcid, uint32_t packetSize);
193 
203  void
204  DlRxPdu (uint16_t cellId, uint64_t imsi, uint16_t rnti, uint8_t lcid, uint32_t packetSize, uint64_t delay);
205 
212  uint32_t
213  GetUlTxPackets (uint64_t imsi, uint8_t lcid);
214 
221  uint32_t
222  GetUlRxPackets (uint64_t imsi, uint8_t lcid);
223 
230  uint64_t
231  GetUlTxData (uint64_t imsi, uint8_t lcid);
232 
239  uint64_t
240  GetUlRxData (uint64_t imsi, uint8_t lcid);
241 
248  uint32_t
249  GetUlCellId (uint64_t imsi, uint8_t lcid);
250 
257  double
258  GetUlDelay (uint64_t imsi, uint8_t lcid);
259 
266  std::vector<double>
267  GetUlDelayStats (uint64_t imsi, uint8_t lcid);
268 
275  std::vector<double>
276  GetUlPduSizeStats (uint64_t imsi, uint8_t lcid);
277 
284  uint32_t
285  GetDlTxPackets (uint64_t imsi, uint8_t lcid);
286 
293  uint32_t
294  GetDlRxPackets (uint64_t imsi, uint8_t lcid);
295 
302  uint64_t
303  GetDlTxData (uint64_t imsi, uint8_t lcid);
304 
311  uint64_t
312  GetDlRxData (uint64_t imsi, uint8_t lcid);
313 
320  uint32_t
321  GetDlCellId (uint64_t imsi, uint8_t lcid);
322 
329  double
330  GetDlDelay (uint64_t imsi, uint8_t lcid);
331 
338  std::vector<double>
339  GetDlDelayStats (uint64_t imsi, uint8_t lcid);
340 
347  std::vector<double>
348  GetDlPduSizeStats (uint64_t imsi, uint8_t lcid);
349 
350 private:
357  void
358  ShowResults (void);
359 
365  void
366  WriteUlResults (std::ofstream& outFile);
367 
373  void
374  WriteDlResults (std::ofstream& outFile);
375 
379  void
380  ResetResults (void);
381 
386  void RescheduleEndEpoch ();
387 
393  void EndEpoch (void);
394 
396 
397  FlowIdMap m_flowId;
398 
399  Uint32Map m_dlCellId;
400  Uint32Map m_dlTxPackets;
401  Uint32Map m_dlRxPackets;
402  Uint64Map m_dlTxData;
403  Uint64Map m_dlRxData;
404  Uint64StatsMap m_dlDelay;
405  Uint32StatsMap m_dlPduSize;
406 
407  Uint32Map m_ulCellId;
408  Uint32Map m_ulTxPackets;
409  Uint32Map m_ulRxPackets;
410  Uint64Map m_ulTxData;
411  Uint64Map m_ulRxData;
412  Uint64StatsMap m_ulDelay;
413  Uint32StatsMap m_ulPduSize;
414 
419 
424 
429 
434 
438  std::string m_protocolType;
439 
444 
449 
450 };
451 
452 } // namespace ns3
453 
454 #endif /* RADIO_BEARER_STATS_CALCULATOR_H_ */
Base class for ***StatsCalculator classes.
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:102
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.
virtual ~RadioBearerStatsCalculator()
Class destructor.
std::string GetDlOutputFilename(void)
Get the name of the file where the downlink statistics will be stored.
static TypeId GetTypeId(void)
Register this type.
double GetUlDelay(uint64_t imsi, uint8_t lcid)
Gets the uplink RLC to RLC delay.
std::string GetUlPdcpOutputFilename(void)
Get the name of the file where the uplink PDCP statistics will be stored.
bool m_pendingOutput
true if any output is pending
Uint64Map m_dlRxData
Amount of DL RX Data by (IMSI, LCID) pair.
Uint32Map m_ulRxPackets
Number of UL RX Packets by (IMSI, LCID) pair.
Uint64Map m_ulRxData
Amount of UL RX Data by (IMSI, LCID) pair.
uint32_t GetDlRxPackets(uint64_t imsi, uint8_t lcid)
Gets the number of received downlink data bytes.
FlowIdMap m_flowId
List of FlowIds, ie.
Uint64Map m_ulTxData
Amount of UL TX Data by (IMSI, LCID) pair.
uint32_t GetUlCellId(uint64_t imsi, uint8_t lcid)
Gets the attached Enb cellId.
void WriteDlResults(std::ofstream &outFile)
Writes collected statistics to DL output file and closes DL output file.
Uint32Map m_dlRxPackets
Number of DL RX Packets by (IMSI, LCID) pair.
void DoDispose()
Destructor implementation.
uint32_t GetUlTxPackets(uint64_t imsi, uint8_t lcid)
Gets the number of transmitted uplink packets.
std::vector< double > GetUlPduSizeStats(uint64_t imsi, uint8_t lcid)
Gets the uplink PDU size statistics: average, min, max and standard deviation.
void WriteUlResults(std::ofstream &outFile)
Writes collected statistics to UL output file and closes UL output file.
uint64_t GetDlRxData(uint64_t imsi, uint8_t lcid)
Gets the number of received downlink data bytes.
void SetUlPdcpOutputFilename(std::string outputFilename)
Set the name of the file where the uplink PDCP statistics will be stored.
double GetDlDelay(uint64_t imsi, uint8_t lcid)
Gets the downlink RLC to RLC delay.
Uint32Map m_dlTxPackets
Number of DL TX Packets by (IMSI, LCID) pair.
std::map< ImsiLcidPair_t, Ptr< MinMaxAvgTotalCalculator< uint32_t > > > Uint32StatsMap
Container: (IMSI, LCID) pair, uint32_t calculator.
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.
Uint64Map m_dlTxData
Amount of DL TX Data by (IMSI, LCID) pair.
Uint32Map m_ulTxPackets
Number of UL TX Packets by (IMSI, LCID) pair.
std::string GetDlPdcpOutputFilename(void)
Get the name of the file where the downlink PDCP statistics will be stored.
Uint64StatsMap m_ulDelay
UL delay by (IMSI, LCID) pair.
EventId m_endEpochEvent
Event id for next end epoch event.
uint32_t GetUlRxPackets(uint64_t imsi, uint8_t lcid)
Gets the number of received uplink packets.
std::map< ImsiLcidPair_t, Ptr< MinMaxAvgTotalCalculator< uint64_t > > > Uint64StatsMap
Container: (IMSI, LCID) pair, uint64_t calculator.
Time m_startTime
Start time of the on going epoch.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Uint64StatsMap m_dlDelay
DL delay by (IMSI, LCID) pair.
std::string GetUlOutputFilename(void)
Get the name of the file where the uplink statistics will be stored.
bool m_firstWrite
true if output files have not been opened yet
uint64_t GetDlTxData(uint64_t imsi, uint8_t lcid)
Gets the number of transmitted downlink data 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 transmission has occurred.
uint32_t GetDlCellId(uint64_t imsi, uint8_t lcid)
Gets the attached Enb cellId.
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.
void ResetResults(void)
Erases collected statistics.
Uint32StatsMap m_ulPduSize
UL PDU Size by (IMSI, LCID) pair.
std::string m_protocolType
Protocol type, by default RLC.
uint64_t GetUlTxData(uint64_t imsi, uint8_t lcid)
Gets the number of transmitted uplink data bytes.
uint64_t GetUlRxData(uint64_t imsi, uint8_t lcid)
Gets the number of received uplink data bytes.
std::vector< double > GetDlDelayStats(uint64_t imsi, uint8_t lcid)
Gets the downlink RLC to RLC statistics: average, min, max and standard deviation.
An identifier for simulation events.
Definition: event-id.h:53
uint32_t GetDlTxPackets(uint64_t imsi, uint8_t lcid)
Gets the number of transmitted downlink data bytes.
void ShowResults(void)
Called after each epoch to write collected statistics to output files.
void RescheduleEndEpoch()
Reschedules EndEpoch event.
void SetDlPdcpOutputFilename(std::string outputFilename)
Set the name of the file where the downlink PDCP statistics will be stored.
static const uint32_t packetSize
Uint32Map m_dlCellId
List of DL CellIds by (IMSI, LCID) pair.
std::map< ImsiLcidPair_t, LteFlowId_t > FlowIdMap
Container: (IMSI, LCID) pair, LteFlowId_t.
void EndEpoch(void)
Function called in every endEpochEvent.
std::vector< double > GetUlDelayStats(uint64_t imsi, uint8_t lcid)
Gets the uplink RLC to RLC statistics: average, min, max and standard deviation.
This class is an ns-3 trace sink that performs the calculation of PDU statistics for uplink and downl...
std::vector< double > GetDlPduSizeStats(uint64_t imsi, uint8_t lcid)
Gets the downlink PDU size statistics: average, min, max and standard deviation.
std::string m_ulPdcpOutputFilename
Name of the file where the uplink PDCP statistics will be saved.
a unique identifier for an interface.
Definition: type-id.h:58
Uint32StatsMap m_dlPduSize
DL PDU Size by (IMSI, LCID) pair.
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.
Uint32Map m_ulCellId
List of UL CellIds by (IMSI, LCID) pair.
std::map< ImsiLcidPair_t, double > DoubleMap
Container: (IMSI, LCID) pair, double.
std::string m_dlPdcpOutputFilename
Name of the file where the downlink PDCP statistics will be saved.