src/lte/helper/rlc-stats-calculator.cc
changeset 7954 80e46addfeee
parent 7941 c92f27568aef
child 7957 76943b3e9d60
equal deleted inserted replaced
7950:4a4009fdd6b8 7954:80e46addfeee
    30 NS_LOG_COMPONENT_DEFINE ("RlcStatsCalculator");
    30 NS_LOG_COMPONENT_DEFINE ("RlcStatsCalculator");
    31 
    31 
    32 NS_OBJECT_ENSURE_REGISTERED (RlcStatsCalculator);
    32 NS_OBJECT_ENSURE_REGISTERED (RlcStatsCalculator);
    33 
    33 
    34 RlcStatsCalculator::RlcStatsCalculator() :
    34 RlcStatsCalculator::RlcStatsCalculator() :
    35     m_outputFilename (""),
    35     m_dlOutputFilename (""),
       
    36     m_ulOutputFilename (""),
    36     m_firstWrite(true)
    37     m_firstWrite(true)
    37 {
    38 {
    38   NS_LOG_FUNCTION (this);
    39   NS_LOG_FUNCTION (this);
    39 
    40 
    40 }
    41 }
    49 RlcStatsCalculator::GetTypeId (void)
    50 RlcStatsCalculator::GetTypeId (void)
    50 {
    51 {
    51   static TypeId tid = TypeId ("ns3::RlcStatsCalculator")
    52   static TypeId tid = TypeId ("ns3::RlcStatsCalculator")
    52     .SetParent<Object> ()
    53     .SetParent<Object> ()
    53     .AddConstructor<RlcStatsCalculator> ()
    54     .AddConstructor<RlcStatsCalculator> ()
    54     .AddAttribute ("OutputFilename",
    55     .AddAttribute ("DlOutputFilename",
    55                    "Name of the file where the output will be saved.",
    56                    "Name of the file where the downlink results will be saved.",
    56                    StringValue ("RlcStats.csv"),
    57                    StringValue ("DlRlcStats.csv"),
    57                    MakeStringAccessor (&RlcStatsCalculator::SetOutputFilename),
    58                    MakeStringAccessor (&RlcStatsCalculator::SetDlOutputFilename),
       
    59                    MakeStringChecker ())
       
    60     .AddAttribute ("UlOutputFilename",
       
    61                    "Name of the file where the uplink results will be saved.",
       
    62                    StringValue ("UlRlcStats.csv"),
       
    63                    MakeStringAccessor (&RlcStatsCalculator::SetUlOutputFilename),
    58                    MakeStringChecker ())
    64                    MakeStringChecker ())
    59     .AddAttribute ("StartTime",
    65     .AddAttribute ("StartTime",
    60                    "Start time of the on going epoch.",
    66                    "Start time of the on going epoch.",
    61                    TimeValue ( Seconds(0.) ),
    67                    TimeValue ( Seconds(0.) ),
    62                    MakeTimeAccessor (&RlcStatsCalculator::m_startTime),
    68                    MakeTimeAccessor (&RlcStatsCalculator::m_startTime),
    68     ;
    74     ;
    69   return tid;
    75   return tid;
    70 }
    76 }
    71 
    77 
    72 void
    78 void
    73 RlcStatsCalculator::SetOutputFilename (std::string outputFilename)
    79 RlcStatsCalculator::SetUlOutputFilename (std::string outputFilename)
    74 {
    80 {
    75   m_outputFilename = outputFilename;
    81   m_ulOutputFilename = outputFilename;
    76 }
    82 }
    77 
    83 
    78 void
    84 void
    79 RlcStatsCalculator::TxPdu (uint16_t rnti, uint8_t lcid, uint32_t packetSize)
    85 RlcStatsCalculator::SetDlOutputFilename (std::string outputFilename)
    80 {
    86 {
    81   NS_LOG_FUNCTION (this << "TxPDU" << rnti << (uint32_t) lcid << packetSize);
    87   m_dlOutputFilename = outputFilename;
       
    88 }
       
    89 
       
    90 void
       
    91 RlcStatsCalculator::UlTxPdu (uint16_t rnti, uint8_t lcid, uint32_t packetSize)
       
    92 {
       
    93   NS_LOG_FUNCTION (this << "UlTxPDU" << rnti << (uint32_t) lcid << packetSize);
    82   if (Simulator::Now () > m_startTime )
    94   if (Simulator::Now () > m_startTime )
    83     {
    95     {
    84       lteFlowId_t pair (rnti, lcid);
    96       lteFlowId_t pair (rnti, lcid);
    85       m_txPackets[pair]++;
    97       m_ulTxPackets[pair]++;
    86     }
    98     }
    87   CheckEpoch ();
    99   CheckEpoch ();
    88 }
   100 }
    89 
   101 
    90 void
   102 void
    91 RlcStatsCalculator::RxPdu (uint16_t rnti, uint8_t lcid, uint32_t packetSize, uint64_t delay)
   103 RlcStatsCalculator::DlTxPdu (uint16_t rnti, uint8_t lcid, uint32_t packetSize)
    92 {
   104 {
    93   NS_LOG_FUNCTION (this << "RxPDU" << rnti << (uint32_t) lcid << packetSize << delay);
   105   NS_LOG_FUNCTION (this << "DlTxPDU" << rnti << (uint32_t) lcid << packetSize);
    94   if (Simulator::Now () > m_startTime )
   106   if (Simulator::Now () > m_startTime )
    95     {
   107     {
       
   108       lteFlowId_t pair (rnti, lcid);
       
   109       m_dlTxPackets[pair]++;
       
   110     }
       
   111   CheckEpoch ();
       
   112 }
       
   113 
       
   114 void
       
   115 RlcStatsCalculator::UlRxPdu (uint16_t rnti, uint8_t lcid, uint32_t packetSize, uint64_t delay)
       
   116 {
       
   117   NS_LOG_FUNCTION (this << "UlRxPDU" << rnti << (uint32_t) lcid << packetSize << delay);
       
   118   if (Simulator::Now () > m_startTime )
       
   119     {
    96       lteFlowId_t pair(rnti, lcid);
   120       lteFlowId_t pair(rnti, lcid);
    97       m_rxPackets[pair]++;
   121       m_ulRxPackets[pair]++;
    98       m_rxData[pair] += packetSize;
   122       m_ulRxData[pair] += packetSize;
    99       m_throughput[pair] = 8 * m_rxData[pair] / 1.0e9 * (Simulator::Now().GetNanoSeconds() - m_startTime.GetNanoSeconds());
   123 
   100 
   124       uint64StatsMap::iterator it = m_ulDelay.find(pair);
   101       uint64StatsMap::iterator it = m_delay.find(pair);
   125       if (it == m_ulDelay.end())
   102       if (it == m_delay.end())
   126         {
   103         {
   127           m_ulDelay[pair] = CreateObject<MinMaxAvgTotalCalculator<uint64_t> > ();
   104           m_delay[pair] = CreateObject<MinMaxAvgTotalCalculator<uint64_t> > ();
   128           m_ulPduSize[pair] = CreateObject<MinMaxAvgTotalCalculator<uint32_t> > ();
   105           }
   129         }
   106       m_delay[pair]->Update(delay);
   130       m_ulDelay[pair]->Update (delay);
       
   131       m_ulPduSize[pair]->Update (packetSize);
   107     }
   132     }
   108   CheckEpoch ();
   133   CheckEpoch ();
   109 }
   134 }
   110 
   135 
   111 void
   136 void
       
   137 RlcStatsCalculator::DlRxPdu (uint16_t rnti, uint8_t lcid, uint32_t packetSize, uint64_t delay)
       
   138 {
       
   139   NS_LOG_FUNCTION (this << "UlRxPDU" << rnti << (uint32_t) lcid << packetSize << delay);
       
   140   if (Simulator::Now () > m_startTime )
       
   141     {
       
   142       lteFlowId_t pair(rnti, lcid);
       
   143       m_dlRxPackets[pair]++;
       
   144       m_dlRxData[pair] += packetSize;
       
   145 
       
   146       uint64StatsMap::iterator it = m_dlDelay.find(pair);
       
   147       if (it == m_dlDelay.end())
       
   148         {
       
   149           m_dlDelay[pair] = CreateObject<MinMaxAvgTotalCalculator<uint64_t> > ();
       
   150           m_dlPduSize[pair] = CreateObject<MinMaxAvgTotalCalculator<uint32_t> > ();
       
   151         }
       
   152       m_dlDelay[pair]->Update(delay);
       
   153       m_dlPduSize[pair]->Update (packetSize);
       
   154     }
       
   155   CheckEpoch ();
       
   156 }
       
   157 
       
   158 void
   112 RlcStatsCalculator::ShowResults (void)
   159 RlcStatsCalculator::ShowResults (void)
   113 {
   160 {
   114   uint32Map::iterator it;
   161 
   115 
   162   NS_LOG_FUNCTION (this <<  m_ulOutputFilename.c_str () << m_dlOutputFilename.c_str () );
   116 
   163   NS_LOG_INFO ("Write Rlc Stats in " << m_ulOutputFilename.c_str () <<
   117   NS_LOG_FUNCTION (this <<  m_outputFilename.c_str ());
   164                " and in " << m_dlOutputFilename.c_str ());
   118   NS_LOG_INFO ("Write Rlc Stats in: " << m_outputFilename.c_str ());
       
   119   
   165   
   120   std::ofstream m_outFile;
   166   std::ofstream ulOutFile;
       
   167   std::ofstream dlOutFile;
       
   168 
   121   if ( m_firstWrite == true )
   169   if ( m_firstWrite == true )
   122     {
   170     {
   123       m_outFile.open (m_outputFilename.c_str ());
   171       ulOutFile.open (m_ulOutputFilename.c_str ());
   124       if (! m_outFile.is_open ())
   172       if (! ulOutFile.is_open ())
   125       {
   173       {
   126         NS_LOG_ERROR ("Can't open file " << m_outputFilename.c_str ());
   174         NS_LOG_ERROR ("Can't open file " << m_ulOutputFilename.c_str ());
       
   175         return;
       
   176       }
       
   177 
       
   178       dlOutFile.open (m_dlOutputFilename.c_str ());
       
   179       if (! dlOutFile.is_open ())
       
   180       {
       
   181         NS_LOG_ERROR ("Can't open file " << m_dlOutputFilename.c_str ());
   127         return;
   182         return;
   128       }
   183       }
   129       m_firstWrite = false;
   184       m_firstWrite = false;
   130       m_outFile << "# startTime, endTime, RNTI, LCID, throughput (bps), delay (s), PDU loss ratio (%)" << std::endl;
   185       ulOutFile << "# startTime, endTime, RNTI, LCID, nTxPDUs, TxBytes, nRxPDUs, RxBytes, ";
       
   186       ulOutFile << "delay mean, delay std dev, delay min, delay max, ";
       
   187       ulOutFile << "PDU size mean, PDU size std dev, PDU size min, PDU size max, ";
       
   188       ulOutFile << std::endl;
       
   189       dlOutFile << "# startTime, endTime, RNTI, LCID, nTxPDUs, TxBytes, nRxPDUs, RxBytes, ";
       
   190       dlOutFile << "delay mean, delay std dev, delay min, delay max, ";
       
   191       dlOutFile << "PDU size mean, PDU size std dev, PDU size min, PDU size max, ";
       
   192       dlOutFile << std::endl;
   131     }
   193     }
   132   else
   194   else
   133     {
   195     {
   134       m_outFile.open (m_outputFilename.c_str (),  std::ios_base::app);
   196       ulOutFile.open (m_ulOutputFilename.c_str (),  std::ios_base::app);
   135       if (! m_outFile.is_open ())
   197       if (! ulOutFile.is_open ())
   136       {
   198       {
   137         NS_LOG_ERROR ("Can't open file " << m_outputFilename.c_str ());
   199         NS_LOG_ERROR ("Can't open file " << m_ulOutputFilename.c_str ());
   138         return;
   200         return;
   139       }
   201       }
   140     }
   202 
   141 
   203       dlOutFile.open (m_dlOutputFilename.c_str (),  std::ios_base::app);
   142 
   204       if (! dlOutFile.is_open ())
       
   205       {
       
   206         NS_LOG_ERROR ("Can't open file " << m_dlOutputFilename.c_str ());
       
   207         return;
       
   208       }
       
   209     }
       
   210 
       
   211   WriteUlResults(ulOutFile);
       
   212   WriteDlResults(dlOutFile);
       
   213 
       
   214 }
       
   215 
       
   216 void
       
   217 RlcStatsCalculator::WriteUlResults (std::ofstream& outFile)
       
   218 {
       
   219   uint32Map::iterator it;
   143 
   220 
   144   // Get all the unique lteFlowIds in the calculator
   221   // Get all the unique lteFlowIds in the calculator
   145   std::vector<lteFlowId_t> lteFlowIds;
   222   std::vector<lteFlowId_t> lteFlowIds;
   146   for ( it = m_txPackets.begin(); it != m_txPackets.end(); ++it)
   223   for ( it = m_ulTxPackets.begin(); it != m_ulTxPackets.end(); ++it)
   147     {
   224     {
   148       if (find (lteFlowIds.begin (), lteFlowIds.end (),  (*it).first ) == lteFlowIds.end () )
   225       if (find (lteFlowIds.begin (), lteFlowIds.end (),  (*it).first ) == lteFlowIds.end () )
   149         {
   226         {
   150           lteFlowIds.push_back ((*it).first);
   227           lteFlowIds.push_back ((*it).first);
   151         }
   228         }
   153 
   230 
   154   std::vector<lteFlowId_t>::iterator itFlow;
   231   std::vector<lteFlowId_t>::iterator itFlow;
   155   Time endTime = m_startTime + m_epochDuration;
   232   Time endTime = m_startTime + m_epochDuration;
   156   for ( itFlow = lteFlowIds.begin(); itFlow != lteFlowIds.end(); ++itFlow)
   233   for ( itFlow = lteFlowIds.begin(); itFlow != lteFlowIds.end(); ++itFlow)
   157     {
   234     {
   158       m_outFile << m_startTime.GetNanoSeconds () / 1.0e9  << " " << endTime.GetNanoSeconds() / 1.0e9;
   235       outFile << m_startTime.GetNanoSeconds () / 1.0e9  << " ";
   159       m_outFile << " " << (*itFlow).m_rnti << " " << (uint32_t) (*itFlow).m_lcId << " " << GetThroughput (*itFlow);
   236       outFile << endTime.GetNanoSeconds() / 1.0e9       << " ";
   160       m_outFile << " " << GetDelay(*itFlow) << " " << GetPacketLossProbability (*itFlow) << std::endl;
   237       outFile << (*itFlow).m_rnti                       << " ";
   161     }
   238       outFile << (uint32_t) (*itFlow).m_lcId            << " ";
   162   m_outFile.close ();
   239       outFile << GetUlTxPackets (*itFlow)               << " ";
       
   240       outFile << GetUlTxData (*itFlow)                  << " ";
       
   241       outFile << GetUlRxPackets (*itFlow)               << " ";
       
   242       outFile << GetUlRxData (*itFlow)                  << " ";
       
   243       std::vector<double> stats = GetUlDelayStats (*itFlow);
       
   244       for( std::vector<double>::iterator it = stats.begin (); it != stats.end (); ++it )
       
   245         {
       
   246           outFile << (*it) * 1e-9 << " ";
       
   247         }
       
   248       stats = GetUlPduSizeStats (*itFlow);
       
   249       for( std::vector<double>::iterator it = stats.begin (); it != stats.end (); ++it )
       
   250         {
       
   251           outFile << (*it) << " ";
       
   252         }
       
   253       outFile << std::endl;
       
   254     }
       
   255 
       
   256   outFile.close ();
       
   257 }
       
   258 
       
   259 void
       
   260 RlcStatsCalculator::WriteDlResults (std::ofstream& outFile)
       
   261 {
       
   262   uint32Map::iterator it;
       
   263 
       
   264   // Get all the unique lteFlowIds in the calculator
       
   265   std::vector<lteFlowId_t> lteFlowIds;
       
   266   for ( it = m_dlTxPackets.begin(); it != m_dlTxPackets.end(); ++it)
       
   267     {
       
   268       if (find (lteFlowIds.begin (), lteFlowIds.end (),  (*it).first ) == lteFlowIds.end () )
       
   269         {
       
   270           lteFlowIds.push_back ((*it).first);
       
   271         }
       
   272     }
       
   273 
       
   274   std::vector<lteFlowId_t>::iterator itFlow;
       
   275   Time endTime = m_startTime + m_epochDuration;
       
   276   for ( itFlow = lteFlowIds.begin(); itFlow != lteFlowIds.end(); ++itFlow)
       
   277     {
       
   278       outFile << m_startTime.GetNanoSeconds () / 1.0e9  << " ";
       
   279       outFile << endTime.GetNanoSeconds() / 1.0e9       << " ";
       
   280       outFile << (*itFlow).m_rnti                       << " ";
       
   281       outFile << (uint32_t) (*itFlow).m_lcId            << " ";
       
   282       outFile << GetDlTxPackets (*itFlow)               << " ";
       
   283       outFile << GetDlTxData (*itFlow)                  << " ";
       
   284       outFile << GetDlRxPackets (*itFlow)               << " ";
       
   285       outFile << GetDlRxData (*itFlow)                  << " ";
       
   286       std::vector<double> stats = GetDlDelayStats (*itFlow);
       
   287       for( std::vector<double>::iterator it = stats.begin (); it != stats.end (); ++it )
       
   288         {
       
   289           outFile << (*it) * 1e-9 << " ";
       
   290         }
       
   291       stats = GetDlPduSizeStats (*itFlow);
       
   292       for( std::vector<double>::iterator it = stats.begin (); it != stats.end (); ++it )
       
   293         {
       
   294           outFile << (*it) << " ";
       
   295         }
       
   296       outFile << std::endl;
       
   297     }
       
   298   outFile.close ();
   163 }
   299 }
   164 
   300 
   165 void
   301 void
   166 RlcStatsCalculator::ResetResults (void)
   302 RlcStatsCalculator::ResetResults (void)
   167 {
   303 {
   168    m_txPackets.erase (m_txPackets.begin (), m_txPackets.end () );
   304    m_ulTxPackets.erase (m_ulTxPackets.begin (), m_ulTxPackets.end () );
   169    m_rxPackets.erase (m_rxPackets.begin (), m_rxPackets.end () );
   305    m_ulRxPackets.erase (m_ulRxPackets.begin (), m_ulRxPackets.end () );
   170    m_rxData.erase (m_rxData.begin (), m_rxData.end () );
   306    m_ulRxData.erase (m_ulRxData.begin (), m_ulRxData.end () );
   171    m_throughput.erase (m_throughput.begin (), m_throughput.end () );
   307    m_ulDelay.erase (m_ulDelay.begin (), m_ulDelay.end () );
   172    m_delay.erase (m_delay.begin (), m_delay.end () );
   308 
       
   309    m_dlTxPackets.erase (m_dlTxPackets.begin (), m_dlTxPackets.end () );
       
   310    m_dlRxPackets.erase (m_dlRxPackets.begin (), m_dlRxPackets.end () );
       
   311    m_dlRxData.erase (m_dlRxData.begin (), m_dlRxData.end () );
       
   312    m_dlDelay.erase (m_dlDelay.begin (), m_dlDelay.end () );
   173 }
   313 }
   174 
   314 
   175 void
   315 void
   176 RlcStatsCalculator::CheckEpoch (void)
   316 RlcStatsCalculator::CheckEpoch (void)
   177 {
   317 {
   189 {
   329 {
   190   m_startTime += m_epochDuration;
   330   m_startTime += m_epochDuration;
   191 }
   331 }
   192 
   332 
   193 uint32_t
   333 uint32_t
   194 RlcStatsCalculator::GetTxPackets (lteFlowId_t p)
   334 RlcStatsCalculator::GetUlTxPackets (lteFlowId_t p)
   195 {
   335 {
   196   return m_txPackets[p];
   336   return m_ulTxPackets[p];
   197 }
   337 }
   198 
   338 
   199 uint32_t
   339 uint32_t
   200 RlcStatsCalculator::GetRxPackets (lteFlowId_t p)
   340 RlcStatsCalculator::GetUlRxPackets (lteFlowId_t p)
   201 {
   341 {
   202   return m_rxPackets[p];
   342   return m_ulRxPackets[p];
   203 }
   343 }
   204 
   344 
   205 uint64_t
   345 uint64_t
   206 RlcStatsCalculator::GetRxData (lteFlowId_t p)
   346 RlcStatsCalculator::GetUlTxData (lteFlowId_t p)
   207 {
   347 {
   208   return m_rxData[p];
   348   return m_ulTxData[p];
   209 }
   349 }
   210 
   350 
   211 uint64_t
   351 uint64_t
   212 RlcStatsCalculator::GetDelay (lteFlowId_t p)
   352 RlcStatsCalculator::GetUlRxData (lteFlowId_t p)
   213 {
   353 {
   214   uint64StatsMap::iterator it = m_delay.find (p);
   354   return m_ulRxData[p];
   215   if ( it == m_delay.end () )
   355 }
   216     {
   356 
       
   357 double
       
   358 RlcStatsCalculator::GetUlDelay (lteFlowId_t p)
       
   359 {
       
   360   uint64StatsMap::iterator it = m_ulDelay.find (p);
       
   361   if ( it == m_ulDelay.end () )
       
   362     {
       
   363       NS_LOG_ERROR("UL delay for " << p.m_rnti << ", " <<
       
   364                    (uint32_t) p.m_lcId << " not found");
   217       return 0;
   365       return 0;
   218     }
   366 
   219   return m_delay[p]->getMean ();
   367     }
       
   368   return m_ulDelay[p]->getMean ();
       
   369 }
       
   370 
       
   371 std::vector<double>
       
   372 RlcStatsCalculator::GetUlDelayStats (lteFlowId_t p)
       
   373 {
       
   374   std::vector<double> stats;
       
   375   uint64StatsMap::iterator it = m_ulDelay.find (p);
       
   376   if ( it == m_ulDelay.end () )
       
   377     {
       
   378       NS_LOG_ERROR("UL delay for " << p.m_rnti << ", " <<
       
   379                    (uint32_t) p.m_lcId << " not found");
       
   380       return stats;
       
   381 
       
   382     }
       
   383   stats.push_back(m_ulDelay[p]->getMean ());
       
   384   stats.push_back(m_ulDelay[p]->getStddev ());
       
   385   stats.push_back(m_ulDelay[p]->getMin ());
       
   386   stats.push_back(m_ulDelay[p]->getMax ());
       
   387   return stats;
       
   388 }
       
   389 
       
   390 std::vector<double>
       
   391 RlcStatsCalculator::GetUlPduSizeStats (lteFlowId_t p)
       
   392 {
       
   393   std::vector<double> stats;
       
   394   uint32StatsMap::iterator it = m_ulPduSize.find (p);
       
   395   if ( it == m_ulPduSize.end () )
       
   396     {
       
   397       NS_LOG_ERROR("UL PDU Size for " << p.m_rnti << ", " <<
       
   398                    (uint32_t) p.m_lcId << " not found");
       
   399       return stats;
       
   400 
       
   401     }
       
   402   stats.push_back (m_ulPduSize[p]->getMean ());
       
   403   stats.push_back (m_ulPduSize[p]->getStddev ());
       
   404   stats.push_back (m_ulPduSize[p]->getMin ());
       
   405   stats.push_back (m_ulPduSize[p]->getMax ());
       
   406   return stats;
       
   407 }
       
   408 
       
   409 uint32_t
       
   410 RlcStatsCalculator::GetDlTxPackets (lteFlowId_t p)
       
   411 {
       
   412   return m_dlTxPackets[p];
       
   413 }
       
   414 
       
   415 uint32_t
       
   416 RlcStatsCalculator::GetDlRxPackets (lteFlowId_t p)
       
   417 {
       
   418   return m_dlRxPackets[p];
       
   419 }
       
   420 
       
   421 uint64_t
       
   422 RlcStatsCalculator::GetDlTxData (lteFlowId_t p)
       
   423 {
       
   424   return m_dlTxData[p];
       
   425 }
       
   426 
       
   427 uint64_t
       
   428 RlcStatsCalculator::GetDlRxData (lteFlowId_t p)
       
   429 {
       
   430   return m_dlRxData[p];
   220 }
   431 }
   221 
   432 
   222 double
   433 double
   223 RlcStatsCalculator::GetThroughput (lteFlowId_t p)
   434 RlcStatsCalculator::GetDlDelay (lteFlowId_t p)
   224 {
   435 {
   225   return m_throughput[p];
   436   uint64StatsMap::iterator it = m_dlDelay.find (p);
       
   437   if ( it == m_dlDelay.end () )
       
   438     {
       
   439       NS_LOG_ERROR("DL delay for " << p.m_rnti << ", " <<
       
   440                    (uint32_t) p.m_lcId << " not found");
       
   441       return 0;
       
   442     }
       
   443   return m_dlDelay[p]->getMean ();
       
   444 }
       
   445 
       
   446 std::vector<double>
       
   447 RlcStatsCalculator::GetDlDelayStats (lteFlowId_t p)
       
   448 {
       
   449   std::vector<double> stats;
       
   450   uint64StatsMap::iterator it = m_dlDelay.find (p);
       
   451   if ( it == m_dlDelay.end () )
       
   452     {
       
   453 
       
   454       NS_LOG_ERROR("DL delay for " << p.m_rnti << ", " <<
       
   455                    (uint32_t) p.m_lcId << " not found");
       
   456       return stats;
       
   457 
       
   458     }
       
   459   stats.push_back(m_dlDelay[p]->getMean ());
       
   460   stats.push_back(m_dlDelay[p]->getStddev ());
       
   461   stats.push_back(m_dlDelay[p]->getMin ());
       
   462   stats.push_back(m_dlDelay[p]->getMax ());
       
   463   return stats;
       
   464 }
       
   465 
       
   466 std::vector<double>
       
   467 RlcStatsCalculator::GetDlPduSizeStats (lteFlowId_t p)
       
   468 {
       
   469   std::vector<double> stats;
       
   470   uint32StatsMap::iterator it = m_dlPduSize.find (p);
       
   471   if ( it == m_dlPduSize.end () )
       
   472     {
       
   473 
       
   474       NS_LOG_ERROR("DL delay for " << p.m_rnti << ", " <<
       
   475                    (uint32_t) p.m_lcId << " not found");
       
   476       return stats;
       
   477 
       
   478     }
       
   479   stats.push_back(m_dlPduSize[p]->getMean ());
       
   480   stats.push_back(m_dlPduSize[p]->getStddev ());
       
   481   stats.push_back(m_dlPduSize[p]->getMin ());
       
   482   stats.push_back(m_dlPduSize[p]->getMax ());
       
   483   return stats;
       
   484 }
       
   485 
       
   486 uint32_t
       
   487 RlcStatsCalculator::GetUlTxPackets (uint16_t rnti, uint8_t lcid)
       
   488 {
       
   489   lteFlowId_t p (rnti, lcid);
       
   490   return GetUlTxPackets (p);
       
   491 }
       
   492 
       
   493 uint32_t
       
   494 RlcStatsCalculator::GetUlRxPackets (uint16_t rnti, uint8_t lcid)
       
   495 {
       
   496   lteFlowId_t p (rnti, lcid);
       
   497   return GetUlRxPackets (p);
       
   498 }
       
   499 
       
   500 uint64_t
       
   501 RlcStatsCalculator::GetUlTxData (uint16_t rnti, uint8_t lcid)
       
   502 {
       
   503   lteFlowId_t p (rnti, lcid);
       
   504   return GetUlTxData (p);
       
   505 }
       
   506 
       
   507 uint64_t
       
   508 RlcStatsCalculator::GetUlRxData (uint16_t rnti, uint8_t lcid)
       
   509 {
       
   510   lteFlowId_t p (rnti, lcid);
       
   511   return GetUlRxData (p);
   226 }
   512 }
   227 
   513 
   228 double
   514 double
   229 RlcStatsCalculator::GetPacketLossProbability (lteFlowId_t p)
   515 RlcStatsCalculator::GetUlDelay (uint16_t rnti, uint8_t lcid)
   230 {
   516 {
   231    return (GetTxPackets (p) - GetRxPackets (p)) / (double) GetTxPackets (p);
   517   lteFlowId_t p (rnti, lcid);
   232 }
   518   return GetUlDelay (p);
   233 
   519 }
   234 uint32_t
   520 
   235 RlcStatsCalculator::GetTxPackets (uint16_t rnti, uint8_t lcid)
   521 std::vector<double>
   236 {
   522 RlcStatsCalculator::GetUlDelayStats (uint16_t rnti, uint8_t lcid)
   237   lteFlowId_t p (rnti, lcid);
   523 {
   238   return GetTxPackets (p);
   524   lteFlowId_t p (rnti, lcid);
   239 }
   525   return GetUlDelayStats (p);
   240 
   526 }
   241 uint32_t
   527 
   242 RlcStatsCalculator::GetRxPackets (uint16_t rnti, uint8_t lcid)
   528 std::vector<double>
   243 {
   529 RlcStatsCalculator::GetUlPduSizeStats (uint16_t rnti, uint8_t lcid)
   244   lteFlowId_t p (rnti, lcid);
   530 {
   245   return GetRxPackets (p);
   531   lteFlowId_t p (rnti, lcid);
   246 }
   532   return GetUlPduSizeStats (p);
   247 
   533 }
   248 uint64_t
   534 
   249 RlcStatsCalculator::GetRxData (uint16_t rnti, uint8_t lcid)
   535 
   250 {
   536 uint32_t
   251   lteFlowId_t p (rnti, lcid);
   537 RlcStatsCalculator::GetDlTxPackets (uint16_t rnti, uint8_t lcid)
   252   return GetRxData (p);
   538 {
   253 }
   539   lteFlowId_t p (rnti, lcid);
   254 
   540   return GetDlTxPackets (p);
   255 uint64_t
   541 }
   256 RlcStatsCalculator::GetDelay (uint16_t rnti, uint8_t lcid)
   542 
   257 {
   543 uint32_t
   258   lteFlowId_t p (rnti, lcid);
   544 RlcStatsCalculator::GetDlRxPackets (uint16_t rnti, uint8_t lcid)
   259   return GetDelay (p);
   545 {
       
   546   lteFlowId_t p (rnti, lcid);
       
   547   return GetDlRxPackets (p);
       
   548 }
       
   549 
       
   550 uint64_t
       
   551 RlcStatsCalculator::GetDlTxData (uint16_t rnti, uint8_t lcid)
       
   552 {
       
   553   lteFlowId_t p (rnti, lcid);
       
   554   return GetDlTxData (p);
       
   555 }
       
   556 
       
   557 uint64_t
       
   558 RlcStatsCalculator::GetDlRxData (uint16_t rnti, uint8_t lcid)
       
   559 {
       
   560   lteFlowId_t p (rnti, lcid);
       
   561   return GetDlRxData (p);
   260 }
   562 }
   261 
   563 
   262 double
   564 double
   263 RlcStatsCalculator::GetThroughput (uint16_t rnti, uint8_t lcid)
   565 RlcStatsCalculator::GetDlDelay (uint16_t rnti, uint8_t lcid)
   264 {
   566 {
   265   lteFlowId_t p (rnti, lcid);
   567   lteFlowId_t p (rnti, lcid);
   266   return GetThroughput (p);
   568   return GetDlDelay (p);
   267 }
   569 }
   268 
   570 
   269 double
   571 std::vector<double>
   270 RlcStatsCalculator::GetPacketLossProbability (uint16_t rnti, uint8_t lcid)
   572 RlcStatsCalculator::GetDlDelayStats (uint16_t rnti, uint8_t lcid)
   271 {
   573 {
   272   lteFlowId_t p (rnti, lcid);
   574   lteFlowId_t p (rnti, lcid);
   273   return GetPacketLossProbability (p);
   575   return GetDlDelayStats (p);
       
   576 }
       
   577 
       
   578 std::vector<double>
       
   579 RlcStatsCalculator::GetDlPduSizeStats (uint16_t rnti, uint8_t lcid)
       
   580 {
       
   581   lteFlowId_t p (rnti, lcid);
       
   582   return GetDlPduSizeStats (p);
   274 }
   583 }
   275 
   584 
   276 } // namespace ns3
   585 } // namespace ns3