A Discrete-Event Network Simulator
API
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 
24 #include "ns3/basic-data-calculators.h"
25 #include "ns3/lte-common.h"
26 #include "ns3/lte-stats-calculator.h"
27 #include "ns3/object.h"
28 #include "ns3/uinteger.h"
29 
30 #include <fstream>
31 #include <map>
32 #include <string>
33 
34 namespace ns3
35 {
37 typedef std::map<ImsiLcidPair_t, uint32_t> Uint32Map;
39 typedef std::map<ImsiLcidPair_t, uint64_t> Uint64Map;
41 typedef std::map<ImsiLcidPair_t, Ptr<MinMaxAvgTotalCalculator<uint32_t>>> Uint32StatsMap;
43 typedef std::map<ImsiLcidPair_t, Ptr<MinMaxAvgTotalCalculator<uint64_t>>> Uint64StatsMap;
45 typedef std::map<ImsiLcidPair_t, double> DoubleMap;
47 typedef std::map<ImsiLcidPair_t, LteFlowId_t> FlowIdMap;
48 
70 {
71  public:
76 
81  RadioBearerStatsCalculator(std::string protocolType);
82 
87  ~RadioBearerStatsCalculator() override;
88 
89  // Inherited from ns3::Object
94  static TypeId GetTypeId();
95  void DoDispose() override;
96 
101  std::string GetUlOutputFilename();
102 
107  std::string GetDlOutputFilename();
108 
114  void SetUlPdcpOutputFilename(std::string outputFilename);
115 
120  std::string GetUlPdcpOutputFilename();
121 
127  void SetDlPdcpOutputFilename(std::string outputFilename);
128 
133  std::string GetDlPdcpOutputFilename();
134 
139  void SetStartTime(Time t);
140 
145  Time GetStartTime() const;
146 
151  void SetEpoch(Time e);
152 
157  Time GetEpoch() const;
158 
167  void UlTxPdu(uint16_t cellId, uint64_t imsi, uint16_t rnti, uint8_t lcid, uint32_t packetSize);
168 
178  void UlRxPdu(uint16_t cellId,
179  uint64_t imsi,
180  uint16_t rnti,
181  uint8_t lcid,
182  uint32_t packetSize,
183  uint64_t delay);
184 
193  void DlTxPdu(uint16_t cellId, uint64_t imsi, uint16_t rnti, uint8_t lcid, uint32_t packetSize);
194 
204  void DlRxPdu(uint16_t cellId,
205  uint64_t imsi,
206  uint16_t rnti,
207  uint8_t lcid,
208  uint32_t packetSize,
209  uint64_t delay);
210 
217  uint32_t GetUlTxPackets(uint64_t imsi, uint8_t lcid);
218 
225  uint32_t GetUlRxPackets(uint64_t imsi, uint8_t lcid);
226 
233  uint64_t GetUlTxData(uint64_t imsi, uint8_t lcid);
234 
241  uint64_t GetUlRxData(uint64_t imsi, uint8_t lcid);
242 
249  uint32_t GetUlCellId(uint64_t imsi, uint8_t lcid);
250 
257  double GetUlDelay(uint64_t imsi, uint8_t lcid);
258 
265  std::vector<double> GetUlDelayStats(uint64_t imsi, uint8_t lcid);
266 
273  std::vector<double> GetUlPduSizeStats(uint64_t imsi, uint8_t lcid);
274 
281  uint32_t GetDlTxPackets(uint64_t imsi, uint8_t lcid);
282 
289  uint32_t GetDlRxPackets(uint64_t imsi, uint8_t lcid);
290 
297  uint64_t GetDlTxData(uint64_t imsi, uint8_t lcid);
298 
305  uint64_t GetDlRxData(uint64_t imsi, uint8_t lcid);
306 
313  uint32_t GetDlCellId(uint64_t imsi, uint8_t lcid);
314 
321  double GetDlDelay(uint64_t imsi, uint8_t lcid);
322 
329  std::vector<double> GetDlDelayStats(uint64_t imsi, uint8_t lcid);
330 
337  std::vector<double> GetDlPduSizeStats(uint64_t imsi, uint8_t lcid);
338 
339  private:
346  void ShowResults();
347 
353  void WriteUlResults(std::ofstream& outFile);
354 
360  void WriteDlResults(std::ofstream& outFile);
361 
365  void ResetResults();
366 
371  void RescheduleEndEpoch();
372 
378  void EndEpoch();
379 
381 
383 
391 
399 
404 
409 
414 
419 
423  std::string m_protocolType;
424 
429 
434 };
435 
436 } // namespace ns3
437 
438 #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:60
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.