5G-LENA nr-v3.1-69-g2dd513a7
The 5G/NR module for the ns-3 simulator
Loading...
Searching...
No Matches
nr-bearer-stats-calculator.h
1// Copyright (c) 2011 Centre Tecnologic de Telecomunicacions de Catalunya (CTTC)
2// Copyright (c) 2015, NYU WIRELESS, Tandon School of Engineering, New York University
3//
4// SPDX-License-Identifier: GPL-2.0-only
5
6#ifndef NR_RADIO_BEARER_STATS_CALCULATOR_H_
7#define NR_RADIO_BEARER_STATS_CALCULATOR_H_
8
9#include "nr-bearer-stats-simple.h"
10
11#include "ns3/basic-data-calculators.h"
12#include "ns3/nr-common.h"
13#include "ns3/object.h"
14#include "ns3/uinteger.h"
15
16#include <fstream>
17#include <map>
18#include <string>
19
20namespace ns3
21{
22namespace nr
23{
25typedef std::map<nr::ImsiLcidPair_t, uint32_t> Uint32Map;
27typedef std::map<nr::ImsiLcidPair_t, uint64_t> Uint64Map;
29typedef std::map<nr::ImsiLcidPair_t, Ptr<MinMaxAvgTotalCalculator<uint32_t>>> Uint32StatsMap;
31typedef std::map<nr::ImsiLcidPair_t, Ptr<MinMaxAvgTotalCalculator<uint64_t>>> Uint64StatsMap;
33typedef std::map<nr::ImsiLcidPair_t, double> DoubleMap;
35typedef std::map<nr::ImsiLcidPair_t, nr::FlowId_t> FlowIdMap;
36} // namespace nr
37
59{
60 public:
68 NrBearerStatsCalculator(std::string protocolType);
72 ~NrBearerStatsCalculator() override;
73 // Inherited from ns3::Object
78 static TypeId GetTypeId();
79 void DoDispose() override;
84 void SetStartTime(Time t);
89 Time GetStartTime() const;
94 void SetEpoch(Time e);
99 Time GetEpoch() const;
108 void UlTxPdu(uint16_t cellId,
109 uint64_t imsi,
110 uint16_t rnti,
111 uint8_t lcid,
112 uint32_t packetSize) override;
122 void UlRxPdu(uint16_t cellId,
123 uint64_t imsi,
124 uint16_t rnti,
125 uint8_t lcid,
126 uint32_t packetSize,
127 uint64_t delay) override;
136 void DlTxPdu(uint16_t cellId,
137 uint64_t imsi,
138 uint16_t rnti,
139 uint8_t lcid,
140 uint32_t packetSize) override;
150 void DlRxPdu(uint16_t cellId,
151 uint64_t imsi,
152 uint16_t rnti,
153 uint8_t lcid,
154 uint32_t packetSize,
155 uint64_t delay) override;
162 uint32_t GetUlTxPackets(uint64_t imsi, uint8_t lcid);
169 uint32_t GetUlRxPackets(uint64_t imsi, uint8_t lcid);
176 uint64_t GetUlTxData(uint64_t imsi, uint8_t lcid);
183 uint64_t GetUlRxData(uint64_t imsi, uint8_t lcid);
190 uint32_t GetUlCellId(uint64_t imsi, uint8_t lcid);
197 double GetUlDelay(uint64_t imsi, uint8_t lcid);
204 std::vector<double> GetUlDelayStats(uint64_t imsi, uint8_t lcid);
211 std::vector<double> GetUlPduSizeStats(uint64_t imsi, uint8_t lcid);
218 uint32_t GetDlTxPackets(uint64_t imsi, uint8_t lcid);
225 uint32_t GetDlRxPackets(uint64_t imsi, uint8_t lcid);
232 uint64_t GetDlTxData(uint64_t imsi, uint8_t lcid);
239 uint64_t GetDlRxData(uint64_t imsi, uint8_t lcid);
246 uint32_t GetDlCellId(uint64_t imsi, uint8_t lcid);
253 double GetDlDelay(uint64_t imsi, uint8_t lcid);
260 std::vector<double> GetDlDelayStats(uint64_t imsi, uint8_t lcid);
267 std::vector<double> GetDlPduSizeStats(uint64_t imsi, uint8_t lcid);
271 std::string GetUlOutputFilename();
275 std::string GetDlOutputFilename();
276
277 private:
284 void ShowResults();
290 void WriteUlResults(std::ofstream& outFile);
296 void WriteDlResults(std::ofstream& outFile);
300 void ResetResults();
305 void RescheduleEndEpoch();
311 void EndEpoch();
312
313 EventId m_endEpochEvent;
314 nr::FlowIdMap m_flowId;
315 nr::Uint32Map m_dlCellId;
316 nr::Uint32Map m_dlTxPackets;
317 nr::Uint32Map m_dlRxPackets;
318 nr::Uint64Map m_dlTxData;
319 nr::Uint64Map m_dlRxData;
320 nr::Uint64StatsMap m_dlDelay;
321 nr::Uint32StatsMap m_dlPduSize;
322 nr::Uint32Map m_ulCellId;
323 nr::Uint32Map m_ulTxPackets;
324 nr::Uint32Map m_ulRxPackets;
325 nr::Uint64Map m_ulTxData;
326 nr::Uint64Map m_ulRxData;
327 nr::Uint64StatsMap m_ulDelay;
328 nr::Uint32StatsMap m_ulPduSize;
332 Time m_startTime;
336 Time m_epochDuration;
340 bool m_firstWrite;
344 bool m_pendingOutput;
348 std::string m_protocolType;
352 std::string m_dlRlcOutputFilename;
356 std::string m_ulRlcOutputFilename;
360 std::string m_dlPdcpOutputFilename;
364 std::string m_ulPdcpOutputFilename;
365 std::ofstream m_dlOutFile;
366 std::ofstream m_ulOutFile;
367};
368
369} // namespace ns3
370
371#endif /* NR_RADIO_BEARER_STATS_CALCULATOR_H_ */
std::vector< double > GetUlPduSizeStats(uint64_t imsi, uint8_t lcid)
void UlRxPdu(uint16_t cellId, uint64_t imsi, uint16_t rnti, uint8_t lcid, uint32_t packetSize, uint64_t delay) override
uint64_t GetDlTxData(uint64_t imsi, uint8_t lcid)
double GetUlDelay(uint64_t imsi, uint8_t lcid)
std::vector< double > GetDlDelayStats(uint64_t imsi, uint8_t lcid)
std::vector< double > GetDlPduSizeStats(uint64_t imsi, uint8_t lcid)
uint64_t GetUlTxData(uint64_t imsi, uint8_t lcid)
uint32_t GetDlCellId(uint64_t imsi, uint8_t lcid)
uint32_t GetDlRxPackets(uint64_t imsi, uint8_t lcid)
void DlTxPdu(uint16_t cellId, uint64_t imsi, uint16_t rnti, uint8_t lcid, uint32_t packetSize) override
void UlTxPdu(uint16_t cellId, uint64_t imsi, uint16_t rnti, uint8_t lcid, uint32_t packetSize) override
uint64_t GetDlRxData(uint64_t imsi, uint8_t lcid)
uint32_t GetUlCellId(uint64_t imsi, uint8_t lcid)
uint32_t GetUlTxPackets(uint64_t imsi, uint8_t lcid)
void DlRxPdu(uint16_t cellId, uint64_t imsi, uint16_t rnti, uint8_t lcid, uint32_t packetSize, uint64_t delay) override
double GetDlDelay(uint64_t imsi, uint8_t lcid)
uint32_t GetUlRxPackets(uint64_t imsi, uint8_t lcid)
uint64_t GetUlRxData(uint64_t imsi, uint8_t lcid)
std::vector< double > GetUlDelayStats(uint64_t imsi, uint8_t lcid)
uint32_t GetDlTxPackets(uint64_t imsi, uint8_t lcid)