22 #include "ns3/string.h"
23 #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")
64 .AddAttribute (
"DlRlcOutputFilename",
65 "Name of the file where the downlink results will be saved.",
69 .AddAttribute (
"UlRlcOutputFilename",
70 "Name of the file where the uplink results will be saved.",
74 .AddAttribute (
"DlPdcpOutputFilename",
75 "Name of the file where the downlink results will be saved.",
79 .AddAttribute (
"UlPdcpOutputFilename",
80 "Name of the file where the uplink results will be saved.",
101 NS_LOG_FUNCTION (
this <<
"UlTxPDU" << imsi << rnti << (uint32_t) lcid << packetSize);
116 NS_LOG_FUNCTION (
this <<
"DlTxPDU" << imsi << rnti << (uint32_t) lcid << packetSize);
133 NS_LOG_FUNCTION (
this <<
"UlRxPDU" << imsi << rnti << (uint32_t) lcid << packetSize << delay);
143 Uint64StatsMap::iterator it =
m_ulDelay.find (p);
146 NS_LOG_DEBUG (
this <<
" Creating UL stats calculators for IMSI " << p.
m_imsi <<
" and LCID " << (uint32_t) p.
m_lcId);
147 m_ulDelay[p] = CreateObject<MinMaxAvgTotalCalculator<uint64_t> > ();
148 m_ulPduSize[p] = CreateObject<MinMaxAvgTotalCalculator<uint32_t> > ();
159 NS_LOG_FUNCTION (
this <<
"DlRxPDU" << imsi << rnti << (uint32_t) lcid << packetSize << delay);
167 Uint64StatsMap::iterator it =
m_dlDelay.find (p);
170 NS_LOG_DEBUG (
this <<
" Creating DL stats calculators for IMSI " << p.
m_imsi <<
" and LCID " << (uint32_t) p.
m_lcId);
171 m_dlDelay[p] = CreateObject<MinMaxAvgTotalCalculator<uint64_t> > ();
172 m_dlPduSize[p] = CreateObject<MinMaxAvgTotalCalculator<uint32_t> > ();
187 std::ofstream ulOutFile;
188 std::ofstream dlOutFile;
193 if (!ulOutFile.is_open ())
200 if (!dlOutFile.is_open ())
206 ulOutFile <<
"% start\tend\tCellId\tIMSI\tRNTI\tLCID\tnTxPDUs\tTxBytes\tnRxPDUs\tRxBytes\t";
207 ulOutFile <<
"delay\tstdDev\tmin\tmax\t";
208 ulOutFile <<
"PduSize\tstdDev\tmin\tmax";
209 ulOutFile << std::endl;
210 dlOutFile <<
"% start\tend\tCellId\tIMSI\tRNTI\tLCID\tnTxPDUs\tTxBytes\tnRxPDUs\tRxBytes\t";
211 dlOutFile <<
"delay\tstdDev\tmin\tmax\t";
212 dlOutFile <<
"PduSize\tstdDev\tmin\tmax";
213 dlOutFile << std::endl;
218 if (!ulOutFile.is_open ())
225 if (!dlOutFile.is_open ())
245 std::vector < ImsiLcidPair_t > pairVector;
248 if (find (pairVector.begin (), pairVector.end (), (*it).first) == pairVector.end ())
250 pairVector.push_back ((*it).first);
255 for (std::vector<ImsiLcidPair_t>::iterator it = pairVector.begin (); it != pairVector.end (); ++it)
261 outFile << p.
m_imsi <<
"\t";
262 outFile <<
m_flowId[p].m_rnti <<
"\t";
263 outFile << (uint32_t)
m_flowId[p].m_lcId <<
"\t";
269 for (std::vector<double>::iterator it = stats.begin (); it != stats.end (); ++it)
271 outFile << (*it) * 1e-9 <<
"\t";
274 for (std::vector<double>::iterator it = stats.begin (); it != stats.end (); ++it)
276 outFile << (*it) <<
"\t";
278 outFile << std::endl;
290 std::vector < ImsiLcidPair_t > pairVector;
293 if (find (pairVector.begin (), pairVector.end (), (*it).first) == pairVector.end ())
295 pairVector.push_back ((*it).first);
300 for (std::vector<ImsiLcidPair_t>::iterator pair = pairVector.begin (); pair != pairVector.end (); ++pair)
306 outFile << p.
m_imsi <<
"\t";
307 outFile <<
m_flowId[p].m_rnti <<
"\t";
308 outFile << (uint32_t)
m_flowId[p].m_lcId <<
"\t";
314 for (std::vector<double>::iterator it = stats.begin (); it != stats.end (); ++it)
316 outFile << (*it) * 1e-9 <<
"\t";
319 for (std::vector<double>::iterator it = stats.begin (); it != stats.end (); ++it)
321 outFile << (*it) <<
"\t";
323 outFile << std::endl;
409 Uint64StatsMap::iterator it =
m_ulDelay.find (p);
412 NS_LOG_ERROR (
"UL delay for " << imsi <<
" - " << (uint16_t) lcid <<
" not found");
424 std::vector<double> stats;
425 Uint64StatsMap::iterator it =
m_ulDelay.find (p);
428 stats.push_back (0.0);
429 stats.push_back (0.0);
430 stats.push_back (0.0);
431 stats.push_back (0.0);
435 stats.push_back (
m_ulDelay[p]->getMean ());
436 stats.push_back (
m_ulDelay[p]->getStddev ());
437 stats.push_back (
m_ulDelay[p]->getMin ());
438 stats.push_back (
m_ulDelay[p]->getMax ());
447 std::vector<double> stats;
448 Uint32StatsMap::iterator it =
m_ulPduSize.find (p);
451 stats.push_back (0.0);
452 stats.push_back (0.0);
453 stats.push_back (0.0);
454 stats.push_back (0.0);
518 Uint64StatsMap::iterator it =
m_dlDelay.find (p);
532 std::vector<double> stats;
533 Uint64StatsMap::iterator it =
m_dlDelay.find (p);
536 stats.push_back (0.0);
537 stats.push_back (0.0);
538 stats.push_back (0.0);
539 stats.push_back (0.0);
543 stats.push_back (
m_dlDelay[p]->getMean ());
544 stats.push_back (
m_dlDelay[p]->getStddev ());
545 stats.push_back (
m_dlDelay[p]->getMin ());
546 stats.push_back (
m_dlDelay[p]->getMax ());
555 std::vector<double> stats;
556 Uint32StatsMap::iterator it =
m_dlPduSize.find (p);
559 stats.push_back (0.0);
560 stats.push_back (0.0);
561 stats.push_back (0.0);
562 stats.push_back (0.0);