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>
31 #include <ns3/mac48-address.h>
32 #include <ns3/magister-gnuplot-aggregator.h>
33 #include <ns3/multi-file-aggregator.h>
35 #include <ns3/object-map.h>
36 #include <ns3/object-vector.h>
37 #include <ns3/probe.h>
38 #include <ns3/satellite-helper.h>
39 #include <ns3/satellite-id-mapper.h>
40 #include <ns3/satellite-orbiter-feeder-phy.h>
41 #include <ns3/satellite-orbiter-net-device.h>
42 #include <ns3/satellite-orbiter-user-phy.h>
43 #include <ns3/satellite-phy.h>
44 #include <ns3/satellite-topology.h>
45 #include <ns3/scalar-collector.h>
46 #include <ns3/singleton.h>
47 #include <ns3/string.h>
48 #include <ns3/unit-conversion-collector.h>
55 NS_LOG_COMPONENT_DEFINE(
"SatStatsSatelliteQueueHelper");
60 NS_OBJECT_ENSURE_REGISTERED(SatStatsSatelliteQueueHelper);
70 return "UNIT_NUMBER_OF_PACKETS";
72 NS_FATAL_ERROR(
"SatStatsSatelliteQueueHelper - Invalid unit type");
76 NS_FATAL_ERROR(
"SatStatsSatelliteQueueHelper - Invalid unit type");
83 NS_LOG_FUNCTION(
this << satHelper);
88 NS_LOG_FUNCTION(
this);
94 static TypeId tid = TypeId(
"ns3::SatStatsSatelliteQueueHelper").SetParent<
SatStatsHelper>();
117 NS_FATAL_ERROR(
"SatStatsSatelliteQueueHelper - Invalid unit type");
124 NS_LOG_FUNCTION(
this << averagingMode);
131 NS_LOG_FUNCTION(
this);
137 <<
" is not a valid output type for this statistics.");
147 "EnableContextPrinting",
155 EnumValue(ScalarCollector::INPUT_DATA_TYPE_DOUBLE));
158 EnumValue(ScalarCollector::OUTPUT_TYPE_AVERAGE_PER_SAMPLE));
162 &MultiFileAggregator::Write1d);
177 EnumValue(UnitConversionCollector::TRANSPARENT));
181 &MultiFileAggregator::Write2d);
196 "EnableContextPrinting",
200 Ptr<MultiFileAggregator> fileAggregator =
202 NS_ASSERT(fileAggregator !=
nullptr);
206 DistributionCollector::OutputType_t outputType =
207 DistributionCollector::OUTPUT_TYPE_HISTOGRAM;
210 outputType = DistributionCollector::OUTPUT_TYPE_PROBABILITY;
214 outputType = DistributionCollector::OUTPUT_TYPE_CUMULATIVE;
221 MakeCallback(&MultiFileAggregator::Write2d, fileAggregator));
225 MakeCallback(&MultiFileAggregator::AddContextHeading, fileAggregator));
229 MakeCallback(&MultiFileAggregator::EnableContextWarning, fileAggregator));
234 EnumValue(ScalarCollector::INPUT_DATA_TYPE_DOUBLE));
237 EnumValue(ScalarCollector::OUTPUT_TYPE_AVERAGE_PER_SAMPLE));
239 Callback<void, double> callback =
245 it->second->TraceConnectWithoutContext(
"Output", callback);
259 DistributionCollector::OutputType_t outputType =
260 DistributionCollector::OUTPUT_TYPE_HISTOGRAM;
263 outputType = DistributionCollector::OUTPUT_TYPE_PROBABILITY;
267 outputType = DistributionCollector::OUTPUT_TYPE_CUMULATIVE;
273 &MultiFileAggregator::Write2d);
276 &MultiFileAggregator::AddContextHeading);
279 &MultiFileAggregator::EnableContextWarning);
288 <<
" is not a valid output type for this statistics.");
298 Ptr<MagisterGnuplotAggregator> plotAggregator =
300 NS_ASSERT(plotAggregator !=
nullptr);
302 plotAggregator->SetLegend(
m_longLabel,
"Frequency");
303 plotAggregator->Set2dDatasetDefaultStyle(Gnuplot2dDataset::LINES);
308 EnumValue(UnitConversionCollector::TRANSPARENT));
314 const std::string context = it->second->GetName();
315 plotAggregator->Add2dDataset(context, context);
319 &MagisterGnuplotAggregator::Write2d);
334 Ptr<MagisterGnuplotAggregator> plotAggregator =
336 NS_ASSERT(plotAggregator !=
nullptr);
338 plotAggregator->SetLegend(
m_longLabel,
"Frequency");
339 plotAggregator->Set2dDatasetDefaultStyle(Gnuplot2dDataset::LINES);
345 DistributionCollector::OutputType_t outputType =
346 DistributionCollector::OUTPUT_TYPE_HISTOGRAM;
349 outputType = DistributionCollector::OUTPUT_TYPE_PROBABILITY;
353 outputType = DistributionCollector::OUTPUT_TYPE_CUMULATIVE;
360 MakeCallback(&MagisterGnuplotAggregator::Write2d, plotAggregator));
366 EnumValue(ScalarCollector::INPUT_DATA_TYPE_DOUBLE));
369 EnumValue(ScalarCollector::OUTPUT_TYPE_AVERAGE_PER_SAMPLE));
371 Callback<void, double> callback =
377 it->second->TraceConnectWithoutContext(
"Output", callback);
388 Ptr<MagisterGnuplotAggregator> plotAggregator =
390 NS_ASSERT(plotAggregator !=
nullptr);
392 plotAggregator->SetLegend(
m_longLabel,
"Frequency");
393 plotAggregator->Set2dDatasetDefaultStyle(Gnuplot2dDataset::LINES);
397 DistributionCollector::OutputType_t outputType =
398 DistributionCollector::OUTPUT_TYPE_HISTOGRAM;
401 outputType = DistributionCollector::OUTPUT_TYPE_PROBABILITY;
405 outputType = DistributionCollector::OUTPUT_TYPE_CUMULATIVE;
413 const std::string context = it->second->GetName();
414 plotAggregator->Add2dDataset(context, context);
418 &MagisterGnuplotAggregator::Write2d);
425 NS_FATAL_ERROR(
"SatStatsLinkDelayHelper - Invalid output type");
439 if (from.IsInvalid())
441 NS_LOG_WARN(
this <<
" discarding a packet"
442 <<
" from statistics collection because of"
443 <<
" invalid sender address");
445 else if (Mac48Address::ConvertFrom(from).IsBroadcast())
455 std::map<const Address, uint32_t>::const_iterator it =
m_identifierMap.find(from);
463 NS_LOG_WARN(
this <<
" discarding a packet"
464 <<
" from statistics collection because of"
465 <<
" unknown sender address " << from);
473 NS_LOG_FUNCTION(
this << probe << probe->GetName() << identifier);
483 &ScalarCollector::TraceSinkDouble);
491 &UnitConversionCollector::TraceSinkDouble);
505 &ScalarCollector::TraceSinkDouble);
512 &DistributionCollector::TraceSinkDouble);
518 <<
" is not a valid output type for this statistics.");
524 NS_LOG_INFO(
this <<
" created probe " << probe->GetName() <<
", connected to collector "
529 NS_LOG_WARN(
this <<
" unable to connect probe " << probe->GetName() <<
" to collector "
542 NS_ASSERT_MSG(collector !=
nullptr,
"Unable to find collector with identifier " << identifier);
548 Ptr<ScalarCollector> c = collector->GetObject<ScalarCollector>();
549 NS_ASSERT(c !=
nullptr);
550 c->TraceSinkDouble(0.0, size);
556 Ptr<UnitConversionCollector> c = collector->GetObject<UnitConversionCollector>();
557 NS_ASSERT(c !=
nullptr);
558 c->TraceSinkDouble(0.0, size);
570 Ptr<ScalarCollector> c = collector->GetObject<ScalarCollector>();
571 NS_ASSERT(c !=
nullptr);
572 c->TraceSinkDouble(0.0, size);
576 Ptr<DistributionCollector> c = collector->GetObject<DistributionCollector>();
577 NS_ASSERT(c !=
nullptr);
578 c->TraceSinkDouble(0.0, size);
584 <<
" is not a valid output type for this statistics.");
605 NS_LOG_FUNCTION(
this << satHelper);
611 NS_LOG_FUNCTION(
this);
625 NS_LOG_FUNCTION(
this);
627 NodeContainer uts = Singleton<SatTopology>::Get()->GetUtNodes();
628 for (NodeContainer::Iterator it = uts.Begin(); it != uts.End(); ++it)
634 NodeContainer sats = Singleton<SatTopology>::Get()->GetOrbiterNodes();
635 Callback<void, uint32_t, const Address&> callback =
638 for (NodeContainer::Iterator it = sats.Begin(); it != sats.End(); ++it)
642 NS_ASSERT(satOrbiterDev !=
nullptr);
644 std::map<uint32_t, Ptr<SatPhy>> satOrbiterFeederPhys = satOrbiterDev->GetFeederPhy();
645 for (std::map<uint32_t, Ptr<SatPhy>>::iterator it2 = satOrbiterFeederPhys.begin();
646 it2 != satOrbiterFeederPhys.end();
649 satPhy = it2->second;
650 NS_ASSERT(satPhy !=
nullptr);
652 NS_ASSERT(satOrbiterFeederPhy !=
nullptr);
654 if (satOrbiterFeederPhy->TraceConnectWithoutContext(
"QueueSizeBytes", callback))
656 NS_LOG_INFO(
this <<
" successfully connected with node ID " << (*it)->GetId()
657 <<
" device #" << satOrbiterDev->GetIfIndex());
661 NS_FATAL_ERROR(
"Error connecting to QueueSizeBytes trace source"
662 <<
" at node ID " << (*it)->GetId() <<
" device #"
663 << satOrbiterDev->GetIfIndex());
675 Ptr<const SatHelper> satHelper)
678 NS_LOG_FUNCTION(
this << satHelper);
684 NS_LOG_FUNCTION(
this);
690 static TypeId tid = TypeId(
"ns3::SatStatsRtnFeederQueuePacketsHelper")
698 NS_LOG_FUNCTION(
this);
700 NodeContainer uts = Singleton<SatTopology>::Get()->GetUtNodes();
701 for (NodeContainer::Iterator it = uts.Begin(); it != uts.End(); ++it)
707 NodeContainer sats = Singleton<SatTopology>::Get()->GetOrbiterNodes();
708 Callback<void, uint32_t, const Address&> callback =
711 for (NodeContainer::Iterator it = sats.Begin(); it != sats.End(); ++it)
715 NS_ASSERT(satOrbiterDev !=
nullptr);
717 std::map<uint32_t, Ptr<SatPhy>> satOrbiterFeederPhys = satOrbiterDev->GetFeederPhy();
718 for (std::map<uint32_t, Ptr<SatPhy>>::iterator it2 = satOrbiterFeederPhys.begin();
719 it2 != satOrbiterFeederPhys.end();
722 satPhy = it2->second;
723 NS_ASSERT(satPhy !=
nullptr);
725 NS_ASSERT(satOrbiterFeederPhy !=
nullptr);
727 if (satOrbiterFeederPhy->TraceConnectWithoutContext(
"QueueSizePackets", callback))
729 NS_LOG_INFO(
this <<
" successfully connected with node ID " << (*it)->GetId()
730 <<
" device #" << satOrbiterDev->GetIfIndex());
734 NS_FATAL_ERROR(
"Error connecting to QueueSizePackets trace source"
735 <<
" at node ID " << (*it)->GetId() <<
" device #"
736 << satOrbiterDev->GetIfIndex());
750 NS_LOG_FUNCTION(
this << satHelper);
756 NS_LOG_FUNCTION(
this);
770 NS_LOG_FUNCTION(
this);
772 NodeContainer uts = Singleton<SatTopology>::Get()->GetUtNodes();
773 for (NodeContainer::Iterator it = uts.Begin(); it != uts.End(); ++it)
779 NodeContainer sats = Singleton<SatTopology>::Get()->GetOrbiterNodes();
780 Callback<void, uint32_t, const Address&> callback =
783 for (NodeContainer::Iterator it = sats.Begin(); it != sats.End(); ++it)
787 NS_ASSERT(satOrbiterDev !=
nullptr);
789 std::map<uint32_t, Ptr<SatPhy>> satOrbiterUserPhys = satOrbiterDev->GetUserPhy();
790 for (std::map<uint32_t, Ptr<SatPhy>>::iterator it2 = satOrbiterUserPhys.begin();
791 it2 != satOrbiterUserPhys.end();
794 satPhy = it2->second;
795 NS_ASSERT(satPhy !=
nullptr);
796 Ptr<SatOrbiterUserPhy> satOrbiterUserPhy = satPhy->GetObject<
SatOrbiterUserPhy>();
797 NS_ASSERT(satOrbiterUserPhy !=
nullptr);
799 if (satOrbiterUserPhy->TraceConnectWithoutContext(
"QueueSizeBytes", callback))
801 NS_LOG_INFO(
this <<
" successfully connected with node ID " << (*it)->GetId()
802 <<
" device #" << satOrbiterDev->GetIfIndex());
806 NS_FATAL_ERROR(
"Error connecting to QueueSizeBytes trace source"
807 <<
" at node ID " << (*it)->GetId() <<
" device #"
808 << satOrbiterDev->GetIfIndex());
822 NS_LOG_FUNCTION(
this << satHelper);
828 NS_LOG_FUNCTION(
this);
842 NS_LOG_FUNCTION(
this);
844 NodeContainer uts = Singleton<SatTopology>::Get()->GetUtNodes();
845 for (NodeContainer::Iterator it = uts.Begin(); it != uts.End(); ++it)
851 NodeContainer sats = Singleton<SatTopology>::Get()->GetOrbiterNodes();
852 Callback<void, uint32_t, const Address&> callback =
855 for (NodeContainer::Iterator it = sats.Begin(); it != sats.End(); ++it)
859 NS_ASSERT(satOrbiterDev !=
nullptr);
861 std::map<uint32_t, Ptr<SatPhy>> satOrbiterUserPhys = satOrbiterDev->GetUserPhy();
862 for (std::map<uint32_t, Ptr<SatPhy>>::iterator it2 = satOrbiterUserPhys.begin();
863 it2 != satOrbiterUserPhys.end();
866 satPhy = it2->second;
867 NS_ASSERT(satPhy !=
nullptr);
868 Ptr<SatOrbiterUserPhy> satOrbiterUserPhy = satPhy->GetObject<
SatOrbiterUserPhy>();
869 NS_ASSERT(satOrbiterUserPhy !=
nullptr);
871 if (satOrbiterUserPhy->TraceConnectWithoutContext(
"QueueSizePackets", callback))
873 NS_LOG_INFO(
this <<
" successfully connected with node ID " << (*it)->GetId()
874 <<
" device #" << satOrbiterDev->GetIfIndex());
878 NS_FATAL_ERROR(
"Error connecting to QueueSizePackets trace source"
879 <<
" at node ID " << (*it)->GetId() <<
" device #"
880 << satOrbiterDev->GetIfIndex());
The SatOrbiterFeederPhy models the feeder link physical layer of the satellite node.
SatOrbiterNetDevice to be utilized in geostationary satellite.
The SatOrbiterUserPhy models the user link physical layer of the satellite node.
Produce queue size statistics in packets for return feeder link.
static TypeId GetTypeId()
inherited from ObjectBase base class
virtual ~SatStatsFwdUserQueueBytesHelper()
/ Destructor.
SatStatsFwdUserQueueBytesHelper(Ptr< const SatHelper > satHelper)
Produce queue size statistics in packets for return feeder link.
SatStatsFwdUserQueuePacketsHelper(Ptr< const SatHelper > satHelper)
virtual ~SatStatsFwdUserQueuePacketsHelper()
/ Destructor.
static TypeId GetTypeId()
inherited from ObjectBase base class
Parent abstract class of all satellite statistics helpers.
static Ptr< NetDevice > GetSatSatOrbiterNetDevice(Ptr< Node > satNode)
virtual void SaveAddressAndIdentifier(Ptr< Node > utNode)
Save the address and the proper identifier from the given UT node.
static std::string GetOutputTypeName(OutputType_t outputType)
virtual std::string GetIdentifierHeading(std::string dataLabel) const
virtual std::string GetOutputPath() const
Ptr< DataCollectionObject > CreateAggregator(std::string aggregatorTypeId, std::string n1="", const AttributeValue &v1=EmptyAttributeValue(), std::string n2="", const AttributeValue &v2=EmptyAttributeValue(), std::string n3="", const AttributeValue &v3=EmptyAttributeValue(), std::string n4="", const AttributeValue &v4=EmptyAttributeValue(), std::string n5="", const AttributeValue &v5=EmptyAttributeValue())
Create the aggregator according to the output type.
virtual std::string GetOutputFileName() const
Compute the path and file name where statistics output should be written to.
uint32_t CreateCollectorPerIdentifier(CollectorMap &collectorMap) const
Create one collector instance for each identifier in the simulation.
OutputType_t GetOutputType() const
std::map< const Address, uint32_t > m_identifierMap
Map of address and the identifier associated with it.
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
virtual ~SatStatsRtnFeederQueueBytesHelper()
/ Destructor.
SatStatsRtnFeederQueueBytesHelper(Ptr< const SatHelper > satHelper)
Produce queue size statistics in packets for return feeder link.
SatStatsRtnFeederQueuePacketsHelper(Ptr< const SatHelper > satHelper)
static TypeId GetTypeId()
inherited from ObjectBase base class
virtual ~SatStatsRtnFeederQueuePacketsHelper()
/ Destructor.
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 SetUnitType(UnitType_t unitType)
Ptr< DistributionCollector > m_averagingCollector
The final collector utilized in averaged output (histogram, PDF, and CDF).
virtual void DoInstallProbes()=0
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
virtual ~SatStatsSatelliteQueueHelper()
/ Destructor.
bool m_averagingMode
AveragingMode attribute.
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.
void SetAveragingMode(bool averagingMode)
Ptr< DataCollectionObject > m_aggregator
The aggregator created by this helper.
SatArqSequenceNumber is handling the sequence numbers for the ARQ process.