23 #include <ns3/boolean.h>
24 #include <ns3/callback.h>
25 #include <ns3/data-collection-object.h>
26 #include <ns3/distribution-collector.h>
29 #include <ns3/magister-gnuplot-aggregator.h>
30 #include <ns3/multi-file-aggregator.h>
31 #include <ns3/node-container.h>
32 #include <ns3/nstime.h>
33 #include <ns3/probe.h>
34 #include <ns3/satellite-helper.h>
35 #include <ns3/satellite-request-manager.h>
36 #include <ns3/satellite-topology.h>
37 #include <ns3/satellite-ut-llc.h>
38 #include <ns3/scalar-collector.h>
39 #include <ns3/singleton.h>
40 #include <ns3/string.h>
41 #include <ns3/unit-conversion-collector.h>
46 NS_LOG_COMPONENT_DEFINE(
"SatStatsRbdcRequestHelper");
51 NS_OBJECT_ENSURE_REGISTERED(SatStatsRbdcRequestHelper);
55 m_averagingMode(false)
57 NS_LOG_FUNCTION(
this << satHelper);
62 NS_LOG_FUNCTION(
this);
69 TypeId(
"ns3::SatStatsRbdcRequestHelper")
71 .AddAttribute(
"AveragingMode",
72 "If true, all samples will be averaged before passed to aggregator. "
73 "Only affects histogram, PDF, and CDF output types.",
77 MakeBooleanChecker());
84 NS_LOG_FUNCTION(
this << averagingMode);
91 NS_LOG_FUNCTION(
this);
98 std::stringstream ss(identifier);
99 uint32_t identifierNum;
100 if (!(ss >> identifierNum))
102 NS_FATAL_ERROR(
"Cannot convert '" << identifier <<
"' to number");
105 NS_ASSERT_MSG(collector !=
nullptr,
106 "Unable to find collector with identifier " << identifierNum);
112 Ptr<ScalarCollector> c = collector->GetObject<ScalarCollector>();
113 NS_ASSERT(c !=
nullptr);
114 c->TraceSinkUinteger32(0, rbdcTraceKbps);
120 Ptr<UnitConversionCollector> c = collector->GetObject<UnitConversionCollector>();
121 NS_ASSERT(c !=
nullptr);
122 c->TraceSinkUinteger32(0, rbdcTraceKbps);
134 Ptr<ScalarCollector> c = collector->GetObject<ScalarCollector>();
135 NS_ASSERT(c !=
nullptr);
136 c->TraceSinkUinteger32(0, rbdcTraceKbps);
140 Ptr<DistributionCollector> c = collector->GetObject<DistributionCollector>();
141 NS_ASSERT(c !=
nullptr);
142 c->TraceSinkUinteger32(0, rbdcTraceKbps);
148 <<
" is not a valid output type for this statistics.");
156 NS_LOG_FUNCTION(
this);
162 <<
" is not a valid output type for this statistics.");
172 "EnableContextPrinting",
180 EnumValue(ScalarCollector::INPUT_DATA_TYPE_DOUBLE));
183 EnumValue(ScalarCollector::OUTPUT_TYPE_AVERAGE_PER_SAMPLE));
187 &MultiFileAggregator::Write1d);
202 EnumValue(UnitConversionCollector::TRANSPARENT));
206 &MultiFileAggregator::Write2d);
221 "EnableContextPrinting",
225 Ptr<MultiFileAggregator> fileAggregator =
227 NS_ASSERT(fileAggregator !=
nullptr);
231 DistributionCollector::OutputType_t outputType =
232 DistributionCollector::OUTPUT_TYPE_HISTOGRAM;
235 outputType = DistributionCollector::OUTPUT_TYPE_PROBABILITY;
239 outputType = DistributionCollector::OUTPUT_TYPE_CUMULATIVE;
246 MakeCallback(&MultiFileAggregator::Write2d, fileAggregator));
250 MakeCallback(&MultiFileAggregator::AddContextHeading, fileAggregator));
254 MakeCallback(&MultiFileAggregator::EnableContextWarning, fileAggregator));
259 EnumValue(ScalarCollector::INPUT_DATA_TYPE_DOUBLE));
262 EnumValue(ScalarCollector::OUTPUT_TYPE_AVERAGE_PER_SAMPLE));
264 Callback<void, double> callback =
270 it->second->TraceConnectWithoutContext(
"Output", callback);
284 DistributionCollector::OutputType_t outputType =
285 DistributionCollector::OUTPUT_TYPE_HISTOGRAM;
288 outputType = DistributionCollector::OUTPUT_TYPE_PROBABILITY;
292 outputType = DistributionCollector::OUTPUT_TYPE_CUMULATIVE;
298 &MultiFileAggregator::Write2d);
301 &MultiFileAggregator::AddContextHeading);
304 &MultiFileAggregator::EnableContextWarning);
313 <<
" is not a valid output type for this statistics.");
323 Ptr<MagisterGnuplotAggregator> plotAggregator =
325 NS_ASSERT(plotAggregator !=
nullptr);
327 plotAggregator->SetLegend(
"Time (in seconds)",
"RBDC requested (in kbps)");
328 plotAggregator->Set2dDatasetDefaultStyle(Gnuplot2dDataset::LINES);
333 EnumValue(UnitConversionCollector::TRANSPARENT));
339 const std::string context = it->second->GetName();
340 plotAggregator->Add2dDataset(context, context);
344 &MagisterGnuplotAggregator::Write2d);
359 Ptr<MagisterGnuplotAggregator> plotAggregator =
361 NS_ASSERT(plotAggregator !=
nullptr);
363 plotAggregator->SetLegend(
"RBDC requested (in kbps)",
"Frequency");
364 plotAggregator->Set2dDatasetDefaultStyle(Gnuplot2dDataset::LINES);
370 DistributionCollector::OutputType_t outputType =
371 DistributionCollector::OUTPUT_TYPE_HISTOGRAM;
374 outputType = DistributionCollector::OUTPUT_TYPE_PROBABILITY;
378 outputType = DistributionCollector::OUTPUT_TYPE_CUMULATIVE;
385 MakeCallback(&MagisterGnuplotAggregator::Write2d, plotAggregator));
391 EnumValue(ScalarCollector::INPUT_DATA_TYPE_DOUBLE));
394 EnumValue(ScalarCollector::OUTPUT_TYPE_AVERAGE_PER_SAMPLE));
396 Callback<void, double> callback =
402 it->second->TraceConnectWithoutContext(
"Output", callback);
413 Ptr<MagisterGnuplotAggregator> plotAggregator =
415 NS_ASSERT(plotAggregator !=
nullptr);
417 plotAggregator->SetLegend(
"RBDC requested (in kbps)",
"Frequency");
418 plotAggregator->Set2dDatasetDefaultStyle(Gnuplot2dDataset::LINES);
422 DistributionCollector::OutputType_t outputType =
423 DistributionCollector::OUTPUT_TYPE_HISTOGRAM;
426 outputType = DistributionCollector::OUTPUT_TYPE_PROBABILITY;
430 outputType = DistributionCollector::OUTPUT_TYPE_CUMULATIVE;
438 const std::string context = it->second->GetName();
439 plotAggregator->Add2dDataset(context, context);
443 &MagisterGnuplotAggregator::Write2d);
450 NS_FATAL_ERROR(
"SatStatsDelayHelper - Invalid output type");
461 NS_LOG_FUNCTION(
this);
463 Callback<void, std::string, uint32_t> callback =
466 NodeContainer uts = Singleton<SatTopology>::Get()->GetUtNodes();
467 for (NodeContainer::Iterator it = uts.Begin(); it != uts.End(); ++it)
469 std::ostringstream context;
481 NS_FATAL_ERROR(
"SatStatsRbdcRequestHelper - Invalid identifier type");
486 Ptr<SatNetDevice> satDev = dev->GetObject<
SatNetDevice>();
487 NS_ASSERT(satDev !=
nullptr);
488 Ptr<SatLlc> satLlc = satDev->GetLlc();
489 NS_ASSERT(satLlc !=
nullptr);
490 Ptr<SatUtLlc> utLlc = satLlc->GetObject<
SatUtLlc>();
491 NS_ASSERT(utLlc !=
nullptr);
492 Ptr<SatRequestManager> requestManager = utLlc->GetRequestManager();
494 const bool ret = requestManager->TraceConnect(
"RbdcTrace", context.str(), callback);
495 NS_ASSERT_MSG(ret,
"Error connecting to CrTraceLog of node " << (*it)->GetId());
496 NS_LOG_INFO(
this <<
" successfully connected"
497 <<
" with node ID " << (*it)->GetId());
SatNetDevice to be utilized in the UT and GW nodes.
Parent abstract class of all satellite statistics helpers.
IdentifierType_t GetIdentifierType() const
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.
static Ptr< NetDevice > GetUtSatNetDevice(Ptr< Node > utNode)
OutputType_t GetOutputType() const
uint32_t GetIdentifierForUt(Ptr< Node > utNode) const
std::string GetName() const
virtual std::string GetTimeHeading(std::string dataLabel) const
virtual std::string GetDistributionHeading(std::string dataLabel) const
void DoInstall()
Install the probes, collectors, and aggregators necessary to produce the statistics output.
virtual ~SatStatsRbdcRequestHelper()
/ Destructor.
bool m_averagingMode
AveragingMode attribute.
static TypeId GetTypeId()
inherited from ObjectBase base class
Ptr< DataCollectionObject > m_aggregator
The aggregator created by this helper.
void InstallProbes()
Set up several probes or other means of listeners and connect them to the collectors.
SatStatsRbdcRequestHelper(Ptr< const SatHelper > satHelper)
void RbdcRateCallback(std::string identifier, uint32_t rbdcTraceKbps)
Receive inputs from trace sources.
CollectorMap m_terminalCollectors
Maintains a list of collectors created by this helper.
Ptr< DistributionCollector > m_averagingCollector
The final collector utilized in averaged output (histogram, PDF, and CDF).
void SetAveragingMode(bool averagingMode)
bool GetAveragingMode() const
SatUtLlc holds the UT implementation of LLC layer.
SatArqSequenceNumber is handling the sequence numbers for the ARQ process.