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