24 #include <ns3/boolean.h>
25 #include <ns3/bytes-probe.h>
26 #include <ns3/data-collection-object.h>
27 #include <ns3/distribution-collector.h>
29 #include <ns3/fatal-error.h>
31 #include <ns3/magister-gnuplot-aggregator.h>
32 #include <ns3/multi-file-aggregator.h>
33 #include <ns3/node-container.h>
34 #include <ns3/probe.h>
35 #include <ns3/satellite-helper.h>
36 #include <ns3/satellite-net-device.h>
37 #include <ns3/satellite-topology.h>
38 #include <ns3/satellite-ut-mac.h>
39 #include <ns3/scalar-collector.h>
40 #include <ns3/simulator.h>
41 #include <ns3/singleton.h>
42 #include <ns3/string.h>
43 #include <ns3/unit-conversion-collector.h>
50 NS_LOG_COMPONENT_DEFINE(
"SatStatsResourcesGrantedHelper");
55 NS_OBJECT_ENSURE_REGISTERED(SatStatsResourcesGrantedHelper);
60 NS_LOG_FUNCTION(
this << satHelper);
65 NS_LOG_FUNCTION(
this);
71 static TypeId tid = TypeId(
"ns3::SatStatsResourcesGrantedHelper").SetParent<
SatStatsHelper>();
78 NS_LOG_FUNCTION(
this);
84 <<
" is not a valid output type for this statistics.");
94 "EnableContextPrinting",
102 EnumValue(ScalarCollector::INPUT_DATA_TYPE_UINTEGER));
105 EnumValue(ScalarCollector::OUTPUT_TYPE_AVERAGE_PER_SAMPLE));
109 &MultiFileAggregator::Write1d);
112 NodeContainer uts = Singleton<SatTopology>::Get()->GetUtNodes();
113 for (NodeContainer::Iterator it = uts.Begin(); it != uts.End(); ++it)
115 InstallProbe(*it, &ScalarCollector::TraceSinkUinteger32);
132 EnumValue(UnitConversionCollector::TRANSPARENT));
136 &MultiFileAggregator::Write2d);
139 NodeContainer uts = Singleton<SatTopology>::Get()->GetUtNodes();
140 for (NodeContainer::Iterator it = uts.Begin(); it != uts.End(); ++it)
142 InstallProbe(*it, &UnitConversionCollector::TraceSinkUinteger32);
160 DistributionCollector::OutputType_t outputType =
161 DistributionCollector::OUTPUT_TYPE_HISTOGRAM;
164 outputType = DistributionCollector::OUTPUT_TYPE_PROBABILITY;
168 outputType = DistributionCollector::OUTPUT_TYPE_CUMULATIVE;
174 &MultiFileAggregator::Write2d);
177 &MultiFileAggregator::AddContextHeading);
180 &MultiFileAggregator::EnableContextWarning);
183 NodeContainer uts = Singleton<SatTopology>::Get()->GetUtNodes();
184 for (NodeContainer::Iterator it = uts.Begin(); it != uts.End(); ++it)
186 InstallProbe(*it, &DistributionCollector::TraceSinkUinteger32);
195 <<
" is not a valid output type for this statistics.");
205 Ptr<MagisterGnuplotAggregator> plotAggregator =
207 NS_ASSERT(plotAggregator !=
nullptr);
209 plotAggregator->SetLegend(
"Time (in seconds)",
"Resources granted (in bytes)");
210 plotAggregator->Set2dDatasetDefaultStyle(Gnuplot2dDataset::LINES_POINTS);
215 EnumValue(UnitConversionCollector::TRANSPARENT));
221 const std::string context = it->second->GetName();
222 plotAggregator->Add2dDataset(context, context);
226 &MagisterGnuplotAggregator::Write2d);
229 NodeContainer uts = Singleton<SatTopology>::Get()->GetUtNodes();
230 for (NodeContainer::Iterator it = uts.Begin(); it != uts.End(); ++it)
232 InstallProbe(*it, &UnitConversionCollector::TraceSinkUinteger32);
247 Ptr<MagisterGnuplotAggregator> plotAggregator =
249 NS_ASSERT(plotAggregator !=
nullptr);
251 plotAggregator->SetLegend(
"Resources granted (in bytes)",
"Frequency");
252 plotAggregator->Set2dDatasetDefaultStyle(Gnuplot2dDataset::LINES);
256 DistributionCollector::OutputType_t outputType =
257 DistributionCollector::OUTPUT_TYPE_HISTOGRAM;
260 outputType = DistributionCollector::OUTPUT_TYPE_PROBABILITY;
264 outputType = DistributionCollector::OUTPUT_TYPE_CUMULATIVE;
272 const std::string context = it->second->GetName();
273 plotAggregator->Add2dDataset(context, context);
277 &MagisterGnuplotAggregator::Write2d);
280 NodeContainer uts = Singleton<SatTopology>::Get()->GetUtNodes();
281 for (NodeContainer::Iterator it = uts.Begin(); it != uts.End(); ++it)
283 InstallProbe(*it, &DistributionCollector::TraceSinkUinteger32);
290 NS_FATAL_ERROR(
"SatStatsResourcesGrantedHelper - Invalid output type");
296 template <
typename R,
typename C,
typename P>
300 NS_LOG_FUNCTION(
this << utNode);
302 const int32_t utId =
GetUtId(utNode);
303 NS_ASSERT_MSG(utId > 0,
"Node " << utNode->GetId() <<
" is not a valid UT");
307 std::ostringstream probeName;
309 Ptr<BytesProbe> probe = CreateObject<BytesProbe>();
310 probe->SetName(probeName.str());
313 Ptr<SatNetDevice> satDev = dev->GetObject<
SatNetDevice>();
314 NS_ASSERT(satDev !=
nullptr);
315 Ptr<SatMac> satMac = satDev->GetMac();
316 NS_ASSERT(satMac !=
nullptr);
317 Ptr<SatUtMac> satUtMac = satMac->GetObject<
SatUtMac>();
318 NS_ASSERT(satUtMac !=
nullptr);
321 if (probe->ConnectByObject(
"DaResourcesTrace", satUtMac))
329 NS_LOG_INFO(
this <<
" created probe " << probeName.str() <<
", connected to collector "
332 std::make_pair(probe->GetObject<Probe>(), std::make_pair(utNode, identifier)));
336 NS_LOG_WARN(
this <<
" unable to connect probe " << probeName.str() <<
" to collector "
342 NS_FATAL_ERROR(
"Error connecting to DaResourcesTrace trace source of SatUtMac"
343 <<
" at node ID " << utNode->GetId() <<
" device #" << satDev->GetIfIndex());
348 template <
typename R,
typename C,
typename P>
352 NS_LOG_FUNCTION(
this);
354 std::map<Ptr<Probe>, std::pair<Ptr<Node>, uint32_t>>::iterator it;
358 Ptr<Probe> probe = it->first;
359 Ptr<Node> node = it->second.first;
360 uint32_t identifier = it->second.second;
361 R (C::*collectorTraceSink)(P, P);
367 <<
" is not a valid output type for this statistics.");
371 collectorTraceSink = &ScalarCollector::TraceSinkUinteger32;
376 collectorTraceSink = &UnitConversionCollector::TraceSinkUinteger32;
383 collectorTraceSink = &DistributionCollector::TraceSinkUinteger32;
389 <<
" is not a valid output type for this statistics.");
393 collectorTraceSink = &UnitConversionCollector::TraceSinkUinteger32;
400 collectorTraceSink = &DistributionCollector::TraceSinkUinteger32;
405 NS_FATAL_ERROR(
"SatStatsResourcesGrantedHelper - Invalid output type");
414 NS_FATAL_ERROR(
"Error disconnecting trace file on handover");
424 NS_FATAL_ERROR(
"Error connecting trace file on handover");
427 it->second.second = identifier;
SatNetDevice to be utilized in the UT and GW nodes.
Parent abstract class of all satellite statistics helpers.
uint32_t GetIdentifierForUtUser(Ptr< Node > utUserNode) 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 GetUtId(Ptr< Node > utNode) const
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
std::map< Ptr< Probe >, std::pair< Ptr< Node >, uint32_t > > m_probes
Maintains a list of probes created by this helper.
void InstallProbe(Ptr< Node > utNode, R(C::*collectorTraceSink)(P, P))
void DoInstall()
Install the probes, collectors, and aggregators necessary to produce the statistics output.
Ptr< DataCollectionObject > m_aggregator
The aggregator created by this helper.
SatStatsResourcesGrantedHelper(Ptr< const SatHelper > satHelper)
virtual ~SatStatsResourcesGrantedHelper()
/ Destructor.
void UpdateIdentifierOnProbes()
Change identifier used on probes, when handovers occur.
static TypeId GetTypeId()
inherited from ObjectBase base class
CollectorMap m_terminalCollectors
Maintains a list of collectors created by this helper.
UT specific Mac class for Sat Net Devices.
SatArqSequenceNumber is handling the sequence numbers for the ARQ process.