23 #include "ns3/string.h"
24 #include "ns3/nstime.h"
37 : m_firstWrite (true),
38 m_pendingOutput (false),
39 m_protocolType (
"RLC")
45 : m_firstWrite (true),
46 m_pendingOutput (false)
61 TypeId (
"ns3::RadioBearerStatsCalculator")
63 .AddAttribute (
"StartTime",
"Start time of the on going epoch.",
68 .AddAttribute (
"EpochDuration",
"Epoch duration.",
73 .AddAttribute (
"DlRlcOutputFilename",
74 "Name of the file where the downlink results will be saved.",
78 .AddAttribute (
"UlRlcOutputFilename",
79 "Name of the file where the uplink results will be saved.",
83 .AddAttribute (
"DlPdcpOutputFilename",
84 "Name of the file where the downlink results will be saved.",
88 .AddAttribute (
"UlPdcpOutputFilename",
89 "Name of the file where the uplink results will be saved.",
136 NS_LOG_FUNCTION (
this <<
"UlTxPDU" << cellId << imsi << rnti << (uint32_t) lcid << packetSize);
151 NS_LOG_FUNCTION (
this <<
"DlTxPDU" << cellId << imsi << rnti << (uint32_t) lcid << packetSize);
167 NS_LOG_FUNCTION (
this <<
"UlRxPDU" << cellId << imsi << rnti << (uint32_t) lcid << packetSize << delay);
175 Uint64StatsMap::iterator it =
m_ulDelay.find (p);
178 NS_LOG_DEBUG (
this <<
" Creating UL stats calculators for IMSI " << p.
m_imsi <<
" and LCID " << (uint32_t) p.
m_lcId);
179 m_ulDelay[p] = CreateObject<MinMaxAvgTotalCalculator<uint64_t> > ();
180 m_ulPduSize[p] = CreateObject<MinMaxAvgTotalCalculator<uint32_t> > ();
191 NS_LOG_FUNCTION (
this <<
"DlRxPDU" << cellId << imsi << rnti << (uint32_t) lcid << packetSize << delay);
199 Uint64StatsMap::iterator it =
m_dlDelay.find (p);
202 NS_LOG_DEBUG (
this <<
" Creating DL stats calculators for IMSI " << p.
m_imsi <<
" and LCID " << (uint32_t) p.
m_lcId);
203 m_dlDelay[p] = CreateObject<MinMaxAvgTotalCalculator<uint64_t> > ();
204 m_dlPduSize[p] = CreateObject<MinMaxAvgTotalCalculator<uint32_t> > ();
219 std::ofstream ulOutFile;
220 std::ofstream dlOutFile;
225 if (!ulOutFile.is_open ())
232 if (!dlOutFile.is_open ())
238 ulOutFile <<
"% start\tend\tCellId\tIMSI\tRNTI\tLCID\tnTxPDUs\tTxBytes\tnRxPDUs\tRxBytes\t";
239 ulOutFile <<
"delay\tstdDev\tmin\tmax\t";
240 ulOutFile <<
"PduSize\tstdDev\tmin\tmax";
241 ulOutFile << std::endl;
242 dlOutFile <<
"% start\tend\tCellId\tIMSI\tRNTI\tLCID\tnTxPDUs\tTxBytes\tnRxPDUs\tRxBytes\t";
243 dlOutFile <<
"delay\tstdDev\tmin\tmax\t";
244 dlOutFile <<
"PduSize\tstdDev\tmin\tmax";
245 dlOutFile << std::endl;
250 if (!ulOutFile.is_open ())
257 if (!dlOutFile.is_open ())
277 std::vector < ImsiLcidPair_t > pairVector;
280 if (find (pairVector.begin (), pairVector.end (), (*it).first) == pairVector.end ())
282 pairVector.push_back ((*it).first);
287 for (std::vector<ImsiLcidPair_t>::iterator it = pairVector.begin (); it != pairVector.end (); ++it)
293 outFile << p.
m_imsi <<
"\t";
294 outFile <<
m_flowId[p].m_rnti <<
"\t";
295 outFile << (uint32_t)
m_flowId[p].m_lcId <<
"\t";
301 for (std::vector<double>::iterator it = stats.begin (); it != stats.end (); ++it)
303 outFile << (*it) * 1e-9 <<
"\t";
306 for (std::vector<double>::iterator it = stats.begin (); it != stats.end (); ++it)
308 outFile << (*it) <<
"\t";
310 outFile << std::endl;
322 std::vector < ImsiLcidPair_t > pairVector;
325 if (find (pairVector.begin (), pairVector.end (), (*it).first) == pairVector.end ())
327 pairVector.push_back ((*it).first);
332 for (std::vector<ImsiLcidPair_t>::iterator pair = pairVector.begin (); pair != pairVector.end (); ++pair)
338 outFile << p.
m_imsi <<
"\t";
339 outFile <<
m_flowId[p].m_rnti <<
"\t";
340 outFile << (uint32_t)
m_flowId[p].m_lcId <<
"\t";
346 for (std::vector<double>::iterator it = stats.begin (); it != stats.end (); ++it)
348 outFile << (*it) * 1e-9 <<
"\t";
351 for (std::vector<double>::iterator it = stats.begin (); it != stats.end (); ++it)
353 outFile << (*it) <<
"\t";
355 outFile << std::endl;
437 Uint64StatsMap::iterator it =
m_ulDelay.find (p);
440 NS_LOG_ERROR (
"UL delay for " << imsi <<
" - " << (uint16_t) lcid <<
" not found");
452 std::vector<double> stats;
453 Uint64StatsMap::iterator it =
m_ulDelay.find (p);
456 stats.push_back (0.0);
457 stats.push_back (0.0);
458 stats.push_back (0.0);
459 stats.push_back (0.0);
463 stats.push_back (
m_ulDelay[p]->getMean ());
464 stats.push_back (
m_ulDelay[p]->getStddev ());
465 stats.push_back (
m_ulDelay[p]->getMin ());
466 stats.push_back (
m_ulDelay[p]->getMax ());
475 std::vector<double> stats;
476 Uint32StatsMap::iterator it =
m_ulPduSize.find (p);
479 stats.push_back (0.0);
480 stats.push_back (0.0);
481 stats.push_back (0.0);
482 stats.push_back (0.0);
546 Uint64StatsMap::iterator it =
m_dlDelay.find (p);
560 std::vector<double> stats;
561 Uint64StatsMap::iterator it =
m_dlDelay.find (p);
564 stats.push_back (0.0);
565 stats.push_back (0.0);
566 stats.push_back (0.0);
567 stats.push_back (0.0);
571 stats.push_back (
m_dlDelay[p]->getMean ());
572 stats.push_back (
m_dlDelay[p]->getStddev ());
573 stats.push_back (
m_dlDelay[p]->getMin ());
574 stats.push_back (
m_dlDelay[p]->getMax ());
583 std::vector<double> stats;
584 Uint32StatsMap::iterator it =
m_dlPduSize.find (p);
587 stats.push_back (0.0);
588 stats.push_back (0.0);
589 stats.push_back (0.0);
590 stats.push_back (0.0);