23#include "ns3/nstime.h"
24#include "ns3/string.h"
39 m_pendingOutput(false),
47 m_pendingOutput(false)
62 TypeId(
"ns3::RadioBearerStatsCalculator")
64 .AddConstructor<RadioBearerStatsCalculator>()
66 .AddAttribute(
"StartTime",
67 "Start time of the on going epoch.",
72 .AddAttribute(
"EpochDuration",
78 .AddAttribute(
"DlRlcOutputFilename",
79 "Name of the file where the downlink results will be saved.",
83 .AddAttribute(
"UlRlcOutputFilename",
84 "Name of the file where the uplink results will be saved.",
88 .AddAttribute(
"DlPdcpOutputFilename",
89 "Name of the file where the downlink results will be saved.",
93 .AddAttribute(
"UlPdcpOutputFilename",
94 "Name of the file where the uplink results will be saved.",
192 Uint64StatsMap::iterator it =
m_ulDelay.find(p);
197 m_ulDelay[p] = CreateObject<MinMaxAvgTotalCalculator<uint64_t>>();
198 m_ulPduSize[p] = CreateObject<MinMaxAvgTotalCalculator<uint32_t>>();
223 Uint64StatsMap::iterator it =
m_dlDelay.find(p);
228 m_dlDelay[p] = CreateObject<MinMaxAvgTotalCalculator<uint64_t>>();
229 m_dlPduSize[p] = CreateObject<MinMaxAvgTotalCalculator<uint32_t>>();
244 std::ofstream ulOutFile;
245 std::ofstream dlOutFile;
250 if (!ulOutFile.is_open())
257 if (!dlOutFile.is_open())
263 ulOutFile <<
"% start\tend\tCellId\tIMSI\tRNTI\tLCID\tnTxPDUs\tTxBytes\tnRxPDUs\tRxBytes\t";
264 ulOutFile <<
"delay\tstdDev\tmin\tmax\t";
265 ulOutFile <<
"PduSize\tstdDev\tmin\tmax";
266 ulOutFile << std::endl;
267 dlOutFile <<
"% start\tend\tCellId\tIMSI\tRNTI\tLCID\tnTxPDUs\tTxBytes\tnRxPDUs\tRxBytes\t";
268 dlOutFile <<
"delay\tstdDev\tmin\tmax\t";
269 dlOutFile <<
"PduSize\tstdDev\tmin\tmax";
270 dlOutFile << std::endl;
275 if (!ulOutFile.is_open())
282 if (!dlOutFile.is_open())
300 std::vector<ImsiLcidPair_t> pairVector;
303 if (find(pairVector.begin(), pairVector.end(), (*it).first) == pairVector.end())
305 pairVector.push_back((*it).first);
311 if (find(pairVector.begin(), pairVector.end(), (*it).first) == pairVector.end())
313 pairVector.push_back((*it).first);
318 for (std::vector<ImsiLcidPair_t>::iterator it = pairVector.begin(); it != pairVector.end();
322 FlowIdMap::const_iterator flowIdIt =
m_flowId.find(p);
332 outFile << p.
m_imsi <<
"\t";
333 outFile << flowId.
m_rnti <<
"\t";
340 for (std::vector<double>::iterator it = stats.begin(); it != stats.end(); ++it)
342 outFile << (*it) * 1e-9 <<
"\t";
345 for (std::vector<double>::iterator it = stats.begin(); it != stats.end(); ++it)
347 outFile << (*it) <<
"\t";
349 outFile << std::endl;
361 std::vector<ImsiLcidPair_t> pairVector;
364 if (find(pairVector.begin(), pairVector.end(), (*it).first) == pairVector.end())
366 pairVector.push_back((*it).first);
372 if (find(pairVector.begin(), pairVector.end(), (*it).first) == pairVector.end())
374 pairVector.push_back((*it).first);
379 for (std::vector<ImsiLcidPair_t>::iterator pair = pairVector.begin(); pair != pairVector.end();
383 FlowIdMap::const_iterator flowIdIt =
m_flowId.find(p);
393 outFile << p.
m_imsi <<
"\t";
394 outFile << flowId.
m_rnti <<
"\t";
401 for (std::vector<double>::iterator it = stats.begin(); it != stats.end(); ++it)
403 outFile << (*it) * 1e-9 <<
"\t";
406 for (std::vector<double>::iterator it = stats.begin(); it != stats.end(); ++it)
408 outFile << (*it) <<
"\t";
410 outFile << std::endl;
495 Uint64StatsMap::iterator it =
m_ulDelay.find(p);
498 NS_LOG_ERROR(
"UL delay for " << imsi <<
" - " << (uint16_t)lcid <<
" not found");
509 std::vector<double> stats;
510 Uint64StatsMap::iterator it =
m_ulDelay.find(p);
513 stats.push_back(0.0);
514 stats.push_back(0.0);
515 stats.push_back(0.0);
516 stats.push_back(0.0);
519 stats.push_back(
m_ulDelay[p]->getMean());
520 stats.push_back(
m_ulDelay[p]->getStddev());
531 std::vector<double> stats;
535 stats.push_back(0.0);
536 stats.push_back(0.0);
537 stats.push_back(0.0);
538 stats.push_back(0.0);
601 Uint64StatsMap::iterator it =
m_dlDelay.find(p);
615 std::vector<double> stats;
616 Uint64StatsMap::iterator it =
m_dlDelay.find(p);
619 stats.push_back(0.0);
620 stats.push_back(0.0);
621 stats.push_back(0.0);
622 stats.push_back(0.0);
625 stats.push_back(
m_dlDelay[p]->getMean());
626 stats.push_back(
m_dlDelay[p]->getStddev());
637 std::vector<double> stats;
641 stats.push_back(0.0);
642 stats.push_back(0.0);
643 stats.push_back(0.0);
644 stats.push_back(0.0);
void Cancel()
This method is syntactic sugar for the ns3::Simulator::Cancel method.
Base class for ***StatsCalculator classes.
std::string GetUlOutputFilename()
Get the name of the file where the uplink statistics will be stored.
void SetDlOutputFilename(std::string outputFilename)
Set the name of the file where the downlink statistics will be stored.
void SetUlOutputFilename(std::string outputFilename)
Set the name of the file where the uplink statistics will be stored.
std::string GetDlOutputFilename()
Get the name of the file where the downlink statistics will be stored.
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.
RadioBearerStatsCalculator()
Class constructor.
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.
void SetStartTime(Time t)
bool m_firstWrite
true if output files have not been opened yet
FlowIdMap m_flowId
List of FlowIds, ie.
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.
Time GetStartTime() const
void SetUlPdcpOutputFilename(std::string outputFilename)
Set the name of the file where the uplink PDCP statistics will be stored.
Time m_epochDuration
Epoch duration.
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.
static EventId Schedule(const Time &delay, FUNC f, Ts &&... args)
Schedule an event to expire after delay.
static Time Now()
Return the current simulation virtual time.
Hold variables of type string.
Simulation virtual time values and global simulation resolution.
double GetSeconds() const
Get an approximation of the time stored in this instance in the indicated unit.
AttributeValue implementation for Time.
a unique identifier for an interface.
TypeId SetParent(TypeId tid)
Set the parent TypeId.
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file,...
#define NS_ASSERT_MSG(condition, message)
At runtime, in debugging builds, if this condition is not true, the program prints the message to out...
Ptr< const AttributeChecker > MakeStringChecker()
Ptr< const AttributeAccessor > MakeStringAccessor(T1 a1)
Ptr< const AttributeChecker > MakeTimeChecker()
Helper to make an unbounded Time checker.
Ptr< const AttributeAccessor > MakeTimeAccessor(T1 a1)
#define NS_LOG_ERROR(msg)
Use NS_LOG to output a message of level LOG_ERROR.
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by ",...
#define NS_LOG_INFO(msg)
Use NS_LOG to output a message of level LOG_INFO.
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Time Seconds(double value)
Construct a Time in the indicated unit.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
static const uint32_t packetSize
Packet size generated at the AP.