A Discrete-Event Network Simulator
API
radio-bearer-stats-calculator.cc
Go to the documentation of this file.
1 /* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2011 Centre Tecnologic de Telecomunicacions de Catalunya (CTTC)
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License version 2 as
7  * published by the Free Software Foundation;
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17  *
18  * Author: Jaume Nin <jnin@cttc.es>
19  * Nicola Baldo <nbaldo@cttc.es>
20  */
21 
23 #include "ns3/string.h"
24 #include "ns3/nstime.h"
25 #include <ns3/log.h>
26 #include <vector>
27 #include <algorithm>
28 
29 namespace ns3 {
30 
31 NS_LOG_COMPONENT_DEFINE ("RadioBearerStatsCalculator");
32 
33 NS_OBJECT_ENSURE_REGISTERED ( RadioBearerStatsCalculator);
34 
36  : m_firstWrite (true),
37  m_pendingOutput (false),
38  m_protocolType ("RLC")
39 {
40  NS_LOG_FUNCTION (this);
41 }
42 
44  : m_firstWrite (true),
45  m_pendingOutput (false)
46 {
47  NS_LOG_FUNCTION (this);
48  m_protocolType = protocolType;
49 }
50 
52 {
53  NS_LOG_FUNCTION (this);
54 }
55 
56 TypeId
58 {
59  static TypeId tid =
60  TypeId ("ns3::RadioBearerStatsCalculator")
61  .SetParent<LteStatsCalculator> ().AddConstructor<RadioBearerStatsCalculator> ()
62  .SetGroupName("Lte")
63  .AddAttribute ("StartTime", "Start time of the on going epoch.",
64  TimeValue (Seconds (0.)),
67  MakeTimeChecker ())
68  .AddAttribute ("EpochDuration", "Epoch duration.",
69  TimeValue (Seconds (0.25)),
72  MakeTimeChecker ())
73  .AddAttribute ("DlRlcOutputFilename",
74  "Name of the file where the downlink results will be saved.",
75  StringValue ("DlRlcStats.txt"),
78  .AddAttribute ("UlRlcOutputFilename",
79  "Name of the file where the uplink results will be saved.",
80  StringValue ("UlRlcStats.txt"),
83  .AddAttribute ("DlPdcpOutputFilename",
84  "Name of the file where the downlink results will be saved.",
85  StringValue ("DlPdcpStats.txt"),
88  .AddAttribute ("UlPdcpOutputFilename",
89  "Name of the file where the uplink results will be saved.",
90  StringValue ("UlPdcpStats.txt"),
93  ;
94  return tid;
95 }
96 
97 void
99 {
100  NS_LOG_FUNCTION (this);
101  if (m_pendingOutput)
102  {
103  ShowResults ();
104  }
105 }
106 
107 void
109 {
110  m_startTime = t;
112 }
113 
114 Time
116 {
117  return m_startTime;
118 }
119 
120 void
122 {
123  m_epochDuration = e;
125 }
126 
127 Time
129 {
130  return m_epochDuration;
131 }
132 
133 void
134 RadioBearerStatsCalculator::UlTxPdu (uint16_t cellId, uint64_t imsi, uint16_t rnti, uint8_t lcid, uint32_t packetSize)
135 {
136  NS_LOG_FUNCTION (this << "UlTxPDU" << cellId << imsi << rnti << (uint32_t) lcid << packetSize);
137  ImsiLcidPair_t p (imsi, lcid);
138  if (Simulator::Now () >= m_startTime)
139  {
140  m_ulCellId[p] = cellId;
141  m_flowId[p] = LteFlowId_t (rnti, lcid);
142  m_ulTxPackets[p]++;
143  m_ulTxData[p] += packetSize;
144  }
145  m_pendingOutput = true;
146 }
147 
148 void
149 RadioBearerStatsCalculator::DlTxPdu (uint16_t cellId, uint64_t imsi, uint16_t rnti, uint8_t lcid, uint32_t packetSize)
150 {
151  NS_LOG_FUNCTION (this << "DlTxPDU" << cellId << imsi << rnti << (uint32_t) lcid << packetSize);
152  ImsiLcidPair_t p (imsi, lcid);
153  if (Simulator::Now () >= m_startTime)
154  {
155  m_dlCellId[p] = cellId;
156  m_flowId[p] = LteFlowId_t (rnti, lcid);
157  m_dlTxPackets[p]++;
158  m_dlTxData[p] += packetSize;
159  }
160  m_pendingOutput = true;
161 }
162 
163 void
164 RadioBearerStatsCalculator::UlRxPdu (uint16_t cellId, uint64_t imsi, uint16_t rnti, uint8_t lcid, uint32_t packetSize,
165  uint64_t delay)
166 {
167  NS_LOG_FUNCTION (this << "UlRxPDU" << cellId << imsi << rnti << (uint32_t) lcid << packetSize << delay);
168  ImsiLcidPair_t p (imsi, lcid);
169  if (Simulator::Now () >= m_startTime)
170  {
171  m_ulCellId[p] = cellId;
172  m_ulRxPackets[p]++;
173  m_ulRxData[p] += packetSize;
174 
175  Uint64StatsMap::iterator it = m_ulDelay.find (p);
176  if (it == m_ulDelay.end ())
177  {
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> > ();
181  }
182  m_ulDelay[p]->Update (delay);
183  m_ulPduSize[p]->Update (packetSize);
184  }
185  m_pendingOutput = true;
186 }
187 
188 void
189 RadioBearerStatsCalculator::DlRxPdu (uint16_t cellId, uint64_t imsi, uint16_t rnti, uint8_t lcid, uint32_t packetSize, uint64_t delay)
190 {
191  NS_LOG_FUNCTION (this << "DlRxPDU" << cellId << imsi << rnti << (uint32_t) lcid << packetSize << delay);
192  ImsiLcidPair_t p (imsi, lcid);
193  if (Simulator::Now () >= m_startTime)
194  {
195  m_dlCellId[p] = cellId;
196  m_dlRxPackets[p]++;
197  m_dlRxData[p] += packetSize;
198 
199  Uint64StatsMap::iterator it = m_dlDelay.find (p);
200  if (it == m_dlDelay.end ())
201  {
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> > ();
205  }
206  m_dlDelay[p]->Update (delay);
207  m_dlPduSize[p]->Update (packetSize);
208  }
209  m_pendingOutput = true;
210 }
211 
212 void
214 {
215 
216  NS_LOG_FUNCTION (this << GetUlOutputFilename ().c_str () << GetDlOutputFilename ().c_str ());
217  NS_LOG_INFO ("Write Rlc Stats in " << GetUlOutputFilename ().c_str () << " and in " << GetDlOutputFilename ().c_str ());
218 
219  std::ofstream ulOutFile;
220  std::ofstream dlOutFile;
221 
222  if (m_firstWrite == true)
223  {
224  ulOutFile.open (GetUlOutputFilename ().c_str ());
225  if (!ulOutFile.is_open ())
226  {
227  NS_LOG_ERROR ("Can't open file " << GetUlOutputFilename ().c_str ());
228  return;
229  }
230 
231  dlOutFile.open (GetDlOutputFilename ().c_str ());
232  if (!dlOutFile.is_open ())
233  {
234  NS_LOG_ERROR ("Can't open file " << GetDlOutputFilename ().c_str ());
235  return;
236  }
237  m_firstWrite = false;
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;
246  }
247  else
248  {
249  ulOutFile.open (GetUlOutputFilename ().c_str (), std::ios_base::app);
250  if (!ulOutFile.is_open ())
251  {
252  NS_LOG_ERROR ("Can't open file " << GetUlOutputFilename ().c_str ());
253  return;
254  }
255 
256  dlOutFile.open (GetDlOutputFilename ().c_str (), std::ios_base::app);
257  if (!dlOutFile.is_open ())
258  {
259  NS_LOG_ERROR ("Can't open file " << GetDlOutputFilename ().c_str ());
260  return;
261  }
262  }
263 
264  WriteUlResults (ulOutFile);
265  WriteDlResults (dlOutFile);
266  m_pendingOutput = false;
267 
268 }
269 
270 void
272 {
273  NS_LOG_FUNCTION (this);
274 
275  // Get the unique IMSI/LCID pairs list
276  std::vector < ImsiLcidPair_t > pairVector;
277  for (Uint32Map::iterator it = m_ulTxPackets.begin (); it != m_ulTxPackets.end (); ++it)
278  {
279  if (find (pairVector.begin (), pairVector.end (), (*it).first) == pairVector.end ())
280  {
281  pairVector.push_back ((*it).first);
282  }
283  }
284 
285  for (Uint32Map::iterator it = m_ulRxPackets.begin (); it != m_ulRxPackets.end (); ++it)
286  {
287  if (find (pairVector.begin (), pairVector.end (), (*it).first) == pairVector.end ())
288  {
289  pairVector.push_back ((*it).first);
290  }
291  }
292 
293  Time endTime = m_startTime + m_epochDuration;
294  for (std::vector<ImsiLcidPair_t>::iterator it = pairVector.begin (); it != pairVector.end (); ++it)
295  {
296  ImsiLcidPair_t p = *it;
297  FlowIdMap::const_iterator flowIdIt = m_flowId.find (p);
298  // \TODO Temporary workaround until traces are connected correctly in LteEnbRrc and LteUeRrc
299  if (flowIdIt == m_flowId.end ()) continue;
300 // NS_ASSERT_MSG (flowIdIt != m_flowId.end (),
301 // "FlowId (imsi " << p.m_imsi << " lcid " << (uint32_t) p.m_lcId << ") is missing");
302  LteFlowId_t flowId = flowIdIt->second;
303  NS_ASSERT_MSG (flowId.m_lcId == p.m_lcId, "lcid mismatch");
304 
305  outFile << m_startTime.GetNanoSeconds () / 1.0e9 << "\t";
306  outFile << endTime.GetNanoSeconds () / 1.0e9 << "\t";
307  outFile << GetUlCellId (p.m_imsi, p.m_lcId) << "\t";
308  outFile << p.m_imsi << "\t";
309  outFile << flowId.m_rnti << "\t";
310  outFile << (uint32_t) flowId.m_lcId << "\t";
311  outFile << GetUlTxPackets (p.m_imsi, p.m_lcId) << "\t";
312  outFile << GetUlTxData (p.m_imsi, p.m_lcId) << "\t";
313  outFile << GetUlRxPackets (p.m_imsi, p.m_lcId) << "\t";
314  outFile << GetUlRxData (p.m_imsi, p.m_lcId) << "\t";
315  std::vector<double> stats = GetUlDelayStats (p.m_imsi, p.m_lcId);
316  for (std::vector<double>::iterator it = stats.begin (); it != stats.end (); ++it)
317  {
318  outFile << (*it) * 1e-9 << "\t";
319  }
320  stats = GetUlPduSizeStats (p.m_imsi, p.m_lcId);
321  for (std::vector<double>::iterator it = stats.begin (); it != stats.end (); ++it)
322  {
323  outFile << (*it) << "\t";
324  }
325  outFile << std::endl;
326  }
327 
328  outFile.close ();
329 }
330 
331 void
333 {
334  NS_LOG_FUNCTION (this);
335 
336  // Get the unique IMSI/LCID pairs list
337  std::vector < ImsiLcidPair_t > pairVector;
338  for (Uint32Map::iterator it = m_dlTxPackets.begin (); it != m_dlTxPackets.end (); ++it)
339  {
340  if (find (pairVector.begin (), pairVector.end (), (*it).first) == pairVector.end ())
341  {
342  pairVector.push_back ((*it).first);
343  }
344  }
345 
346  for (Uint32Map::iterator it = m_dlRxPackets.begin (); it != m_dlRxPackets.end (); ++it)
347  {
348  if (find (pairVector.begin (), pairVector.end (), (*it).first) == pairVector.end ())
349  {
350  pairVector.push_back ((*it).first);
351  }
352  }
353 
354  Time endTime = m_startTime + m_epochDuration;
355  for (std::vector<ImsiLcidPair_t>::iterator pair = pairVector.begin (); pair != pairVector.end (); ++pair)
356  {
357  ImsiLcidPair_t p = *pair;
358  FlowIdMap::const_iterator flowIdIt = m_flowId.find (p);
359  // \TODO Temporary workaround until traces are connected correctly in LteEnbRrc and LteUeRrc
360  if (flowIdIt == m_flowId.end ()) continue;
361 // NS_ASSERT_MSG (flowIdIt != m_flowId.end (),
362 // "FlowId (imsi " << p.m_imsi << " lcid " << (uint32_t) p.m_lcId << ") is missing");
363  LteFlowId_t flowId = flowIdIt->second;
364  NS_ASSERT_MSG (flowId.m_lcId == p.m_lcId, "lcid mismatch");
365 
366  outFile << m_startTime.GetNanoSeconds () / 1.0e9 << "\t";
367  outFile << endTime.GetNanoSeconds () / 1.0e9 << "\t";
368  outFile << GetDlCellId (p.m_imsi, p.m_lcId) << "\t";
369  outFile << p.m_imsi << "\t";
370  outFile << flowId.m_rnti << "\t";
371  outFile << (uint32_t) flowId.m_lcId << "\t";
372  outFile << GetDlTxPackets (p.m_imsi, p.m_lcId) << "\t";
373  outFile << GetDlTxData (p.m_imsi, p.m_lcId) << "\t";
374  outFile << GetDlRxPackets (p.m_imsi, p.m_lcId) << "\t";
375  outFile << GetDlRxData (p.m_imsi, p.m_lcId) << "\t";
376  std::vector<double> stats = GetDlDelayStats (p.m_imsi, p.m_lcId);
377  for (std::vector<double>::iterator it = stats.begin (); it != stats.end (); ++it)
378  {
379  outFile << (*it) * 1e-9 << "\t";
380  }
381  stats = GetDlPduSizeStats (p.m_imsi, p.m_lcId);
382  for (std::vector<double>::iterator it = stats.begin (); it != stats.end (); ++it)
383  {
384  outFile << (*it) << "\t";
385  }
386  outFile << std::endl;
387  }
388 
389  outFile.close ();
390 }
391 
392 void
394 {
395  NS_LOG_FUNCTION (this);
396 
397  m_ulTxPackets.erase (m_ulTxPackets.begin (), m_ulTxPackets.end ());
398  m_ulRxPackets.erase (m_ulRxPackets.begin (), m_ulRxPackets.end ());
399  m_ulRxData.erase (m_ulRxData.begin (), m_ulRxData.end ());
400  m_ulTxData.erase (m_ulTxData.begin (), m_ulTxData.end ());
401  m_ulDelay.erase (m_ulDelay.begin (), m_ulDelay.end ());
402  m_ulPduSize.erase (m_ulPduSize.begin (), m_ulPduSize.end ());
403 
404  m_dlTxPackets.erase (m_dlTxPackets.begin (), m_dlTxPackets.end ());
405  m_dlRxPackets.erase (m_dlRxPackets.begin (), m_dlRxPackets.end ());
406  m_dlRxData.erase (m_dlRxData.begin (), m_dlRxData.end ());
407  m_dlTxData.erase (m_dlTxData.begin (), m_dlTxData.end ());
408  m_dlDelay.erase (m_dlDelay.begin (), m_dlDelay.end ());
409  m_dlPduSize.erase (m_dlPduSize.begin (), m_dlPduSize.end ());
410 }
411 
412 void
414 {
415  NS_LOG_FUNCTION (this);
417  NS_ASSERT (Simulator::Now ().GetMilliSeconds () == 0); // below event time assumes this
419 }
420 
421 void
423 {
424  NS_LOG_FUNCTION (this);
425  ShowResults ();
426  ResetResults ();
429 }
430 
431 uint32_t
432 RadioBearerStatsCalculator::GetUlTxPackets (uint64_t imsi, uint8_t lcid)
433 {
434  NS_LOG_FUNCTION (this << imsi << (uint16_t) lcid);
435  ImsiLcidPair_t p (imsi, lcid);
436  return m_ulTxPackets[p];
437 }
438 
439 uint32_t
440 RadioBearerStatsCalculator::GetUlRxPackets (uint64_t imsi, uint8_t lcid)
441 {
442  NS_LOG_FUNCTION (this << imsi << (uint16_t) lcid);
443  ImsiLcidPair_t p (imsi, lcid);
444  return m_ulRxPackets[p];
445 }
446 
447 uint64_t
448 RadioBearerStatsCalculator::GetUlTxData (uint64_t imsi, uint8_t lcid)
449 {
450  NS_LOG_FUNCTION (this << imsi << (uint16_t) lcid);
451  ImsiLcidPair_t p (imsi, lcid);
452  return m_ulTxData[p];
453 }
454 
455 uint64_t
456 RadioBearerStatsCalculator::GetUlRxData (uint64_t imsi, uint8_t lcid)
457 {
458  NS_LOG_FUNCTION (this << imsi << (uint16_t) lcid);
459  ImsiLcidPair_t p (imsi, lcid);
460  return m_ulRxData[p];
461 }
462 
463 double
464 RadioBearerStatsCalculator::GetUlDelay (uint64_t imsi, uint8_t lcid)
465 {
466  NS_LOG_FUNCTION (this << imsi << (uint16_t) lcid);
467  ImsiLcidPair_t p (imsi, lcid);
468  Uint64StatsMap::iterator it = m_ulDelay.find (p);
469  if (it == m_ulDelay.end ())
470  {
471  NS_LOG_ERROR ("UL delay for " << imsi << " - " << (uint16_t) lcid << " not found");
472  return 0;
473 
474  }
475  return m_ulDelay[p]->getMean ();
476 }
477 
478 std::vector<double>
479 RadioBearerStatsCalculator::GetUlDelayStats (uint64_t imsi, uint8_t lcid)
480 {
481  NS_LOG_FUNCTION (this << imsi << (uint16_t) lcid);
482  ImsiLcidPair_t p (imsi, lcid);
483  std::vector<double> stats;
484  Uint64StatsMap::iterator it = m_ulDelay.find (p);
485  if (it == m_ulDelay.end ())
486  {
487  stats.push_back (0.0);
488  stats.push_back (0.0);
489  stats.push_back (0.0);
490  stats.push_back (0.0);
491  return stats;
492 
493  }
494  stats.push_back (m_ulDelay[p]->getMean ());
495  stats.push_back (m_ulDelay[p]->getStddev ());
496  stats.push_back (m_ulDelay[p]->getMin ());
497  stats.push_back (m_ulDelay[p]->getMax ());
498  return stats;
499 }
500 
501 std::vector<double>
503 {
504  NS_LOG_FUNCTION (this << imsi << (uint16_t) lcid);
505  ImsiLcidPair_t p (imsi, lcid);
506  std::vector<double> stats;
507  Uint32StatsMap::iterator it = m_ulPduSize.find (p);
508  if (it == m_ulPduSize.end ())
509  {
510  stats.push_back (0.0);
511  stats.push_back (0.0);
512  stats.push_back (0.0);
513  stats.push_back (0.0);
514  return stats;
515 
516  }
517  stats.push_back (m_ulPduSize[p]->getMean ());
518  stats.push_back (m_ulPduSize[p]->getStddev ());
519  stats.push_back (m_ulPduSize[p]->getMin ());
520  stats.push_back (m_ulPduSize[p]->getMax ());
521  return stats;
522 }
523 
524 uint32_t
525 RadioBearerStatsCalculator::GetDlTxPackets (uint64_t imsi, uint8_t lcid)
526 {
527  NS_LOG_FUNCTION (this << imsi << (uint16_t) lcid);
528  ImsiLcidPair_t p (imsi, lcid);
529  return m_dlTxPackets[p];
530 }
531 
532 uint32_t
533 RadioBearerStatsCalculator::GetDlRxPackets (uint64_t imsi, uint8_t lcid)
534 {
535  NS_LOG_FUNCTION (this << imsi << (uint16_t) lcid);
536  ImsiLcidPair_t p (imsi, lcid);
537  return m_dlRxPackets[p];
538 }
539 
540 uint64_t
541 RadioBearerStatsCalculator::GetDlTxData (uint64_t imsi, uint8_t lcid)
542 {
543  NS_LOG_FUNCTION (this << imsi << (uint16_t) lcid);
544  ImsiLcidPair_t p (imsi, lcid);
545  return m_dlTxData[p];
546 }
547 
548 uint64_t
549 RadioBearerStatsCalculator::GetDlRxData (uint64_t imsi, uint8_t lcid)
550 {
551  NS_LOG_FUNCTION (this << imsi << (uint16_t) lcid);
552  ImsiLcidPair_t p (imsi, lcid);
553  return m_dlRxData[p];
554 }
555 
556 uint32_t
557 RadioBearerStatsCalculator::GetUlCellId (uint64_t imsi, uint8_t lcid)
558 {
559  NS_LOG_FUNCTION (this << imsi << (uint16_t) lcid);
560  ImsiLcidPair_t p (imsi, lcid);
561  return m_ulCellId[p];
562 }
563 
564 uint32_t
565 RadioBearerStatsCalculator::GetDlCellId (uint64_t imsi, uint8_t lcid)
566 {
567  NS_LOG_FUNCTION (this << imsi << (uint16_t) lcid);
568  ImsiLcidPair_t p (imsi, lcid);
569  return m_dlCellId[p];
570 }
571 
572 double
573 RadioBearerStatsCalculator::GetDlDelay (uint64_t imsi, uint8_t lcid)
574 {
575  NS_LOG_FUNCTION (this << imsi << (uint16_t) lcid);
576  ImsiLcidPair_t p (imsi, lcid);
577  Uint64StatsMap::iterator it = m_dlDelay.find (p);
578  if (it == m_dlDelay.end ())
579  {
580  NS_LOG_ERROR ("DL delay for " << imsi << " not found");
581  return 0;
582  }
583  return m_dlDelay[p]->getMean ();
584 }
585 
586 std::vector<double>
587 RadioBearerStatsCalculator::GetDlDelayStats (uint64_t imsi, uint8_t lcid)
588 {
589  NS_LOG_FUNCTION (this << imsi << (uint16_t) lcid);
590  ImsiLcidPair_t p (imsi, lcid);
591  std::vector<double> stats;
592  Uint64StatsMap::iterator it = m_dlDelay.find (p);
593  if (it == m_dlDelay.end ())
594  {
595  stats.push_back (0.0);
596  stats.push_back (0.0);
597  stats.push_back (0.0);
598  stats.push_back (0.0);
599  return stats;
600 
601  }
602  stats.push_back (m_dlDelay[p]->getMean ());
603  stats.push_back (m_dlDelay[p]->getStddev ());
604  stats.push_back (m_dlDelay[p]->getMin ());
605  stats.push_back (m_dlDelay[p]->getMax ());
606  return stats;
607 }
608 
609 std::vector<double>
611 {
612  NS_LOG_FUNCTION (this << imsi << (uint16_t) lcid);
613  ImsiLcidPair_t p (imsi, lcid);
614  std::vector<double> stats;
615  Uint32StatsMap::iterator it = m_dlPduSize.find (p);
616  if (it == m_dlPduSize.end ())
617  {
618  stats.push_back (0.0);
619  stats.push_back (0.0);
620  stats.push_back (0.0);
621  stats.push_back (0.0);
622  return stats;
623 
624  }
625  stats.push_back (m_dlPduSize[p]->getMean ());
626  stats.push_back (m_dlPduSize[p]->getStddev ());
627  stats.push_back (m_dlPduSize[p]->getMin ());
628  stats.push_back (m_dlPduSize[p]->getMax ());
629  return stats;
630 }
631 
632 std::string
634 {
635  if (m_protocolType == "RLC")
636  {
638  }
639  else
640  {
641  return GetUlPdcpOutputFilename ();
642  }
643 }
644 
645 std::string
647 {
648  if (m_protocolType == "RLC")
649  {
651  }
652  else
653  {
654  return GetDlPdcpOutputFilename ();
655  }
656 }
657 
658 void
660 {
661  m_ulPdcpOutputFilename = outputFilename;
662 }
663 
664 std::string
666 {
667  return m_ulPdcpOutputFilename;
668 }
669 void
671 {
672  m_dlPdcpOutputFilename = outputFilename;
673 }
674 
675 std::string
677 {
678  return m_dlPdcpOutputFilename;
679 }
680 
681 } // namespace ns3
Ptr< const AttributeChecker > MakeStringChecker(void)
Definition: string.cc:30
Base class for ***StatsCalculator classes.
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:102
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by "...
virtual ~RadioBearerStatsCalculator()
Class destructor.
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Definition: object-base.h:45
std::string GetDlOutputFilename(void)
Get the name of the file where the downlink statistics will be stored.
static TypeId GetTypeId(void)
Register this type.
NS_ASSERT_MSG(false, "Ipv4AddressGenerator::MaskToIndex(): Impossible")
Hold variables of type string.
Definition: string.h:41
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...
Definition: assert.h:67
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:202
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.
Definition: log.h:278
Uint64Map m_ulTxData
Amount of UL TX Data by (IMSI, LCID) pair.
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.
Definition: time.cc:446
void DoDispose()
Destructor implementation.
uint32_t GetUlTxPackets(uint64_t imsi, uint8_t lcid)
Gets the number of transmitted uplink packets.
static EventId Schedule(Time const &delay, MEM mem_ptr, OBJ obj)
Schedule an event to expire after delay.
Definition: simulator.h:1381
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.
Definition: nstime.h:1076
ImsiLcidPair structure.
Definition: lte-common.h:56
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.
int64_t GetNanoSeconds(void) const
Get an approximation of the time stored in this instance in the indicated unit.
Definition: nstime.h:367
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 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
Ptr< const AttributeAccessor > MakeTimeAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method...
Definition: nstime.h:1077
static Time Now(void)
Return the current simulation virtual time.
Definition: simulator.cc:249
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.
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.
LteFlowId structure.
Definition: lte-common.h:36
uint64_t m_imsi
IMSI.
Definition: lte-common.h:58
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
Definition: log.h:270
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.
Definition: nstime.h:1014
void RescheduleEndEpoch()
Reschedules EndEpoch event.
uint8_t m_lcId
LCID.
Definition: lte-common.h:39
void Cancel(void)
This method is syntactic sugar for the ns3::Simulator::Cancel method.
Definition: event-id.cc:53
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.
Definition: log.h:254
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...
Definition: string.h:42
uint8_t m_lcId
LCID.
Definition: lte-common.h:59
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.
Definition: type-id.h:58
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition: type-id.cc:915
uint16_t m_rnti
RNTI.
Definition: lte-common.h:38
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.