satellite-stats-throughput-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-packet-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/interval-rate-collector.h>
33 #include <ns3/ipv4.h>
34 #include <ns3/log.h>
35 #include <ns3/mac48-address.h>
36 #include <ns3/magister-gnuplot-aggregator.h>
37 #include <ns3/multi-file-aggregator.h>
38 #include <ns3/net-device.h>
39 #include <ns3/node-container.h>
40 #include <ns3/packet.h>
41 #include <ns3/probe.h>
42 #include <ns3/satellite-geo-net-device.h>
43 #include <ns3/satellite-helper.h>
44 #include <ns3/satellite-id-mapper.h>
45 #include <ns3/satellite-mac.h>
46 #include <ns3/satellite-net-device.h>
47 #include <ns3/satellite-phy.h>
48 #include <ns3/scalar-collector.h>
49 #include <ns3/singleton.h>
50 #include <ns3/string.h>
51 #include <ns3/unit-conversion-collector.h>
52 
53 #include <sstream>
54 
55 NS_LOG_COMPONENT_DEFINE("SatStatsThroughputHelper");
56 
57 namespace ns3
58 {
59 
60 NS_OBJECT_ENSURE_REGISTERED(SatStatsThroughputHelper);
61 
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::SatStatsThroughputHelper")
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(&SatStatsThroughputHelper::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("throughput_kbps")));
126 
127  // Setup second-level 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_SECOND));
135  m_terminalCollectors.ConnectToAggregator("Output",
136  m_aggregator,
137  &MultiFileAggregator::Write1d);
138 
139  // Setup first-level collectors.
140  m_conversionCollectors.SetType("ns3::UnitConversionCollector");
141  m_conversionCollectors.SetAttribute("ConversionType",
142  EnumValue(UnitConversionCollector::FROM_BYTES_TO_KBIT));
144  m_conversionCollectors.ConnectToCollector("Output",
146  &ScalarCollector::TraceSinkDouble);
147  break;
148  }
149 
151  // Setup aggregator.
152  m_aggregator = CreateAggregator("ns3::MultiFileAggregator",
153  "OutputFileName",
154  StringValue(GetOutputFileName()),
155  "GeneralHeading",
156  StringValue(GetTimeHeading("throughput_kbps")));
157 
158  // Setup second-level collectors.
159  m_terminalCollectors.SetType("ns3::IntervalRateCollector");
160  m_terminalCollectors.SetAttribute("InputDataType",
161  EnumValue(IntervalRateCollector::INPUT_DATA_TYPE_DOUBLE));
163  m_terminalCollectors.ConnectToAggregator("OutputWithTime",
164  m_aggregator,
165  &MultiFileAggregator::Write2d);
166  m_terminalCollectors.ConnectToAggregator("OutputString",
167  m_aggregator,
168  &MultiFileAggregator::AddContextHeading);
169 
170  // Setup first-level collectors.
171  m_conversionCollectors.SetType("ns3::UnitConversionCollector");
172  m_conversionCollectors.SetAttribute("ConversionType",
173  EnumValue(UnitConversionCollector::FROM_BYTES_TO_KBIT));
175  m_conversionCollectors.ConnectToCollector("Output",
177  &IntervalRateCollector::TraceSinkDouble);
178  break;
179  }
180 
184  if (!m_averagingMode)
185  {
186  NS_FATAL_ERROR("This statistics require AveragingMode to be enabled");
187  }
188 
189  // Setup aggregator.
190  m_aggregator = CreateAggregator("ns3::MultiFileAggregator",
191  "OutputFileName",
192  StringValue(GetOutputFileName()),
193  "MultiFileMode",
194  BooleanValue(false),
195  "EnableContextPrinting",
196  BooleanValue(false),
197  "GeneralHeading",
198  StringValue(GetDistributionHeading("throughput_kbps")));
199  Ptr<MultiFileAggregator> fileAggregator = m_aggregator->GetObject<MultiFileAggregator>();
200  NS_ASSERT(fileAggregator != nullptr);
201 
202  // Setup the final-level collector.
203  m_averagingCollector = CreateObject<DistributionCollector>();
204  DistributionCollector::OutputType_t outputType =
205  DistributionCollector::OUTPUT_TYPE_HISTOGRAM;
207  {
208  outputType = DistributionCollector::OUTPUT_TYPE_PROBABILITY;
209  }
211  {
212  outputType = DistributionCollector::OUTPUT_TYPE_CUMULATIVE;
213  }
214  m_averagingCollector->SetOutputType(outputType);
215  m_averagingCollector->SetName("0");
216  m_averagingCollector->TraceConnect(
217  "Output",
218  "0",
219  MakeCallback(&MultiFileAggregator::Write2d, fileAggregator));
220  m_averagingCollector->TraceConnect(
221  "OutputString",
222  "0",
223  MakeCallback(&MultiFileAggregator::AddContextHeading, fileAggregator));
224  m_averagingCollector->TraceConnect(
225  "Warning",
226  "0",
227  MakeCallback(&MultiFileAggregator::EnableContextWarning, fileAggregator));
228 
229  // Setup second-level collectors.
230  m_terminalCollectors.SetType("ns3::ScalarCollector");
231  m_terminalCollectors.SetAttribute("InputDataType",
232  EnumValue(ScalarCollector::INPUT_DATA_TYPE_DOUBLE));
233  m_terminalCollectors.SetAttribute(
234  "OutputType",
235  EnumValue(ScalarCollector::OUTPUT_TYPE_AVERAGE_PER_SECOND));
237  Callback<void, double> callback =
238  MakeCallback(&DistributionCollector::TraceSinkDouble1, m_averagingCollector);
239  for (CollectorMap::Iterator it = m_terminalCollectors.Begin();
240  it != m_terminalCollectors.End();
241  ++it)
242  {
243  it->second->TraceConnectWithoutContext("Output", callback);
244  }
245 
246  // Setup first-level collectors.
247  m_conversionCollectors.SetType("ns3::UnitConversionCollector");
248  m_conversionCollectors.SetAttribute("ConversionType",
249  EnumValue(UnitConversionCollector::FROM_BYTES_TO_KBIT));
251  m_conversionCollectors.ConnectToCollector("Output",
253  &ScalarCollector::TraceSinkDouble);
254  break;
255  }
256 
259  NS_FATAL_ERROR(GetOutputTypeName(GetOutputType())
260  << " is not a valid output type for this statistics.");
261  break;
262 
264  // Setup aggregator.
265  m_aggregator = CreateAggregator("ns3::MagisterGnuplotAggregator",
266  "OutputPath",
267  StringValue(GetOutputPath()),
268  "OutputFileName",
269  StringValue(GetName()));
270  Ptr<MagisterGnuplotAggregator> plotAggregator =
271  m_aggregator->GetObject<MagisterGnuplotAggregator>();
272  NS_ASSERT(plotAggregator != nullptr);
273  // plot->SetTitle ("");
274  plotAggregator->SetLegend("Time (in seconds)",
275  "Received throughput (in kilobits per second)");
276  plotAggregator->Set2dDatasetDefaultStyle(Gnuplot2dDataset::LINES);
277 
278  // Setup second-level collectors.
279  m_terminalCollectors.SetType("ns3::IntervalRateCollector");
280  m_terminalCollectors.SetAttribute("InputDataType",
281  EnumValue(IntervalRateCollector::INPUT_DATA_TYPE_DOUBLE));
283  for (CollectorMap::Iterator it = m_terminalCollectors.Begin();
284  it != m_terminalCollectors.End();
285  ++it)
286  {
287  const std::string context = it->second->GetName();
288  plotAggregator->Add2dDataset(context, context);
289  }
290  m_terminalCollectors.ConnectToAggregator("OutputWithTime",
291  m_aggregator,
292  &MagisterGnuplotAggregator::Write2d);
293 
294  // Setup first-level collectors.
295  m_conversionCollectors.SetType("ns3::UnitConversionCollector");
296  m_conversionCollectors.SetAttribute("ConversionType",
297  EnumValue(UnitConversionCollector::FROM_BYTES_TO_KBIT));
299  m_conversionCollectors.ConnectToCollector("Output",
301  &IntervalRateCollector::TraceSinkDouble);
302  break;
303  }
304 
308  if (!m_averagingMode)
309  {
310  NS_FATAL_ERROR("This statistics require AveragingMode to be enabled");
311  }
312 
313  // Setup aggregator.
314  m_aggregator = CreateAggregator("ns3::MagisterGnuplotAggregator",
315  "OutputPath",
316  StringValue(GetOutputPath()),
317  "OutputFileName",
318  StringValue(GetName()));
319  Ptr<MagisterGnuplotAggregator> plotAggregator =
320  m_aggregator->GetObject<MagisterGnuplotAggregator>();
321  NS_ASSERT(plotAggregator != nullptr);
322  // plot->SetTitle ("");
323  plotAggregator->SetLegend("Received throughput (in kilobits per second)", "Frequency");
324  plotAggregator->Set2dDatasetDefaultStyle(Gnuplot2dDataset::LINES);
325  plotAggregator->Add2dDataset(GetName(), GetName());
327 
328  // Setup the final-level collector.
329  m_averagingCollector = CreateObject<DistributionCollector>();
330  DistributionCollector::OutputType_t outputType =
331  DistributionCollector::OUTPUT_TYPE_HISTOGRAM;
333  {
334  outputType = DistributionCollector::OUTPUT_TYPE_PROBABILITY;
335  }
337  {
338  outputType = DistributionCollector::OUTPUT_TYPE_CUMULATIVE;
339  }
340  m_averagingCollector->SetOutputType(outputType);
341  m_averagingCollector->SetName("0");
342  m_averagingCollector->TraceConnect(
343  "Output",
344  GetName(),
345  MakeCallback(&MagisterGnuplotAggregator::Write2d, plotAggregator));
347 
348  // Setup second-level collectors.
349  m_terminalCollectors.SetType("ns3::ScalarCollector");
350  m_terminalCollectors.SetAttribute("InputDataType",
351  EnumValue(ScalarCollector::INPUT_DATA_TYPE_DOUBLE));
352  m_terminalCollectors.SetAttribute(
353  "OutputType",
354  EnumValue(ScalarCollector::OUTPUT_TYPE_AVERAGE_PER_SECOND));
356  Callback<void, double> callback =
357  MakeCallback(&DistributionCollector::TraceSinkDouble1, m_averagingCollector);
358  for (CollectorMap::Iterator it = m_terminalCollectors.Begin();
359  it != m_terminalCollectors.End();
360  ++it)
361  {
362  it->second->TraceConnectWithoutContext("Output", callback);
363  }
364 
365  // Setup first-level collectors.
366  m_conversionCollectors.SetType("ns3::UnitConversionCollector");
367  m_conversionCollectors.SetAttribute("ConversionType",
368  EnumValue(UnitConversionCollector::FROM_BYTES_TO_KBIT));
370  m_conversionCollectors.ConnectToCollector("Output",
372  &ScalarCollector::TraceSinkDouble);
373  break;
374  }
375 
376  default:
377  NS_FATAL_ERROR("SatStatsThroughputHelper - Invalid output type");
378  break;
379  }
380 
381  // Setup probes and connect them to conversion collectors.
382  InstallProbes();
383 
384 } // end of `void DoInstall ();`
385 
386 void
388 {
389  NS_LOG_FUNCTION(this);
390 
391  // The method below is supposed to be implemented by the child class.
392  DoInstallProbes();
393 }
394 
395 void
396 SatStatsThroughputHelper::RxCallback(Ptr<const Packet> packet, const Address& from)
397 {
398  NS_LOG_FUNCTION(this << packet->GetSize() << from);
399 
400  if (from.IsInvalid())
401  {
402  NS_LOG_WARN(this << " discarding packet " << packet << " (" << packet->GetSize()
403  << " bytes)"
404  << " from statistics collection because of"
405  << " invalid sender address");
406  }
407  else
408  {
409  // Determine the identifier associated with the sender address.
410  std::map<const Address, uint32_t>::const_iterator it = m_identifierMap.find(from);
411 
412  if (it == m_identifierMap.end())
413  {
414  NS_LOG_WARN(this << " discarding packet " << packet << " (" << packet->GetSize()
415  << " bytes)"
416  << " from statistics collection because of"
417  << " unknown sender address " << from);
418  }
419  else
420  {
421  // Find the first-level collector with the right identifier.
422  Ptr<DataCollectionObject> collector = m_conversionCollectors.Get(it->second);
423  NS_ASSERT_MSG(collector != nullptr,
424  "Unable to find collector with identifier " << it->second);
425  Ptr<UnitConversionCollector> c = collector->GetObject<UnitConversionCollector>();
426  NS_ASSERT(c != nullptr);
427 
428  // Pass the sample to the collector.
429  c->TraceSinkUinteger32(0, packet->GetSize());
430  }
431  }
432 
433 } // end of `void RxCallback (Ptr<const Packet>, const Address);`
434 
435 void
437 {
438  NS_LOG_FUNCTION(this << utNode->GetId());
439 
440  const SatIdMapper* satIdMapper = Singleton<SatIdMapper>::Get();
441  const Address addr = satIdMapper->GetUtMacWithNode(utNode);
442 
443  if (addr.IsInvalid())
444  {
445  NS_LOG_WARN(this << " Node " << utNode->GetId() << " is not a valid UT");
446  }
447  else
448  {
449  const uint32_t identifier = GetIdentifierForUt(utNode);
450  m_identifierMap[addr] = identifier;
451  NS_LOG_INFO(this << " associated address " << addr << " with identifier " << identifier);
452  }
453 }
454 
455 // FORWARD LINK APPLICATION-LEVEL /////////////////////////////////////////////
456 
457 NS_OBJECT_ENSURE_REGISTERED(SatStatsFwdAppThroughputHelper);
458 
460  : SatStatsThroughputHelper(satHelper)
461 {
462  NS_LOG_FUNCTION(this << satHelper);
463 }
464 
466 {
467  NS_LOG_FUNCTION(this);
468 }
469 
470 TypeId // static
472 {
473  static TypeId tid =
474  TypeId("ns3::SatStatsFwdAppThroughputHelper").SetParent<SatStatsThroughputHelper>();
475  return tid;
476 }
477 
478 void
480 {
481  NS_LOG_FUNCTION(this);
482  NodeContainer utUsers = GetSatHelper()->GetUtUsers();
483 
484  for (NodeContainer::Iterator it = utUsers.Begin(); it != utUsers.End(); ++it)
485  {
486  const int32_t utUserId = GetUtUserId(*it);
487  NS_ASSERT_MSG(utUserId > 0, "Node " << (*it)->GetId() << " is not a valid UT user");
488  const uint32_t identifier = GetIdentifierForUtUser(*it);
489 
490  for (uint32_t i = 0; i < (*it)->GetNApplications(); i++)
491  {
492  // Create the probe.
493  std::ostringstream probeName;
494  probeName << utUserId << "-" << i;
495  Ptr<ApplicationPacketProbe> probe = CreateObject<ApplicationPacketProbe>();
496  probe->SetName(probeName.str());
497 
498  // Connect the object to the probe.
499  if (probe->ConnectByObject("Rx", (*it)->GetApplication(i)))
500  {
501  // Connect the probe to the right collector.
502  if (m_conversionCollectors.ConnectWithProbe(
503  probe->GetObject<Probe>(),
504  "OutputBytes",
505  identifier,
506  &UnitConversionCollector::TraceSinkUinteger32))
507  {
508  NS_LOG_INFO(this << " created probe " << probeName.str()
509  << ", connected to collector " << identifier);
510  m_probes.push_back(probe->GetObject<Probe>());
511  }
512  else
513  {
514  NS_LOG_WARN(this << " unable to connect probe " << probeName.str()
515  << " to collector " << identifier);
516  }
517  }
518  else
519  {
520  /*
521  * We're being tolerant here by only logging a warning, because
522  * not every kind of Application is equipped with the expected
523  * Rx trace source.
524  */
525  NS_LOG_WARN(this << " unable to connect probe " << probeName.str()
526  << " with node ID " << (*it)->GetId() << " application #" << i);
527  }
528 
529  } // end of `for (i = 0; i < (*it)->GetNApplications (); i++)`
530 
531  } // end of `for (it = utUsers.Begin(); it != utUsers.End (); ++it)`
532 
533 } // end of `void DoInstallProbes ();`
534 
535 // FORWARD FEEDER LINK DEVICE-LEVEL //////////////////////////////////////////////////
536 
537 NS_OBJECT_ENSURE_REGISTERED(SatStatsFwdFeederDevThroughputHelper);
538 
540  Ptr<const SatHelper> satHelper)
541  : SatStatsThroughputHelper(satHelper)
542 {
543  NS_LOG_FUNCTION(this << satHelper);
544 }
545 
547 {
548  NS_LOG_FUNCTION(this);
549 }
550 
551 TypeId // static
553 {
554  static TypeId tid =
555  TypeId("ns3::SatStatsFwdFeederDevThroughputHelper").SetParent<SatStatsThroughputHelper>();
556  return tid;
557 }
558 
559 void
561 {
562  NS_LOG_FUNCTION(this);
563 
564  NodeContainer sats = GetSatHelper()->GetBeamHelper()->GetGeoSatNodes();
565  Callback<void, Ptr<const Packet>, const Address&> callback =
567 
568  for (NodeContainer::Iterator it = sats.Begin(); it != sats.End(); ++it)
569  {
570  Ptr<NetDevice> dev = GetSatSatGeoNetDevice(*it);
571  Ptr<SatGeoNetDevice> satGeoDev = dev->GetObject<SatGeoNetDevice>();
572  NS_ASSERT(satGeoDev != nullptr);
573  satGeoDev->SetAttribute("EnableStatisticsTags", BooleanValue(true));
574 
575  if (satGeoDev->TraceConnectWithoutContext("RxFeeder", callback))
576  {
577  NS_LOG_INFO(this << " successfully connected with node ID " << (*it)->GetId()
578  << " device #" << satGeoDev->GetIfIndex());
579 
580  // Enable statistics-related tags and trace sources on the device.
581  satGeoDev->SetAttribute("EnableStatisticsTags", BooleanValue(true));
582  }
583  else
584  {
585  NS_FATAL_ERROR("Error connecting to Rx trace source of SatNetDevice"
586  << " at node ID " << (*it)->GetId() << " device #"
587  << satGeoDev->GetIfIndex());
588  }
589  } // end of `for (it = sats.Begin(); it != sats.End (); ++it)`
590 
591  NodeContainer uts = GetSatHelper()->GetBeamHelper()->GetUtNodes();
592 
593  for (NodeContainer::Iterator it = uts.Begin(); it != uts.End(); ++it)
594  {
595  // Create a map of UT addresses and identifiers.
597 
598  Ptr<NetDevice> dev = GetUtSatNetDevice(*it);
599  Ptr<SatNetDevice> satDev = dev->GetObject<SatNetDevice>();
600  NS_ASSERT(satDev != nullptr);
601 
602  satDev->SetAttribute("EnableStatisticsTags", BooleanValue(true));
603 
604  } // end of `for (it = uts.Begin(); it != uts.End (); ++it)`
605 
606  // Enable statistics-related tags on the transmitting device.
607  NodeContainer gws = GetSatHelper()->GetBeamHelper()->GetGwNodes();
608  for (NodeContainer::Iterator it = gws.Begin(); it != gws.End(); ++it)
609  {
610  NetDeviceContainer devs = GetGwSatNetDevice(*it);
611 
612  for (NetDeviceContainer::Iterator itDev = devs.Begin(); itDev != devs.End(); ++itDev)
613  {
614  Ptr<SatNetDevice> satDev = (*itDev)->GetObject<SatNetDevice>();
615  NS_ASSERT(satDev != nullptr);
616 
617  satDev->SetAttribute("EnableStatisticsTags", BooleanValue(true));
618  }
619  }
620 } // end of `void DoInstallProbes ();`
621 
622 // FORWARD USER LINK DEVICE-LEVEL //////////////////////////////////////////////////
623 
624 NS_OBJECT_ENSURE_REGISTERED(SatStatsFwdUserDevThroughputHelper);
625 
627  Ptr<const SatHelper> satHelper)
628  : SatStatsThroughputHelper(satHelper)
629 {
630  NS_LOG_FUNCTION(this << satHelper);
631 }
632 
634 {
635  NS_LOG_FUNCTION(this);
636 }
637 
638 TypeId // static
640 {
641  static TypeId tid =
642  TypeId("ns3::SatStatsFwdUserDevThroughputHelper").SetParent<SatStatsThroughputHelper>();
643  return tid;
644 }
645 
646 void
648 {
649  NS_LOG_FUNCTION(this);
650  NodeContainer uts = GetSatHelper()->GetBeamHelper()->GetUtNodes();
651 
652  for (NodeContainer::Iterator it = uts.Begin(); it != uts.End(); ++it)
653  {
654  const int32_t utId = GetUtId(*it);
655  NS_ASSERT_MSG(utId > 0, "Node " << (*it)->GetId() << " is not a valid UT");
656  const uint32_t identifier = GetIdentifierForUt(*it);
657 
658  // Create the probe.
659  std::ostringstream probeName;
660  probeName << utId;
661  Ptr<ApplicationPacketProbe> probe = CreateObject<ApplicationPacketProbe>();
662  probe->SetName(probeName.str());
663 
664  Ptr<NetDevice> dev = GetUtSatNetDevice(*it);
665 
666  // Connect the object to the probe.
667  if (probe->ConnectByObject("Rx", dev))
668  {
669  // Connect the probe to the right collector.
670  if (m_conversionCollectors.ConnectWithProbe(
671  probe->GetObject<Probe>(),
672  "OutputBytes",
673  identifier,
674  &UnitConversionCollector::TraceSinkUinteger32))
675  {
676  NS_LOG_INFO(this << " created probe " << probeName.str()
677  << ", connected to collector " << identifier);
678  m_probes.push_back(probe->GetObject<Probe>());
679 
680  // Enable statistics-related tags and trace sources on the device.
681  dev->SetAttribute("EnableStatisticsTags", BooleanValue(true));
682  }
683  else
684  {
685  NS_LOG_WARN(this << " unable to connect probe " << probeName.str()
686  << " to collector " << identifier);
687  }
688 
689  } // end of `if (probe->ConnectByObject ("Rx", dev))`
690  else
691  {
692  NS_FATAL_ERROR("Error connecting to Rx trace source of SatNetDevice"
693  << " at node ID " << (*it)->GetId() << " device #2");
694  }
695 
696  } // end of `for (it = uts.Begin(); it != uts.End (); ++it)`
697 
698  // Enable statistics-related tags on the transmitting device.
699  NodeContainer gws = GetSatHelper()->GetBeamHelper()->GetGwNodes();
700  for (NodeContainer::Iterator it = gws.Begin(); it != gws.End(); ++it)
701  {
702  NetDeviceContainer devs = GetGwSatNetDevice(*it);
703 
704  for (NetDeviceContainer::Iterator itDev = devs.Begin(); itDev != devs.End(); ++itDev)
705  {
706  NS_ASSERT((*itDev)->GetObject<SatNetDevice>() != nullptr);
707  (*itDev)->SetAttribute("EnableStatisticsTags", BooleanValue(true));
708  }
709  }
710 
711 } // end of `void DoInstallProbes ();`
712 
713 // FORWARD FEEDER LINK MAC-LEVEL /////////////////////////////////////////////////////
714 
715 NS_OBJECT_ENSURE_REGISTERED(SatStatsFwdFeederMacThroughputHelper);
716 
718  Ptr<const SatHelper> satHelper)
719  : SatStatsThroughputHelper(satHelper)
720 {
721  NS_LOG_FUNCTION(this << satHelper);
722 }
723 
725 {
726  NS_LOG_FUNCTION(this);
727 }
728 
729 TypeId // static
731 {
732  static TypeId tid =
733  TypeId("ns3::SatStatsFwdFeederMacThroughputHelper").SetParent<SatStatsThroughputHelper>();
734  return tid;
735 }
736 
737 void
739 {
740  NS_LOG_FUNCTION(this);
741 
742  NodeContainer sats = GetSatHelper()->GetBeamHelper()->GetGeoSatNodes();
743  Callback<void, Ptr<const Packet>, const Address&> callback =
745 
746  for (NodeContainer::Iterator it = sats.Begin(); it != sats.End(); ++it)
747  {
748  Ptr<NetDevice> dev = GetSatSatGeoNetDevice(*it);
749  Ptr<SatGeoNetDevice> satGeoDev = dev->GetObject<SatGeoNetDevice>();
750  NS_ASSERT(satGeoDev != nullptr);
751  satGeoDev->SetAttribute("EnableStatisticsTags", BooleanValue(true));
752  std::map<uint32_t, Ptr<SatMac>> satGeoFeederMacs = satGeoDev->GetAllFeederMac();
753  Ptr<SatMac> satMac;
754  for (std::map<uint32_t, Ptr<SatMac>>::iterator it2 = satGeoFeederMacs.begin();
755  it2 != satGeoFeederMacs.end();
756  ++it2)
757  {
758  satMac = it2->second;
759  NS_ASSERT(satMac != nullptr);
760  satMac->SetAttribute("EnableStatisticsTags", BooleanValue(true));
761 
762  // Connect the object to the probe.
763  if (satMac->TraceConnectWithoutContext("Rx", callback))
764  {
765  NS_LOG_INFO(this << " successfully connected with node ID " << (*it)->GetId()
766  << " device #" << satGeoDev->GetIfIndex());
767  }
768  else
769  {
770  NS_FATAL_ERROR("Error connecting to Rx trace source of SatMac"
771  << " at node ID " << (*it)->GetId() << " device #"
772  << satGeoDev->GetIfIndex());
773  }
774  }
775  std::map<uint32_t, Ptr<SatMac>> satGeoUserMacs = satGeoDev->GetUserMac();
776  for (std::map<uint32_t, Ptr<SatMac>>::iterator it2 = satGeoUserMacs.begin();
777  it2 != satGeoUserMacs.end();
778  ++it2)
779  {
780  satMac = it2->second;
781  NS_ASSERT(satMac != nullptr);
782  satMac->SetAttribute("EnableStatisticsTags", BooleanValue(true));
783  }
784  } // end of `for (it = sats.Begin(); it != sats.End (); ++it)`
785 
786  NodeContainer uts = GetSatHelper()->GetBeamHelper()->GetUtNodes();
787 
788  for (NodeContainer::Iterator it = uts.Begin(); it != uts.End(); ++it)
789  {
790  // Create a map of UT addresses and identifiers.
792 
793  Ptr<NetDevice> dev = GetUtSatNetDevice(*it);
794  Ptr<SatNetDevice> satDev = dev->GetObject<SatNetDevice>();
795  NS_ASSERT(satDev != nullptr);
796  Ptr<SatMac> satMac = satDev->GetMac();
797  NS_ASSERT(satMac != nullptr);
798 
799  satDev->SetAttribute("EnableStatisticsTags", BooleanValue(true));
800  satMac->SetAttribute("EnableStatisticsTags", BooleanValue(true));
801 
802  } // end of `for (it = uts.Begin(); it != uts.End (); ++it)`
803 
804  // Enable statistics-related tags on the transmitting device.
805  NodeContainer gws = GetSatHelper()->GetBeamHelper()->GetGwNodes();
806  for (NodeContainer::Iterator it = gws.Begin(); it != gws.End(); ++it)
807  {
808  NetDeviceContainer devs = GetGwSatNetDevice(*it);
809 
810  for (NetDeviceContainer::Iterator itDev = devs.Begin(); itDev != devs.End(); ++itDev)
811  {
812  Ptr<SatNetDevice> satDev = (*itDev)->GetObject<SatNetDevice>();
813  NS_ASSERT(satDev != nullptr);
814  Ptr<SatMac> satMac = satDev->GetMac();
815  NS_ASSERT(satMac != nullptr);
816 
817  satDev->SetAttribute("EnableStatisticsTags", BooleanValue(true));
818  satMac->SetAttribute("EnableStatisticsTags", BooleanValue(true));
819  }
820  }
821 
822 } // end of `void DoInstallProbes ();`
823 
824 // FORWARD USER LINK MAC-LEVEL /////////////////////////////////////////////////////
825 
826 NS_OBJECT_ENSURE_REGISTERED(SatStatsFwdUserMacThroughputHelper);
827 
829  Ptr<const SatHelper> satHelper)
830  : SatStatsThroughputHelper(satHelper)
831 {
832  NS_LOG_FUNCTION(this << satHelper);
833 }
834 
836 {
837  NS_LOG_FUNCTION(this);
838 }
839 
840 TypeId // static
842 {
843  static TypeId tid =
844  TypeId("ns3::SatStatsFwdUserMacThroughputHelper").SetParent<SatStatsThroughputHelper>();
845  return tid;
846 }
847 
848 void
850 {
851  NS_LOG_FUNCTION(this);
852 
853  NodeContainer sats = GetSatHelper()->GetBeamHelper()->GetGeoSatNodes();
854 
855  for (NodeContainer::Iterator it = sats.Begin(); it != sats.End(); ++it)
856  {
857  Ptr<NetDevice> dev = GetSatSatGeoNetDevice(*it);
858  Ptr<SatGeoNetDevice> satGeoDev = dev->GetObject<SatGeoNetDevice>();
859  NS_ASSERT(satGeoDev != nullptr);
860  satGeoDev->SetAttribute("EnableStatisticsTags", BooleanValue(true));
861  std::map<uint32_t, Ptr<SatMac>> satGeoFeederMacs = satGeoDev->GetAllFeederMac();
862  Ptr<SatMac> satMac;
863  for (std::map<uint32_t, Ptr<SatMac>>::iterator it2 = satGeoFeederMacs.begin();
864  it2 != satGeoFeederMacs.end();
865  ++it2)
866  {
867  satMac = it2->second;
868  NS_ASSERT(satMac != nullptr);
869  satMac->SetAttribute("EnableStatisticsTags", BooleanValue(true));
870  }
871  std::map<uint32_t, Ptr<SatMac>> satGeoUserMacs = satGeoDev->GetUserMac();
872  for (std::map<uint32_t, Ptr<SatMac>>::iterator it2 = satGeoUserMacs.begin();
873  it2 != satGeoUserMacs.end();
874  ++it2)
875  {
876  satMac = it2->second;
877  NS_ASSERT(satMac != nullptr);
878  satMac->SetAttribute("EnableStatisticsTags", BooleanValue(true));
879  }
880  } // end of `for (it = sats.Begin(); it != sats.End (); ++it)`
881 
882  NodeContainer uts = GetSatHelper()->GetBeamHelper()->GetUtNodes();
883 
884  for (NodeContainer::Iterator it = uts.Begin(); it != uts.End(); ++it)
885  {
886  const int32_t utId = GetUtId(*it);
887  NS_ASSERT_MSG(utId > 0, "Node " << (*it)->GetId() << " is not a valid UT");
888  const uint32_t identifier = GetIdentifierForUt(*it);
889 
890  // Create the probe.
891  std::ostringstream probeName;
892  probeName << utId;
893  Ptr<ApplicationPacketProbe> probe = CreateObject<ApplicationPacketProbe>();
894  probe->SetName(probeName.str());
895 
896  Ptr<NetDevice> dev = GetUtSatNetDevice(*it);
897  Ptr<SatNetDevice> satDev = dev->GetObject<SatNetDevice>();
898  NS_ASSERT(satDev != nullptr);
899  Ptr<SatMac> satMac = satDev->GetMac();
900  NS_ASSERT(satMac != nullptr);
901 
902  // Connect the object to the probe.
903  if (probe->ConnectByObject("Rx", satMac))
904  {
905  // Connect the probe to the right collector.
906  if (m_conversionCollectors.ConnectWithProbe(
907  probe->GetObject<Probe>(),
908  "OutputBytes",
909  identifier,
910  &UnitConversionCollector::TraceSinkUinteger32))
911  {
912  m_probes.push_back(probe->GetObject<Probe>());
913 
914  // Enable statistics-related tags and trace sources on the device.
915  satDev->SetAttribute("EnableStatisticsTags", BooleanValue(true));
916  satMac->SetAttribute("EnableStatisticsTags", BooleanValue(true));
917  }
918  else
919  {
920  NS_LOG_WARN(this << " unable to connect probe " << probeName.str()
921  << " to collector " << identifier);
922  }
923  }
924  else
925  {
926  NS_FATAL_ERROR("Error connecting to Rx trace source of SatMac"
927  << " at node ID " << (*it)->GetId() << " device #2");
928  }
929  } // end of `for (it = uts.Begin(); it != uts.End (); ++it)`
930 
931  // Enable statistics-related tags on the transmitting device.
932  NodeContainer gws = GetSatHelper()->GetBeamHelper()->GetGwNodes();
933  for (NodeContainer::Iterator it = gws.Begin(); it != gws.End(); ++it)
934  {
935  NetDeviceContainer devs = GetGwSatNetDevice(*it);
936 
937  for (NetDeviceContainer::Iterator itDev = devs.Begin(); itDev != devs.End(); ++itDev)
938  {
939  Ptr<SatNetDevice> satDev = (*itDev)->GetObject<SatNetDevice>();
940  NS_ASSERT(satDev != nullptr);
941  Ptr<SatMac> satMac = satDev->GetMac();
942  NS_ASSERT(satMac != nullptr);
943 
944  satDev->SetAttribute("EnableStatisticsTags", BooleanValue(true));
945  satMac->SetAttribute("EnableStatisticsTags", BooleanValue(true));
946  }
947  }
948 
949 } // end of `void DoInstallProbes ();`
950 
951 // FORWARD FEEDER LINK PHY-LEVEL /////////////////////////////////////////////////////
952 
953 NS_OBJECT_ENSURE_REGISTERED(SatStatsFwdFeederPhyThroughputHelper);
954 
956  Ptr<const SatHelper> satHelper)
957  : SatStatsThroughputHelper(satHelper)
958 {
959  NS_LOG_FUNCTION(this << satHelper);
960 }
961 
963 {
964  NS_LOG_FUNCTION(this);
965 }
966 
967 TypeId // static
969 {
970  static TypeId tid =
971  TypeId("ns3::SatStatsFwdFeederPhyThroughputHelper").SetParent<SatStatsThroughputHelper>();
972  return tid;
973 }
974 
975 void
977 {
978  NS_LOG_FUNCTION(this);
979 
980  NodeContainer sats = GetSatHelper()->GetBeamHelper()->GetGeoSatNodes();
981  Callback<void, Ptr<const Packet>, const Address&> callback =
983 
984  for (NodeContainer::Iterator it = sats.Begin(); it != sats.End(); ++it)
985  {
986  Ptr<NetDevice> dev = GetSatSatGeoNetDevice(*it);
987  Ptr<SatGeoNetDevice> satGeoDev = dev->GetObject<SatGeoNetDevice>();
988  NS_ASSERT(satGeoDev != nullptr);
989  satGeoDev->SetAttribute("EnableStatisticsTags", BooleanValue(true));
990  std::map<uint32_t, Ptr<SatPhy>> satGeoFeederPhys = satGeoDev->GetFeederPhy();
991  Ptr<SatPhy> satPhy;
992  for (std::map<uint32_t, Ptr<SatPhy>>::iterator it2 = satGeoFeederPhys.begin();
993  it2 != satGeoFeederPhys.end();
994  ++it2)
995  {
996  satPhy = it2->second;
997  NS_ASSERT(satPhy != nullptr);
998  satPhy->SetAttribute("EnableStatisticsTags", BooleanValue(true));
999 
1000  // Connect the object to the probe.
1001  if (satPhy->TraceConnectWithoutContext("Rx", callback))
1002  {
1003  NS_LOG_INFO(this << " successfully connected with node ID " << (*it)->GetId()
1004  << " device #" << satGeoDev->GetIfIndex());
1005 
1006  // Enable statistics-related tags and trace sources on the device.
1007  satPhy->SetAttribute("EnableStatisticsTags", BooleanValue(true));
1008  }
1009  else
1010  {
1011  NS_FATAL_ERROR("Error connecting to Rx trace source of SatPhy"
1012  << " at node ID " << (*it)->GetId() << " device #"
1013  << satGeoDev->GetIfIndex());
1014  }
1015  }
1016  std::map<uint32_t, Ptr<SatPhy>> satGeoUserPhys = satGeoDev->GetUserPhy();
1017  for (std::map<uint32_t, Ptr<SatPhy>>::iterator it2 = satGeoUserPhys.begin();
1018  it2 != satGeoUserPhys.end();
1019  ++it2)
1020  {
1021  satPhy = it2->second;
1022  NS_ASSERT(satPhy != nullptr);
1023  satPhy->SetAttribute("EnableStatisticsTags", BooleanValue(true));
1024  }
1025  } // end of `for (it = sats.Begin(); it != sats.End (); ++it)`
1026 
1027  NodeContainer uts = GetSatHelper()->GetBeamHelper()->GetUtNodes();
1028 
1029  for (NodeContainer::Iterator it = uts.Begin(); it != uts.End(); ++it)
1030  {
1031  // Create a map of UT addresses and identifiers.
1033 
1034  Ptr<NetDevice> dev = GetUtSatNetDevice(*it);
1035  Ptr<SatNetDevice> satDev = dev->GetObject<SatNetDevice>();
1036  NS_ASSERT(satDev != nullptr);
1037  Ptr<SatPhy> satPhy = satDev->GetPhy();
1038  NS_ASSERT(satPhy != nullptr);
1039 
1040  satDev->SetAttribute("EnableStatisticsTags", BooleanValue(true));
1041  satPhy->SetAttribute("EnableStatisticsTags", BooleanValue(true));
1042 
1043  } // end of `for (it = uts.Begin(); it != uts.End (); ++it)`
1044 
1045  // Enable statistics-related tags on the transmitting device.
1046  NodeContainer gws = GetSatHelper()->GetBeamHelper()->GetGwNodes();
1047  for (NodeContainer::Iterator it = gws.Begin(); it != gws.End(); ++it)
1048  {
1049  NetDeviceContainer devs = GetGwSatNetDevice(*it);
1050 
1051  for (NetDeviceContainer::Iterator itDev = devs.Begin(); itDev != devs.End(); ++itDev)
1052  {
1053  Ptr<SatNetDevice> satDev = (*itDev)->GetObject<SatNetDevice>();
1054  NS_ASSERT(satDev != nullptr);
1055  Ptr<SatPhy> satPhy = satDev->GetPhy();
1056  NS_ASSERT(satPhy != nullptr);
1057 
1058  satDev->SetAttribute("EnableStatisticsTags", BooleanValue(true));
1059  satPhy->SetAttribute("EnableStatisticsTags", BooleanValue(true));
1060  }
1061  }
1062 
1063 } // end of `void DoInstallProbes ();`
1064 
1065 // FORWARD USER LINK PHY-LEVEL /////////////////////////////////////////////////////
1066 
1067 NS_OBJECT_ENSURE_REGISTERED(SatStatsFwdUserPhyThroughputHelper);
1068 
1070  Ptr<const SatHelper> satHelper)
1071  : SatStatsThroughputHelper(satHelper)
1072 {
1073  NS_LOG_FUNCTION(this << satHelper);
1074 }
1075 
1077 {
1078  NS_LOG_FUNCTION(this);
1079 }
1080 
1081 TypeId // static
1083 {
1084  static TypeId tid =
1085  TypeId("ns3::SatStatsFwdUserPhyThroughputHelper").SetParent<SatStatsThroughputHelper>();
1086  return tid;
1087 }
1088 
1089 void
1091 {
1092  NS_LOG_FUNCTION(this);
1093 
1094  NodeContainer sats = GetSatHelper()->GetBeamHelper()->GetGeoSatNodes();
1095 
1096  for (NodeContainer::Iterator it = sats.Begin(); it != sats.End(); ++it)
1097  {
1098  Ptr<NetDevice> dev = GetSatSatGeoNetDevice(*it);
1099  Ptr<SatGeoNetDevice> satGeoDev = dev->GetObject<SatGeoNetDevice>();
1100  NS_ASSERT(satGeoDev != nullptr);
1101  satGeoDev->SetAttribute("EnableStatisticsTags", BooleanValue(true));
1102  std::map<uint32_t, Ptr<SatPhy>> satGeoFeederPhys = satGeoDev->GetFeederPhy();
1103  Ptr<SatPhy> satPhy;
1104  for (std::map<uint32_t, Ptr<SatPhy>>::iterator it2 = satGeoFeederPhys.begin();
1105  it2 != satGeoFeederPhys.end();
1106  ++it2)
1107  {
1108  satPhy = it2->second;
1109  NS_ASSERT(satPhy != nullptr);
1110  satPhy->SetAttribute("EnableStatisticsTags", BooleanValue(true));
1111  }
1112  std::map<uint32_t, Ptr<SatPhy>> satGeoUserPhys = satGeoDev->GetUserPhy();
1113  for (std::map<uint32_t, Ptr<SatPhy>>::iterator it2 = satGeoUserPhys.begin();
1114  it2 != satGeoUserPhys.end();
1115  ++it2)
1116  {
1117  satPhy = it2->second;
1118  NS_ASSERT(satPhy != nullptr);
1119  satPhy->SetAttribute("EnableStatisticsTags", BooleanValue(true));
1120  }
1121  } // end of `for (it = sats.Begin(); it != sats.End (); ++it)`
1122 
1123  NodeContainer uts = GetSatHelper()->GetBeamHelper()->GetUtNodes();
1124 
1125  for (NodeContainer::Iterator it = uts.Begin(); it != uts.End(); ++it)
1126  {
1127  const int32_t utId = GetUtId(*it);
1128  NS_ASSERT_MSG(utId > 0, "Node " << (*it)->GetId() << " is not a valid UT");
1129  const uint32_t identifier = GetIdentifierForUt(*it);
1130 
1131  // Create the probe.
1132  std::ostringstream probeName;
1133  probeName << utId;
1134  Ptr<ApplicationPacketProbe> probe = CreateObject<ApplicationPacketProbe>();
1135  probe->SetName(probeName.str());
1136 
1137  Ptr<NetDevice> dev = GetUtSatNetDevice(*it);
1138  Ptr<SatNetDevice> satDev = dev->GetObject<SatNetDevice>();
1139  NS_ASSERT(satDev != nullptr);
1140  Ptr<SatPhy> satPhy = satDev->GetPhy();
1141  NS_ASSERT(satPhy != nullptr);
1142 
1143  // Connect the object to the probe.
1144  if (probe->ConnectByObject("Rx", satPhy))
1145  { // Connect the probe to the right collector.
1146  if (m_conversionCollectors.ConnectWithProbe(
1147  probe->GetObject<Probe>(),
1148  "OutputBytes",
1149  identifier,
1150  &UnitConversionCollector::TraceSinkUinteger32))
1151  {
1152  m_probes.push_back(probe->GetObject<Probe>());
1153 
1154  // Enable statistics-related tags and trace sources on the device.
1155  satDev->SetAttribute("EnableStatisticsTags", BooleanValue(true));
1156  satPhy->SetAttribute("EnableStatisticsTags", BooleanValue(true));
1157  }
1158  else
1159  {
1160  NS_LOG_WARN(this << " unable to connect probe " << probeName.str()
1161  << " to collector " << identifier);
1162  }
1163  }
1164  else
1165  {
1166  NS_FATAL_ERROR("Error connecting to Rx trace source of SatPhy"
1167  << " at node ID " << (*it)->GetId() << " device #2");
1168  }
1169  } // end of `for (it = uts.Begin(); it != uts.End (); ++it)`
1170 
1171  // Enable statistics-related tags on the transmitting device.
1172  NodeContainer gws = GetSatHelper()->GetBeamHelper()->GetGwNodes();
1173  for (NodeContainer::Iterator it = gws.Begin(); it != gws.End(); ++it)
1174  {
1175  NetDeviceContainer devs = GetGwSatNetDevice(*it);
1176 
1177  for (NetDeviceContainer::Iterator itDev = devs.Begin(); itDev != devs.End(); ++itDev)
1178  {
1179  Ptr<SatNetDevice> satDev = (*itDev)->GetObject<SatNetDevice>();
1180  NS_ASSERT(satDev != nullptr);
1181  Ptr<SatPhy> satPhy = satDev->GetPhy();
1182  NS_ASSERT(satPhy != nullptr);
1183 
1184  satDev->SetAttribute("EnableStatisticsTags", BooleanValue(true));
1185  satPhy->SetAttribute("EnableStatisticsTags", BooleanValue(true));
1186  }
1187  }
1188 
1189 } // end of `void DoInstallProbes ();`
1190 
1191 // RETURN LINK APPLICATION-LEVEL //////////////////////////////////////////////
1192 
1193 NS_OBJECT_ENSURE_REGISTERED(SatStatsRtnAppThroughputHelper);
1194 
1196  : SatStatsThroughputHelper(satHelper)
1197 {
1198  NS_LOG_FUNCTION(this << satHelper);
1199 }
1200 
1202 {
1203  NS_LOG_FUNCTION(this);
1204 }
1205 
1206 TypeId // static
1208 {
1209  static TypeId tid =
1210  TypeId("ns3::SatStatsRtnAppThroughputHelper").SetParent<SatStatsThroughputHelper>();
1211  return tid;
1212 }
1213 
1214 void
1216 {
1217  NS_LOG_FUNCTION(this);
1218 
1219  // Create a map of UT user addresses and identifiers.
1220  NodeContainer utUsers = GetSatHelper()->GetUtUsers();
1221  for (NodeContainer::Iterator it = utUsers.Begin(); it != utUsers.End(); ++it)
1222  {
1224  }
1225 
1226  // Connect to trace sources at GW user node's applications.
1227 
1228  NodeContainer gwUsers = GetSatHelper()->GetGwUsers();
1229  Callback<void, Ptr<const Packet>, const Address&> callback =
1230  MakeCallback(&SatStatsRtnAppThroughputHelper::Ipv4Callback, this);
1231 
1232  for (NodeContainer::Iterator it = gwUsers.Begin(); it != gwUsers.End(); ++it)
1233  {
1234  for (uint32_t i = 0; i < (*it)->GetNApplications(); i++)
1235  {
1236  Ptr<Application> app = (*it)->GetApplication(i);
1237 
1238  if (app->TraceConnectWithoutContext("Rx", callback))
1239  {
1240  NS_LOG_INFO(this << " successfully connected with node ID " << (*it)->GetId()
1241  << " application #" << i);
1242  }
1243  else
1244  {
1245  /*
1246  * We're being tolerant here by only logging a warning, because
1247  * not every kind of Application is equipped with the expected
1248  * Rx trace source.
1249  */
1250  NS_LOG_WARN(this << " unable to connect with node ID " << (*it)->GetId()
1251  << " application #" << i);
1252  }
1253  }
1254  }
1255 
1256 } // end of `void DoInstallProbes ();`
1257 
1258 void
1259 SatStatsRtnAppThroughputHelper::Ipv4Callback(Ptr<const Packet> packet, const Address& from)
1260 {
1261  // NS_LOG_FUNCTION (this << packet->GetSize () << from);
1262 
1263  if (InetSocketAddress::IsMatchingType(from))
1264  {
1265  // Determine the identifier associated with the sender address.
1266  const Address ipv4Addr = InetSocketAddress::ConvertFrom(from).GetIpv4();
1267  std::map<const Address, uint32_t>::const_iterator it1 = m_identifierMap.find(ipv4Addr);
1268 
1269  if (it1 == m_identifierMap.end())
1270  {
1271  NS_LOG_WARN(this << " discarding packet " << packet << " (" << packet->GetSize()
1272  << " bytes)"
1273  << " from statistics collection because of"
1274  << " unknown sender IPv4 address " << ipv4Addr);
1275  }
1276  else
1277  {
1278  // Find the collector with the right identifier.
1279  Ptr<DataCollectionObject> collector = m_conversionCollectors.Get(it1->second);
1280  NS_ASSERT_MSG(collector != nullptr,
1281  "Unable to find collector with identifier " << it1->second);
1282  Ptr<UnitConversionCollector> c = collector->GetObject<UnitConversionCollector>();
1283  NS_ASSERT(c != nullptr);
1284 
1285  // Pass the sample to the collector.
1286  c->TraceSinkUinteger32(0, packet->GetSize());
1287  }
1288  }
1289  else
1290  {
1291  NS_LOG_WARN(
1292  this << " discarding packet " << packet << " (" << packet->GetSize() << " bytes)"
1293  << " from statistics collection"
1294  << " because it comes from sender " << from << " without valid InetSocketAddress");
1295  }
1296 
1297 } // end of `void Ipv4Callback (Ptr<const Packet>, const Address);`
1298 
1299 void
1301 {
1302  NS_LOG_FUNCTION(this << utUserNode->GetId());
1303 
1304  Ptr<Ipv4> ipv4 = utUserNode->GetObject<Ipv4>();
1305 
1306  if (ipv4 == nullptr)
1307  {
1308  NS_LOG_INFO(this << " Node " << utUserNode->GetId() << " does not support IPv4 protocol");
1309  }
1310  else if (ipv4->GetNInterfaces() >= 2)
1311  {
1312  const uint32_t identifier = GetIdentifierForUtUser(utUserNode);
1313 
1314  /*
1315  * Assuming that #0 is for loopback interface and #1 is for subscriber
1316  * network interface.
1317  */
1318  for (uint32_t i = 0; i < ipv4->GetNAddresses(1); i++)
1319  {
1320  const Address addr = ipv4->GetAddress(1, i).GetLocal();
1321  m_identifierMap[addr] = identifier;
1322  NS_LOG_INFO(this << " associated address " << addr << " with identifier "
1323  << identifier);
1324  }
1325  }
1326  else
1327  {
1328  NS_LOG_WARN(this << " Node " << utUserNode->GetId() << " is not a valid UT user");
1329  }
1330 }
1331 
1332 // RETURN FEEDER LINK DEVICE-LEVEL ///////////////////////////////////////////////////
1333 
1334 NS_OBJECT_ENSURE_REGISTERED(SatStatsRtnFeederDevThroughputHelper);
1335 
1337  Ptr<const SatHelper> satHelper)
1338  : SatStatsThroughputHelper(satHelper)
1339 {
1340  NS_LOG_FUNCTION(this << satHelper);
1341 }
1342 
1344 {
1345  NS_LOG_FUNCTION(this);
1346 }
1347 
1348 TypeId // static
1350 {
1351  static TypeId tid =
1352  TypeId("ns3::SatStatsRtnFeederDevThroughputHelper").SetParent<SatStatsThroughputHelper>();
1353  return tid;
1354 }
1355 
1356 void
1358 {
1359  NS_LOG_FUNCTION(this);
1360 
1361  NodeContainer uts = GetSatHelper()->GetBeamHelper()->GetUtNodes();
1362  for (NodeContainer::Iterator it = uts.Begin(); it != uts.End(); ++it)
1363  {
1364  // Create a map of UT addresses and identifiers.
1366 
1367  // Enable statistics-related tags and trace sources on the device.
1368  Ptr<NetDevice> dev = GetUtSatNetDevice(*it);
1369  dev->SetAttribute("EnableStatisticsTags", BooleanValue(true));
1370  }
1371 
1372  // Connect to trace sources at GW nodes.
1373 
1374  NodeContainer gws = GetSatHelper()->GetBeamHelper()->GetGwNodes();
1375  Callback<void, Ptr<const Packet>, const Address&> callback =
1377 
1378  for (NodeContainer::Iterator it = gws.Begin(); it != gws.End(); ++it)
1379  {
1380  NetDeviceContainer devs = GetGwSatNetDevice(*it);
1381 
1382  for (NetDeviceContainer::Iterator itDev = devs.Begin(); itDev != devs.End(); ++itDev)
1383  {
1384  NS_ASSERT((*itDev)->GetObject<SatNetDevice>() != nullptr);
1385 
1386  if ((*itDev)->TraceConnectWithoutContext("Rx", callback))
1387  {
1388  NS_LOG_INFO(this << " successfully connected with node ID " << (*it)->GetId()
1389  << " device #" << (*itDev)->GetIfIndex());
1390 
1391  // Enable statistics-related tags and trace sources on the device.
1392  (*itDev)->SetAttribute("EnableStatisticsTags", BooleanValue(true));
1393  }
1394  else
1395  {
1396  NS_FATAL_ERROR("Error connecting to Rx trace source of SatNetDevice"
1397  << " at node ID " << (*it)->GetId() << " device #"
1398  << (*itDev)->GetIfIndex());
1399  }
1400 
1401  } // end of `for (NetDeviceContainer::Iterator itDev = devs)`
1402 
1403  } // end of `for (NodeContainer::Iterator it = gws)`
1404 
1405 } // end of `void DoInstallProbes ();`
1406 
1407 // RETURN USER LINK DEVICE-LEVEL ///////////////////////////////////////////////////
1408 
1409 NS_OBJECT_ENSURE_REGISTERED(SatStatsRtnUserDevThroughputHelper);
1410 
1412  Ptr<const SatHelper> satHelper)
1413  : SatStatsThroughputHelper(satHelper)
1414 {
1415  NS_LOG_FUNCTION(this << satHelper);
1416 }
1417 
1419 {
1420  NS_LOG_FUNCTION(this);
1421 }
1422 
1423 TypeId // static
1425 {
1426  static TypeId tid =
1427  TypeId("ns3::SatStatsRtnUserDevThroughputHelper").SetParent<SatStatsThroughputHelper>();
1428  return tid;
1429 }
1430 
1431 void
1433 {
1434  NS_LOG_FUNCTION(this);
1435 
1436  NodeContainer sats = GetSatHelper()->GetBeamHelper()->GetGeoSatNodes();
1437  Callback<void, Ptr<const Packet>, const Address&> callback =
1439 
1440  for (NodeContainer::Iterator it = sats.Begin(); it != sats.End(); ++it)
1441  {
1442  Ptr<NetDevice> dev = GetSatSatGeoNetDevice(*it);
1443  Ptr<SatGeoNetDevice> satGeoDev = dev->GetObject<SatGeoNetDevice>();
1444  NS_ASSERT(satGeoDev != nullptr);
1445  satGeoDev->SetAttribute("EnableStatisticsTags", BooleanValue(true));
1446 
1447  // Connect the object to the probe.
1448  if (satGeoDev->TraceConnectWithoutContext("RxUser", callback))
1449  {
1450  NS_LOG_INFO(this << " successfully connected with node ID " << (*it)->GetId()
1451  << " device #" << satGeoDev->GetIfIndex());
1452  }
1453  else
1454  {
1455  NS_FATAL_ERROR("Error connecting to Rx trace source of SatMac"
1456  << " at node ID " << (*it)->GetId() << " device #"
1457  << satGeoDev->GetIfIndex());
1458  }
1459  } // end of `for (it = sats.Begin(); it != sats.End (); ++it)`
1460 
1461  NodeContainer uts = GetSatHelper()->GetBeamHelper()->GetUtNodes();
1462  for (NodeContainer::Iterator it = uts.Begin(); it != uts.End(); ++it)
1463  {
1464  // Create a map of UT addresses and identifiers.
1466 
1467  // Enable statistics-related tags and trace sources on the device.
1468  Ptr<NetDevice> dev = GetUtSatNetDevice(*it);
1469  Ptr<SatNetDevice> satDev = dev->GetObject<SatNetDevice>();
1470  NS_ASSERT(satDev != nullptr);
1471  satDev->SetAttribute("EnableStatisticsTags", BooleanValue(true));
1472  }
1473 
1474  // Connect to trace sources at GW nodes.
1475 
1476  NodeContainer gws = GetSatHelper()->GetBeamHelper()->GetGwNodes();
1477 
1478  for (NodeContainer::Iterator it = gws.Begin(); it != gws.End(); ++it)
1479  {
1480  NetDeviceContainer devs = GetGwSatNetDevice(*it);
1481 
1482  for (NetDeviceContainer::Iterator itDev = devs.Begin(); itDev != devs.End(); ++itDev)
1483  {
1484  Ptr<SatNetDevice> satDev = (*itDev)->GetObject<SatNetDevice>();
1485  NS_ASSERT(satDev != nullptr);
1486 
1487  satDev->SetAttribute("EnableStatisticsTags", BooleanValue(true));
1488  } // end of `for (NetDeviceContainer::Iterator itDev = devs)`
1489 
1490  } // end of `for (NodeContainer::Iterator it = gws)`
1491 
1492 } // end of `void DoInstallProbes ();`
1493 
1494 // RETURN FEEDER LINK MAC-LEVEL //////////////////////////////////////////////////////
1495 
1496 NS_OBJECT_ENSURE_REGISTERED(SatStatsRtnFeederMacThroughputHelper);
1497 
1499  Ptr<const SatHelper> satHelper)
1500  : SatStatsThroughputHelper(satHelper)
1501 {
1502  NS_LOG_FUNCTION(this << satHelper);
1503 }
1504 
1506 {
1507  NS_LOG_FUNCTION(this);
1508 }
1509 
1510 TypeId // static
1512 {
1513  static TypeId tid =
1514  TypeId("ns3::SatStatsRtnFeederMacThroughputHelper").SetParent<SatStatsThroughputHelper>();
1515  return tid;
1516 }
1517 
1518 void
1520 {
1521  NS_LOG_FUNCTION(this);
1522 
1523  NodeContainer sats = GetSatHelper()->GetBeamHelper()->GetGeoSatNodes();
1524 
1525  for (NodeContainer::Iterator it = sats.Begin(); it != sats.End(); ++it)
1526  {
1527  Ptr<SatMac> satMac;
1528  Ptr<NetDevice> dev = GetSatSatGeoNetDevice(*it);
1529  Ptr<SatGeoNetDevice> satGeoDev = dev->GetObject<SatGeoNetDevice>();
1530  NS_ASSERT(satGeoDev != nullptr);
1531  satGeoDev->SetAttribute("EnableStatisticsTags", BooleanValue(true));
1532  std::map<uint32_t, Ptr<SatMac>> satGeoFeederMacs = satGeoDev->GetAllFeederMac();
1533  for (std::map<uint32_t, Ptr<SatMac>>::iterator it2 = satGeoFeederMacs.begin();
1534  it2 != satGeoFeederMacs.end();
1535  ++it2)
1536  {
1537  satMac = it2->second;
1538  NS_ASSERT(satMac != nullptr);
1539  satMac->SetAttribute("EnableStatisticsTags", BooleanValue(true));
1540  }
1541  std::map<uint32_t, Ptr<SatMac>> satGeoUserMacs = satGeoDev->GetUserMac();
1542  for (std::map<uint32_t, Ptr<SatMac>>::iterator it2 = satGeoUserMacs.begin();
1543  it2 != satGeoUserMacs.end();
1544  ++it2)
1545  {
1546  satMac = it2->second;
1547  NS_ASSERT(satMac != nullptr);
1548  satMac->SetAttribute("EnableStatisticsTags", BooleanValue(true));
1549  }
1550  } // end of `for (it = sats.Begin(); it != sats.End (); ++it)`
1551 
1552  NodeContainer uts = GetSatHelper()->GetBeamHelper()->GetUtNodes();
1553  for (NodeContainer::Iterator it = uts.Begin(); it != uts.End(); ++it)
1554  {
1555  // Create a map of UT addresses and identifiers.
1557 
1558  // Enable statistics-related tags and trace sources on the device.
1559  Ptr<NetDevice> dev = GetUtSatNetDevice(*it);
1560  Ptr<SatNetDevice> satDev = dev->GetObject<SatNetDevice>();
1561  NS_ASSERT(satDev != nullptr);
1562  Ptr<SatMac> satMac = satDev->GetMac();
1563  NS_ASSERT(satMac != nullptr);
1564  satDev->SetAttribute("EnableStatisticsTags", BooleanValue(true));
1565  satMac->SetAttribute("EnableStatisticsTags", BooleanValue(true));
1566  }
1567 
1568  // Connect to trace sources at GW nodes.
1569 
1570  NodeContainer gws = GetSatHelper()->GetBeamHelper()->GetGwNodes();
1571  Callback<void, Ptr<const Packet>, const Address&> callback =
1573 
1574  for (NodeContainer::Iterator it = gws.Begin(); it != gws.End(); ++it)
1575  {
1576  NetDeviceContainer devs = GetGwSatNetDevice(*it);
1577 
1578  for (NetDeviceContainer::Iterator itDev = devs.Begin(); itDev != devs.End(); ++itDev)
1579  {
1580  Ptr<SatNetDevice> satDev = (*itDev)->GetObject<SatNetDevice>();
1581  NS_ASSERT(satDev != nullptr);
1582  Ptr<SatMac> satMac = satDev->GetMac();
1583  NS_ASSERT(satMac != nullptr);
1584 
1585  // Connect the object to the probe.
1586  if (satMac->TraceConnectWithoutContext("Rx", callback))
1587  {
1588  NS_LOG_INFO(this << " successfully connected with node ID " << (*it)->GetId()
1589  << " device #" << satDev->GetIfIndex());
1590 
1591  // Enable statistics-related tags and trace sources on the device.
1592  satDev->SetAttribute("EnableStatisticsTags", BooleanValue(true));
1593  satMac->SetAttribute("EnableStatisticsTags", BooleanValue(true));
1594  }
1595  else
1596  {
1597  NS_FATAL_ERROR("Error connecting to Rx trace source of SatMac"
1598  << " at node ID " << (*it)->GetId() << " device #"
1599  << satDev->GetIfIndex());
1600  }
1601 
1602  } // end of `for (NetDeviceContainer::Iterator itDev = devs)`
1603 
1604  } // end of `for (NodeContainer::Iterator it = gws)`
1605 
1606 } // end of `void DoInstallProbes ();`
1607 
1608 // RETURN USER LINK MAC-LEVEL //////////////////////////////////////////////////////
1609 
1610 NS_OBJECT_ENSURE_REGISTERED(SatStatsRtnUserMacThroughputHelper);
1611 
1613  Ptr<const SatHelper> satHelper)
1614  : SatStatsThroughputHelper(satHelper)
1615 {
1616  NS_LOG_FUNCTION(this << satHelper);
1617 }
1618 
1620 {
1621  NS_LOG_FUNCTION(this);
1622 }
1623 
1624 TypeId // static
1626 {
1627  static TypeId tid =
1628  TypeId("ns3::SatStatsRtnUserMacThroughputHelper").SetParent<SatStatsThroughputHelper>();
1629  return tid;
1630 }
1631 
1632 void
1634 {
1635  NS_LOG_FUNCTION(this);
1636 
1637  NodeContainer sats = GetSatHelper()->GetBeamHelper()->GetGeoSatNodes();
1638  Callback<void, Ptr<const Packet>, const Address&> callback =
1640 
1641  for (NodeContainer::Iterator it = sats.Begin(); it != sats.End(); ++it)
1642  {
1643  Ptr<NetDevice> dev = GetSatSatGeoNetDevice(*it);
1644  Ptr<SatGeoNetDevice> satGeoDev = dev->GetObject<SatGeoNetDevice>();
1645  NS_ASSERT(satGeoDev != nullptr);
1646  satGeoDev->SetAttribute("EnableStatisticsTags", BooleanValue(true));
1647  std::map<uint32_t, Ptr<SatMac>> satGeoFeederMacs = satGeoDev->GetAllFeederMac();
1648  Ptr<SatMac> satMac;
1649  for (std::map<uint32_t, Ptr<SatMac>>::iterator it2 = satGeoFeederMacs.begin();
1650  it2 != satGeoFeederMacs.end();
1651  ++it2)
1652  {
1653  satMac = it2->second;
1654  NS_ASSERT(satMac != nullptr);
1655  satMac->SetAttribute("EnableStatisticsTags", BooleanValue(true));
1656  }
1657  std::map<uint32_t, Ptr<SatMac>> satGeoUserMacs = satGeoDev->GetUserMac();
1658  for (std::map<uint32_t, Ptr<SatMac>>::iterator it2 = satGeoUserMacs.begin();
1659  it2 != satGeoUserMacs.end();
1660  ++it2)
1661  {
1662  satMac = it2->second;
1663  NS_ASSERT(satMac != nullptr);
1664  satMac->SetAttribute("EnableStatisticsTags", BooleanValue(true));
1665 
1666  // Connect the object to the probe.
1667  if (satMac->TraceConnectWithoutContext("Rx", callback))
1668  {
1669  NS_LOG_INFO(this << " successfully connected with node ID " << (*it)->GetId()
1670  << " device #" << satGeoDev->GetIfIndex());
1671  }
1672  else
1673  {
1674  NS_FATAL_ERROR("Error connecting to Rx trace source of SatMac"
1675  << " at node ID " << (*it)->GetId() << " device #"
1676  << satGeoDev->GetIfIndex());
1677  }
1678  }
1679  } // end of `for (it = sats.Begin(); it != sats.End (); ++it)`
1680 
1681  NodeContainer uts = GetSatHelper()->GetBeamHelper()->GetUtNodes();
1682  for (NodeContainer::Iterator it = uts.Begin(); it != uts.End(); ++it)
1683  {
1684  // Create a map of UT addresses and identifiers.
1686 
1687  // Enable statistics-related tags and trace sources on the device.
1688  Ptr<NetDevice> dev = GetUtSatNetDevice(*it);
1689  Ptr<SatNetDevice> satDev = dev->GetObject<SatNetDevice>();
1690  NS_ASSERT(satDev != nullptr);
1691  Ptr<SatMac> satMac = satDev->GetMac();
1692  NS_ASSERT(satMac != nullptr);
1693  satDev->SetAttribute("EnableStatisticsTags", BooleanValue(true));
1694  satMac->SetAttribute("EnableStatisticsTags", BooleanValue(true));
1695  }
1696 
1697  // Connect to trace sources at GW nodes.
1698 
1699  NodeContainer gws = GetSatHelper()->GetBeamHelper()->GetGwNodes();
1700 
1701  for (NodeContainer::Iterator it = gws.Begin(); it != gws.End(); ++it)
1702  {
1703  NetDeviceContainer devs = GetGwSatNetDevice(*it);
1704 
1705  for (NetDeviceContainer::Iterator itDev = devs.Begin(); itDev != devs.End(); ++itDev)
1706  {
1707  Ptr<SatNetDevice> satDev = (*itDev)->GetObject<SatNetDevice>();
1708  NS_ASSERT(satDev != nullptr);
1709  Ptr<SatMac> satMac = satDev->GetMac();
1710  NS_ASSERT(satMac != nullptr);
1711 
1712  satDev->SetAttribute("EnableStatisticsTags", BooleanValue(true));
1713  satMac->SetAttribute("EnableStatisticsTags", BooleanValue(true));
1714  } // end of `for (NetDeviceContainer::Iterator itDev = devs)`
1715 
1716  } // end of `for (NodeContainer::Iterator it = gws)`
1717 
1718 } // end of `void DoInstallProbes ();`
1719 
1720 // RETURN FEEDER LINK PHY-LEVEL //////////////////////////////////////////////////////
1721 
1722 NS_OBJECT_ENSURE_REGISTERED(SatStatsRtnFeederPhyThroughputHelper);
1723 
1725  Ptr<const SatHelper> satHelper)
1726  : SatStatsThroughputHelper(satHelper)
1727 {
1728  NS_LOG_FUNCTION(this << satHelper);
1729 }
1730 
1732 {
1733  NS_LOG_FUNCTION(this);
1734 }
1735 
1736 TypeId // static
1738 {
1739  static TypeId tid =
1740  TypeId("ns3::SatStatsRtnFeederPhyThroughputHelper").SetParent<SatStatsThroughputHelper>();
1741  return tid;
1742 }
1743 
1744 void
1746 {
1747  NS_LOG_FUNCTION(this);
1748 
1749  NodeContainer sats = GetSatHelper()->GetBeamHelper()->GetGeoSatNodes();
1750 
1751  for (NodeContainer::Iterator it = sats.Begin(); it != sats.End(); ++it)
1752  {
1753  Ptr<SatPhy> satPhy;
1754  Ptr<NetDevice> dev = GetSatSatGeoNetDevice(*it);
1755  Ptr<SatGeoNetDevice> satGeoDev = dev->GetObject<SatGeoNetDevice>();
1756  NS_ASSERT(satGeoDev != nullptr);
1757  satGeoDev->SetAttribute("EnableStatisticsTags", BooleanValue(true));
1758  std::map<uint32_t, Ptr<SatPhy>> satGeoFeederPhys = satGeoDev->GetFeederPhy();
1759  for (std::map<uint32_t, Ptr<SatPhy>>::iterator it2 = satGeoFeederPhys.begin();
1760  it2 != satGeoFeederPhys.end();
1761  ++it2)
1762  {
1763  satPhy = it2->second;
1764  NS_ASSERT(satPhy != nullptr);
1765  satPhy->SetAttribute("EnableStatisticsTags", BooleanValue(true));
1766  }
1767  std::map<uint32_t, Ptr<SatPhy>> satGeoUserPhys = satGeoDev->GetUserPhy();
1768  for (std::map<uint32_t, Ptr<SatPhy>>::iterator it2 = satGeoUserPhys.begin();
1769  it2 != satGeoUserPhys.end();
1770  ++it2)
1771  {
1772  satPhy = it2->second;
1773  NS_ASSERT(satPhy != nullptr);
1774  satPhy->SetAttribute("EnableStatisticsTags", BooleanValue(true));
1775  }
1776  } // end of `for (it = sats.Begin(); it != sats.End (); ++it)`
1777 
1778  NodeContainer uts = GetSatHelper()->GetBeamHelper()->GetUtNodes();
1779  for (NodeContainer::Iterator it = uts.Begin(); it != uts.End(); ++it)
1780  {
1781  // Create a map of UT addresses and identifiers.
1783 
1784  // Enable statistics-related tags and trace sources on the device.
1785  Ptr<NetDevice> dev = GetUtSatNetDevice(*it);
1786  Ptr<SatNetDevice> satDev = dev->GetObject<SatNetDevice>();
1787  NS_ASSERT(satDev != nullptr);
1788  Ptr<SatPhy> satPhy = satDev->GetPhy();
1789  NS_ASSERT(satPhy != nullptr);
1790  satDev->SetAttribute("EnableStatisticsTags", BooleanValue(true));
1791  satPhy->SetAttribute("EnableStatisticsTags", BooleanValue(true));
1792  }
1793 
1794  // Connect to trace sources at GW nodes.
1795 
1796  NodeContainer gws = GetSatHelper()->GetBeamHelper()->GetGwNodes();
1797  Callback<void, Ptr<const Packet>, const Address&> callback =
1799 
1800  for (NodeContainer::Iterator it = gws.Begin(); it != gws.End(); ++it)
1801  {
1802  NetDeviceContainer devs = GetGwSatNetDevice(*it);
1803 
1804  for (NetDeviceContainer::Iterator itDev = devs.Begin(); itDev != devs.End(); ++itDev)
1805  {
1806  Ptr<SatNetDevice> satDev = (*itDev)->GetObject<SatNetDevice>();
1807  NS_ASSERT(satDev != nullptr);
1808  Ptr<SatPhy> satPhy = satDev->GetPhy();
1809  NS_ASSERT(satPhy != nullptr);
1810 
1811  // Connect the object to the probe.
1812  if (satPhy->TraceConnectWithoutContext("Rx", callback))
1813  {
1814  NS_LOG_INFO(this << " successfully connected with node ID " << (*it)->GetId()
1815  << " device #" << satDev->GetIfIndex());
1816 
1817  // Enable statistics-related tags and trace sources on the device.
1818  satDev->SetAttribute("EnableStatisticsTags", BooleanValue(true));
1819  satPhy->SetAttribute("EnableStatisticsTags", BooleanValue(true));
1820  }
1821  else
1822  {
1823  NS_FATAL_ERROR("Error connecting to Rx trace source of SatPhy"
1824  << " at node ID " << (*it)->GetId() << " device #"
1825  << satDev->GetIfIndex());
1826  }
1827 
1828  } // end of `for (NetDeviceContainer::Iterator itDev = devs)`
1829 
1830  } // end of `for (NodeContainer::Iterator it = gws)`
1831 
1832 } // end of `void DoInstallProbes ();`
1833 
1834 // RETURN USER LINK PHY-LEVEL //////////////////////////////////////////////////////
1835 
1836 NS_OBJECT_ENSURE_REGISTERED(SatStatsRtnUserPhyThroughputHelper);
1837 
1839  Ptr<const SatHelper> satHelper)
1840  : SatStatsThroughputHelper(satHelper)
1841 {
1842  NS_LOG_FUNCTION(this << satHelper);
1843 }
1844 
1846 {
1847  NS_LOG_FUNCTION(this);
1848 }
1849 
1850 TypeId // static
1852 {
1853  static TypeId tid =
1854  TypeId("ns3::SatStatsRtnUserPhyThroughputHelper").SetParent<SatStatsThroughputHelper>();
1855  return tid;
1856 }
1857 
1858 void
1860 {
1861  NS_LOG_FUNCTION(this);
1862 
1863  NodeContainer sats = GetSatHelper()->GetBeamHelper()->GetGeoSatNodes();
1864  Callback<void, Ptr<const Packet>, const Address&> callback =
1866 
1867  for (NodeContainer::Iterator it = sats.Begin(); it != sats.End(); ++it)
1868  {
1869  Ptr<NetDevice> dev = GetSatSatGeoNetDevice(*it);
1870  Ptr<SatGeoNetDevice> satGeoDev = dev->GetObject<SatGeoNetDevice>();
1871  NS_ASSERT(satGeoDev != nullptr);
1872  satGeoDev->SetAttribute("EnableStatisticsTags", BooleanValue(true));
1873  std::map<uint32_t, Ptr<SatPhy>> satGeoFeederPhys = satGeoDev->GetFeederPhy();
1874  Ptr<SatPhy> satPhy;
1875  for (std::map<uint32_t, Ptr<SatPhy>>::iterator it2 = satGeoFeederPhys.begin();
1876  it2 != satGeoFeederPhys.end();
1877  ++it2)
1878  {
1879  satPhy = it2->second;
1880  NS_ASSERT(satPhy != nullptr);
1881  satPhy->SetAttribute("EnableStatisticsTags", BooleanValue(true));
1882  }
1883  std::map<uint32_t, Ptr<SatPhy>> satGeoUserPhys = satGeoDev->GetUserPhy();
1884  for (std::map<uint32_t, Ptr<SatPhy>>::iterator it2 = satGeoUserPhys.begin();
1885  it2 != satGeoUserPhys.end();
1886  ++it2)
1887  {
1888  satPhy = it2->second;
1889  NS_ASSERT(satPhy != nullptr);
1890  satPhy->SetAttribute("EnableStatisticsTags", BooleanValue(true));
1891 
1892  // Connect the object to the probe.
1893  if (satPhy->TraceConnectWithoutContext("Rx", callback))
1894  {
1895  NS_LOG_INFO(this << " successfully connected with node ID " << (*it)->GetId()
1896  << " device #" << satGeoDev->GetIfIndex());
1897  }
1898  else
1899  {
1900  NS_FATAL_ERROR("Error connecting to Rx trace source of SatPhy"
1901  << " at node ID " << (*it)->GetId() << " device #"
1902  << satGeoDev->GetIfIndex());
1903  }
1904  }
1905  } // end of `for (it = sats.Begin(); it != sats.End (); ++it)`
1906 
1907  NodeContainer uts = GetSatHelper()->GetBeamHelper()->GetUtNodes();
1908  for (NodeContainer::Iterator it = uts.Begin(); it != uts.End(); ++it)
1909  {
1910  // Create a map of UT addresses and identifiers.
1912 
1913  // Enable statistics-related tags and trace sources on the device.
1914  Ptr<NetDevice> dev = GetUtSatNetDevice(*it);
1915  Ptr<SatNetDevice> satDev = dev->GetObject<SatNetDevice>();
1916  NS_ASSERT(satDev != nullptr);
1917  Ptr<SatPhy> satPhy = satDev->GetPhy();
1918  NS_ASSERT(satPhy != nullptr);
1919  satDev->SetAttribute("EnableStatisticsTags", BooleanValue(true));
1920  satPhy->SetAttribute("EnableStatisticsTags", BooleanValue(true));
1921  }
1922 
1923  // Connect to trace sources at GW nodes.
1924 
1925  NodeContainer gws = GetSatHelper()->GetBeamHelper()->GetGwNodes();
1926 
1927  for (NodeContainer::Iterator it = gws.Begin(); it != gws.End(); ++it)
1928  {
1929  NetDeviceContainer devs = GetGwSatNetDevice(*it);
1930 
1931  for (NetDeviceContainer::Iterator itDev = devs.Begin(); itDev != devs.End(); ++itDev)
1932  {
1933  Ptr<SatNetDevice> satDev = (*itDev)->GetObject<SatNetDevice>();
1934  NS_ASSERT(satDev != nullptr);
1935  Ptr<SatPhy> satPhy = satDev->GetPhy();
1936  NS_ASSERT(satPhy != nullptr);
1937 
1938  satDev->SetAttribute("EnableStatisticsTags", BooleanValue(true));
1939  satPhy->SetAttribute("EnableStatisticsTags", BooleanValue(true));
1940  } // end of `for (NetDeviceContainer::Iterator itDev = devs)`
1941 
1942  } // end of `for (NodeContainer::Iterator it = gws)`
1943 
1944 } // end of `void DoInstallProbes ();`
1945 
1946 } // end of namespace ns3
SatGeoNetDevice to be utilized in geostationary satellite.
Class for ID-mapper.
Address GetUtMacWithNode(Ptr< Node > utNode) const
SatNetDevice to be utilized in the UT and GW nodes.
Produce forward link application-level throughput statistics from a satellite module simulation.
SatStatsFwdAppThroughputHelper(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
Produce forward feeder link device-level throughput statistics from a satellite module simulation.
static TypeId GetTypeId()
inherited from ObjectBase base class
SatStatsFwdFeederDevThroughputHelper(Ptr< const SatHelper > satHelper)
Produce forward feeder link MAC-level throughput statistics from a satellite module simulation.
SatStatsFwdFeederMacThroughputHelper(Ptr< const SatHelper > satHelper)
static TypeId GetTypeId()
inherited from ObjectBase base class
Produce forward feeder link PHY-level throughput statistics from a satellite module simulation.
SatStatsFwdFeederPhyThroughputHelper(Ptr< const SatHelper > satHelper)
static TypeId GetTypeId()
inherited from ObjectBase base class
Produce forward user link device-level throughput statistics from a satellite module simulation.
std::list< Ptr< Probe > > m_probes
Maintains a list of probes created by this helper.
SatStatsFwdUserDevThroughputHelper(Ptr< const SatHelper > satHelper)
static TypeId GetTypeId()
inherited from ObjectBase base class
Produce forward user link MAC-level throughput statistics from a satellite module simulation.
SatStatsFwdUserMacThroughputHelper(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
Produce forward user link PHY-level throughput statistics from a satellite module simulation.
SatStatsFwdUserPhyThroughputHelper(Ptr< const SatHelper > satHelper)
static TypeId GetTypeId()
inherited from ObjectBase base class
std::list< Ptr< Probe > > m_probes
Maintains a list of probes created by this helper.
Parent abstract class of all satellite statistics helpers.
Ptr< const SatHelper > GetSatHelper() const
uint32_t GetIdentifierForUtUser(Ptr< Node > utUserNode) const
static NetDeviceContainer GetGwSatNetDevice(Ptr< Node > gwNode)
static std::string GetOutputTypeName(OutputType_t outputType)
static Ptr< NetDevice > GetSatSatGeoNetDevice(Ptr< Node > satNode)
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
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
Produce return link application-level throughput statistics from a satellite module simulation.
void Ipv4Callback(Ptr< const Packet > packet, const Address &from)
Receive inputs from trace sources and determine the right collector to forward the inputs to.
SatStatsRtnAppThroughputHelper(Ptr< const SatHelper > satHelper)
static TypeId GetTypeId()
inherited from ObjectBase base class
void SaveIpv4AddressAndIdentifier(Ptr< Node > utUserNode)
Save the IPv4 address and the proper identifier from the given UT user node.
Produce return feeder link device-level throughput statistics from a satellite module simulation.
SatStatsRtnFeederDevThroughputHelper(Ptr< const SatHelper > satHelper)
static TypeId GetTypeId()
inherited from ObjectBase base class
Produce return feeder link MAC-level throughput statistics from a satellite module simulation.
SatStatsRtnFeederMacThroughputHelper(Ptr< const SatHelper > satHelper)
static TypeId GetTypeId()
inherited from ObjectBase base class
Produce return feeder link PHY-level throughput statistics from a satellite module simulation.
static TypeId GetTypeId()
inherited from ObjectBase base class
SatStatsRtnFeederPhyThroughputHelper(Ptr< const SatHelper > satHelper)
Produce return user link device-level throughput statistics from a satellite module simulation.
static TypeId GetTypeId()
inherited from ObjectBase base class
SatStatsRtnUserDevThroughputHelper(Ptr< const SatHelper > satHelper)
Produce return user link MAC-level throughput statistics from a satellite module simulation.
SatStatsRtnUserMacThroughputHelper(Ptr< const SatHelper > satHelper)
static TypeId GetTypeId()
inherited from ObjectBase base class
Produce return user link PHY-level throughput statistics from a satellite module simulation.
static TypeId GetTypeId()
inherited from ObjectBase base class
SatStatsRtnUserPhyThroughputHelper(Ptr< const SatHelper > satHelper)
CollectorMap m_conversionCollectors
Maintains a list of first-level collectors created by this helper.
void InstallProbes()
Set up several probes or other means of listeners and connect them to the first-level collectors.
Ptr< DistributionCollector > m_averagingCollector
The final collector utilized in averaged output (histogram, PDF, and CDF).
void RxCallback(Ptr< const Packet > packet, const Address &from)
Receive inputs from trace sources and determine the right collector to forward the inputs to.
Ptr< DataCollectionObject > m_aggregator
The aggregator created by this helper.
static TypeId GetTypeId()
inherited from ObjectBase base class
virtual void DoInstallProbes()=0
CollectorMap m_terminalCollectors
Maintains a list of second-level collectors created by this helper.
SatStatsThroughputHelper(Ptr< const SatHelper > satHelper)
std::map< const Address, uint32_t > m_identifierMap
Map of address and the identifier associated with it (for return link).
void DoInstall()
Install the probes, collectors, and aggregators necessary to produce the statistics output.
void SaveAddressAndIdentifier(Ptr< Node > utNode)
Save the address and the proper identifier from the given UT node.
SatArqSequenceNumber is handling the sequence numbers for the ARQ process.