satellite-stats-satellite-queue-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/boolean.h>
25 #include <ns3/callback.h>
26 #include <ns3/data-collection-object.h>
27 #include <ns3/distribution-collector.h>
28 #include <ns3/double-probe.h>
29 #include <ns3/enum.h>
30 #include <ns3/log.h>
31 #include <ns3/mac48-address.h>
32 #include <ns3/magister-gnuplot-aggregator.h>
33 #include <ns3/multi-file-aggregator.h>
34 #include <ns3/node.h>
35 #include <ns3/object-map.h>
36 #include <ns3/object-vector.h>
37 #include <ns3/probe.h>
38 #include <ns3/satellite-geo-feeder-phy.h>
39 #include <ns3/satellite-geo-net-device.h>
40 #include <ns3/satellite-geo-user-phy.h>
41 #include <ns3/satellite-helper.h>
42 #include <ns3/satellite-id-mapper.h>
43 #include <ns3/satellite-phy.h>
44 #include <ns3/scalar-collector.h>
45 #include <ns3/singleton.h>
46 #include <ns3/string.h>
47 #include <ns3/unit-conversion-collector.h>
48 
49 #include <sstream>
50 
51 NS_LOG_COMPONENT_DEFINE("SatStatsSatelliteQueueHelper");
52 
53 namespace ns3
54 {
55 
56 NS_OBJECT_ENSURE_REGISTERED(SatStatsSatelliteQueueHelper);
57 
58 std::string // static
60 {
61  switch (unitType)
62  {
64  return "UNIT_BYTES";
66  return "UNIT_NUMBER_OF_PACKETS";
67  default:
68  NS_FATAL_ERROR("SatStatsSatelliteQueueHelper - Invalid unit type");
69  break;
70  }
71 
72  NS_FATAL_ERROR("SatStatsSatelliteQueueHelper - Invalid unit type");
73  return "";
74 }
75 
77  : SatStatsHelper(satHelper)
78 {
79  NS_LOG_FUNCTION(this << satHelper);
80 }
81 
83 {
84  NS_LOG_FUNCTION(this);
85 }
86 
87 TypeId // static
89 {
90  static TypeId tid = TypeId("ns3::SatStatsSatelliteQueueHelper").SetParent<SatStatsHelper>();
91  return tid;
92 }
93 
94 void
96 {
97  NS_LOG_FUNCTION(this << GetUnitTypeName(unitType));
98  m_unitType = unitType;
99 
100  // Update presentation-based attributes.
102  {
103  m_shortLabel = "size_bytes";
104  m_longLabel = "Queue size (in bytes)";
105  }
107  {
108  m_shortLabel = "num_packets";
109  m_longLabel = "Queue size (in number of packets)";
110  }
111  else
112  {
113  NS_FATAL_ERROR("SatStatsSatelliteQueueHelper - Invalid unit type");
114  }
115 }
116 
117 void
119 {
120  NS_LOG_FUNCTION(this << averagingMode);
121  m_averagingMode = averagingMode;
122 }
123 
124 void
126 {
127  NS_LOG_FUNCTION(this);
128 
129  switch (GetOutputType())
130  {
132  NS_FATAL_ERROR(GetOutputTypeName(GetOutputType())
133  << " is not a valid output type for this statistics.");
134  break;
135 
137  // Setup aggregator.
138  m_aggregator = CreateAggregator("ns3::MultiFileAggregator",
139  "OutputFileName",
140  StringValue(GetOutputFileName()),
141  "MultiFileMode",
142  BooleanValue(false),
143  "EnableContextPrinting",
144  BooleanValue(true),
145  "GeneralHeading",
146  StringValue(GetIdentifierHeading(m_shortLabel)));
147 
148  // Setup collectors.
149  m_terminalCollectors.SetType("ns3::ScalarCollector");
150  m_terminalCollectors.SetAttribute("InputDataType",
151  EnumValue(ScalarCollector::INPUT_DATA_TYPE_DOUBLE));
152  m_terminalCollectors.SetAttribute(
153  "OutputType",
154  EnumValue(ScalarCollector::OUTPUT_TYPE_AVERAGE_PER_SAMPLE));
156  m_terminalCollectors.ConnectToAggregator("Output",
157  m_aggregator,
158  &MultiFileAggregator::Write1d);
159  break;
160  }
161 
163  // Setup aggregator.
164  m_aggregator = CreateAggregator("ns3::MultiFileAggregator",
165  "OutputFileName",
166  StringValue(GetOutputFileName()),
167  "GeneralHeading",
168  StringValue(GetTimeHeading(m_shortLabel)));
169 
170  // Setup collectors.
171  m_terminalCollectors.SetType("ns3::UnitConversionCollector");
172  m_terminalCollectors.SetAttribute("ConversionType",
173  EnumValue(UnitConversionCollector::TRANSPARENT));
175  m_terminalCollectors.ConnectToAggregator("OutputTimeValue",
176  m_aggregator,
177  &MultiFileAggregator::Write2d);
178  break;
179  }
180 
184  if (m_averagingMode)
185  {
186  // Setup aggregator.
187  m_aggregator = CreateAggregator("ns3::MultiFileAggregator",
188  "OutputFileName",
189  StringValue(GetOutputFileName()),
190  "MultiFileMode",
191  BooleanValue(false),
192  "EnableContextPrinting",
193  BooleanValue(false),
194  "GeneralHeading",
195  StringValue(GetDistributionHeading(m_shortLabel)));
196  Ptr<MultiFileAggregator> fileAggregator =
197  m_aggregator->GetObject<MultiFileAggregator>();
198  NS_ASSERT(fileAggregator != nullptr);
199 
200  // Setup the final-level collector.
201  m_averagingCollector = CreateObject<DistributionCollector>();
202  DistributionCollector::OutputType_t outputType =
203  DistributionCollector::OUTPUT_TYPE_HISTOGRAM;
205  {
206  outputType = DistributionCollector::OUTPUT_TYPE_PROBABILITY;
207  }
209  {
210  outputType = DistributionCollector::OUTPUT_TYPE_CUMULATIVE;
211  }
212  m_averagingCollector->SetOutputType(outputType);
213  m_averagingCollector->SetName("0");
214  m_averagingCollector->TraceConnect(
215  "Output",
216  "0",
217  MakeCallback(&MultiFileAggregator::Write2d, fileAggregator));
218  m_averagingCollector->TraceConnect(
219  "OutputString",
220  "0",
221  MakeCallback(&MultiFileAggregator::AddContextHeading, fileAggregator));
222  m_averagingCollector->TraceConnect(
223  "Warning",
224  "0",
225  MakeCallback(&MultiFileAggregator::EnableContextWarning, fileAggregator));
226 
227  // Setup collectors.
228  m_terminalCollectors.SetType("ns3::ScalarCollector");
229  m_terminalCollectors.SetAttribute("InputDataType",
230  EnumValue(ScalarCollector::INPUT_DATA_TYPE_DOUBLE));
231  m_terminalCollectors.SetAttribute(
232  "OutputType",
233  EnumValue(ScalarCollector::OUTPUT_TYPE_AVERAGE_PER_SAMPLE));
235  Callback<void, double> callback =
236  MakeCallback(&DistributionCollector::TraceSinkDouble1, m_averagingCollector);
237  for (CollectorMap::Iterator it = m_terminalCollectors.Begin();
238  it != m_terminalCollectors.End();
239  ++it)
240  {
241  it->second->TraceConnectWithoutContext("Output", callback);
242  }
243  }
244  else
245  {
246  // Setup aggregator.
247  m_aggregator = CreateAggregator("ns3::MultiFileAggregator",
248  "OutputFileName",
249  StringValue(GetOutputFileName()),
250  "GeneralHeading",
251  StringValue(GetDistributionHeading(m_shortLabel)));
252 
253  // Setup collectors.
254  m_terminalCollectors.SetType("ns3::DistributionCollector");
255  DistributionCollector::OutputType_t outputType =
256  DistributionCollector::OUTPUT_TYPE_HISTOGRAM;
258  {
259  outputType = DistributionCollector::OUTPUT_TYPE_PROBABILITY;
260  }
262  {
263  outputType = DistributionCollector::OUTPUT_TYPE_CUMULATIVE;
264  }
265  m_terminalCollectors.SetAttribute("OutputType", EnumValue(outputType));
267  m_terminalCollectors.ConnectToAggregator("Output",
268  m_aggregator,
269  &MultiFileAggregator::Write2d);
270  m_terminalCollectors.ConnectToAggregator("OutputString",
271  m_aggregator,
272  &MultiFileAggregator::AddContextHeading);
273  m_terminalCollectors.ConnectToAggregator("Warning",
274  m_aggregator,
275  &MultiFileAggregator::EnableContextWarning);
276  }
277 
278  break;
279  }
280 
283  NS_FATAL_ERROR(GetOutputTypeName(GetOutputType())
284  << " is not a valid output type for this statistics.");
285  break;
286 
288  // Setup aggregator.
289  m_aggregator = CreateAggregator("ns3::MagisterGnuplotAggregator",
290  "OutputPath",
291  StringValue(GetOutputPath()),
292  "OutputFileName",
293  StringValue(GetName()));
294  Ptr<MagisterGnuplotAggregator> plotAggregator =
295  m_aggregator->GetObject<MagisterGnuplotAggregator>();
296  NS_ASSERT(plotAggregator != nullptr);
297  // plot->SetTitle ("");
298  plotAggregator->SetLegend(m_longLabel, "Frequency");
299  plotAggregator->Set2dDatasetDefaultStyle(Gnuplot2dDataset::LINES);
300 
301  // Setup collectors.
302  m_terminalCollectors.SetType("ns3::UnitConversionCollector");
303  m_terminalCollectors.SetAttribute("ConversionType",
304  EnumValue(UnitConversionCollector::TRANSPARENT));
306  for (CollectorMap::Iterator it = m_terminalCollectors.Begin();
307  it != m_terminalCollectors.End();
308  ++it)
309  {
310  const std::string context = it->second->GetName();
311  plotAggregator->Add2dDataset(context, context);
312  }
313  m_terminalCollectors.ConnectToAggregator("OutputTimeValue",
314  m_aggregator,
315  &MagisterGnuplotAggregator::Write2d);
316  break;
317  }
318 
322  if (m_averagingMode)
323  {
324  // Setup aggregator.
325  m_aggregator = CreateAggregator("ns3::MagisterGnuplotAggregator",
326  "OutputPath",
327  StringValue(GetOutputPath()),
328  "OutputFileName",
329  StringValue(GetName()));
330  Ptr<MagisterGnuplotAggregator> plotAggregator =
331  m_aggregator->GetObject<MagisterGnuplotAggregator>();
332  NS_ASSERT(plotAggregator != nullptr);
333  // plot->SetTitle ("");
334  plotAggregator->SetLegend(m_longLabel, "Frequency");
335  plotAggregator->Set2dDatasetDefaultStyle(Gnuplot2dDataset::LINES);
336  plotAggregator->Add2dDataset(GetName(), GetName());
338 
339  // Setup the final-level collector.
340  m_averagingCollector = CreateObject<DistributionCollector>();
341  DistributionCollector::OutputType_t outputType =
342  DistributionCollector::OUTPUT_TYPE_HISTOGRAM;
344  {
345  outputType = DistributionCollector::OUTPUT_TYPE_PROBABILITY;
346  }
348  {
349  outputType = DistributionCollector::OUTPUT_TYPE_CUMULATIVE;
350  }
351  m_averagingCollector->SetOutputType(outputType);
352  m_averagingCollector->SetName("0");
353  m_averagingCollector->TraceConnect(
354  "Output",
355  GetName(),
356  MakeCallback(&MagisterGnuplotAggregator::Write2d, plotAggregator));
358 
359  // Setup collectors.
360  m_terminalCollectors.SetType("ns3::ScalarCollector");
361  m_terminalCollectors.SetAttribute("InputDataType",
362  EnumValue(ScalarCollector::INPUT_DATA_TYPE_DOUBLE));
363  m_terminalCollectors.SetAttribute(
364  "OutputType",
365  EnumValue(ScalarCollector::OUTPUT_TYPE_AVERAGE_PER_SAMPLE));
367  Callback<void, double> callback =
368  MakeCallback(&DistributionCollector::TraceSinkDouble1, m_averagingCollector);
369  for (CollectorMap::Iterator it = m_terminalCollectors.Begin();
370  it != m_terminalCollectors.End();
371  ++it)
372  {
373  it->second->TraceConnectWithoutContext("Output", callback);
374  }
375  }
376  else
377  {
378  // Setup aggregator.
379  m_aggregator = CreateAggregator("ns3::MagisterGnuplotAggregator",
380  "OutputPath",
381  StringValue(GetOutputPath()),
382  "OutputFileName",
383  StringValue(GetName()));
384  Ptr<MagisterGnuplotAggregator> plotAggregator =
385  m_aggregator->GetObject<MagisterGnuplotAggregator>();
386  NS_ASSERT(plotAggregator != nullptr);
387  // plot->SetTitle ("");
388  plotAggregator->SetLegend(m_longLabel, "Frequency");
389  plotAggregator->Set2dDatasetDefaultStyle(Gnuplot2dDataset::LINES);
390 
391  // Setup collectors.
392  m_terminalCollectors.SetType("ns3::DistributionCollector");
393  DistributionCollector::OutputType_t outputType =
394  DistributionCollector::OUTPUT_TYPE_HISTOGRAM;
396  {
397  outputType = DistributionCollector::OUTPUT_TYPE_PROBABILITY;
398  }
400  {
401  outputType = DistributionCollector::OUTPUT_TYPE_CUMULATIVE;
402  }
403  m_terminalCollectors.SetAttribute("OutputType", EnumValue(outputType));
405  for (CollectorMap::Iterator it = m_terminalCollectors.Begin();
406  it != m_terminalCollectors.End();
407  ++it)
408  {
409  const std::string context = it->second->GetName();
410  plotAggregator->Add2dDataset(context, context);
411  }
412  m_terminalCollectors.ConnectToAggregator("Output",
413  m_aggregator,
414  &MagisterGnuplotAggregator::Write2d);
415  }
416 
417  break;
418  }
419 
420  default:
421  NS_FATAL_ERROR("SatStatsLinkDelayHelper - Invalid output type");
422  break;
423  }
424 
425  // Setup probes and connect them to the collectors.
426  InstallProbes();
427 
428 } // end of `void DoInstall ();`
429 
430 void
431 SatStatsSatelliteQueueHelper::QueueSizeCallback(uint32_t size, const Address& from)
432 {
433  // NS_LOG_FUNCTION (this << size << from);
434 
435  if (from.IsInvalid())
436  {
437  NS_LOG_WARN(this << " discarding a packet"
438  << " from statistics collection because of"
439  << " invalid sender address");
440  }
441  else if (Mac48Address::ConvertFrom(from).IsBroadcast())
442  {
443  for (std::pair<const Address, uint32_t> item : m_identifierMap)
444  {
445  PassSampleToCollector(size, item.second);
446  }
447  }
448  else
449  {
450  // Determine the identifier associated with the sender address.
451  std::map<const Address, uint32_t>::const_iterator it = m_identifierMap.find(from);
452 
453  if (it != m_identifierMap.end())
454  {
455  PassSampleToCollector(size, it->second);
456  }
457  else
458  {
459  NS_LOG_WARN(this << " discarding a packet"
460  << " from statistics collection because of"
461  << " unknown sender address " << from);
462  }
463  }
464 }
465 
466 void
468 {
469  NS_LOG_FUNCTION(this << utNode->GetId());
470 
471  const SatIdMapper* satIdMapper = Singleton<SatIdMapper>::Get();
472  const Address addr = satIdMapper->GetUtMacWithNode(utNode);
473 
474  if (addr.IsInvalid())
475  {
476  NS_LOG_WARN(this << " Node " << utNode->GetId() << " is not a valid UT");
477  }
478  else
479  {
480  const uint32_t identifier = GetIdentifierForUt(utNode);
481  m_identifierMap[addr] = identifier;
482  NS_LOG_INFO(this << " associated address " << addr << " with identifier " << identifier);
483  }
484 }
485 
486 bool
487 SatStatsSatelliteQueueHelper::ConnectProbeToCollector(Ptr<Probe> probe, uint32_t identifier)
488 {
489  NS_LOG_FUNCTION(this << probe << probe->GetName() << identifier);
490 
491  bool ret = false;
492  switch (GetOutputType())
493  {
496  ret = m_terminalCollectors.ConnectWithProbe(probe,
497  "OutputSeconds",
498  identifier,
499  &ScalarCollector::TraceSinkDouble);
500  break;
501 
504  ret = m_terminalCollectors.ConnectWithProbe(probe,
505  "OutputSeconds",
506  identifier,
507  &UnitConversionCollector::TraceSinkDouble);
508  break;
509 
516  if (m_averagingMode)
517  {
518  ret = m_terminalCollectors.ConnectWithProbe(probe,
519  "OutputSeconds",
520  identifier,
521  &ScalarCollector::TraceSinkDouble);
522  }
523  else
524  {
525  ret = m_terminalCollectors.ConnectWithProbe(probe,
526  "OutputSeconds",
527  identifier,
528  &DistributionCollector::TraceSinkDouble);
529  }
530  break;
531 
532  default:
533  NS_FATAL_ERROR(GetOutputTypeName(GetOutputType())
534  << " is not a valid output type for this statistics.");
535  break;
536  }
537 
538  if (ret)
539  {
540  NS_LOG_INFO(this << " created probe " << probe->GetName() << ", connected to collector "
541  << identifier);
542  }
543  else
544  {
545  NS_LOG_WARN(this << " unable to connect probe " << probe->GetName() << " to collector "
546  << identifier);
547  }
548 
549  return ret;
550 }
551 
552 void
553 SatStatsSatelliteQueueHelper::PassSampleToCollector(uint32_t size, uint32_t identifier)
554 {
555  // NS_LOG_FUNCTION (this << size << identifier);
556 
557  Ptr<DataCollectionObject> collector = m_terminalCollectors.Get(identifier);
558  NS_ASSERT_MSG(collector != nullptr, "Unable to find collector with identifier " << identifier);
559 
560  switch (GetOutputType())
561  {
564  Ptr<ScalarCollector> c = collector->GetObject<ScalarCollector>();
565  NS_ASSERT(c != nullptr);
566  c->TraceSinkDouble(0.0, size);
567  break;
568  }
569 
572  Ptr<UnitConversionCollector> c = collector->GetObject<UnitConversionCollector>();
573  NS_ASSERT(c != nullptr);
574  c->TraceSinkDouble(0.0, size);
575  break;
576  }
577 
584  if (m_averagingMode)
585  {
586  Ptr<ScalarCollector> c = collector->GetObject<ScalarCollector>();
587  NS_ASSERT(c != nullptr);
588  c->TraceSinkDouble(0.0, size);
589  }
590  else
591  {
592  Ptr<DistributionCollector> c = collector->GetObject<DistributionCollector>();
593  NS_ASSERT(c != nullptr);
594  c->TraceSinkDouble(0.0, size);
595  }
596  break;
597 
598  default:
599  NS_FATAL_ERROR(GetOutputTypeName(GetOutputType())
600  << " is not a valid output type for this statistics.");
601  break;
602 
603  } // end of `switch (GetOutputType ())`
604 
605 } // end of `void PassSampleToCollector (double, uint32_t)`
606 
607 void
609 {
610  // The method below is supposed to be implemented by the child class.
611  DoInstallProbes();
612 }
613 
614 // RTN FEEDER QUEUE IN BYTES ////////////////////////////////////////////////////////
615 
616 NS_OBJECT_ENSURE_REGISTERED(SatStatsRtnFeederQueueBytesHelper);
617 
619  : SatStatsSatelliteQueueHelper(satHelper)
620 {
621  NS_LOG_FUNCTION(this << satHelper);
623 }
624 
626 {
627  NS_LOG_FUNCTION(this);
628 }
629 
630 TypeId // static
632 {
633  static TypeId tid =
634  TypeId("ns3::SatStatsRtnFeederQueueBytesHelper").SetParent<SatStatsSatelliteQueueHelper>();
635  return tid;
636 }
637 
638 void
640 {
641  NS_LOG_FUNCTION(this);
642 
643  NodeContainer uts = GetSatHelper()->GetBeamHelper()->GetUtNodes();
644  for (NodeContainer::Iterator it = uts.Begin(); it != uts.End(); ++it)
645  {
646  // Create a map of UT addresses and identifiers.
648  }
649 
650  NodeContainer sats = GetSatHelper()->GetBeamHelper()->GetGeoSatNodes();
651  Callback<void, uint32_t, const Address&> callback =
653 
654  for (NodeContainer::Iterator it = sats.Begin(); it != sats.End(); ++it)
655  {
656  Ptr<NetDevice> dev = GetSatSatGeoNetDevice(*it);
657  Ptr<SatGeoNetDevice> satGeoDev = dev->GetObject<SatGeoNetDevice>();
658  NS_ASSERT(satGeoDev != nullptr);
659  Ptr<SatPhy> satPhy;
660  std::map<uint32_t, Ptr<SatPhy>> satGeoFeederPhys = satGeoDev->GetFeederPhy();
661  for (std::map<uint32_t, Ptr<SatPhy>>::iterator it2 = satGeoFeederPhys.begin();
662  it2 != satGeoFeederPhys.end();
663  ++it2)
664  {
665  satPhy = it2->second;
666  NS_ASSERT(satPhy != nullptr);
667  Ptr<SatGeoFeederPhy> satGeoFeederPhy = satPhy->GetObject<SatGeoFeederPhy>();
668  NS_ASSERT(satGeoFeederPhy != nullptr);
669 
670  if (satGeoFeederPhy->TraceConnectWithoutContext("QueueSizeBytes", callback))
671  {
672  NS_LOG_INFO(this << " successfully connected with node ID " << (*it)->GetId()
673  << " device #" << satGeoDev->GetIfIndex());
674  }
675  else
676  {
677  NS_FATAL_ERROR("Error connecting to QueueSizeBytes trace source"
678  << " at node ID " << (*it)->GetId() << " device #"
679  << satGeoDev->GetIfIndex());
680  }
681  }
682  } // end of `for (it = sats.Begin(); it != sats.End (); ++it)`
683 
684 } // end of `void DoInstallProbes ();`
685 
686 // RTN FEEDER QUEUE IN PACKETS ////////////////////////////////////////////////////////
687 
688 NS_OBJECT_ENSURE_REGISTERED(SatStatsRtnFeederQueuePacketsHelper);
689 
691  Ptr<const SatHelper> satHelper)
692  : SatStatsSatelliteQueueHelper(satHelper)
693 {
694  NS_LOG_FUNCTION(this << satHelper);
696 }
697 
699 {
700  NS_LOG_FUNCTION(this);
701 }
702 
703 TypeId // static
705 {
706  static TypeId tid = TypeId("ns3::SatStatsRtnFeederQueuePacketsHelper")
707  .SetParent<SatStatsSatelliteQueueHelper>();
708  return tid;
709 }
710 
711 void
713 {
714  NS_LOG_FUNCTION(this);
715 
716  NodeContainer uts = GetSatHelper()->GetBeamHelper()->GetUtNodes();
717  for (NodeContainer::Iterator it = uts.Begin(); it != uts.End(); ++it)
718  {
719  // Create a map of UT addresses and identifiers.
721  }
722 
723  NodeContainer sats = GetSatHelper()->GetBeamHelper()->GetGeoSatNodes();
724  Callback<void, uint32_t, const Address&> callback =
726 
727  for (NodeContainer::Iterator it = sats.Begin(); it != sats.End(); ++it)
728  {
729  Ptr<NetDevice> dev = GetSatSatGeoNetDevice(*it);
730  Ptr<SatGeoNetDevice> satGeoDev = dev->GetObject<SatGeoNetDevice>();
731  NS_ASSERT(satGeoDev != nullptr);
732  Ptr<SatPhy> satPhy;
733  std::map<uint32_t, Ptr<SatPhy>> satGeoFeederPhys = satGeoDev->GetFeederPhy();
734  for (std::map<uint32_t, Ptr<SatPhy>>::iterator it2 = satGeoFeederPhys.begin();
735  it2 != satGeoFeederPhys.end();
736  ++it2)
737  {
738  satPhy = it2->second;
739  NS_ASSERT(satPhy != nullptr);
740  Ptr<SatGeoFeederPhy> satGeoFeederPhy = satPhy->GetObject<SatGeoFeederPhy>();
741  NS_ASSERT(satGeoFeederPhy != nullptr);
742 
743  if (satGeoFeederPhy->TraceConnectWithoutContext("QueueSizePackets", callback))
744  {
745  NS_LOG_INFO(this << " successfully connected with node ID " << (*it)->GetId()
746  << " device #" << satGeoDev->GetIfIndex());
747  }
748  else
749  {
750  NS_FATAL_ERROR("Error connecting to QueueSizePackets trace source"
751  << " at node ID " << (*it)->GetId() << " device #"
752  << satGeoDev->GetIfIndex());
753  }
754  }
755  } // end of `for (it = sats.Begin(); it != sats.End (); ++it)`
756 
757 } // end of `void DoInstallProbes ();`
758 
759 // FWD USER QUEUE IN BYTES ////////////////////////////////////////////////////////
760 
761 NS_OBJECT_ENSURE_REGISTERED(SatStatsFwdUserQueueBytesHelper);
762 
764  : SatStatsSatelliteQueueHelper(satHelper)
765 {
766  NS_LOG_FUNCTION(this << satHelper);
768 }
769 
771 {
772  NS_LOG_FUNCTION(this);
773 }
774 
775 TypeId // static
777 {
778  static TypeId tid =
779  TypeId("ns3::SatStatsFwdUserQueueBytesHelper").SetParent<SatStatsSatelliteQueueHelper>();
780  return tid;
781 }
782 
783 void
785 {
786  NS_LOG_FUNCTION(this);
787 
788  NodeContainer uts = GetSatHelper()->GetBeamHelper()->GetUtNodes();
789  for (NodeContainer::Iterator it = uts.Begin(); it != uts.End(); ++it)
790  {
791  // Create a map of UT addresses and identifiers.
793  }
794 
795  NodeContainer sats = GetSatHelper()->GetBeamHelper()->GetGeoSatNodes();
796  Callback<void, uint32_t, const Address&> callback =
798 
799  for (NodeContainer::Iterator it = sats.Begin(); it != sats.End(); ++it)
800  {
801  Ptr<NetDevice> dev = GetSatSatGeoNetDevice(*it);
802  Ptr<SatGeoNetDevice> satGeoDev = dev->GetObject<SatGeoNetDevice>();
803  NS_ASSERT(satGeoDev != nullptr);
804  Ptr<SatPhy> satPhy;
805  std::map<uint32_t, Ptr<SatPhy>> satGeoUserPhys = satGeoDev->GetUserPhy();
806  for (std::map<uint32_t, Ptr<SatPhy>>::iterator it2 = satGeoUserPhys.begin();
807  it2 != satGeoUserPhys.end();
808  ++it2)
809  {
810  satPhy = it2->second;
811  NS_ASSERT(satPhy != nullptr);
812  Ptr<SatGeoUserPhy> satGeoUserPhy = satPhy->GetObject<SatGeoUserPhy>();
813  NS_ASSERT(satGeoUserPhy != nullptr);
814 
815  if (satGeoUserPhy->TraceConnectWithoutContext("QueueSizeBytes", callback))
816  {
817  NS_LOG_INFO(this << " successfully connected with node ID " << (*it)->GetId()
818  << " device #" << satGeoDev->GetIfIndex());
819  }
820  else
821  {
822  NS_FATAL_ERROR("Error connecting to QueueSizeBytes trace source"
823  << " at node ID " << (*it)->GetId() << " device #"
824  << satGeoDev->GetIfIndex());
825  }
826  }
827  } // end of `for (it = sats.Begin(); it != sats.End (); ++it)`
828 
829 } // end of `void DoInstallProbes ();`
830 
831 // FWD USER QUEUE IN PACKETS ////////////////////////////////////////////////////////
832 
833 NS_OBJECT_ENSURE_REGISTERED(SatStatsFwdUserQueuePacketsHelper);
834 
836  : SatStatsSatelliteQueueHelper(satHelper)
837 {
838  NS_LOG_FUNCTION(this << satHelper);
840 }
841 
843 {
844  NS_LOG_FUNCTION(this);
845 }
846 
847 TypeId // static
849 {
850  static TypeId tid =
851  TypeId("ns3::SatStatsFwdUserQueuePacketsHelper").SetParent<SatStatsSatelliteQueueHelper>();
852  return tid;
853 }
854 
855 void
857 {
858  NS_LOG_FUNCTION(this);
859 
860  NodeContainer uts = GetSatHelper()->GetBeamHelper()->GetUtNodes();
861  for (NodeContainer::Iterator it = uts.Begin(); it != uts.End(); ++it)
862  {
863  // Create a map of UT addresses and identifiers.
865  }
866 
867  NodeContainer sats = GetSatHelper()->GetBeamHelper()->GetGeoSatNodes();
868  Callback<void, uint32_t, const Address&> callback =
870 
871  for (NodeContainer::Iterator it = sats.Begin(); it != sats.End(); ++it)
872  {
873  Ptr<NetDevice> dev = GetSatSatGeoNetDevice(*it);
874  Ptr<SatGeoNetDevice> satGeoDev = dev->GetObject<SatGeoNetDevice>();
875  NS_ASSERT(satGeoDev != nullptr);
876  Ptr<SatPhy> satPhy;
877  std::map<uint32_t, Ptr<SatPhy>> satGeoUserPhys = satGeoDev->GetUserPhy();
878  for (std::map<uint32_t, Ptr<SatPhy>>::iterator it2 = satGeoUserPhys.begin();
879  it2 != satGeoUserPhys.end();
880  ++it2)
881  {
882  satPhy = it2->second;
883  NS_ASSERT(satPhy != nullptr);
884  Ptr<SatGeoUserPhy> satGeoUserPhy = satPhy->GetObject<SatGeoUserPhy>();
885  NS_ASSERT(satGeoUserPhy != nullptr);
886 
887  if (satGeoUserPhy->TraceConnectWithoutContext("QueueSizePackets", callback))
888  {
889  NS_LOG_INFO(this << " successfully connected with node ID " << (*it)->GetId()
890  << " device #" << satGeoDev->GetIfIndex());
891  }
892  else
893  {
894  NS_FATAL_ERROR("Error connecting to QueueSizePackets trace source"
895  << " at node ID " << (*it)->GetId() << " device #"
896  << satGeoDev->GetIfIndex());
897  }
898  }
899  } // end of `for (it = sats.Begin(); it != sats.End (); ++it)`
900 
901 } // end of `void DoInstallProbes ();`
902 
903 } // end of namespace ns3
The SatGeoFeederPhy models the feeder link physical layer of the satellite node.
SatGeoNetDevice to be utilized in geostationary satellite.
The SatGeoUserPhy models the user link physical layer of the satellite node.
Class for ID-mapper.
Address GetUtMacWithNode(Ptr< Node > utNode) const
Produce queue size statistics in packets for return feeder link.
static TypeId GetTypeId()
inherited from ObjectBase base class
SatStatsFwdUserQueueBytesHelper(Ptr< const SatHelper > satHelper)
Produce queue size statistics in packets for return feeder link.
SatStatsFwdUserQueuePacketsHelper(Ptr< const SatHelper > satHelper)
static TypeId GetTypeId()
inherited from ObjectBase base class
Parent abstract class of all satellite statistics helpers.
Ptr< const SatHelper > GetSatHelper() const
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 CreateCollectorPerIdentifier(CollectorMap &collectorMap) const
Create one collector instance for each identifier in the simulation.
OutputType_t GetOutputType() const
uint32_t GetIdentifierForUt(Ptr< Node > utNode) const
std::string GetName() const
virtual std::string GetTimeHeading(std::string dataLabel) const
virtual std::string GetDistributionHeading(std::string dataLabel) const
Produce queue size statistics in packets for return feeder link.
static TypeId GetTypeId()
inherited from ObjectBase base class
SatStatsRtnFeederQueueBytesHelper(Ptr< const SatHelper > satHelper)
Produce queue size statistics in packets for return feeder link.
static TypeId GetTypeId()
inherited from ObjectBase base class
Base class for sat queue statistics helpers.
SatStatsSatelliteQueueHelper(Ptr< const SatHelper > satHelper)
void DoInstall()
Install the probes, collectors, and aggregators necessary to produce the statistics output.
bool ConnectProbeToCollector(Ptr< Probe > probe, uint32_t identifier)
Connect the probe to the right collector.
void SaveAddressAndIdentifier(Ptr< Node > utNode)
Save the address and the proper identifier from the given UT node.
Ptr< DistributionCollector > m_averagingCollector
The final collector utilized in averaged output (histogram, PDF, and CDF).
void InstallProbes()
Set up several probes or other means of listeners and connect them to the collectors.
static TypeId GetTypeId()
inherited from ObjectBase base class
std::map< const Address, uint32_t > m_identifierMap
Map of address and the identifier associated with it (for return link).
void QueueSizeCallback(uint32_t size, const Address &addr)
Receive inputs from trace sources and forward them to the collector.
CollectorMap m_terminalCollectors
Maintains a list of collectors created by this helper.
static std::string GetUnitTypeName(UnitType_t unitType)
void PassSampleToCollector(uint32_t size, uint32_t identifier)
Find a collector with the right identifier and pass a sample data to it.
Ptr< DataCollectionObject > m_aggregator
The aggregator created by this helper.
SatArqSequenceNumber is handling the sequence numbers for the ARQ process.