satellite-stats-plt-helper.cc
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2014 Magister Solutions
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: Budiarto Herman <budiarto.herman@magister.fi>
19  *
20  */
21 
23 
24 #include <ns3/application-delay-probe.h>
25 #include <ns3/application.h>
26 #include <ns3/boolean.h>
27 #include <ns3/callback.h>
28 #include <ns3/data-collection-object.h>
29 #include <ns3/distribution-collector.h>
30 #include <ns3/enum.h>
31 #include <ns3/inet-socket-address.h>
32 #include <ns3/ipv4.h>
33 #include <ns3/log.h>
34 #include <ns3/mac48-address.h>
35 #include <ns3/magister-gnuplot-aggregator.h>
36 #include <ns3/multi-file-aggregator.h>
37 #include <ns3/net-device.h>
38 #include <ns3/node-container.h>
39 #include <ns3/nstime.h>
40 #include <ns3/probe.h>
41 #include <ns3/satellite-helper.h>
42 #include <ns3/satellite-id-mapper.h>
43 #include <ns3/satellite-mac.h>
44 #include <ns3/satellite-net-device.h>
45 #include <ns3/satellite-phy.h>
46 #include <ns3/satellite-time-tag.h>
47 #include <ns3/scalar-collector.h>
48 #include <ns3/singleton.h>
49 #include <ns3/string.h>
50 #include <ns3/traffic-time-tag.h>
51 #include <ns3/unit-conversion-collector.h>
52 
53 #include <sstream>
54 
55 NS_LOG_COMPONENT_DEFINE("SatStatsPltHelper");
56 
57 namespace ns3
58 {
59 
60 NS_OBJECT_ENSURE_REGISTERED(SatStatsPltHelper);
61 
62 SatStatsPltHelper::SatStatsPltHelper(Ptr<const SatHelper> satHelper)
63  : SatStatsHelper(satHelper),
64  m_averagingMode(false)
65 {
66  NS_LOG_FUNCTION(this << satHelper);
67 }
68 
70 {
71  NS_LOG_FUNCTION(this);
72 }
73 
74 TypeId // static
76 {
77  static TypeId tid =
78  TypeId("ns3::SatStatsPltHelper")
79  .SetParent<SatStatsHelper>()
80  .AddAttribute("AveragingMode",
81  "If true, all samples will be averaged before passed to aggregator. "
82  "Only affects histogram, PDF, and CDF output types.",
83  BooleanValue(false),
84  MakeBooleanAccessor(&SatStatsPltHelper::SetAveragingMode,
86  MakeBooleanChecker());
87  return tid;
88 }
89 
90 void
92 {
93  NS_LOG_FUNCTION(this << averagingMode);
94  m_averagingMode = averagingMode;
95 }
96 
97 bool
99 {
100  return m_averagingMode;
101 }
102 
103 void
105 {
106  NS_LOG_FUNCTION(this);
107 
108  switch (GetOutputType())
109  {
111  NS_FATAL_ERROR(GetOutputTypeName(GetOutputType())
112  << " is not a valid output type for this statistics.");
113  break;
114 
116  // Setup aggregator.
117  m_aggregator = CreateAggregator("ns3::MultiFileAggregator",
118  "OutputFileName",
119  StringValue(GetOutputFileName()),
120  "MultiFileMode",
121  BooleanValue(false),
122  "EnableContextPrinting",
123  BooleanValue(true),
124  "GeneralHeading",
125  StringValue(GetIdentifierHeading("plt_sec")));
126 
127  // Setup collectors.
128  m_terminalCollectors.SetType("ns3::ScalarCollector");
129  m_terminalCollectors.SetAttribute("InputDataType",
130  EnumValue(ScalarCollector::INPUT_DATA_TYPE_DOUBLE));
131  m_terminalCollectors.SetAttribute(
132  "OutputType",
133  EnumValue(ScalarCollector::OUTPUT_TYPE_AVERAGE_PER_SAMPLE));
135  m_terminalCollectors.ConnectToAggregator("Output",
136  m_aggregator,
137  &MultiFileAggregator::Write1d);
138  break;
139  }
140 
142  // Setup aggregator.
143  m_aggregator = CreateAggregator("ns3::MultiFileAggregator",
144  "OutputFileName",
145  StringValue(GetOutputFileName()),
146  "GeneralHeading",
147  StringValue(GetTimeHeading("plt_sec")));
148 
149  // Setup collectors.
150  m_terminalCollectors.SetType("ns3::UnitConversionCollector");
151  m_terminalCollectors.SetAttribute("ConversionType",
152  EnumValue(UnitConversionCollector::TRANSPARENT));
154  m_terminalCollectors.ConnectToAggregator("OutputTimeValue",
155  m_aggregator,
156  &MultiFileAggregator::Write2d);
157  break;
158  }
159 
163  if (m_averagingMode)
164  {
165  // Setup aggregator.
166  m_aggregator = CreateAggregator("ns3::MultiFileAggregator",
167  "OutputFileName",
168  StringValue(GetOutputFileName()),
169  "MultiFileMode",
170  BooleanValue(false),
171  "EnableContextPrinting",
172  BooleanValue(false),
173  "GeneralHeading",
174  StringValue(GetDistributionHeading("plt_sec")));
175  Ptr<MultiFileAggregator> fileAggregator =
176  m_aggregator->GetObject<MultiFileAggregator>();
177  NS_ASSERT(fileAggregator != nullptr);
178 
179  // Setup the final-level collector.
180  m_averagingCollector = CreateObject<DistributionCollector>();
181  DistributionCollector::OutputType_t outputType =
182  DistributionCollector::OUTPUT_TYPE_HISTOGRAM;
184  {
185  outputType = DistributionCollector::OUTPUT_TYPE_PROBABILITY;
186  }
188  {
189  outputType = DistributionCollector::OUTPUT_TYPE_CUMULATIVE;
190  }
191  m_averagingCollector->SetOutputType(outputType);
192  m_averagingCollector->SetName("0");
193  m_averagingCollector->TraceConnect(
194  "Output",
195  "0",
196  MakeCallback(&MultiFileAggregator::Write2d, fileAggregator));
197  m_averagingCollector->TraceConnect(
198  "OutputString",
199  "0",
200  MakeCallback(&MultiFileAggregator::AddContextHeading, fileAggregator));
201  m_averagingCollector->TraceConnect(
202  "Warning",
203  "0",
204  MakeCallback(&MultiFileAggregator::EnableContextWarning, fileAggregator));
205 
206  // Setup collectors.
207  m_terminalCollectors.SetType("ns3::ScalarCollector");
208  m_terminalCollectors.SetAttribute("InputDataType",
209  EnumValue(ScalarCollector::INPUT_DATA_TYPE_DOUBLE));
210  m_terminalCollectors.SetAttribute(
211  "OutputType",
212  EnumValue(ScalarCollector::OUTPUT_TYPE_AVERAGE_PER_SAMPLE));
214  Callback<void, double> callback =
215  MakeCallback(&DistributionCollector::TraceSinkDouble1, m_averagingCollector);
216  for (CollectorMap::Iterator it = m_terminalCollectors.Begin();
217  it != m_terminalCollectors.End();
218  ++it)
219  {
220  it->second->TraceConnectWithoutContext("Output", callback);
221  }
222  }
223  else
224  {
225  // Setup aggregator.
226  m_aggregator = CreateAggregator("ns3::MultiFileAggregator",
227  "OutputFileName",
228  StringValue(GetOutputFileName()),
229  "GeneralHeading",
230  StringValue(GetDistributionHeading("plt_sec")));
231 
232  // Setup collectors.
233  m_terminalCollectors.SetType("ns3::DistributionCollector");
234  DistributionCollector::OutputType_t outputType =
235  DistributionCollector::OUTPUT_TYPE_HISTOGRAM;
237  {
238  outputType = DistributionCollector::OUTPUT_TYPE_PROBABILITY;
239  }
241  {
242  outputType = DistributionCollector::OUTPUT_TYPE_CUMULATIVE;
243  }
244  m_terminalCollectors.SetAttribute("OutputType", EnumValue(outputType));
246  m_terminalCollectors.ConnectToAggregator("Output",
247  m_aggregator,
248  &MultiFileAggregator::Write2d);
249  m_terminalCollectors.ConnectToAggregator("OutputString",
250  m_aggregator,
251  &MultiFileAggregator::AddContextHeading);
252  m_terminalCollectors.ConnectToAggregator("Warning",
253  m_aggregator,
254  &MultiFileAggregator::EnableContextWarning);
255  }
256 
257  break;
258  }
259 
262  NS_FATAL_ERROR(GetOutputTypeName(GetOutputType())
263  << " is not a valid output type for this statistics.");
264  break;
265 
267  // Setup aggregator.
268  m_aggregator = CreateAggregator("ns3::MagisterGnuplotAggregator",
269  "OutputPath",
270  StringValue(GetOutputPath()),
271  "OutputFileName",
272  StringValue(GetName()));
273  Ptr<MagisterGnuplotAggregator> plotAggregator =
274  m_aggregator->GetObject<MagisterGnuplotAggregator>();
275  NS_ASSERT(plotAggregator != nullptr);
276  // plot->SetTitle ("");
277  plotAggregator->SetLegend("Time (in seconds)", "Object PLT (in seconds)");
278  plotAggregator->Set2dDatasetDefaultStyle(Gnuplot2dDataset::LINES);
279 
280  // Setup collectors.
281  m_terminalCollectors.SetType("ns3::UnitConversionCollector");
282  m_terminalCollectors.SetAttribute("ConversionType",
283  EnumValue(UnitConversionCollector::TRANSPARENT));
285  for (CollectorMap::Iterator it = m_terminalCollectors.Begin();
286  it != m_terminalCollectors.End();
287  ++it)
288  {
289  const std::string context = it->second->GetName();
290  plotAggregator->Add2dDataset(context, context);
291  }
292  m_terminalCollectors.ConnectToAggregator("OutputTimeValue",
293  m_aggregator,
294  &MagisterGnuplotAggregator::Write2d);
295  break;
296  }
297 
301  if (m_averagingMode)
302  {
303  // Setup aggregator.
304  m_aggregator = CreateAggregator("ns3::MagisterGnuplotAggregator",
305  "OutputPath",
306  StringValue(GetOutputPath()),
307  "OutputFileName",
308  StringValue(GetName()));
309  Ptr<MagisterGnuplotAggregator> plotAggregator =
310  m_aggregator->GetObject<MagisterGnuplotAggregator>();
311  NS_ASSERT(plotAggregator != nullptr);
312  // plot->SetTitle ("");
313  plotAggregator->SetLegend("Object PLT (in seconds)", "Frequency");
314  plotAggregator->Set2dDatasetDefaultStyle(Gnuplot2dDataset::LINES);
315  plotAggregator->Add2dDataset(GetName(), GetName());
317 
318  // Setup the final-level collector.
319  m_averagingCollector = CreateObject<DistributionCollector>();
320  DistributionCollector::OutputType_t outputType =
321  DistributionCollector::OUTPUT_TYPE_HISTOGRAM;
323  {
324  outputType = DistributionCollector::OUTPUT_TYPE_PROBABILITY;
325  }
327  {
328  outputType = DistributionCollector::OUTPUT_TYPE_CUMULATIVE;
329  }
330  m_averagingCollector->SetOutputType(outputType);
331  m_averagingCollector->SetName("0");
332  m_averagingCollector->TraceConnect(
333  "Output",
334  GetName(),
335  MakeCallback(&MagisterGnuplotAggregator::Write2d, plotAggregator));
337 
338  // Setup collectors.
339  m_terminalCollectors.SetType("ns3::ScalarCollector");
340  m_terminalCollectors.SetAttribute("InputDataType",
341  EnumValue(ScalarCollector::INPUT_DATA_TYPE_DOUBLE));
342  m_terminalCollectors.SetAttribute(
343  "OutputType",
344  EnumValue(ScalarCollector::OUTPUT_TYPE_AVERAGE_PER_SAMPLE));
346  Callback<void, double> callback =
347  MakeCallback(&DistributionCollector::TraceSinkDouble1, m_averagingCollector);
348  for (CollectorMap::Iterator it = m_terminalCollectors.Begin();
349  it != m_terminalCollectors.End();
350  ++it)
351  {
352  it->second->TraceConnectWithoutContext("Output", callback);
353  }
354  }
355  else
356  {
357  // Setup aggregator.
358  m_aggregator = CreateAggregator("ns3::MagisterGnuplotAggregator",
359  "OutputPath",
360  StringValue(GetOutputPath()),
361  "OutputFileName",
362  StringValue(GetName()));
363  Ptr<MagisterGnuplotAggregator> plotAggregator =
364  m_aggregator->GetObject<MagisterGnuplotAggregator>();
365  NS_ASSERT(plotAggregator != nullptr);
366  // plot->SetTitle ("");
367  plotAggregator->SetLegend("Object PLT (in seconds)", "Frequency");
368  plotAggregator->Set2dDatasetDefaultStyle(Gnuplot2dDataset::LINES);
369 
370  // Setup collectors.
371  m_terminalCollectors.SetType("ns3::DistributionCollector");
372  DistributionCollector::OutputType_t outputType =
373  DistributionCollector::OUTPUT_TYPE_HISTOGRAM;
375  {
376  outputType = DistributionCollector::OUTPUT_TYPE_PROBABILITY;
377  }
379  {
380  outputType = DistributionCollector::OUTPUT_TYPE_CUMULATIVE;
381  }
382  m_terminalCollectors.SetAttribute("OutputType", EnumValue(outputType));
384  for (CollectorMap::Iterator it = m_terminalCollectors.Begin();
385  it != m_terminalCollectors.End();
386  ++it)
387  {
388  const std::string context = it->second->GetName();
389  plotAggregator->Add2dDataset(context, context);
390  }
391  m_terminalCollectors.ConnectToAggregator("Output",
392  m_aggregator,
393  &MagisterGnuplotAggregator::Write2d);
394  }
395 
396  break;
397  }
398 
399  default:
400  NS_FATAL_ERROR("SatStatsPltHelper - Invalid output type");
401  break;
402  }
403 
404  // Setup probes and connect them to the collectors.
405  InstallProbes();
406 
407 } // end of `void DoInstall ();`
408 
409 void
411 {
412  // The method below is supposed to be implemented by the child class.
413  DoInstallProbes();
414 }
415 
416 void
417 SatStatsPltHelper::RxPltCallback(const Time& plt, const Address& from)
418 {
419  // NS_LOG_FUNCTION (this << plt.GetSeconds () << from);
420 
421  if (from.IsInvalid())
422  {
423  NS_LOG_WARN(this << " discarding a object PLT of " << plt.GetSeconds()
424  << " from statistics collection because of"
425  << " invalid sender address");
426  }
427  else
428  {
429  // Determine the identifier associated with the sender address.
430  std::map<const Address, uint32_t>::const_iterator it = m_identifierMap.find(from);
431 
432  if (it != m_identifierMap.end())
433  {
434  PassSampleToCollector(plt, it->second);
435  }
436  else
437  {
438  NS_LOG_WARN(this << " discarding a object PLT of " << plt.GetSeconds()
439  << " from statistics collection because of"
440  << " unknown sender address " << from);
441  }
442  }
443 }
444 
445 void
447 {
448  NS_LOG_FUNCTION(this << utNode->GetId());
449 
450  const SatIdMapper* satIdMapper = Singleton<SatIdMapper>::Get();
451  const Address addr = satIdMapper->GetUtMacWithNode(utNode);
452 
453  if (addr.IsInvalid())
454  {
455  NS_LOG_WARN(this << " Node " << utNode->GetId() << " is not a valid UT");
456  }
457  else
458  {
459  const uint32_t identifier = GetIdentifierForUt(utNode);
460  m_identifierMap[addr] = identifier;
461  NS_LOG_INFO(this << " associated address " << addr << " with identifier " << identifier);
462  }
463 }
464 
465 bool
466 SatStatsPltHelper::ConnectProbeToCollector(Ptr<Probe> probe, uint32_t identifier)
467 {
468  NS_LOG_FUNCTION(this << probe << probe->GetName() << identifier);
469 
470  bool ret = false;
471  switch (GetOutputType())
472  {
475  ret = m_terminalCollectors.ConnectWithProbe(probe,
476  "OutputSeconds",
477  identifier,
478  &ScalarCollector::TraceSinkDouble);
479  break;
480 
483  ret = m_terminalCollectors.ConnectWithProbe(probe,
484  "OutputSeconds",
485  identifier,
486  &UnitConversionCollector::TraceSinkDouble);
487  break;
488 
495  if (m_averagingMode)
496  {
497  ret = m_terminalCollectors.ConnectWithProbe(probe,
498  "OutputSeconds",
499  identifier,
500  &ScalarCollector::TraceSinkDouble);
501  }
502  else
503  {
504  ret = m_terminalCollectors.ConnectWithProbe(probe,
505  "OutputSeconds",
506  identifier,
507  &DistributionCollector::TraceSinkDouble);
508  }
509  break;
510 
511  default:
512  NS_FATAL_ERROR(GetOutputTypeName(GetOutputType())
513  << " is not a valid output type for this statistics.");
514  break;
515  }
516 
517  if (ret)
518  {
519  NS_LOG_INFO(this << " created probe " << probe->GetName() << ", connected to collector "
520  << identifier);
521  }
522  else
523  {
524  NS_LOG_WARN(this << " unable to connect probe " << probe->GetName() << " to collector "
525  << identifier);
526  }
527 
528  return ret;
529 }
530 
531 void
532 SatStatsPltHelper::PassSampleToCollector(const Time& plt, uint32_t identifier)
533 {
534  // NS_LOG_FUNCTION (this << plt.GetSeconds () << identifier);
535 
536  Ptr<DataCollectionObject> collector = m_terminalCollectors.Get(identifier);
537  NS_ASSERT_MSG(collector != nullptr, "Unable to find collector with identifier " << identifier);
538 
539  switch (GetOutputType())
540  {
543  Ptr<ScalarCollector> c = collector->GetObject<ScalarCollector>();
544  NS_ASSERT(c != nullptr);
545  c->TraceSinkDouble(0.0, plt.GetSeconds());
546  break;
547  }
548 
551  Ptr<UnitConversionCollector> c = collector->GetObject<UnitConversionCollector>();
552  NS_ASSERT(c != nullptr);
553  c->TraceSinkDouble(0.0, plt.GetSeconds());
554  break;
555  }
556 
563  if (m_averagingMode)
564  {
565  Ptr<ScalarCollector> c = collector->GetObject<ScalarCollector>();
566  NS_ASSERT(c != nullptr);
567  c->TraceSinkDouble(0.0, plt.GetSeconds());
568  }
569  else
570  {
571  Ptr<DistributionCollector> c = collector->GetObject<DistributionCollector>();
572  NS_ASSERT(c != nullptr);
573  c->TraceSinkDouble(0.0, plt.GetSeconds());
574  }
575  break;
576 
577  default:
578  NS_FATAL_ERROR(GetOutputTypeName(GetOutputType())
579  << " is not a valid output type for this statistics.");
580  break;
581 
582  } // end of `switch (GetOutputType ())`
583 
584 } // end of `void PassSampleToCollector (Time, uint32_t)`
585 
586 // FORWARD LINK APPLICATION-LEVEL /////////////////////////////////////////////
587 
588 NS_OBJECT_ENSURE_REGISTERED(SatStatsFwdAppPltHelper);
589 
591  : SatStatsPltHelper(satHelper)
592 {
593  NS_LOG_FUNCTION(this << satHelper);
594 }
595 
597 {
598  NS_LOG_FUNCTION(this);
599 }
600 
601 TypeId // static
603 {
604  static TypeId tid = TypeId("ns3::SatStatsFwdAppPltHelper").SetParent<SatStatsPltHelper>();
605  return tid;
606 }
607 
608 void
610 {
611  NS_LOG_FUNCTION(this);
612  NodeContainer utUsers = GetSatHelper()->GetUtUsers();
613 
614  for (NodeContainer::Iterator it = utUsers.Begin(); it != utUsers.End(); ++it)
615  {
616  const int32_t utUserId = GetUtUserId(*it);
617  NS_ASSERT_MSG(utUserId > 0, "Node " << (*it)->GetId() << " is not a valid UT user");
618  const uint32_t identifier = GetIdentifierForUtUser(*it);
619 
620  for (uint32_t i = 0; i < (*it)->GetNApplications(); i++)
621  {
622  Ptr<Application> app = (*it)->GetApplication(i);
623  bool isConnected = false;
624 
625  if (app->GetInstanceTypeId().LookupTraceSourceByName("RxPlt") != nullptr)
626  {
627  NS_LOG_INFO(this << " attempt to connect using RxPlt");
628 
629  // Create the probe.
630  std::ostringstream probeName;
631  probeName << utUserId << "-" << i;
632  Ptr<ApplicationDelayProbe> probe = CreateObject<ApplicationDelayProbe>();
633  probe->SetName(probeName.str());
634 
635  // Connect the object to the probe.
636  if (probe->ConnectByObject("RxPlt", app))
637  {
638  isConnected = ConnectProbeToCollector(probe, identifier);
639  m_probes.push_back(probe->GetObject<Probe>());
640  }
641  }
642 
643  if (isConnected)
644  {
645  NS_LOG_INFO(this << " successfully connected"
646  << " with node ID " << (*it)->GetId() << " application #" << i);
647  }
648  else
649  {
650  /*
651  * We're being tolerant here by only logging a warning, because
652  * not every kind of Application is equipped with the expected
653  * RxPlt or Rx trace source.
654  */
655  NS_LOG_WARN(this << " unable to connect"
656  << " with node ID " << (*it)->GetId() << " application #" << i);
657  }
658 
659  } // end of `for (i = 0; i < (*it)->GetNApplications (); i++)`
660 
661  } // end of `for (it = utUsers.Begin(); it != utUsers.End (); ++it)`
662 
663 } // end of `void DoInstallProbes ();`
664 
665 // RETURN LINK APPLICATION-LEVEL //////////////////////////////////////////////
666 
667 NS_OBJECT_ENSURE_REGISTERED(SatStatsRtnAppPltHelper);
668 
670  : SatStatsPltHelper(satHelper)
671 {
672  NS_LOG_FUNCTION(this << satHelper);
673 }
674 
676 {
677  NS_LOG_FUNCTION(this);
678 }
679 
680 TypeId // static
682 {
683  static TypeId tid = TypeId("ns3::SatStatsRtnAppPltHelper").SetParent<SatStatsPltHelper>();
684  return tid;
685 }
686 
687 void
689 {
690  NS_LOG_FUNCTION(this);
691 
692  // Connect to trace sources at GW user node's applications.
693  NodeContainer gwUsers = GetSatHelper()->GetGwUsers();
694  Callback<void, const Time&, const Address&> rxPltCallback =
695  MakeCallback(&SatStatsRtnAppPltHelper::Ipv4Callback, this);
696 
697  for (NodeContainer::Iterator it = gwUsers.Begin(); it != gwUsers.End(); ++it)
698  {
699  for (uint32_t i = 0; i < (*it)->GetNApplications(); i++)
700  {
701  Ptr<Application> app = (*it)->GetApplication(i);
702  bool isConnected = false;
703 
704  if (app->GetInstanceTypeId().LookupTraceSourceByName("RxPlt") != nullptr)
705  {
706  isConnected = app->TraceConnectWithoutContext("RxPlt", rxPltCallback);
707  }
708 
709  if (isConnected)
710  {
711  NS_LOG_INFO(this << " successfully connected"
712  << " with node ID " << (*it)->GetId() << " application #" << i);
713  }
714  else
715  {
716  /*
717  * We're being tolerant here by only logging a warning, because
718  * not every kind of Application is equipped with the expected
719  * RxPlt or Rx trace source.
720  */
721  NS_LOG_WARN(this << " unable to connect"
722  << " with node ID " << (*it)->GetId() << " application #" << i);
723  }
724 
725  } // end of `for (i = 0; i < (*it)->GetNApplications (); i++)`
726 
727  } // end of `for (NodeContainer::Iterator it: gwUsers)`
728 
729 } // end of `void DoInstallProbes ();`
730 
731 void
732 SatStatsRtnAppPltHelper::Ipv4Callback(const Time& plt, const Address& from)
733 {
734  // NS_LOG_FUNCTION (this << Time.GetSeconds () << from);
735 
736  if (InetSocketAddress::IsMatchingType(from))
737  {
738  // Determine the identifier associated with the sender address.
739  const Address ipv4Addr = InetSocketAddress::ConvertFrom(from).GetIpv4();
740  std::map<const Address, uint32_t>::const_iterator it1 = m_identifierMap.find(ipv4Addr);
741 
742  if (it1 == m_identifierMap.end())
743  {
744  NS_LOG_WARN(this << " discarding a object PLT of " << plt.GetSeconds()
745  << " from statistics collection because of"
746  << " unknown sender IPV4 address " << ipv4Addr);
747  }
748  else
749  {
750  PassSampleToCollector(plt, it1->second);
751  }
752  }
753  else
754  {
755  NS_LOG_WARN(this << " discarding a object PLT of " << plt.GetSeconds()
756  << " from statistics collection"
757  << " because it comes from sender " << from
758  << " without valid InetSocketAddress");
759  }
760 }
761 
762 void
764 {
765  NS_LOG_FUNCTION(this << utUserNode->GetId());
766 
767  Ptr<Ipv4> ipv4 = utUserNode->GetObject<Ipv4>();
768 
769  if (ipv4 == nullptr)
770  {
771  NS_LOG_INFO(this << " Node " << utUserNode->GetId() << " does not support IPv4 protocol");
772  }
773  else if (ipv4->GetNInterfaces() >= 2)
774  {
775  const uint32_t identifier = GetIdentifierForUtUser(utUserNode);
776 
777  /*
778  * Assuming that #0 is for loopback interface and #1 is for subscriber
779  * network interface.
780  */
781  for (uint32_t i = 0; i < ipv4->GetNAddresses(1); i++)
782  {
783  const Address addr = ipv4->GetAddress(1, i).GetLocal();
784  m_identifierMap[addr] = identifier;
785  NS_LOG_INFO(this << " associated address " << addr << " with identifier "
786  << identifier);
787  }
788  }
789  else
790  {
791  NS_LOG_WARN(this << " Node " << utUserNode->GetId() << " is not a valid UT user");
792  }
793 }
794 
795 } // end of namespace ns3
Class for ID-mapper.
Address GetUtMacWithNode(Ptr< Node > utNode) const
virtual ~SatStatsFwdAppPltHelper()
Destructor for SatStatsFwdAppPltHelper.
SatStatsFwdAppPltHelper(Ptr< const SatHelper > satHelper)
std::list< Ptr< Probe > > m_probes
Maintains a list of probes created by this helper.
static TypeId GetTypeId()
inherited from ObjectBase base class
Parent abstract class of all satellite statistics helpers.
Ptr< const SatHelper > GetSatHelper() const
uint32_t GetIdentifierForUtUser(Ptr< Node > utUserNode) const
static std::string GetOutputTypeName(OutputType_t outputType)
virtual std::string GetIdentifierHeading(std::string dataLabel) const
virtual std::string GetOutputPath() const
Ptr< DataCollectionObject > CreateAggregator(std::string aggregatorTypeId, std::string n1="", const AttributeValue &v1=EmptyAttributeValue(), std::string n2="", const AttributeValue &v2=EmptyAttributeValue(), std::string n3="", const AttributeValue &v3=EmptyAttributeValue(), std::string n4="", const AttributeValue &v4=EmptyAttributeValue(), std::string n5="", const AttributeValue &v5=EmptyAttributeValue())
Create the aggregator according to the output type.
virtual std::string GetOutputFileName() const
Compute the path and file name where statistics output should be written to.
uint32_t CreateCollectorPerIdentifier(CollectorMap &collectorMap) const
Create one collector instance for each identifier in the simulation.
OutputType_t GetOutputType() const
uint32_t GetIdentifierForUt(Ptr< Node > utNode) const
uint32_t GetUtUserId(Ptr< Node > utUserNode) const
std::string GetName() const
virtual std::string GetTimeHeading(std::string dataLabel) const
virtual std::string GetDistributionHeading(std::string dataLabel) const
Base class for PLT statistics helpers.
static TypeId GetTypeId()
inherited from ObjectBase base class
virtual void DoInstallProbes()=0
void RxPltCallback(const Time &plt, const Address &from)
Receive inputs from trace sources and determine the right collector to forward the inputs to.
void DoInstall()
Install the probes, collectors, and aggregators necessary to produce the statistics output.
CollectorMap m_terminalCollectors
Maintains a list of collectors created by this helper.
Ptr< DistributionCollector > m_averagingCollector
The final collector utilized in averaged output (histogram, PDF, and CDF).
bool ConnectProbeToCollector(Ptr< Probe > probe, uint32_t identifier)
Connect the probe to the right collector.
bool m_averagingMode
AveragingMode attribute.
void SetAveragingMode(bool averagingMode)
virtual ~SatStatsPltHelper()
/ Destructor.
void SaveAddressAndIdentifier(Ptr< Node > utNode)
Save the address and the proper identifier from the given UT node.
SatStatsPltHelper(Ptr< const SatHelper > satHelper)
void InstallProbes()
Set up several probes or other means of listeners and connect them to the collectors.
Ptr< DataCollectionObject > m_aggregator
The aggregator created by this helper.
void PassSampleToCollector(const Time &plt, uint32_t identifier)
Find a collector with the right identifier and pass a sample data to it.
std::map< const Address, uint32_t > m_identifierMap
Map of address and the identifier associated with it (for return link).
void Ipv4Callback(const Time &plt, const Address &from)
Receive inputs from trace sources and determine the right collector to forward the inputs to.
virtual ~SatStatsRtnAppPltHelper()
/ Destructor.
void SaveIpv4AddressAndIdentifier(Ptr< Node > utUserNode)
Save the IPv4 address and the proper identifier from the given UT user node.
static TypeId GetTypeId()
inherited from ObjectBase base class
SatStatsRtnAppPltHelper(Ptr< const SatHelper > satHelper)
SatArqSequenceNumber is handling the sequence numbers for the ARQ process.