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-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>
51 NS_LOG_COMPONENT_DEFINE(
"SatStatsSatelliteQueueHelper");
56 NS_OBJECT_ENSURE_REGISTERED(SatStatsSatelliteQueueHelper);
66 return "UNIT_NUMBER_OF_PACKETS";
68 NS_FATAL_ERROR(
"SatStatsSatelliteQueueHelper - Invalid unit type");
72 NS_FATAL_ERROR(
"SatStatsSatelliteQueueHelper - Invalid unit type");
79 NS_LOG_FUNCTION(
this << satHelper);
84 NS_LOG_FUNCTION(
this);
90 static TypeId tid = TypeId(
"ns3::SatStatsSatelliteQueueHelper").SetParent<
SatStatsHelper>();
113 NS_FATAL_ERROR(
"SatStatsSatelliteQueueHelper - Invalid unit type");
120 NS_LOG_FUNCTION(
this << averagingMode);
127 NS_LOG_FUNCTION(
this);
133 <<
" is not a valid output type for this statistics.");
143 "EnableContextPrinting",
151 EnumValue(ScalarCollector::INPUT_DATA_TYPE_DOUBLE));
154 EnumValue(ScalarCollector::OUTPUT_TYPE_AVERAGE_PER_SAMPLE));
158 &MultiFileAggregator::Write1d);
173 EnumValue(UnitConversionCollector::TRANSPARENT));
177 &MultiFileAggregator::Write2d);
192 "EnableContextPrinting",
196 Ptr<MultiFileAggregator> fileAggregator =
198 NS_ASSERT(fileAggregator !=
nullptr);
202 DistributionCollector::OutputType_t outputType =
203 DistributionCollector::OUTPUT_TYPE_HISTOGRAM;
206 outputType = DistributionCollector::OUTPUT_TYPE_PROBABILITY;
210 outputType = DistributionCollector::OUTPUT_TYPE_CUMULATIVE;
217 MakeCallback(&MultiFileAggregator::Write2d, fileAggregator));
221 MakeCallback(&MultiFileAggregator::AddContextHeading, fileAggregator));
225 MakeCallback(&MultiFileAggregator::EnableContextWarning, fileAggregator));
230 EnumValue(ScalarCollector::INPUT_DATA_TYPE_DOUBLE));
233 EnumValue(ScalarCollector::OUTPUT_TYPE_AVERAGE_PER_SAMPLE));
235 Callback<void, double> callback =
241 it->second->TraceConnectWithoutContext(
"Output", callback);
255 DistributionCollector::OutputType_t outputType =
256 DistributionCollector::OUTPUT_TYPE_HISTOGRAM;
259 outputType = DistributionCollector::OUTPUT_TYPE_PROBABILITY;
263 outputType = DistributionCollector::OUTPUT_TYPE_CUMULATIVE;
269 &MultiFileAggregator::Write2d);
272 &MultiFileAggregator::AddContextHeading);
275 &MultiFileAggregator::EnableContextWarning);
284 <<
" is not a valid output type for this statistics.");
294 Ptr<MagisterGnuplotAggregator> plotAggregator =
296 NS_ASSERT(plotAggregator !=
nullptr);
298 plotAggregator->SetLegend(
m_longLabel,
"Frequency");
299 plotAggregator->Set2dDatasetDefaultStyle(Gnuplot2dDataset::LINES);
304 EnumValue(UnitConversionCollector::TRANSPARENT));
310 const std::string context = it->second->GetName();
311 plotAggregator->Add2dDataset(context, context);
315 &MagisterGnuplotAggregator::Write2d);
330 Ptr<MagisterGnuplotAggregator> plotAggregator =
332 NS_ASSERT(plotAggregator !=
nullptr);
334 plotAggregator->SetLegend(
m_longLabel,
"Frequency");
335 plotAggregator->Set2dDatasetDefaultStyle(Gnuplot2dDataset::LINES);
341 DistributionCollector::OutputType_t outputType =
342 DistributionCollector::OUTPUT_TYPE_HISTOGRAM;
345 outputType = DistributionCollector::OUTPUT_TYPE_PROBABILITY;
349 outputType = DistributionCollector::OUTPUT_TYPE_CUMULATIVE;
356 MakeCallback(&MagisterGnuplotAggregator::Write2d, plotAggregator));
362 EnumValue(ScalarCollector::INPUT_DATA_TYPE_DOUBLE));
365 EnumValue(ScalarCollector::OUTPUT_TYPE_AVERAGE_PER_SAMPLE));
367 Callback<void, double> callback =
373 it->second->TraceConnectWithoutContext(
"Output", callback);
384 Ptr<MagisterGnuplotAggregator> plotAggregator =
386 NS_ASSERT(plotAggregator !=
nullptr);
388 plotAggregator->SetLegend(
m_longLabel,
"Frequency");
389 plotAggregator->Set2dDatasetDefaultStyle(Gnuplot2dDataset::LINES);
393 DistributionCollector::OutputType_t outputType =
394 DistributionCollector::OUTPUT_TYPE_HISTOGRAM;
397 outputType = DistributionCollector::OUTPUT_TYPE_PROBABILITY;
401 outputType = DistributionCollector::OUTPUT_TYPE_CUMULATIVE;
409 const std::string context = it->second->GetName();
410 plotAggregator->Add2dDataset(context, context);
414 &MagisterGnuplotAggregator::Write2d);
421 NS_FATAL_ERROR(
"SatStatsLinkDelayHelper - Invalid output type");
435 if (from.IsInvalid())
437 NS_LOG_WARN(
this <<
" discarding a packet"
438 <<
" from statistics collection because of"
439 <<
" invalid sender address");
441 else if (Mac48Address::ConvertFrom(from).IsBroadcast())
451 std::map<const Address, uint32_t>::const_iterator it =
m_identifierMap.find(from);
459 NS_LOG_WARN(
this <<
" discarding a packet"
460 <<
" from statistics collection because of"
461 <<
" unknown sender address " << from);
469 NS_LOG_FUNCTION(
this << utNode->GetId());
471 const SatIdMapper* satIdMapper = Singleton<SatIdMapper>::Get();
474 if (addr.IsInvalid())
476 NS_LOG_WARN(
this <<
" Node " << utNode->GetId() <<
" is not a valid UT");
482 NS_LOG_INFO(
this <<
" associated address " << addr <<
" with identifier " << identifier);
489 NS_LOG_FUNCTION(
this << probe << probe->GetName() << identifier);
499 &ScalarCollector::TraceSinkDouble);
507 &UnitConversionCollector::TraceSinkDouble);
521 &ScalarCollector::TraceSinkDouble);
528 &DistributionCollector::TraceSinkDouble);
534 <<
" is not a valid output type for this statistics.");
540 NS_LOG_INFO(
this <<
" created probe " << probe->GetName() <<
", connected to collector "
545 NS_LOG_WARN(
this <<
" unable to connect probe " << probe->GetName() <<
" to collector "
558 NS_ASSERT_MSG(collector !=
nullptr,
"Unable to find collector with identifier " << identifier);
564 Ptr<ScalarCollector> c = collector->GetObject<ScalarCollector>();
565 NS_ASSERT(c !=
nullptr);
566 c->TraceSinkDouble(0.0, size);
572 Ptr<UnitConversionCollector> c = collector->GetObject<UnitConversionCollector>();
573 NS_ASSERT(c !=
nullptr);
574 c->TraceSinkDouble(0.0, size);
586 Ptr<ScalarCollector> c = collector->GetObject<ScalarCollector>();
587 NS_ASSERT(c !=
nullptr);
588 c->TraceSinkDouble(0.0, size);
592 Ptr<DistributionCollector> c = collector->GetObject<DistributionCollector>();
593 NS_ASSERT(c !=
nullptr);
594 c->TraceSinkDouble(0.0, size);
600 <<
" is not a valid output type for this statistics.");
621 NS_LOG_FUNCTION(
this << satHelper);
627 NS_LOG_FUNCTION(
this);
641 NS_LOG_FUNCTION(
this);
643 NodeContainer uts =
GetSatHelper()->GetBeamHelper()->GetUtNodes();
644 for (NodeContainer::Iterator it = uts.Begin(); it != uts.End(); ++it)
650 NodeContainer sats =
GetSatHelper()->GetBeamHelper()->GetGeoSatNodes();
651 Callback<void, uint32_t, const Address&> callback =
654 for (NodeContainer::Iterator it = sats.Begin(); it != sats.End(); ++it)
658 NS_ASSERT(satGeoDev !=
nullptr);
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();
665 satPhy = it2->second;
666 NS_ASSERT(satPhy !=
nullptr);
667 Ptr<SatGeoFeederPhy> satGeoFeederPhy = satPhy->GetObject<
SatGeoFeederPhy>();
668 NS_ASSERT(satGeoFeederPhy !=
nullptr);
670 if (satGeoFeederPhy->TraceConnectWithoutContext(
"QueueSizeBytes", callback))
672 NS_LOG_INFO(
this <<
" successfully connected with node ID " << (*it)->GetId()
673 <<
" device #" << satGeoDev->GetIfIndex());
677 NS_FATAL_ERROR(
"Error connecting to QueueSizeBytes trace source"
678 <<
" at node ID " << (*it)->GetId() <<
" device #"
679 << satGeoDev->GetIfIndex());
691 Ptr<const SatHelper> satHelper)
694 NS_LOG_FUNCTION(
this << satHelper);
700 NS_LOG_FUNCTION(
this);
706 static TypeId tid = TypeId(
"ns3::SatStatsRtnFeederQueuePacketsHelper")
714 NS_LOG_FUNCTION(
this);
716 NodeContainer uts =
GetSatHelper()->GetBeamHelper()->GetUtNodes();
717 for (NodeContainer::Iterator it = uts.Begin(); it != uts.End(); ++it)
723 NodeContainer sats =
GetSatHelper()->GetBeamHelper()->GetGeoSatNodes();
724 Callback<void, uint32_t, const Address&> callback =
727 for (NodeContainer::Iterator it = sats.Begin(); it != sats.End(); ++it)
731 NS_ASSERT(satGeoDev !=
nullptr);
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();
738 satPhy = it2->second;
739 NS_ASSERT(satPhy !=
nullptr);
740 Ptr<SatGeoFeederPhy> satGeoFeederPhy = satPhy->GetObject<
SatGeoFeederPhy>();
741 NS_ASSERT(satGeoFeederPhy !=
nullptr);
743 if (satGeoFeederPhy->TraceConnectWithoutContext(
"QueueSizePackets", callback))
745 NS_LOG_INFO(
this <<
" successfully connected with node ID " << (*it)->GetId()
746 <<
" device #" << satGeoDev->GetIfIndex());
750 NS_FATAL_ERROR(
"Error connecting to QueueSizePackets trace source"
751 <<
" at node ID " << (*it)->GetId() <<
" device #"
752 << satGeoDev->GetIfIndex());
766 NS_LOG_FUNCTION(
this << satHelper);
772 NS_LOG_FUNCTION(
this);
786 NS_LOG_FUNCTION(
this);
788 NodeContainer uts =
GetSatHelper()->GetBeamHelper()->GetUtNodes();
789 for (NodeContainer::Iterator it = uts.Begin(); it != uts.End(); ++it)
795 NodeContainer sats =
GetSatHelper()->GetBeamHelper()->GetGeoSatNodes();
796 Callback<void, uint32_t, const Address&> callback =
799 for (NodeContainer::Iterator it = sats.Begin(); it != sats.End(); ++it)
803 NS_ASSERT(satGeoDev !=
nullptr);
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();
810 satPhy = it2->second;
811 NS_ASSERT(satPhy !=
nullptr);
812 Ptr<SatGeoUserPhy> satGeoUserPhy = satPhy->GetObject<
SatGeoUserPhy>();
813 NS_ASSERT(satGeoUserPhy !=
nullptr);
815 if (satGeoUserPhy->TraceConnectWithoutContext(
"QueueSizeBytes", callback))
817 NS_LOG_INFO(
this <<
" successfully connected with node ID " << (*it)->GetId()
818 <<
" device #" << satGeoDev->GetIfIndex());
822 NS_FATAL_ERROR(
"Error connecting to QueueSizeBytes trace source"
823 <<
" at node ID " << (*it)->GetId() <<
" device #"
824 << satGeoDev->GetIfIndex());
838 NS_LOG_FUNCTION(
this << satHelper);
844 NS_LOG_FUNCTION(
this);
858 NS_LOG_FUNCTION(
this);
860 NodeContainer uts =
GetSatHelper()->GetBeamHelper()->GetUtNodes();
861 for (NodeContainer::Iterator it = uts.Begin(); it != uts.End(); ++it)
867 NodeContainer sats =
GetSatHelper()->GetBeamHelper()->GetGeoSatNodes();
868 Callback<void, uint32_t, const Address&> callback =
871 for (NodeContainer::Iterator it = sats.Begin(); it != sats.End(); ++it)
875 NS_ASSERT(satGeoDev !=
nullptr);
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();
882 satPhy = it2->second;
883 NS_ASSERT(satPhy !=
nullptr);
884 Ptr<SatGeoUserPhy> satGeoUserPhy = satPhy->GetObject<
SatGeoUserPhy>();
885 NS_ASSERT(satGeoUserPhy !=
nullptr);
887 if (satGeoUserPhy->TraceConnectWithoutContext(
"QueueSizePackets", callback))
889 NS_LOG_INFO(
this <<
" successfully connected with node ID " << (*it)->GetId()
890 <<
" device #" << satGeoDev->GetIfIndex());
894 NS_FATAL_ERROR(
"Error connecting to QueueSizePackets trace source"
895 <<
" at node ID " << (*it)->GetId() <<
" device #"
896 << satGeoDev->GetIfIndex());
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.
Address GetUtMacWithNode(Ptr< Node > utNode) const
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.
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
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 SaveAddressAndIdentifier(Ptr< Node > utNode)
Save the address and the proper identifier from the given UT node.
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
std::map< const Address, uint32_t > m_identifierMap
Map of address and the identifier associated with it (for return link).
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.