23 #include "ns3/string.h"
24 #include "ns3/nstime.h"
36 : m_firstWrite (true),
37 m_pendingOutput (false),
38 m_protocolType (
"RLC")
44 : m_firstWrite (true),
45 m_pendingOutput (false)
60 TypeId (
"ns3::RadioBearerStatsCalculator")
62 .AddAttribute (
"StartTime",
"Start time of the on going epoch.",
67 .AddAttribute (
"EpochDuration",
"Epoch duration.",
72 .AddAttribute (
"DlRlcOutputFilename",
73 "Name of the file where the downlink results will be saved.",
77 .AddAttribute (
"UlRlcOutputFilename",
78 "Name of the file where the uplink results will be saved.",
82 .AddAttribute (
"DlPdcpOutputFilename",
83 "Name of the file where the downlink results will be saved.",
87 .AddAttribute (
"UlPdcpOutputFilename",
88 "Name of the file where the uplink results will be saved.",
135 NS_LOG_FUNCTION (
this <<
"UlTxPDU" << cellId << imsi << rnti << (uint32_t) lcid << packetSize);
150 NS_LOG_FUNCTION (
this <<
"DlTxPDU" << cellId << imsi << rnti << (uint32_t) lcid << packetSize);
166 NS_LOG_FUNCTION (
this <<
"UlRxPDU" << cellId << imsi << rnti << (uint32_t) lcid << packetSize << delay);
174 Uint64StatsMap::iterator it =
m_ulDelay.find (p);
177 NS_LOG_DEBUG (
this <<
" Creating UL stats calculators for IMSI " << p.
m_imsi <<
" and LCID " << (uint32_t) p.
m_lcId);
178 m_ulDelay[p] = CreateObject<MinMaxAvgTotalCalculator<uint64_t> > ();
179 m_ulPduSize[p] = CreateObject<MinMaxAvgTotalCalculator<uint32_t> > ();
190 NS_LOG_FUNCTION (
this <<
"DlRxPDU" << cellId << imsi << rnti << (uint32_t) lcid << packetSize << delay);
198 Uint64StatsMap::iterator it =
m_dlDelay.find (p);
201 NS_LOG_DEBUG (
this <<
" Creating DL stats calculators for IMSI " << p.
m_imsi <<
" and LCID " << (uint32_t) p.
m_lcId);
202 m_dlDelay[p] = CreateObject<MinMaxAvgTotalCalculator<uint64_t> > ();
203 m_dlPduSize[p] = CreateObject<MinMaxAvgTotalCalculator<uint32_t> > ();
218 std::ofstream ulOutFile;
219 std::ofstream dlOutFile;
224 if (!ulOutFile.is_open ())
231 if (!dlOutFile.is_open ())
237 ulOutFile <<
"% start\tend\tCellId\tIMSI\tRNTI\tLCID\tnTxPDUs\tTxBytes\tnRxPDUs\tRxBytes\t";
238 ulOutFile <<
"delay\tstdDev\tmin\tmax\t";
239 ulOutFile <<
"PduSize\tstdDev\tmin\tmax";
240 ulOutFile << std::endl;
241 dlOutFile <<
"% start\tend\tCellId\tIMSI\tRNTI\tLCID\tnTxPDUs\tTxBytes\tnRxPDUs\tRxBytes\t";
242 dlOutFile <<
"delay\tstdDev\tmin\tmax\t";
243 dlOutFile <<
"PduSize\tstdDev\tmin\tmax";
244 dlOutFile << std::endl;
249 if (!ulOutFile.is_open ())
256 if (!dlOutFile.is_open ())
276 std::vector < ImsiLcidPair_t > pairVector;
279 if (find (pairVector.begin (), pairVector.end (), (*it).first) == pairVector.end ())
281 pairVector.push_back ((*it).first);
286 for (std::vector<ImsiLcidPair_t>::iterator it = pairVector.begin (); it != pairVector.end (); ++it)
292 outFile << p.
m_imsi <<
"\t";
293 outFile <<
m_flowId[p].m_rnti <<
"\t";
294 outFile << (uint32_t)
m_flowId[p].m_lcId <<
"\t";
300 for (std::vector<double>::iterator it = stats.begin (); it != stats.end (); ++it)
302 outFile << (*it) * 1e-9 <<
"\t";
305 for (std::vector<double>::iterator it = stats.begin (); it != stats.end (); ++it)
307 outFile << (*it) <<
"\t";
309 outFile << std::endl;
321 std::vector < ImsiLcidPair_t > pairVector;
324 if (find (pairVector.begin (), pairVector.end (), (*it).first) == pairVector.end ())
326 pairVector.push_back ((*it).first);
331 for (std::vector<ImsiLcidPair_t>::iterator pair = pairVector.begin (); pair != pairVector.end (); ++pair)
337 outFile << p.
m_imsi <<
"\t";
338 outFile <<
m_flowId[p].m_rnti <<
"\t";
339 outFile << (uint32_t)
m_flowId[p].m_lcId <<
"\t";
345 for (std::vector<double>::iterator it = stats.begin (); it != stats.end (); ++it)
347 outFile << (*it) * 1e-9 <<
"\t";
350 for (std::vector<double>::iterator it = stats.begin (); it != stats.end (); ++it)
352 outFile << (*it) <<
"\t";
354 outFile << std::endl;
436 Uint64StatsMap::iterator it =
m_ulDelay.find (p);
439 NS_LOG_ERROR (
"UL delay for " << imsi <<
" - " << (uint16_t) lcid <<
" not found");
451 std::vector<double> stats;
452 Uint64StatsMap::iterator it =
m_ulDelay.find (p);
455 stats.push_back (0.0);
456 stats.push_back (0.0);
457 stats.push_back (0.0);
458 stats.push_back (0.0);
462 stats.push_back (
m_ulDelay[p]->getMean ());
463 stats.push_back (
m_ulDelay[p]->getStddev ());
464 stats.push_back (
m_ulDelay[p]->getMin ());
465 stats.push_back (
m_ulDelay[p]->getMax ());
474 std::vector<double> stats;
475 Uint32StatsMap::iterator it =
m_ulPduSize.find (p);
478 stats.push_back (0.0);
479 stats.push_back (0.0);
480 stats.push_back (0.0);
481 stats.push_back (0.0);
545 Uint64StatsMap::iterator it =
m_dlDelay.find (p);
559 std::vector<double> stats;
560 Uint64StatsMap::iterator it =
m_dlDelay.find (p);
563 stats.push_back (0.0);
564 stats.push_back (0.0);
565 stats.push_back (0.0);
566 stats.push_back (0.0);
570 stats.push_back (
m_dlDelay[p]->getMean ());
571 stats.push_back (
m_dlDelay[p]->getStddev ());
572 stats.push_back (
m_dlDelay[p]->getMin ());
573 stats.push_back (
m_dlDelay[p]->getMax ());
582 std::vector<double> stats;
583 Uint32StatsMap::iterator it =
m_dlPduSize.find (p);
586 stats.push_back (0.0);
587 stats.push_back (0.0);
588 stats.push_back (0.0);
589 stats.push_back (0.0);
Ptr< const AttributeChecker > MakeStringChecker(void)
Base class for ***StatsCalculator classes.
Simulation virtual time values and global simulation resolution.
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by "...
Time GetStartTime() const
virtual ~RadioBearerStatsCalculator()
Class destructor.
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
std::string GetDlOutputFilename(void)
Get the name of the file where the downlink statistics will be stored.
static TypeId GetTypeId(void)
Register this type.
Hold variables of type string.
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.
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file...
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
uint32_t GetDlRxPackets(uint64_t imsi, uint8_t lcid)
Gets the number of received downlink data bytes.
FlowIdMap m_flowId
List of FlowIds, ie.
#define NS_LOG_INFO(msg)
Use NS_LOG to output a message of level LOG_INFO.
Uint64Map m_ulTxData
Amount of UL TX Data by (IMSI, LCID) pair.
static EventId Schedule(Time const &time, MEM mem_ptr, OBJ obj)
Schedule an event to expire at the relative time "time" is reached.
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.
Ptr< const AttributeChecker > MakeTimeChecker(const Time min, const Time max)
Helper to make a Time checker with bounded range.
void DoDispose()
Destructor implementation.
RadioBearerStatsCalculator()
Class constructor.
uint32_t GetUlTxPackets(uint64_t imsi, uint8_t lcid)
Gets the number of transmitted uplink packets.
void SetUlOutputFilename(std::string outputFilename)
Set the name of the file where the uplink statistics will be stored.
std::vector< double > GetUlPduSizeStats(uint64_t imsi, uint8_t lcid)
Gets the uplink PDU size statistics: average, min, max and standard deviation.
AttributeValue implementation for Time.
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.
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.
Time m_startTime
Start time of the on going epoch.
std::string GetUlOutputFilename(void)
Get the name of the file where the uplink statistics will be stored.
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.
void SetStartTime(Time t)
void SetDlOutputFilename(std::string outputFilename)
Set the name of the file where the downlink statistics will be stored.
bool m_firstWrite
true if output files have not been opened yet
Time m_epochDuration
Epoch duration.
Ptr< const AttributeAccessor > MakeTimeAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method...
static Time Now(void)
Return the current simulation virtual time.
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.
int64_t GetNanoSeconds(void) const
Get an approximation of the time stored in this instance in the indicated unit.
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.
uint32_t GetDlTxPackets(uint64_t imsi, uint8_t lcid)
Gets the number of transmitted downlink data bytes.
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
void ShowResults(void)
Called after each epoch to write collected statistics to output files.
Time Seconds(double value)
Construct a Time in the indicated unit.
void RescheduleEndEpoch()
Reschedules EndEpoch event.
void Cancel(void)
This method is syntactic sugar for the ns3::Simulator::Cancel method.
void SetDlPdcpOutputFilename(std::string outputFilename)
Set the name of the file where the downlink PDCP statistics will be stored.
#define NS_LOG_ERROR(msg)
Use NS_LOG to output a message of level LOG_ERROR.
static const uint32_t packetSize
Uint32Map m_dlCellId
List of DL CellIds by (IMSI, LCID) pair.
void EndEpoch(void)
Function called in every endEpochEvent.
Ptr< const AttributeAccessor > MakeStringAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method...
std::vector< double > GetUlDelayStats(uint64_t imsi, uint8_t lcid)
Gets the uplink RLC to RLC statistics: average, min, max and standard deviation.
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.
TypeId SetParent(TypeId tid)
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::string m_dlPdcpOutputFilename
Name of the file where the downlink PDCP statistics will be saved.
std::string GetDlOutputFilename(void)
Get the name of the file where the downlink statistics will be stored.