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-ut-llc.h>
37 #include <ns3/scalar-collector.h>
38 #include <ns3/singleton.h>
39 #include <ns3/string.h>
40 #include <ns3/unit-conversion-collector.h>
44 NS_LOG_COMPONENT_DEFINE(
"SatStatsRbdcRequestHelper");
49 NS_OBJECT_ENSURE_REGISTERED(SatStatsRbdcRequestHelper);
53 m_averagingMode(false)
55 NS_LOG_FUNCTION(
this << satHelper);
60 NS_LOG_FUNCTION(
this);
67 TypeId(
"ns3::SatStatsRbdcRequestHelper")
69 .AddAttribute(
"AveragingMode",
70 "If true, all samples will be averaged before passed to aggregator. "
71 "Only affects histogram, PDF, and CDF output types.",
75 MakeBooleanChecker());
82 NS_LOG_FUNCTION(
this << averagingMode);
89 NS_LOG_FUNCTION(
this);
96 std::stringstream ss(identifier);
97 uint32_t identifierNum;
98 if (!(ss >> identifierNum))
100 NS_FATAL_ERROR(
"Cannot convert '" << identifier <<
"' to number");
103 NS_ASSERT_MSG(collector !=
nullptr,
104 "Unable to find collector with identifier " << identifierNum);
110 Ptr<ScalarCollector> c = collector->GetObject<ScalarCollector>();
111 NS_ASSERT(c !=
nullptr);
112 c->TraceSinkUinteger32(0, rbdcTraceKbps);
118 Ptr<UnitConversionCollector> c = collector->GetObject<UnitConversionCollector>();
119 NS_ASSERT(c !=
nullptr);
120 c->TraceSinkUinteger32(0, rbdcTraceKbps);
132 Ptr<ScalarCollector> c = collector->GetObject<ScalarCollector>();
133 NS_ASSERT(c !=
nullptr);
134 c->TraceSinkUinteger32(0, rbdcTraceKbps);
138 Ptr<DistributionCollector> c = collector->GetObject<DistributionCollector>();
139 NS_ASSERT(c !=
nullptr);
140 c->TraceSinkUinteger32(0, rbdcTraceKbps);
146 <<
" is not a valid output type for this statistics.");
154 NS_LOG_FUNCTION(
this);
160 <<
" is not a valid output type for this statistics.");
170 "EnableContextPrinting",
178 EnumValue(ScalarCollector::INPUT_DATA_TYPE_DOUBLE));
181 EnumValue(ScalarCollector::OUTPUT_TYPE_AVERAGE_PER_SAMPLE));
185 &MultiFileAggregator::Write1d);
200 EnumValue(UnitConversionCollector::TRANSPARENT));
204 &MultiFileAggregator::Write2d);
219 "EnableContextPrinting",
223 Ptr<MultiFileAggregator> fileAggregator =
225 NS_ASSERT(fileAggregator !=
nullptr);
229 DistributionCollector::OutputType_t outputType =
230 DistributionCollector::OUTPUT_TYPE_HISTOGRAM;
233 outputType = DistributionCollector::OUTPUT_TYPE_PROBABILITY;
237 outputType = DistributionCollector::OUTPUT_TYPE_CUMULATIVE;
244 MakeCallback(&MultiFileAggregator::Write2d, fileAggregator));
248 MakeCallback(&MultiFileAggregator::AddContextHeading, fileAggregator));
252 MakeCallback(&MultiFileAggregator::EnableContextWarning, fileAggregator));
257 EnumValue(ScalarCollector::INPUT_DATA_TYPE_DOUBLE));
260 EnumValue(ScalarCollector::OUTPUT_TYPE_AVERAGE_PER_SAMPLE));
262 Callback<void, double> callback =
268 it->second->TraceConnectWithoutContext(
"Output", callback);
282 DistributionCollector::OutputType_t outputType =
283 DistributionCollector::OUTPUT_TYPE_HISTOGRAM;
286 outputType = DistributionCollector::OUTPUT_TYPE_PROBABILITY;
290 outputType = DistributionCollector::OUTPUT_TYPE_CUMULATIVE;
296 &MultiFileAggregator::Write2d);
299 &MultiFileAggregator::AddContextHeading);
302 &MultiFileAggregator::EnableContextWarning);
311 <<
" is not a valid output type for this statistics.");
321 Ptr<MagisterGnuplotAggregator> plotAggregator =
323 NS_ASSERT(plotAggregator !=
nullptr);
325 plotAggregator->SetLegend(
"Time (in seconds)",
"RBDC requested (in kbps)");
326 plotAggregator->Set2dDatasetDefaultStyle(Gnuplot2dDataset::LINES);
331 EnumValue(UnitConversionCollector::TRANSPARENT));
337 const std::string context = it->second->GetName();
338 plotAggregator->Add2dDataset(context, context);
342 &MagisterGnuplotAggregator::Write2d);
357 Ptr<MagisterGnuplotAggregator> plotAggregator =
359 NS_ASSERT(plotAggregator !=
nullptr);
361 plotAggregator->SetLegend(
"RBDC requested (in kbps)",
"Frequency");
362 plotAggregator->Set2dDatasetDefaultStyle(Gnuplot2dDataset::LINES);
368 DistributionCollector::OutputType_t outputType =
369 DistributionCollector::OUTPUT_TYPE_HISTOGRAM;
372 outputType = DistributionCollector::OUTPUT_TYPE_PROBABILITY;
376 outputType = DistributionCollector::OUTPUT_TYPE_CUMULATIVE;
383 MakeCallback(&MagisterGnuplotAggregator::Write2d, plotAggregator));
389 EnumValue(ScalarCollector::INPUT_DATA_TYPE_DOUBLE));
392 EnumValue(ScalarCollector::OUTPUT_TYPE_AVERAGE_PER_SAMPLE));
394 Callback<void, double> callback =
400 it->second->TraceConnectWithoutContext(
"Output", callback);
411 Ptr<MagisterGnuplotAggregator> plotAggregator =
413 NS_ASSERT(plotAggregator !=
nullptr);
415 plotAggregator->SetLegend(
"RBDC requested (in kbps)",
"Frequency");
416 plotAggregator->Set2dDatasetDefaultStyle(Gnuplot2dDataset::LINES);
420 DistributionCollector::OutputType_t outputType =
421 DistributionCollector::OUTPUT_TYPE_HISTOGRAM;
424 outputType = DistributionCollector::OUTPUT_TYPE_PROBABILITY;
428 outputType = DistributionCollector::OUTPUT_TYPE_CUMULATIVE;
436 const std::string context = it->second->GetName();
437 plotAggregator->Add2dDataset(context, context);
441 &MagisterGnuplotAggregator::Write2d);
448 NS_FATAL_ERROR(
"SatStatsDelayHelper - Invalid output type");
459 NS_LOG_FUNCTION(
this);
461 Callback<void, std::string, uint32_t> callback =
464 NodeContainer uts =
GetSatHelper()->GetBeamHelper()->GetUtNodes();
465 for (NodeContainer::Iterator it = uts.Begin(); it != uts.End(); ++it)
467 std::ostringstream context;
479 NS_FATAL_ERROR(
"SatStatsRbdcRequestHelper - Invalid identifier type");
484 Ptr<SatNetDevice> satDev = dev->GetObject<
SatNetDevice>();
485 NS_ASSERT(satDev !=
nullptr);
486 Ptr<SatLlc> satLlc = satDev->GetLlc();
487 NS_ASSERT(satLlc !=
nullptr);
488 Ptr<SatUtLlc> utLlc = satLlc->GetObject<
SatUtLlc>();
489 NS_ASSERT(utLlc !=
nullptr);
490 Ptr<SatRequestManager> requestManager = utLlc->GetRequestManager();
492 const bool ret = requestManager->TraceConnect(
"RbdcTrace", context.str(), callback);
493 NS_ASSERT_MSG(ret,
"Error connecting to CrTraceLog of node " << (*it)->GetId());
494 NS_LOG_INFO(
this <<
" successfully connected"
495 <<
" with node ID " << (*it)->GetId());
SatNetDevice to be utilized in the UT and GW nodes.
Parent abstract class of all satellite statistics helpers.
Ptr< const SatHelper > GetSatHelper() const
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.