satellite-stats-link-delay-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: Bastien Tauran <bastien.tauran@viveris.fr>
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-orbiter-net-device.h>
46 #include <ns3/satellite-phy.h>
47 #include <ns3/satellite-time-tag.h>
48 #include <ns3/satellite-topology.h>
49 #include <ns3/scalar-collector.h>
50 #include <ns3/singleton.h>
51 #include <ns3/string.h>
52 #include <ns3/traffic-time-tag.h>
53 #include <ns3/unit-conversion-collector.h>
54 
55 #include <map>
56 #include <sstream>
57 #include <string>
58 #include <utility>
59 
60 NS_LOG_COMPONENT_DEFINE("SatStatsLinkDelayHelper");
61 
62 namespace ns3
63 {
64 
65 NS_OBJECT_ENSURE_REGISTERED(SatStatsLinkDelayHelper);
66 
67 SatStatsLinkDelayHelper::SatStatsLinkDelayHelper(Ptr<const SatHelper> satHelper)
68  : SatStatsHelper(satHelper),
69  m_averagingMode(false)
70 {
71  NS_LOG_FUNCTION(this << satHelper);
72 }
73 
75 {
76  NS_LOG_FUNCTION(this);
77 }
78 
79 TypeId // static
81 {
82  static TypeId tid =
83  TypeId("ns3::SatStatsLinkDelayHelper")
84  .SetParent<SatStatsHelper>()
85  .AddAttribute("AveragingMode",
86  "If true, all samples will be averaged before passed to aggregator. "
87  "Only affects histogram, PDF, and CDF output types.",
88  BooleanValue(false),
89  MakeBooleanAccessor(&SatStatsLinkDelayHelper::SetAveragingMode,
91  MakeBooleanChecker());
92  return tid;
93 }
94 
95 void
97 {
98  NS_LOG_FUNCTION(this << averagingMode);
99  m_averagingMode = averagingMode;
100 }
101 
102 bool
104 {
105  return m_averagingMode;
106 }
107 
108 void
110 {
111  NS_LOG_FUNCTION(this);
112 
113  switch (GetOutputType())
114  {
116  NS_FATAL_ERROR(GetOutputTypeName(GetOutputType())
117  << " is not a valid output type for this statistics.");
118  break;
119 
121  // Setup aggregator.
122  m_aggregator = CreateAggregator("ns3::MultiFileAggregator",
123  "OutputFileName",
124  StringValue(GetOutputFileName()),
125  "MultiFileMode",
126  BooleanValue(false),
127  "EnableContextPrinting",
128  BooleanValue(true),
129  "GeneralHeading",
130  StringValue(GetIdentifierHeading("delay_sec")));
131 
132  // Setup collectors.
133  m_terminalCollectors.SetType("ns3::ScalarCollector");
134  m_terminalCollectors.SetAttribute("InputDataType",
135  EnumValue(ScalarCollector::INPUT_DATA_TYPE_DOUBLE));
136  m_terminalCollectors.SetAttribute(
137  "OutputType",
138  EnumValue(ScalarCollector::OUTPUT_TYPE_AVERAGE_PER_SAMPLE));
140  m_terminalCollectors.ConnectToAggregator("Output",
141  m_aggregator,
142  &MultiFileAggregator::Write1d);
143  break;
144  }
145 
147  // Setup aggregator.
148  m_aggregator = CreateAggregator("ns3::MultiFileAggregator",
149  "OutputFileName",
150  StringValue(GetOutputFileName()),
151  "GeneralHeading",
152  StringValue(GetTimeHeading("delay_sec")));
153 
154  // Setup collectors.
155  m_terminalCollectors.SetType("ns3::UnitConversionCollector");
156  m_terminalCollectors.SetAttribute("ConversionType",
157  EnumValue(UnitConversionCollector::TRANSPARENT));
159  m_terminalCollectors.ConnectToAggregator("OutputTimeValue",
160  m_aggregator,
161  &MultiFileAggregator::Write2d);
162  break;
163  }
164 
168  if (m_averagingMode)
169  {
170  // Setup aggregator.
171  m_aggregator = CreateAggregator("ns3::MultiFileAggregator",
172  "OutputFileName",
173  StringValue(GetOutputFileName()),
174  "MultiFileMode",
175  BooleanValue(false),
176  "EnableContextPrinting",
177  BooleanValue(false),
178  "GeneralHeading",
179  StringValue(GetDistributionHeading("delay_sec")));
180  Ptr<MultiFileAggregator> fileAggregator =
181  m_aggregator->GetObject<MultiFileAggregator>();
182  NS_ASSERT(fileAggregator != nullptr);
183 
184  // Setup the final-level collector.
185  m_averagingCollector = CreateObject<DistributionCollector>();
186  DistributionCollector::OutputType_t outputType =
187  DistributionCollector::OUTPUT_TYPE_HISTOGRAM;
189  {
190  outputType = DistributionCollector::OUTPUT_TYPE_PROBABILITY;
191  }
193  {
194  outputType = DistributionCollector::OUTPUT_TYPE_CUMULATIVE;
195  }
196  m_averagingCollector->SetOutputType(outputType);
197  m_averagingCollector->SetName("0");
198  m_averagingCollector->TraceConnect(
199  "Output",
200  "0",
201  MakeCallback(&MultiFileAggregator::Write2d, fileAggregator));
202  m_averagingCollector->TraceConnect(
203  "OutputString",
204  "0",
205  MakeCallback(&MultiFileAggregator::AddContextHeading, fileAggregator));
206  m_averagingCollector->TraceConnect(
207  "Warning",
208  "0",
209  MakeCallback(&MultiFileAggregator::EnableContextWarning, fileAggregator));
210 
211  // Setup collectors.
212  m_terminalCollectors.SetType("ns3::ScalarCollector");
213  m_terminalCollectors.SetAttribute("InputDataType",
214  EnumValue(ScalarCollector::INPUT_DATA_TYPE_DOUBLE));
215  m_terminalCollectors.SetAttribute(
216  "OutputType",
217  EnumValue(ScalarCollector::OUTPUT_TYPE_AVERAGE_PER_SAMPLE));
219  Callback<void, double> callback =
220  MakeCallback(&DistributionCollector::TraceSinkDouble1, m_averagingCollector);
221  for (CollectorMap::Iterator it = m_terminalCollectors.Begin();
222  it != m_terminalCollectors.End();
223  ++it)
224  {
225  it->second->TraceConnectWithoutContext("Output", callback);
226  }
227  }
228  else
229  {
230  // Setup aggregator.
231  m_aggregator = CreateAggregator("ns3::MultiFileAggregator",
232  "OutputFileName",
233  StringValue(GetOutputFileName()),
234  "GeneralHeading",
235  StringValue(GetDistributionHeading("delay_sec")));
236 
237  // Setup collectors.
238  m_terminalCollectors.SetType("ns3::DistributionCollector");
239  DistributionCollector::OutputType_t outputType =
240  DistributionCollector::OUTPUT_TYPE_HISTOGRAM;
242  {
243  outputType = DistributionCollector::OUTPUT_TYPE_PROBABILITY;
244  }
246  {
247  outputType = DistributionCollector::OUTPUT_TYPE_CUMULATIVE;
248  }
249  m_terminalCollectors.SetAttribute("OutputType", EnumValue(outputType));
251  m_terminalCollectors.ConnectToAggregator("Output",
252  m_aggregator,
253  &MultiFileAggregator::Write2d);
254  m_terminalCollectors.ConnectToAggregator("OutputString",
255  m_aggregator,
256  &MultiFileAggregator::AddContextHeading);
257  m_terminalCollectors.ConnectToAggregator("Warning",
258  m_aggregator,
259  &MultiFileAggregator::EnableContextWarning);
260  }
261 
262  break;
263  }
264 
267  NS_FATAL_ERROR(GetOutputTypeName(GetOutputType())
268  << " is not a valid output type for this statistics.");
269  break;
270 
272  // Setup aggregator.
273  m_aggregator = CreateAggregator("ns3::MagisterGnuplotAggregator",
274  "OutputPath",
275  StringValue(GetOutputPath()),
276  "OutputFileName",
277  StringValue(GetName()));
278  Ptr<MagisterGnuplotAggregator> plotAggregator =
279  m_aggregator->GetObject<MagisterGnuplotAggregator>();
280  NS_ASSERT(plotAggregator != nullptr);
281  // plot->SetTitle ("");
282  plotAggregator->SetLegend("Time (in seconds)", "Packet delay (in seconds)");
283  plotAggregator->Set2dDatasetDefaultStyle(Gnuplot2dDataset::LINES);
284 
285  // Setup collectors.
286  m_terminalCollectors.SetType("ns3::UnitConversionCollector");
287  m_terminalCollectors.SetAttribute("ConversionType",
288  EnumValue(UnitConversionCollector::TRANSPARENT));
290  for (CollectorMap::Iterator it = m_terminalCollectors.Begin();
291  it != m_terminalCollectors.End();
292  ++it)
293  {
294  const std::string context = it->second->GetName();
295  plotAggregator->Add2dDataset(context, context);
296  }
297  m_terminalCollectors.ConnectToAggregator("OutputTimeValue",
298  m_aggregator,
299  &MagisterGnuplotAggregator::Write2d);
300  break;
301  }
302 
306  if (m_averagingMode)
307  {
308  // Setup aggregator.
309  m_aggregator = CreateAggregator("ns3::MagisterGnuplotAggregator",
310  "OutputPath",
311  StringValue(GetOutputPath()),
312  "OutputFileName",
313  StringValue(GetName()));
314  Ptr<MagisterGnuplotAggregator> plotAggregator =
315  m_aggregator->GetObject<MagisterGnuplotAggregator>();
316  NS_ASSERT(plotAggregator != nullptr);
317  // plot->SetTitle ("");
318  plotAggregator->SetLegend("Packet delay (in seconds)", "Frequency");
319  plotAggregator->Set2dDatasetDefaultStyle(Gnuplot2dDataset::LINES);
320  plotAggregator->Add2dDataset(GetName(), GetName());
322 
323  // Setup the final-level collector.
324  m_averagingCollector = CreateObject<DistributionCollector>();
325  DistributionCollector::OutputType_t outputType =
326  DistributionCollector::OUTPUT_TYPE_HISTOGRAM;
328  {
329  outputType = DistributionCollector::OUTPUT_TYPE_PROBABILITY;
330  }
332  {
333  outputType = DistributionCollector::OUTPUT_TYPE_CUMULATIVE;
334  }
335  m_averagingCollector->SetOutputType(outputType);
336  m_averagingCollector->SetName("0");
337  m_averagingCollector->TraceConnect(
338  "Output",
339  GetName(),
340  MakeCallback(&MagisterGnuplotAggregator::Write2d, plotAggregator));
342 
343  // Setup collectors.
344  m_terminalCollectors.SetType("ns3::ScalarCollector");
345  m_terminalCollectors.SetAttribute("InputDataType",
346  EnumValue(ScalarCollector::INPUT_DATA_TYPE_DOUBLE));
347  m_terminalCollectors.SetAttribute(
348  "OutputType",
349  EnumValue(ScalarCollector::OUTPUT_TYPE_AVERAGE_PER_SAMPLE));
351  Callback<void, double> callback =
352  MakeCallback(&DistributionCollector::TraceSinkDouble1, m_averagingCollector);
353  for (CollectorMap::Iterator it = m_terminalCollectors.Begin();
354  it != m_terminalCollectors.End();
355  ++it)
356  {
357  it->second->TraceConnectWithoutContext("Output", callback);
358  }
359  }
360  else
361  {
362  // Setup aggregator.
363  m_aggregator = CreateAggregator("ns3::MagisterGnuplotAggregator",
364  "OutputPath",
365  StringValue(GetOutputPath()),
366  "OutputFileName",
367  StringValue(GetName()));
368  Ptr<MagisterGnuplotAggregator> plotAggregator =
369  m_aggregator->GetObject<MagisterGnuplotAggregator>();
370  NS_ASSERT(plotAggregator != nullptr);
371  // plot->SetTitle ("");
372  plotAggregator->SetLegend("Packet delay (in seconds)", "Frequency");
373  plotAggregator->Set2dDatasetDefaultStyle(Gnuplot2dDataset::LINES);
374 
375  // Setup collectors.
376  m_terminalCollectors.SetType("ns3::DistributionCollector");
377  DistributionCollector::OutputType_t outputType =
378  DistributionCollector::OUTPUT_TYPE_HISTOGRAM;
380  {
381  outputType = DistributionCollector::OUTPUT_TYPE_PROBABILITY;
382  }
384  {
385  outputType = DistributionCollector::OUTPUT_TYPE_CUMULATIVE;
386  }
387  m_terminalCollectors.SetAttribute("OutputType", EnumValue(outputType));
389  for (CollectorMap::Iterator it = m_terminalCollectors.Begin();
390  it != m_terminalCollectors.End();
391  ++it)
392  {
393  const std::string context = it->second->GetName();
394  plotAggregator->Add2dDataset(context, context);
395  }
396  m_terminalCollectors.ConnectToAggregator("Output",
397  m_aggregator,
398  &MagisterGnuplotAggregator::Write2d);
399  }
400 
401  break;
402  }
403 
404  default:
405  NS_FATAL_ERROR("SatStatsLinkDelayHelper - Invalid output type");
406  break;
407  }
408 
409  // Setup probes and connect them to the collectors.
410  InstallProbes();
411 
412 } // end of `void DoInstall ();`
413 
414 void
416 {
417  // The method below is supposed to be implemented by the child class.
418  DoInstallProbes();
419 }
420 
421 void
422 SatStatsLinkDelayHelper::RxLinkDelayCallback(const Time& delay, const Address& from)
423 {
424  // NS_LOG_FUNCTION (this << delay.GetSeconds () << from);
425 
426  if (from.IsInvalid())
427  {
428  NS_LOG_WARN(this << " discarding a packet delay of " << delay.GetSeconds()
429  << " from statistics collection because of"
430  << " invalid sender address");
431  }
432  else if (Mac48Address::ConvertFrom(from).IsBroadcast())
433  {
434  for (std::pair<const Address, uint32_t> item : m_identifierMap)
435  {
436  PassSampleToCollector(delay, item.second);
437  }
438  }
439  else
440  {
441  // Determine the identifier associated with the sender address.
442  std::map<const Address, uint32_t>::const_iterator it = m_identifierMap.find(from);
443 
444  if (it != m_identifierMap.end())
445  {
446  PassSampleToCollector(delay, it->second);
447  }
448  else
449  {
450  NS_LOG_WARN(this << " discarding a packet delay of " << delay.GetSeconds()
451  << " from statistics collection because of"
452  << " unknown sender address " << from);
453  }
454  }
455 }
456 
457 bool
458 SatStatsLinkDelayHelper::ConnectProbeToCollector(Ptr<Probe> probe, uint32_t identifier)
459 {
460  NS_LOG_FUNCTION(this << probe << probe->GetName() << identifier);
461 
462  bool ret = false;
463  switch (GetOutputType())
464  {
467  ret = m_terminalCollectors.ConnectWithProbe(probe,
468  "OutputSeconds",
469  identifier,
470  &ScalarCollector::TraceSinkDouble);
471  break;
472 
475  ret = m_terminalCollectors.ConnectWithProbe(probe,
476  "OutputSeconds",
477  identifier,
478  &UnitConversionCollector::TraceSinkDouble);
479  break;
480 
487  if (m_averagingMode)
488  {
489  ret = m_terminalCollectors.ConnectWithProbe(probe,
490  "OutputSeconds",
491  identifier,
492  &ScalarCollector::TraceSinkDouble);
493  }
494  else
495  {
496  ret = m_terminalCollectors.ConnectWithProbe(probe,
497  "OutputSeconds",
498  identifier,
499  &DistributionCollector::TraceSinkDouble);
500  }
501  break;
502 
503  default:
504  NS_FATAL_ERROR(GetOutputTypeName(GetOutputType())
505  << " is not a valid output type for this statistics.");
506  break;
507  }
508 
509  if (ret)
510  {
511  NS_LOG_INFO(this << " created probe " << probe->GetName() << ", connected to collector "
512  << identifier);
513  }
514  else
515  {
516  NS_LOG_WARN(this << " unable to connect probe " << probe->GetName() << " to collector "
517  << identifier);
518  }
519 
520  return ret;
521 }
522 
523 bool
524 SatStatsLinkDelayHelper::DisconnectProbeFromCollector(Ptr<Probe> probe, uint32_t identifier)
525 {
526  NS_LOG_FUNCTION(this << probe << probe->GetName() << identifier);
527 
528  bool ret = false;
529  switch (GetOutputType())
530  {
533  ret = m_terminalCollectors.DisconnectWithProbe(probe,
534  "OutputSeconds",
535  identifier,
536  &ScalarCollector::TraceSinkDouble);
537  break;
538 
541  ret = m_terminalCollectors.DisconnectWithProbe(probe,
542  "OutputSeconds",
543  identifier,
544  &UnitConversionCollector::TraceSinkDouble);
545  break;
546 
553  if (m_averagingMode)
554  {
555  ret = m_terminalCollectors.DisconnectWithProbe(probe,
556  "OutputSeconds",
557  identifier,
558  &ScalarCollector::TraceSinkDouble);
559  }
560  else
561  {
562  ret = m_terminalCollectors.DisconnectWithProbe(probe,
563  "OutputSeconds",
564  identifier,
565  &DistributionCollector::TraceSinkDouble);
566  }
567  break;
568 
569  default:
570  NS_FATAL_ERROR(GetOutputTypeName(GetOutputType())
571  << " is not a valid output type for this statistics.");
572  break;
573  }
574 
575  if (ret)
576  {
577  NS_LOG_INFO(this << " probe " << probe->GetName() << ", disconnected from collector "
578  << identifier);
579  }
580  else
581  {
582  NS_LOG_WARN(this << " unable to disconnect probe " << probe->GetName() << " from collector "
583  << identifier);
584  }
585 
586  return ret;
587 }
588 
589 void
590 SatStatsLinkDelayHelper::PassSampleToCollector(const Time& delay, uint32_t identifier)
591 {
592  // NS_LOG_FUNCTION (this << delay.GetSeconds () << identifier);
593 
594  Ptr<DataCollectionObject> collector = m_terminalCollectors.Get(identifier);
595  NS_ASSERT_MSG(collector != nullptr, "Unable to find collector with identifier " << identifier);
596 
597  switch (GetOutputType())
598  {
601  Ptr<ScalarCollector> c = collector->GetObject<ScalarCollector>();
602  NS_ASSERT(c != nullptr);
603  c->TraceSinkDouble(0.0, delay.GetSeconds());
604  break;
605  }
606 
609  Ptr<UnitConversionCollector> c = collector->GetObject<UnitConversionCollector>();
610  NS_ASSERT(c != nullptr);
611  c->TraceSinkDouble(0.0, delay.GetSeconds());
612  break;
613  }
614 
621  if (m_averagingMode)
622  {
623  Ptr<ScalarCollector> c = collector->GetObject<ScalarCollector>();
624  NS_ASSERT(c != nullptr);
625  c->TraceSinkDouble(0.0, delay.GetSeconds());
626  }
627  else
628  {
629  Ptr<DistributionCollector> c = collector->GetObject<DistributionCollector>();
630  NS_ASSERT(c != nullptr);
631  c->TraceSinkDouble(0.0, delay.GetSeconds());
632  }
633  break;
634 
635  default:
636  NS_FATAL_ERROR(GetOutputTypeName(GetOutputType())
637  << " is not a valid output type for this statistics.");
638  break;
639 
640  } // end of `switch (GetOutputType ())`
641 
642 } // end of `void PassSampleToCollector (Time, uint32_t)`
643 
644 // FORWARD FEEDER LINK DEV-LEVEL /////////////////////////////////////////////////////
645 
646 NS_OBJECT_ENSURE_REGISTERED(SatStatsFwdFeederDevLinkDelayHelper);
647 
649  Ptr<const SatHelper> satHelper)
650  : SatStatsLinkDelayHelper(satHelper)
651 {
652  NS_LOG_FUNCTION(this << satHelper);
653 }
654 
656 {
657  NS_LOG_FUNCTION(this);
658 }
659 
660 TypeId // static
662 {
663  static TypeId tid =
664  TypeId("ns3::SatStatsFwdFeederDevLinkDelayHelper").SetParent<SatStatsLinkDelayHelper>();
665  return tid;
666 }
667 
668 void
670 {
671  NS_LOG_FUNCTION(this);
672 
673  NodeContainer sats = Singleton<SatTopology>::Get()->GetOrbiterNodes();
674  Callback<void, const Time&, const Address&> callback =
676 
677  for (NodeContainer::Iterator it = sats.Begin(); it != sats.End(); ++it)
678  {
679  Ptr<NetDevice> dev = GetSatSatOrbiterNetDevice(*it);
680  Ptr<SatOrbiterNetDevice> satOrbiterDev = dev->GetObject<SatOrbiterNetDevice>();
681  NS_ASSERT(satOrbiterDev != nullptr);
682  satOrbiterDev->SetAttribute("EnableStatisticsTags", BooleanValue(true));
683 
684  // Connect the object to the probe.
685  if (satOrbiterDev->TraceConnectWithoutContext("RxFeederLinkDelay", callback))
686  {
687  NS_LOG_INFO(this << " successfully connected with node ID " << (*it)->GetId()
688  << " device #" << satOrbiterDev->GetIfIndex());
689  }
690  else
691  {
692  NS_FATAL_ERROR("Error connecting to RxFeederLinkDelay trace source of SatNetDevice"
693  << " at node ID " << (*it)->GetId() << " device #"
694  << satOrbiterDev->GetIfIndex());
695  }
696  } // end of `for (it = sats.Begin(); it != sats.End (); ++it)`
697 
698  NodeContainer uts = Singleton<SatTopology>::Get()->GetUtNodes();
699 
700  for (NodeContainer::Iterator it = uts.Begin(); it != uts.End(); ++it)
701  {
702  // Create a map of UT addresses and identifiers.
704 
705  Ptr<NetDevice> dev = GetUtSatNetDevice(*it);
706  Ptr<SatNetDevice> satDev = dev->GetObject<SatNetDevice>();
707  NS_ASSERT(satDev != nullptr);
708 
709  satDev->SetAttribute("EnableStatisticsTags", BooleanValue(true));
710 
711  } // end of `for (it = uts.Begin(); it != uts.End (); ++it)`
712 
713  // Enable statistics-related tags on the transmitting device.
714  NodeContainer gws = Singleton<SatTopology>::Get()->GetGwNodes();
715  for (NodeContainer::Iterator it = gws.Begin(); it != gws.End(); ++it)
716  {
717  NetDeviceContainer devs = GetGwSatNetDevice(*it);
718 
719  for (NetDeviceContainer::Iterator itDev = devs.Begin(); itDev != devs.End(); ++itDev)
720  {
721  Ptr<SatNetDevice> satDev = (*itDev)->GetObject<SatNetDevice>();
722  NS_ASSERT(satDev != nullptr);
723 
724  satDev->SetAttribute("EnableStatisticsTags", BooleanValue(true));
725  }
726  }
727 
728 } // end of `void DoInstallProbes ();`
729 
730 // FORWARD USER LINK DEV-LEVEL /////////////////////////////////////////////////////
731 
732 NS_OBJECT_ENSURE_REGISTERED(SatStatsFwdUserDevLinkDelayHelper);
733 
735  : SatStatsLinkDelayHelper(satHelper)
736 {
737  NS_LOG_FUNCTION(this << satHelper);
738 }
739 
741 {
742  NS_LOG_FUNCTION(this);
743 }
744 
745 TypeId // static
747 {
748  static TypeId tid =
749  TypeId("ns3::SatStatsFwdUserDevLinkDelayHelper").SetParent<SatStatsLinkDelayHelper>();
750  return tid;
751 }
752 
753 void
755 {
756  NS_LOG_FUNCTION(this);
757 
758  NodeContainer sats = Singleton<SatTopology>::Get()->GetOrbiterNodes();
759 
760  for (NodeContainer::Iterator it = sats.Begin(); it != sats.End(); ++it)
761  {
762  Ptr<NetDevice> dev = GetSatSatOrbiterNetDevice(*it);
763  Ptr<SatOrbiterNetDevice> satOrbiterDev = dev->GetObject<SatOrbiterNetDevice>();
764  satOrbiterDev->SetAttribute("EnableStatisticsTags", BooleanValue(true));
765  } // end of `for (it = sats.Begin(); it != sats.End (); ++it)`
766 
767  NodeContainer uts = Singleton<SatTopology>::Get()->GetUtNodes();
768 
769  for (NodeContainer::Iterator it = uts.Begin(); it != uts.End(); ++it)
770  {
771  const int32_t utId = GetUtId(*it);
772  NS_ASSERT_MSG(utId > 0, "Node " << (*it)->GetId() << " is not a valid UT");
773  const uint32_t identifier = GetIdentifierForUt(*it);
774 
775  // Create the probe.
776  std::ostringstream probeName;
777  probeName << utId;
778  Ptr<ApplicationDelayProbe> probe = CreateObject<ApplicationDelayProbe>();
779  probe->SetName(probeName.str());
780 
781  Ptr<NetDevice> dev = GetUtSatNetDevice(*it);
782  Ptr<SatNetDevice> satDev = dev->GetObject<SatNetDevice>();
783  NS_ASSERT(satDev != nullptr);
784 
785  // Connect the object to the probe.
786  if (probe->ConnectByObject("RxLinkDelay", satDev) &&
787  ConnectProbeToCollector(probe, identifier))
788  {
789  m_probes.insert(
790  std::make_pair(probe->GetObject<Probe>(), std::make_pair(*it, identifier)));
791 
792  // Enable statistics-related tags and trace sources on the device.
793  satDev->SetAttribute("EnableStatisticsTags", BooleanValue(true));
794  }
795  else
796  {
797  NS_FATAL_ERROR("Error connecting to RxLinkDelay trace source of SatMac"
798  << " at node ID " << (*it)->GetId() << " device #2");
799  }
800 
801  } // end of `for (it = uts.Begin(); it != uts.End (); ++it)`
802 
803  // Enable statistics-related tags on the transmitting device.
804  NodeContainer gws = Singleton<SatTopology>::Get()->GetGwNodes();
805  for (NodeContainer::Iterator it = gws.Begin(); it != gws.End(); ++it)
806  {
807  NetDeviceContainer devs = GetGwSatNetDevice(*it);
808 
809  for (NetDeviceContainer::Iterator itDev = devs.Begin(); itDev != devs.End(); ++itDev)
810  {
811  Ptr<SatNetDevice> satDev = (*itDev)->GetObject<SatNetDevice>();
812  NS_ASSERT(satDev != nullptr);
813 
814  satDev->SetAttribute("EnableStatisticsTags", BooleanValue(true));
815  }
816  }
817 
818 } // end of `void DoInstallProbes ();`
819 
820 void
822 {
823  NS_LOG_FUNCTION(this);
824 
825  std::map<Ptr<Probe>, std::pair<Ptr<Node>, uint32_t>>::iterator it;
826 
827  for (it = m_probes.begin(); it != m_probes.end(); it++)
828  {
829  Ptr<Probe> probe = it->first;
830  Ptr<Node> node = it->second.first;
831  uint32_t identifier = it->second.second;
832 
833  if (!DisconnectProbeFromCollector(probe, identifier))
834  {
835  NS_FATAL_ERROR("Error disconnecting trace file on handover");
836  }
837 
838  identifier = GetIdentifierForUt(node);
839 
840  if (!ConnectProbeToCollector(probe, identifier))
841  {
842  NS_FATAL_ERROR("Error connecting trace file on handover");
843  }
844 
845  it->second.second = identifier;
846  }
847 } // end of `void UpdateIdentifierOnProbes ();`
848 
849 // FORWARD FEEDER LINK MAC-LEVEL /////////////////////////////////////////////////////
850 
851 NS_OBJECT_ENSURE_REGISTERED(SatStatsFwdFeederMacLinkDelayHelper);
852 
854  Ptr<const SatHelper> satHelper)
855  : SatStatsLinkDelayHelper(satHelper)
856 {
857  NS_LOG_FUNCTION(this << satHelper);
858 }
859 
861 {
862  NS_LOG_FUNCTION(this);
863 }
864 
865 TypeId // static
867 {
868  static TypeId tid =
869  TypeId("ns3::SatStatsFwdFeederMacLinkDelayHelper").SetParent<SatStatsLinkDelayHelper>();
870  return tid;
871 }
872 
873 void
875 {
876  NS_LOG_FUNCTION(this);
877 
878  NodeContainer sats = Singleton<SatTopology>::Get()->GetOrbiterNodes();
879  Callback<void, const Time&, const Address&> callback =
881 
882  for (NodeContainer::Iterator it = sats.Begin(); it != sats.End(); ++it)
883  {
884  Ptr<NetDevice> dev = GetSatSatOrbiterNetDevice(*it);
885  Ptr<SatOrbiterNetDevice> satOrbiterDev = dev->GetObject<SatOrbiterNetDevice>();
886  NS_ASSERT(satOrbiterDev != nullptr);
887  satOrbiterDev->SetAttribute("EnableStatisticsTags", BooleanValue(true));
888  std::map<uint32_t, Ptr<SatMac>> satOrbiterFeederMacs = satOrbiterDev->GetFeederMac();
889  Ptr<SatMac> satMac;
890  for (std::map<uint32_t, Ptr<SatMac>>::iterator it2 = satOrbiterFeederMacs.begin();
891  it2 != satOrbiterFeederMacs.end();
892  ++it2)
893  {
894  satMac = it2->second;
895  NS_ASSERT(satMac != nullptr);
896  satMac->SetAttribute("EnableStatisticsTags", BooleanValue(true));
897 
898  // Connect the object to the probe.
899  if (satMac->TraceConnectWithoutContext("RxLinkDelay", callback))
900  {
901  NS_LOG_INFO(this << " successfully connected with node ID " << (*it)->GetId()
902  << " device #" << satOrbiterDev->GetIfIndex());
903 
904  // Enable statistics-related tags and trace sources on the device.
905  satMac->SetAttribute("EnableStatisticsTags", BooleanValue(true));
906  }
907  else
908  {
909  NS_FATAL_ERROR("Error connecting to RxLinkDelay trace source of SatNetDevice"
910  << " at node ID " << (*it)->GetId() << " device #"
911  << satOrbiterDev->GetIfIndex());
912  }
913  }
914  std::map<uint32_t, Ptr<SatMac>> satOrbiterUserMacs = satOrbiterDev->GetUserMac();
915  for (std::map<uint32_t, Ptr<SatMac>>::iterator it2 = satOrbiterUserMacs.begin();
916  it2 != satOrbiterUserMacs.end();
917  ++it2)
918  {
919  satMac = it2->second;
920  NS_ASSERT(satMac != nullptr);
921  satMac->SetAttribute("EnableStatisticsTags", BooleanValue(true));
922  }
923  } // end of `for (it = sats.Begin(); it != sats.End (); ++it)`
924 
925  NodeContainer uts = Singleton<SatTopology>::Get()->GetUtNodes();
926 
927  for (NodeContainer::Iterator it = uts.Begin(); it != uts.End(); ++it)
928  {
929  // Create a map of UT addresses and identifiers.
931 
932  Ptr<NetDevice> dev = GetUtSatNetDevice(*it);
933  Ptr<SatNetDevice> satDev = dev->GetObject<SatNetDevice>();
934  NS_ASSERT(satDev != nullptr);
935  Ptr<SatMac> satMac = satDev->GetMac();
936  NS_ASSERT(satMac != nullptr);
937 
938  satDev->SetAttribute("EnableStatisticsTags", BooleanValue(true));
939  satMac->SetAttribute("EnableStatisticsTags", BooleanValue(true));
940 
941  } // end of `for (it = uts.Begin(); it != uts.End (); ++it)`
942 
943  // Enable statistics-related tags on the transmitting device.
944  NodeContainer gws = Singleton<SatTopology>::Get()->GetGwNodes();
945  for (NodeContainer::Iterator it = gws.Begin(); it != gws.End(); ++it)
946  {
947  NetDeviceContainer devs = GetGwSatNetDevice(*it);
948 
949  for (NetDeviceContainer::Iterator itDev = devs.Begin(); itDev != devs.End(); ++itDev)
950  {
951  Ptr<SatNetDevice> satDev = (*itDev)->GetObject<SatNetDevice>();
952  NS_ASSERT(satDev != nullptr);
953  Ptr<SatMac> satMac = satDev->GetMac();
954  NS_ASSERT(satMac != nullptr);
955 
956  satDev->SetAttribute("EnableStatisticsTags", BooleanValue(true));
957  satMac->SetAttribute("EnableStatisticsTags", BooleanValue(true));
958  }
959  }
960 
961 } // end of `void DoInstallProbes ();`
962 
963 // FORWARD USER LINK MAC-LEVEL /////////////////////////////////////////////////////
964 
965 NS_OBJECT_ENSURE_REGISTERED(SatStatsFwdUserMacLinkDelayHelper);
966 
968  : SatStatsLinkDelayHelper(satHelper)
969 {
970  NS_LOG_FUNCTION(this << satHelper);
971 }
972 
974 {
975  NS_LOG_FUNCTION(this);
976 }
977 
978 TypeId // static
980 {
981  static TypeId tid =
982  TypeId("ns3::SatStatsFwdUserMacLinkDelayHelper").SetParent<SatStatsLinkDelayHelper>();
983  return tid;
984 }
985 
986 void
988 {
989  NS_LOG_FUNCTION(this);
990 
991  NodeContainer sats = Singleton<SatTopology>::Get()->GetOrbiterNodes();
992 
993  for (NodeContainer::Iterator it = sats.Begin(); it != sats.End(); ++it)
994  {
995  Ptr<NetDevice> dev = GetSatSatOrbiterNetDevice(*it);
996  Ptr<SatOrbiterNetDevice> satOrbiterDev = dev->GetObject<SatOrbiterNetDevice>();
997  NS_ASSERT(satOrbiterDev != nullptr);
998  satOrbiterDev->SetAttribute("EnableStatisticsTags", BooleanValue(true));
999  std::map<uint32_t, Ptr<SatMac>> satOrbiterFeederMacs = satOrbiterDev->GetFeederMac();
1000  Ptr<SatMac> satMac;
1001  for (std::map<uint32_t, Ptr<SatMac>>::iterator it2 = satOrbiterFeederMacs.begin();
1002  it2 != satOrbiterFeederMacs.end();
1003  ++it2)
1004  {
1005  satMac = it2->second;
1006  NS_ASSERT(satMac != nullptr);
1007  satMac->SetAttribute("EnableStatisticsTags", BooleanValue(true));
1008  }
1009  std::map<uint32_t, Ptr<SatMac>> satOrbiterUserMacs = satOrbiterDev->GetUserMac();
1010  for (std::map<uint32_t, Ptr<SatMac>>::iterator it2 = satOrbiterUserMacs.begin();
1011  it2 != satOrbiterUserMacs.end();
1012  ++it2)
1013  {
1014  satMac = it2->second;
1015  NS_ASSERT(satMac != nullptr);
1016  satMac->SetAttribute("EnableStatisticsTags", BooleanValue(true));
1017  }
1018  } // end of `for (it = sats.Begin(); it != sats.End (); ++it)`
1019 
1020  NodeContainer uts = Singleton<SatTopology>::Get()->GetUtNodes();
1021 
1022  for (NodeContainer::Iterator it = uts.Begin(); it != uts.End(); ++it)
1023  {
1024  const int32_t utId = GetUtId(*it);
1025  NS_ASSERT_MSG(utId > 0, "Node " << (*it)->GetId() << " is not a valid UT");
1026  const uint32_t identifier = GetIdentifierForUt(*it);
1027 
1028  // Create the probe.
1029  std::ostringstream probeName;
1030  probeName << utId;
1031  Ptr<ApplicationDelayProbe> probe = CreateObject<ApplicationDelayProbe>();
1032  probe->SetName(probeName.str());
1033 
1034  Ptr<NetDevice> dev = GetUtSatNetDevice(*it);
1035  Ptr<SatNetDevice> satDev = dev->GetObject<SatNetDevice>();
1036  NS_ASSERT(satDev != nullptr);
1037  Ptr<SatMac> satMac = satDev->GetMac();
1038  NS_ASSERT(satMac != nullptr);
1039 
1040  // Connect the object to the probe.
1041  if (probe->ConnectByObject("RxLinkDelay", satMac) &&
1042  ConnectProbeToCollector(probe, identifier))
1043  {
1044  m_probes.insert(
1045  std::make_pair(probe->GetObject<Probe>(), std::make_pair(*it, identifier)));
1046 
1047  // Enable statistics-related tags and trace sources on the device.
1048  satDev->SetAttribute("EnableStatisticsTags", BooleanValue(true));
1049  satMac->SetAttribute("EnableStatisticsTags", BooleanValue(true));
1050  }
1051  else
1052  {
1053  NS_FATAL_ERROR("Error connecting to RxLinkDelay trace source of SatMac"
1054  << " at node ID " << (*it)->GetId() << " device #2");
1055  }
1056 
1057  } // end of `for (it = uts.Begin(); it != uts.End (); ++it)`
1058 
1059  // Enable statistics-related tags on the transmitting device.
1060  NodeContainer gws = Singleton<SatTopology>::Get()->GetGwNodes();
1061  for (NodeContainer::Iterator it = gws.Begin(); it != gws.End(); ++it)
1062  {
1063  NetDeviceContainer devs = GetGwSatNetDevice(*it);
1064 
1065  for (NetDeviceContainer::Iterator itDev = devs.Begin(); itDev != devs.End(); ++itDev)
1066  {
1067  Ptr<SatNetDevice> satDev = (*itDev)->GetObject<SatNetDevice>();
1068  NS_ASSERT(satDev != nullptr);
1069  Ptr<SatMac> satMac = satDev->GetMac();
1070  NS_ASSERT(satMac != nullptr);
1071 
1072  satDev->SetAttribute("EnableStatisticsTags", BooleanValue(true));
1073  satMac->SetAttribute("EnableStatisticsTags", BooleanValue(true));
1074  }
1075  }
1076 
1077 } // end of `void DoInstallProbes ();`
1078 
1079 void
1081 {
1082  NS_LOG_FUNCTION(this);
1083 
1084  std::map<Ptr<Probe>, std::pair<Ptr<Node>, uint32_t>>::iterator it;
1085 
1086  for (it = m_probes.begin(); it != m_probes.end(); it++)
1087  {
1088  Ptr<Probe> probe = it->first;
1089  Ptr<Node> node = it->second.first;
1090  uint32_t identifier = it->second.second;
1091 
1092  if (!DisconnectProbeFromCollector(probe, identifier))
1093  {
1094  NS_FATAL_ERROR("Error disconnecting trace file on handover");
1095  }
1096 
1097  identifier = GetIdentifierForUt(node);
1098 
1099  if (!ConnectProbeToCollector(probe, identifier))
1100  {
1101  NS_FATAL_ERROR("Error connecting trace file on handover");
1102  }
1103 
1104  it->second.second = identifier;
1105  }
1106 } // end of `void UpdateIdentifierOnProbes ();`
1107 
1108 // FORWARD FEEDER LINK PHY-LEVEL /////////////////////////////////////////////////////
1109 
1110 NS_OBJECT_ENSURE_REGISTERED(SatStatsFwdFeederPhyLinkDelayHelper);
1111 
1113  Ptr<const SatHelper> satHelper)
1114  : SatStatsLinkDelayHelper(satHelper)
1115 {
1116  NS_LOG_FUNCTION(this << satHelper);
1117 }
1118 
1120 {
1121  NS_LOG_FUNCTION(this);
1122 }
1123 
1124 TypeId // static
1126 {
1127  static TypeId tid =
1128  TypeId("ns3::SatStatsFwdFeederPhyLinkDelayHelper").SetParent<SatStatsLinkDelayHelper>();
1129  return tid;
1130 }
1131 
1132 void
1134 {
1135  NS_LOG_FUNCTION(this);
1136 
1137  NodeContainer sats = Singleton<SatTopology>::Get()->GetOrbiterNodes();
1138  Callback<void, const Time&, const Address&> callback =
1140 
1141  for (NodeContainer::Iterator it = sats.Begin(); it != sats.End(); ++it)
1142  {
1143  Ptr<NetDevice> dev = GetSatSatOrbiterNetDevice(*it);
1144  Ptr<SatOrbiterNetDevice> satOrbiterDev = dev->GetObject<SatOrbiterNetDevice>();
1145  NS_ASSERT(satOrbiterDev != nullptr);
1146  satOrbiterDev->SetAttribute("EnableStatisticsTags", BooleanValue(true));
1147  std::map<uint32_t, Ptr<SatPhy>> satOrbiterFeederPhys = satOrbiterDev->GetFeederPhy();
1148  Ptr<SatPhy> satPhy;
1149  for (std::map<uint32_t, Ptr<SatPhy>>::iterator it2 = satOrbiterFeederPhys.begin();
1150  it2 != satOrbiterFeederPhys.end();
1151  ++it2)
1152  {
1153  satPhy = it2->second;
1154  NS_ASSERT(satPhy != nullptr);
1155  satPhy->SetAttribute("EnableStatisticsTags", BooleanValue(true));
1156 
1157  // Connect the object to the probe.
1158  if (satPhy->TraceConnectWithoutContext("RxLinkDelay", callback))
1159  {
1160  NS_LOG_INFO(this << " successfully connected with node ID " << (*it)->GetId()
1161  << " device #" << satOrbiterDev->GetIfIndex());
1162 
1163  // Enable statistics-related tags and trace sources on the device.
1164  satPhy->SetAttribute("EnableStatisticsTags", BooleanValue(true));
1165  }
1166  else
1167  {
1168  NS_FATAL_ERROR("Error connecting to RxLinkDelay trace source of SatNetDevice"
1169  << " at node ID " << (*it)->GetId() << " device #"
1170  << satOrbiterDev->GetIfIndex());
1171  }
1172  }
1173  std::map<uint32_t, Ptr<SatPhy>> satOrbiterUserPhys = satOrbiterDev->GetUserPhy();
1174  for (std::map<uint32_t, Ptr<SatPhy>>::iterator it2 = satOrbiterUserPhys.begin();
1175  it2 != satOrbiterUserPhys.end();
1176  ++it2)
1177  {
1178  satPhy = it2->second;
1179  NS_ASSERT(satPhy != nullptr);
1180  satPhy->SetAttribute("EnableStatisticsTags", BooleanValue(true));
1181  }
1182  } // end of `for (it = sats.Begin(); it != sats.End (); ++it)`
1183 
1184  NodeContainer uts = Singleton<SatTopology>::Get()->GetUtNodes();
1185 
1186  for (NodeContainer::Iterator it = uts.Begin(); it != uts.End(); ++it)
1187  {
1188  // Create a map of UT addresses and identifiers.
1190 
1191  Ptr<NetDevice> dev = GetUtSatNetDevice(*it);
1192  Ptr<SatNetDevice> satDev = dev->GetObject<SatNetDevice>();
1193  NS_ASSERT(satDev != nullptr);
1194  Ptr<SatPhy> satPhy = satDev->GetPhy();
1195  NS_ASSERT(satPhy != nullptr);
1196 
1197  satDev->SetAttribute("EnableStatisticsTags", BooleanValue(true));
1198  satPhy->SetAttribute("EnableStatisticsTags", BooleanValue(true));
1199 
1200  } // end of `for (it = uts.Begin(); it != uts.End (); ++it)`
1201 
1202  // Enable statistics-related tags on the transmitting device.
1203  NodeContainer gws = Singleton<SatTopology>::Get()->GetGwNodes();
1204  for (NodeContainer::Iterator it = gws.Begin(); it != gws.End(); ++it)
1205  {
1206  NetDeviceContainer devs = GetGwSatNetDevice(*it);
1207 
1208  for (NetDeviceContainer::Iterator itDev = devs.Begin(); itDev != devs.End(); ++itDev)
1209  {
1210  Ptr<SatNetDevice> satDev = (*itDev)->GetObject<SatNetDevice>();
1211  NS_ASSERT(satDev != nullptr);
1212  Ptr<SatPhy> satPhy = satDev->GetPhy();
1213  NS_ASSERT(satPhy != nullptr);
1214 
1215  satDev->SetAttribute("EnableStatisticsTags", BooleanValue(true));
1216  satPhy->SetAttribute("EnableStatisticsTags", BooleanValue(true));
1217  }
1218  }
1219 
1220 } // end of `void DoInstallProbes ();`
1221 
1222 // FORWARD USER LINK PHY-LEVEL /////////////////////////////////////////////////////
1223 
1224 NS_OBJECT_ENSURE_REGISTERED(SatStatsFwdUserPhyLinkDelayHelper);
1225 
1227  : SatStatsLinkDelayHelper(satHelper)
1228 {
1229  NS_LOG_FUNCTION(this << satHelper);
1230 }
1231 
1233 {
1234  NS_LOG_FUNCTION(this);
1235 }
1236 
1237 TypeId // static
1239 {
1240  static TypeId tid =
1241  TypeId("ns3::SatStatsFwdUserPhyLinkDelayHelper").SetParent<SatStatsLinkDelayHelper>();
1242  return tid;
1243 }
1244 
1245 void
1247 {
1248  NS_LOG_FUNCTION(this);
1249 
1250  NodeContainer sats = Singleton<SatTopology>::Get()->GetOrbiterNodes();
1251 
1252  for (NodeContainer::Iterator it = sats.Begin(); it != sats.End(); ++it)
1253  {
1254  Ptr<NetDevice> dev = GetSatSatOrbiterNetDevice(*it);
1255  Ptr<SatOrbiterNetDevice> satOrbiterDev = dev->GetObject<SatOrbiterNetDevice>();
1256  NS_ASSERT(satOrbiterDev != nullptr);
1257  satOrbiterDev->SetAttribute("EnableStatisticsTags", BooleanValue(true));
1258  std::map<uint32_t, Ptr<SatPhy>> satOrbiterFeederPhys = satOrbiterDev->GetFeederPhy();
1259  Ptr<SatPhy> satPhy;
1260  for (std::map<uint32_t, Ptr<SatPhy>>::iterator it2 = satOrbiterFeederPhys.begin();
1261  it2 != satOrbiterFeederPhys.end();
1262  ++it2)
1263  {
1264  satPhy = it2->second;
1265  NS_ASSERT(satPhy != nullptr);
1266  satPhy->SetAttribute("EnableStatisticsTags", BooleanValue(true));
1267  }
1268  std::map<uint32_t, Ptr<SatPhy>> satOrbiterUserPhys = satOrbiterDev->GetUserPhy();
1269  for (std::map<uint32_t, Ptr<SatPhy>>::iterator it2 = satOrbiterUserPhys.begin();
1270  it2 != satOrbiterUserPhys.end();
1271  ++it2)
1272  {
1273  satPhy = it2->second;
1274  NS_ASSERT(satPhy != nullptr);
1275  satPhy->SetAttribute("EnableStatisticsTags", BooleanValue(true));
1276  }
1277  } // end of `for (it = sats.Begin(); it != sats.End (); ++it)`
1278 
1279  NodeContainer uts = Singleton<SatTopology>::Get()->GetUtNodes();
1280 
1281  for (NodeContainer::Iterator it = uts.Begin(); it != uts.End(); ++it)
1282  {
1283  const int32_t utId = GetUtId(*it);
1284  NS_ASSERT_MSG(utId > 0, "Node " << (*it)->GetId() << " is not a valid UT");
1285  const uint32_t identifier = GetIdentifierForUt(*it);
1286 
1287  // Create the probe.
1288  std::ostringstream probeName;
1289  probeName << utId;
1290  Ptr<ApplicationDelayProbe> probe = CreateObject<ApplicationDelayProbe>();
1291  probe->SetName(probeName.str());
1292 
1293  Ptr<NetDevice> dev = GetUtSatNetDevice(*it);
1294  Ptr<SatNetDevice> satDev = dev->GetObject<SatNetDevice>();
1295  NS_ASSERT(satDev != nullptr);
1296  Ptr<SatPhy> satPhy = satDev->GetPhy();
1297  NS_ASSERT(satPhy != nullptr);
1298 
1299  // Connect the object to the probe.
1300  if (probe->ConnectByObject("RxLinkDelay", satPhy) &&
1301  ConnectProbeToCollector(probe, identifier))
1302  {
1303  m_probes.insert(
1304  std::make_pair(probe->GetObject<Probe>(), std::make_pair(*it, identifier)));
1305 
1306  // Enable statistics-related tags and trace sources on the device.
1307  satDev->SetAttribute("EnableStatisticsTags", BooleanValue(true));
1308  satPhy->SetAttribute("EnableStatisticsTags", BooleanValue(true));
1309  }
1310  else
1311  {
1312  NS_FATAL_ERROR("Error connecting to RxLinkDelay trace source of SatPhy"
1313  << " at node ID " << (*it)->GetId() << " device #2");
1314  }
1315 
1316  } // end of `for (it = uts.Begin(); it != uts.End (); ++it)`
1317 
1318  // Enable statistics-related tags on the transmitting device.
1319  NodeContainer gws = Singleton<SatTopology>::Get()->GetGwNodes();
1320  for (NodeContainer::Iterator it = gws.Begin(); it != gws.End(); ++it)
1321  {
1322  NetDeviceContainer devs = GetGwSatNetDevice(*it);
1323 
1324  for (NetDeviceContainer::Iterator itDev = devs.Begin(); itDev != devs.End(); ++itDev)
1325  {
1326  Ptr<SatNetDevice> satDev = (*itDev)->GetObject<SatNetDevice>();
1327  NS_ASSERT(satDev != nullptr);
1328  Ptr<SatPhy> satPhy = satDev->GetPhy();
1329  NS_ASSERT(satPhy != nullptr);
1330 
1331  satDev->SetAttribute("EnableStatisticsTags", BooleanValue(true));
1332  satPhy->SetAttribute("EnableStatisticsTags", BooleanValue(true));
1333  }
1334  }
1335 
1336 } // end of `void DoInstallProbes ();`
1337 
1338 void
1340 {
1341  NS_LOG_FUNCTION(this);
1342 
1343  std::map<Ptr<Probe>, std::pair<Ptr<Node>, uint32_t>>::iterator it;
1344 
1345  for (it = m_probes.begin(); it != m_probes.end(); it++)
1346  {
1347  Ptr<Probe> probe = it->first;
1348  Ptr<Node> node = it->second.first;
1349  uint32_t identifier = it->second.second;
1350 
1351  if (!DisconnectProbeFromCollector(probe, identifier))
1352  {
1353  NS_FATAL_ERROR("Error disconnecting trace file on handover");
1354  }
1355 
1356  identifier = GetIdentifierForUt(node);
1357 
1358  if (!ConnectProbeToCollector(probe, identifier))
1359  {
1360  NS_FATAL_ERROR("Error connecting trace file on handover");
1361  }
1362 
1363  it->second.second = identifier;
1364  }
1365 } // end of `void UpdateIdentifierOnProbes ();`
1366 
1367 // RETURN FEEDER LINK DEV-LEVEL //////////////////////////////////////////////////////
1368 
1369 NS_OBJECT_ENSURE_REGISTERED(SatStatsRtnFeederDevLinkDelayHelper);
1370 
1372  Ptr<const SatHelper> satHelper)
1373  : SatStatsLinkDelayHelper(satHelper)
1374 {
1375  NS_LOG_FUNCTION(this << satHelper);
1376 }
1377 
1379 {
1380  NS_LOG_FUNCTION(this);
1381 }
1382 
1383 TypeId // static
1385 {
1386  static TypeId tid =
1387  TypeId("ns3::SatStatsRtnFeederDevLinkDelayHelper").SetParent<SatStatsLinkDelayHelper>();
1388  return tid;
1389 }
1390 
1391 void
1393 {
1394  NS_LOG_FUNCTION(this);
1395 
1396  NodeContainer sats = Singleton<SatTopology>::Get()->GetOrbiterNodes();
1397 
1398  for (NodeContainer::Iterator it = sats.Begin(); it != sats.End(); ++it)
1399  {
1400  Ptr<SatMac> satMac;
1401  Ptr<NetDevice> dev = GetSatSatOrbiterNetDevice(*it);
1402  Ptr<SatOrbiterNetDevice> satOrbiterDev = dev->GetObject<SatOrbiterNetDevice>();
1403  NS_ASSERT(satOrbiterDev != nullptr);
1404  satOrbiterDev->SetAttribute("EnableStatisticsTags", BooleanValue(true));
1405  } // end of `for (it = sats.Begin(); it != sats.End (); ++it)`
1406 
1407  NodeContainer uts = Singleton<SatTopology>::Get()->GetUtNodes();
1408  for (NodeContainer::Iterator it = uts.Begin(); it != uts.End(); ++it)
1409  {
1410  // Create a map of UT addresses and identifiers.
1412 
1413  // Enable statistics-related tags and trace sources on the device.
1414  Ptr<NetDevice> dev = GetUtSatNetDevice(*it);
1415  Ptr<SatNetDevice> satDev = dev->GetObject<SatNetDevice>();
1416  NS_ASSERT(satDev != nullptr);
1417  satDev->SetAttribute("EnableStatisticsTags", BooleanValue(true));
1418  }
1419 
1420  // Connect to trace sources at GW nodes.
1421 
1422  NodeContainer gws = Singleton<SatTopology>::Get()->GetGwNodes();
1423  Callback<void, const Time&, const Address&> callback =
1425 
1426  for (NodeContainer::Iterator it = gws.Begin(); it != gws.End(); ++it)
1427  {
1428  NetDeviceContainer devs = GetGwSatNetDevice(*it);
1429 
1430  for (NetDeviceContainer::Iterator itDev = devs.Begin(); itDev != devs.End(); ++itDev)
1431  {
1432  Ptr<SatNetDevice> satDev = (*itDev)->GetObject<SatNetDevice>();
1433  NS_ASSERT(satDev != nullptr);
1434 
1435  // Connect the object to the probe.
1436  if (satDev->TraceConnectWithoutContext("RxLinkDelay", callback))
1437  {
1438  NS_LOG_INFO(this << " successfully connected with node ID " << (*it)->GetId()
1439  << " device #" << satDev->GetIfIndex());
1440 
1441  // Enable statistics-related tags and trace sources on the device.
1442  satDev->SetAttribute("EnableStatisticsTags", BooleanValue(true));
1443  }
1444  else
1445  {
1446  NS_FATAL_ERROR("Error connecting to RxLinkDelay trace source of SatNetDevice"
1447  << " at node ID " << (*it)->GetId() << " device #"
1448  << satDev->GetIfIndex());
1449  }
1450 
1451  } // end of `for (NetDeviceContainer::Iterator itDev = devs)`
1452 
1453  } // end of `for (NodeContainer::Iterator it = gws)`
1454 
1455 } // end of `void DoInstallProbes ();`
1456 
1457 // RETURN USER LINK DEV-LEVEL //////////////////////////////////////////////////////
1458 
1459 NS_OBJECT_ENSURE_REGISTERED(SatStatsRtnUserDevLinkDelayHelper);
1460 
1462  : SatStatsLinkDelayHelper(satHelper)
1463 {
1464  NS_LOG_FUNCTION(this << satHelper);
1465 }
1466 
1468 {
1469  NS_LOG_FUNCTION(this);
1470 }
1471 
1472 TypeId // static
1474 {
1475  static TypeId tid =
1476  TypeId("ns3::SatStatsRtnUserDevLinkDelayHelper").SetParent<SatStatsLinkDelayHelper>();
1477  return tid;
1478 }
1479 
1480 void
1482 {
1483  NS_LOG_FUNCTION(this);
1484 
1485  NodeContainer sats = Singleton<SatTopology>::Get()->GetOrbiterNodes();
1486  Callback<void, const Time&, const Address&> callback =
1488 
1489  for (NodeContainer::Iterator it = sats.Begin(); it != sats.End(); ++it)
1490  {
1491  Ptr<NetDevice> dev = GetSatSatOrbiterNetDevice(*it);
1492  Ptr<SatOrbiterNetDevice> satOrbiterDev = dev->GetObject<SatOrbiterNetDevice>();
1493  NS_ASSERT(satOrbiterDev != nullptr);
1494  satOrbiterDev->SetAttribute("EnableStatisticsTags", BooleanValue(true));
1495 
1496  // Connect the object to the probe.
1497  if (satOrbiterDev->TraceConnectWithoutContext("RxUserLinkDelay", callback))
1498  {
1499  NS_LOG_INFO(this << " successfully connected with node ID " << (*it)->GetId()
1500  << " device #" << satOrbiterDev->GetIfIndex());
1501  }
1502  else
1503  {
1504  NS_FATAL_ERROR("Error connecting to RxUserLinkDelay trace source of SatNetDevice"
1505  << " at node ID " << (*it)->GetId() << " device #"
1506  << satOrbiterDev->GetIfIndex());
1507  }
1508  } // end of `for (it = sats.Begin(); it != sats.End (); ++it)`
1509 
1510  NodeContainer uts = Singleton<SatTopology>::Get()->GetUtNodes();
1511  for (NodeContainer::Iterator it = uts.Begin(); it != uts.End(); ++it)
1512  {
1513  // Create a map of UT addresses and identifiers.
1515 
1516  // Enable statistics-related tags and trace sources on the device.
1517  Ptr<NetDevice> dev = GetUtSatNetDevice(*it);
1518  Ptr<SatNetDevice> satDev = dev->GetObject<SatNetDevice>();
1519  NS_ASSERT(satDev != nullptr);
1520  satDev->SetAttribute("EnableStatisticsTags", BooleanValue(true));
1521  }
1522 
1523  // Connect to trace sources at GW nodes.
1524 
1525  NodeContainer gws = Singleton<SatTopology>::Get()->GetGwNodes();
1526 
1527  for (NodeContainer::Iterator it = gws.Begin(); it != gws.End(); ++it)
1528  {
1529  NetDeviceContainer devs = GetGwSatNetDevice(*it);
1530 
1531  for (NetDeviceContainer::Iterator itDev = devs.Begin(); itDev != devs.End(); ++itDev)
1532  {
1533  Ptr<SatNetDevice> satDev = (*itDev)->GetObject<SatNetDevice>();
1534  NS_ASSERT(satDev != nullptr);
1535 
1536  satDev->SetAttribute("EnableStatisticsTags", BooleanValue(true));
1537  } // end of `for (NetDeviceContainer::Iterator itDev = devs)`
1538 
1539  } // end of `for (NodeContainer::Iterator it = gws)`
1540 
1541 } // end of `void DoInstallProbes ();`
1542 
1543 // RETURN FEEDER LINK MAC-LEVEL //////////////////////////////////////////////////////
1544 
1545 NS_OBJECT_ENSURE_REGISTERED(SatStatsRtnFeederMacLinkDelayHelper);
1546 
1548  Ptr<const SatHelper> satHelper)
1549  : SatStatsLinkDelayHelper(satHelper)
1550 {
1551  NS_LOG_FUNCTION(this << satHelper);
1552 }
1553 
1555 {
1556  NS_LOG_FUNCTION(this);
1557 }
1558 
1559 TypeId // static
1561 {
1562  static TypeId tid =
1563  TypeId("ns3::SatStatsRtnFeederMacLinkDelayHelper").SetParent<SatStatsLinkDelayHelper>();
1564  return tid;
1565 }
1566 
1567 void
1569 {
1570  NS_LOG_FUNCTION(this);
1571 
1572  NodeContainer sats = Singleton<SatTopology>::Get()->GetOrbiterNodes();
1573 
1574  for (NodeContainer::Iterator it = sats.Begin(); it != sats.End(); ++it)
1575  {
1576  Ptr<SatMac> satMac;
1577  Ptr<NetDevice> dev = GetSatSatOrbiterNetDevice(*it);
1578  Ptr<SatOrbiterNetDevice> satOrbiterDev = dev->GetObject<SatOrbiterNetDevice>();
1579  NS_ASSERT(satOrbiterDev != nullptr);
1580  satOrbiterDev->SetAttribute("EnableStatisticsTags", BooleanValue(true));
1581  std::map<uint32_t, Ptr<SatMac>> satOrbiterFeederMacs = satOrbiterDev->GetFeederMac();
1582  for (std::map<uint32_t, Ptr<SatMac>>::iterator it2 = satOrbiterFeederMacs.begin();
1583  it2 != satOrbiterFeederMacs.end();
1584  ++it2)
1585  {
1586  satMac = it2->second;
1587  NS_ASSERT(satMac != nullptr);
1588  satMac->SetAttribute("EnableStatisticsTags", BooleanValue(true));
1589  }
1590  std::map<uint32_t, Ptr<SatMac>> satOrbiterUserMacs = satOrbiterDev->GetUserMac();
1591  for (std::map<uint32_t, Ptr<SatMac>>::iterator it2 = satOrbiterUserMacs.begin();
1592  it2 != satOrbiterUserMacs.end();
1593  ++it2)
1594  {
1595  satMac = it2->second;
1596  NS_ASSERT(satMac != nullptr);
1597  satMac->SetAttribute("EnableStatisticsTags", BooleanValue(true));
1598  }
1599  } // end of `for (it = sats.Begin(); it != sats.End (); ++it)`
1600 
1601  NodeContainer uts = Singleton<SatTopology>::Get()->GetUtNodes();
1602  for (NodeContainer::Iterator it = uts.Begin(); it != uts.End(); ++it)
1603  {
1604  // Create a map of UT addresses and identifiers.
1606 
1607  // Enable statistics-related tags and trace sources on the device.
1608  Ptr<NetDevice> dev = GetUtSatNetDevice(*it);
1609  Ptr<SatNetDevice> satDev = dev->GetObject<SatNetDevice>();
1610  NS_ASSERT(satDev != nullptr);
1611  Ptr<SatMac> satMac = satDev->GetMac();
1612  NS_ASSERT(satMac != nullptr);
1613  satDev->SetAttribute("EnableStatisticsTags", BooleanValue(true));
1614  satMac->SetAttribute("EnableStatisticsTags", BooleanValue(true));
1615  }
1616 
1617  // Connect to trace sources at GW nodes.
1618 
1619  NodeContainer gws = Singleton<SatTopology>::Get()->GetGwNodes();
1620  Callback<void, const Time&, const Address&> callback =
1622 
1623  for (NodeContainer::Iterator it = gws.Begin(); it != gws.End(); ++it)
1624  {
1625  NetDeviceContainer devs = GetGwSatNetDevice(*it);
1626 
1627  for (NetDeviceContainer::Iterator itDev = devs.Begin(); itDev != devs.End(); ++itDev)
1628  {
1629  Ptr<SatNetDevice> satDev = (*itDev)->GetObject<SatNetDevice>();
1630  NS_ASSERT(satDev != nullptr);
1631  Ptr<SatMac> satMac = satDev->GetMac();
1632  NS_ASSERT(satMac != nullptr);
1633 
1634  // Connect the object to the probe.
1635  if (satMac->TraceConnectWithoutContext("RxLinkDelay", callback))
1636  {
1637  NS_LOG_INFO(this << " successfully connected with node ID " << (*it)->GetId()
1638  << " device #" << satDev->GetIfIndex());
1639 
1640  // Enable statistics-related tags and trace sources on the device.
1641  satDev->SetAttribute("EnableStatisticsTags", BooleanValue(true));
1642  satMac->SetAttribute("EnableStatisticsTags", BooleanValue(true));
1643  }
1644  else
1645  {
1646  NS_FATAL_ERROR("Error connecting to RxLinkDelay trace source of SatNetDevice"
1647  << " at node ID " << (*it)->GetId() << " device #"
1648  << satDev->GetIfIndex());
1649  }
1650 
1651  } // end of `for (NetDeviceContainer::Iterator itDev = devs)`
1652 
1653  } // end of `for (NodeContainer::Iterator it = gws)`
1654 
1655 } // end of `void DoInstallProbes ();`
1656 
1657 // RETURN USER LINK MAC-LEVEL //////////////////////////////////////////////////////
1658 
1659 NS_OBJECT_ENSURE_REGISTERED(SatStatsRtnUserMacLinkDelayHelper);
1660 
1662  : SatStatsLinkDelayHelper(satHelper)
1663 {
1664  NS_LOG_FUNCTION(this << satHelper);
1665 }
1666 
1668 {
1669  NS_LOG_FUNCTION(this);
1670 }
1671 
1672 TypeId // static
1674 {
1675  static TypeId tid =
1676  TypeId("ns3::SatStatsRtnUserMacLinkDelayHelper").SetParent<SatStatsLinkDelayHelper>();
1677  return tid;
1678 }
1679 
1680 void
1682 {
1683  NS_LOG_FUNCTION(this);
1684 
1685  NodeContainer sats = Singleton<SatTopology>::Get()->GetOrbiterNodes();
1686  Callback<void, const Time&, const Address&> callback =
1688 
1689  for (NodeContainer::Iterator it = sats.Begin(); it != sats.End(); ++it)
1690  {
1691  Ptr<NetDevice> dev = GetSatSatOrbiterNetDevice(*it);
1692  Ptr<SatOrbiterNetDevice> satOrbiterDev = dev->GetObject<SatOrbiterNetDevice>();
1693  NS_ASSERT(satOrbiterDev != nullptr);
1694  satOrbiterDev->SetAttribute("EnableStatisticsTags", BooleanValue(true));
1695  std::map<uint32_t, Ptr<SatMac>> satOrbiterFeederMacs = satOrbiterDev->GetFeederMac();
1696  Ptr<SatMac> satMac;
1697  for (std::map<uint32_t, Ptr<SatMac>>::iterator it2 = satOrbiterFeederMacs.begin();
1698  it2 != satOrbiterFeederMacs.end();
1699  ++it2)
1700  {
1701  satMac = it2->second;
1702  NS_ASSERT(satMac != nullptr);
1703  satMac->SetAttribute("EnableStatisticsTags", BooleanValue(true));
1704  }
1705  std::map<uint32_t, Ptr<SatMac>> satOrbiterUserMacs = satOrbiterDev->GetUserMac();
1706  for (std::map<uint32_t, Ptr<SatMac>>::iterator it2 = satOrbiterUserMacs.begin();
1707  it2 != satOrbiterUserMacs.end();
1708  ++it2)
1709  {
1710  satMac = it2->second;
1711  NS_ASSERT(satMac != nullptr);
1712  satMac->SetAttribute("EnableStatisticsTags", BooleanValue(true));
1713 
1714  // Connect the object to the probe.
1715  if (satMac->TraceConnectWithoutContext("RxLinkDelay", callback))
1716  {
1717  NS_LOG_INFO(this << " successfully connected with node ID " << (*it)->GetId()
1718  << " device #" << satOrbiterDev->GetIfIndex());
1719  }
1720  else
1721  {
1722  NS_FATAL_ERROR("Error connecting to RxLinkDelay trace source of SatNetDevice"
1723  << " at node ID " << (*it)->GetId() << " device #"
1724  << satOrbiterDev->GetIfIndex());
1725  }
1726  }
1727  } // end of `for (it = sats.Begin(); it != sats.End (); ++it)`
1728 
1729  NodeContainer uts = Singleton<SatTopology>::Get()->GetUtNodes();
1730  for (NodeContainer::Iterator it = uts.Begin(); it != uts.End(); ++it)
1731  {
1732  // Create a map of UT addresses and identifiers.
1734 
1735  // Enable statistics-related tags and trace sources on the device.
1736  Ptr<NetDevice> dev = GetUtSatNetDevice(*it);
1737  Ptr<SatNetDevice> satDev = dev->GetObject<SatNetDevice>();
1738  NS_ASSERT(satDev != nullptr);
1739  Ptr<SatMac> satMac = satDev->GetMac();
1740  NS_ASSERT(satMac != nullptr);
1741  satDev->SetAttribute("EnableStatisticsTags", BooleanValue(true));
1742  satMac->SetAttribute("EnableStatisticsTags", BooleanValue(true));
1743  }
1744 
1745  // Connect to trace sources at GW nodes.
1746 
1747  NodeContainer gws = Singleton<SatTopology>::Get()->GetGwNodes();
1748 
1749  for (NodeContainer::Iterator it = gws.Begin(); it != gws.End(); ++it)
1750  {
1751  NetDeviceContainer devs = GetGwSatNetDevice(*it);
1752 
1753  for (NetDeviceContainer::Iterator itDev = devs.Begin(); itDev != devs.End(); ++itDev)
1754  {
1755  Ptr<SatNetDevice> satDev = (*itDev)->GetObject<SatNetDevice>();
1756  NS_ASSERT(satDev != nullptr);
1757  Ptr<SatMac> satMac = satDev->GetMac();
1758  NS_ASSERT(satMac != nullptr);
1759 
1760  satDev->SetAttribute("EnableStatisticsTags", BooleanValue(true));
1761  satMac->SetAttribute("EnableStatisticsTags", BooleanValue(true));
1762  } // end of `for (NetDeviceContainer::Iterator itDev = devs)`
1763 
1764  } // end of `for (NodeContainer::Iterator it = gws)`
1765 
1766 } // end of `void DoInstallProbes ();`
1767 
1768 // RETURN FEEDER LINK PHY-LEVEL //////////////////////////////////////////////////////
1769 
1770 NS_OBJECT_ENSURE_REGISTERED(SatStatsRtnFeederPhyLinkDelayHelper);
1771 
1773  Ptr<const SatHelper> satHelper)
1774  : SatStatsLinkDelayHelper(satHelper)
1775 {
1776  NS_LOG_FUNCTION(this << satHelper);
1777 }
1778 
1780 {
1781  NS_LOG_FUNCTION(this);
1782 }
1783 
1784 TypeId // static
1786 {
1787  static TypeId tid =
1788  TypeId("ns3::SatStatsRtnFeederPhyLinkDelayHelper").SetParent<SatStatsLinkDelayHelper>();
1789  return tid;
1790 }
1791 
1792 void
1794 {
1795  NS_LOG_FUNCTION(this);
1796 
1797  NodeContainer sats = Singleton<SatTopology>::Get()->GetOrbiterNodes();
1798 
1799  for (NodeContainer::Iterator it = sats.Begin(); it != sats.End(); ++it)
1800  {
1801  Ptr<SatPhy> satPhy;
1802  Ptr<NetDevice> dev = GetSatSatOrbiterNetDevice(*it);
1803  Ptr<SatOrbiterNetDevice> satOrbiterDev = dev->GetObject<SatOrbiterNetDevice>();
1804  NS_ASSERT(satOrbiterDev != nullptr);
1805  satOrbiterDev->SetAttribute("EnableStatisticsTags", BooleanValue(true));
1806  std::map<uint32_t, Ptr<SatPhy>> satOrbiterFeederPhys = satOrbiterDev->GetFeederPhy();
1807  for (std::map<uint32_t, Ptr<SatPhy>>::iterator it2 = satOrbiterFeederPhys.begin();
1808  it2 != satOrbiterFeederPhys.end();
1809  ++it2)
1810  {
1811  satPhy = it2->second;
1812  NS_ASSERT(satPhy != nullptr);
1813  satPhy->SetAttribute("EnableStatisticsTags", BooleanValue(true));
1814  }
1815  std::map<uint32_t, Ptr<SatPhy>> satOrbiterUserPhys = satOrbiterDev->GetUserPhy();
1816  for (std::map<uint32_t, Ptr<SatPhy>>::iterator it2 = satOrbiterUserPhys.begin();
1817  it2 != satOrbiterUserPhys.end();
1818  ++it2)
1819  {
1820  satPhy = it2->second;
1821  NS_ASSERT(satPhy != nullptr);
1822  satPhy->SetAttribute("EnableStatisticsTags", BooleanValue(true));
1823  }
1824  } // end of `for (it = sats.Begin(); it != sats.End (); ++it)`
1825 
1826  NodeContainer uts = Singleton<SatTopology>::Get()->GetUtNodes();
1827  for (NodeContainer::Iterator it = uts.Begin(); it != uts.End(); ++it)
1828  {
1829  // Create a map of UT addresses and identifiers.
1831 
1832  // Enable statistics-related tags and trace sources on the device.
1833  Ptr<NetDevice> dev = GetUtSatNetDevice(*it);
1834  Ptr<SatNetDevice> satDev = dev->GetObject<SatNetDevice>();
1835  NS_ASSERT(satDev != nullptr);
1836  Ptr<SatPhy> satPhy = satDev->GetPhy();
1837  NS_ASSERT(satPhy != nullptr);
1838  satDev->SetAttribute("EnableStatisticsTags", BooleanValue(true));
1839  satPhy->SetAttribute("EnableStatisticsTags", BooleanValue(true));
1840  }
1841 
1842  // Connect to trace sources at GW nodes.
1843 
1844  NodeContainer gws = Singleton<SatTopology>::Get()->GetGwNodes();
1845  Callback<void, const Time&, const Address&> callback =
1847 
1848  for (NodeContainer::Iterator it = gws.Begin(); it != gws.End(); ++it)
1849  {
1850  NetDeviceContainer devs = GetGwSatNetDevice(*it);
1851 
1852  for (NetDeviceContainer::Iterator itDev = devs.Begin(); itDev != devs.End(); ++itDev)
1853  {
1854  Ptr<SatNetDevice> satDev = (*itDev)->GetObject<SatNetDevice>();
1855  NS_ASSERT(satDev != nullptr);
1856  Ptr<SatPhy> satPhy = satDev->GetPhy();
1857  NS_ASSERT(satPhy != nullptr);
1858 
1859  // Connect the object to the probe.
1860  if (satPhy->TraceConnectWithoutContext("RxLinkDelay", callback))
1861  {
1862  NS_LOG_INFO(this << " successfully connected with node ID " << (*it)->GetId()
1863  << " device #" << satDev->GetIfIndex());
1864 
1865  // Enable statistics-related tags and trace sources on the device.
1866  satDev->SetAttribute("EnableStatisticsTags", BooleanValue(true));
1867  satPhy->SetAttribute("EnableStatisticsTags", BooleanValue(true));
1868  }
1869  else
1870  {
1871  NS_FATAL_ERROR("Error connecting to RxLinkDelay trace source of SatNetDevice"
1872  << " at node ID " << (*it)->GetId() << " device #"
1873  << satDev->GetIfIndex());
1874  }
1875 
1876  } // end of `for (NetDeviceContainer::Iterator itDev = devs)`
1877 
1878  } // end of `for (NodeContainer::Iterator it = gws)`
1879 
1880 } // end of `void DoInstallProbes ();`
1881 
1882 // RETURN USER LINK PHY-LEVEL //////////////////////////////////////////////////////
1883 
1884 NS_OBJECT_ENSURE_REGISTERED(SatStatsRtnUserPhyLinkDelayHelper);
1885 
1887  : SatStatsLinkDelayHelper(satHelper)
1888 {
1889  NS_LOG_FUNCTION(this << satHelper);
1890 }
1891 
1893 {
1894  NS_LOG_FUNCTION(this);
1895 }
1896 
1897 TypeId // static
1899 {
1900  static TypeId tid =
1901  TypeId("ns3::SatStatsRtnUserPhyLinkDelayHelper").SetParent<SatStatsLinkDelayHelper>();
1902  return tid;
1903 }
1904 
1905 void
1907 {
1908  NS_LOG_FUNCTION(this);
1909 
1910  NodeContainer sats = Singleton<SatTopology>::Get()->GetOrbiterNodes();
1911  Callback<void, const Time&, const Address&> callback =
1913 
1914  for (NodeContainer::Iterator it = sats.Begin(); it != sats.End(); ++it)
1915  {
1916  Ptr<NetDevice> dev = GetSatSatOrbiterNetDevice(*it);
1917  Ptr<SatOrbiterNetDevice> satOrbiterDev = dev->GetObject<SatOrbiterNetDevice>();
1918  NS_ASSERT(satOrbiterDev != nullptr);
1919  satOrbiterDev->SetAttribute("EnableStatisticsTags", BooleanValue(true));
1920  std::map<uint32_t, Ptr<SatPhy>> satOrbiterFeederPhys = satOrbiterDev->GetFeederPhy();
1921  Ptr<SatPhy> satPhy;
1922  for (std::map<uint32_t, Ptr<SatPhy>>::iterator it2 = satOrbiterFeederPhys.begin();
1923  it2 != satOrbiterFeederPhys.end();
1924  ++it2)
1925  {
1926  satPhy = it2->second;
1927  NS_ASSERT(satPhy != nullptr);
1928  satPhy->SetAttribute("EnableStatisticsTags", BooleanValue(true));
1929  }
1930  std::map<uint32_t, Ptr<SatPhy>> satOrbiterUserPhys = satOrbiterDev->GetUserPhy();
1931  for (std::map<uint32_t, Ptr<SatPhy>>::iterator it2 = satOrbiterUserPhys.begin();
1932  it2 != satOrbiterUserPhys.end();
1933  ++it2)
1934  {
1935  satPhy = it2->second;
1936  NS_ASSERT(satPhy != nullptr);
1937  satPhy->SetAttribute("EnableStatisticsTags", BooleanValue(true));
1938 
1939  // Connect the object to the probe.
1940  if (satPhy->TraceConnectWithoutContext("RxLinkDelay", callback))
1941  {
1942  NS_LOG_INFO(this << " successfully connected with node ID " << (*it)->GetId()
1943  << " device #" << satOrbiterDev->GetIfIndex());
1944  }
1945  else
1946  {
1947  NS_FATAL_ERROR("Error connecting to RxLinkDelay trace source of SatNetDevice"
1948  << " at node ID " << (*it)->GetId() << " device #"
1949  << satOrbiterDev->GetIfIndex());
1950  }
1951  }
1952  } // end of `for (it = sats.Begin(); it != sats.End (); ++it)`
1953 
1954  NodeContainer uts = Singleton<SatTopology>::Get()->GetUtNodes();
1955  for (NodeContainer::Iterator it = uts.Begin(); it != uts.End(); ++it)
1956  {
1957  // Create a map of UT addresses and identifiers.
1959 
1960  // Enable statistics-related tags and trace sources on the device.
1961  Ptr<NetDevice> dev = GetUtSatNetDevice(*it);
1962  Ptr<SatNetDevice> satDev = dev->GetObject<SatNetDevice>();
1963  NS_ASSERT(satDev != nullptr);
1964  Ptr<SatPhy> satPhy = satDev->GetPhy();
1965  NS_ASSERT(satPhy != nullptr);
1966  satDev->SetAttribute("EnableStatisticsTags", BooleanValue(true));
1967  satPhy->SetAttribute("EnableStatisticsTags", BooleanValue(true));
1968  }
1969 
1970  // Connect to trace sources at GW nodes.
1971 
1972  NodeContainer gws = Singleton<SatTopology>::Get()->GetGwNodes();
1973 
1974  for (NodeContainer::Iterator it = gws.Begin(); it != gws.End(); ++it)
1975  {
1976  NetDeviceContainer devs = GetGwSatNetDevice(*it);
1977 
1978  for (NetDeviceContainer::Iterator itDev = devs.Begin(); itDev != devs.End(); ++itDev)
1979  {
1980  Ptr<SatNetDevice> satDev = (*itDev)->GetObject<SatNetDevice>();
1981  NS_ASSERT(satDev != nullptr);
1982  Ptr<SatPhy> satPhy = satDev->GetPhy();
1983  NS_ASSERT(satPhy != nullptr);
1984 
1985  satDev->SetAttribute("EnableStatisticsTags", BooleanValue(true));
1986  satPhy->SetAttribute("EnableStatisticsTags", BooleanValue(true));
1987  } // end of `for (NetDeviceContainer::Iterator itDev = devs)`
1988 
1989  } // end of `for (NodeContainer::Iterator it = gws)`
1990 
1991 } // end of `void DoInstallProbes ();`
1992 
1993 } // end of namespace ns3
SatNetDevice to be utilized in the UT and GW nodes.
SatOrbiterNetDevice to be utilized in geostationary satellite.
Parent abstract class of all satellite statistics helpers.
static Ptr< NetDevice > GetSatSatOrbiterNetDevice(Ptr< Node > satNode)
static NetDeviceContainer GetGwSatNetDevice(Ptr< Node > gwNode)
virtual void SaveAddressAndIdentifier(Ptr< Node > utNode)
Save the address and the proper identifier from the given UT node.
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 GetUtId(Ptr< Node > utNode) const
uint32_t CreateCollectorPerIdentifier(CollectorMap &collectorMap) const
Create one collector instance for each identifier in the simulation.
static Ptr< NetDevice > GetUtSatNetDevice(Ptr< Node > utNode)
OutputType_t GetOutputType() const
uint32_t GetIdentifierForUt(Ptr< Node > utNode) const
std::string GetName() const
virtual std::string GetTimeHeading(std::string dataLabel) const
virtual std::string GetDistributionHeading(std::string dataLabel) const
SatArqSequenceNumber is handling the sequence numbers for the ARQ process.