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-ut-mac.h>
38 #include <ns3/scalar-collector.h>
39 #include <ns3/simulator.h>
40 #include <ns3/string.h>
41 #include <ns3/unit-conversion-collector.h>
43 NS_LOG_COMPONENT_DEFINE(
"SatStatsResourcesGrantedHelper");
48 NS_OBJECT_ENSURE_REGISTERED(SatStatsResourcesGrantedHelper);
53 NS_LOG_FUNCTION(
this << satHelper);
58 NS_LOG_FUNCTION(
this);
64 static TypeId tid = TypeId(
"ns3::SatStatsResourcesGrantedHelper").SetParent<
SatStatsHelper>();
71 NS_LOG_FUNCTION(
this);
77 <<
" is not a valid output type for this statistics.");
87 "EnableContextPrinting",
95 EnumValue(ScalarCollector::INPUT_DATA_TYPE_UINTEGER));
98 EnumValue(ScalarCollector::OUTPUT_TYPE_AVERAGE_PER_SAMPLE));
102 &MultiFileAggregator::Write1d);
105 NodeContainer uts =
GetSatHelper()->GetBeamHelper()->GetUtNodes();
106 for (NodeContainer::Iterator it = uts.Begin(); it != uts.End(); ++it)
108 InstallProbe(*it, &ScalarCollector::TraceSinkUinteger32);
125 EnumValue(UnitConversionCollector::TRANSPARENT));
129 &MultiFileAggregator::Write2d);
132 NodeContainer uts =
GetSatHelper()->GetBeamHelper()->GetUtNodes();
133 for (NodeContainer::Iterator it = uts.Begin(); it != uts.End(); ++it)
135 InstallProbe(*it, &UnitConversionCollector::TraceSinkUinteger32);
153 DistributionCollector::OutputType_t outputType =
154 DistributionCollector::OUTPUT_TYPE_HISTOGRAM;
157 outputType = DistributionCollector::OUTPUT_TYPE_PROBABILITY;
161 outputType = DistributionCollector::OUTPUT_TYPE_CUMULATIVE;
167 &MultiFileAggregator::Write2d);
170 &MultiFileAggregator::AddContextHeading);
173 &MultiFileAggregator::EnableContextWarning);
176 NodeContainer uts =
GetSatHelper()->GetBeamHelper()->GetUtNodes();
177 for (NodeContainer::Iterator it = uts.Begin(); it != uts.End(); ++it)
179 InstallProbe(*it, &DistributionCollector::TraceSinkUinteger32);
188 <<
" is not a valid output type for this statistics.");
198 Ptr<MagisterGnuplotAggregator> plotAggregator =
200 NS_ASSERT(plotAggregator !=
nullptr);
202 plotAggregator->SetLegend(
"Time (in seconds)",
"Resources granted (in bytes)");
203 plotAggregator->Set2dDatasetDefaultStyle(Gnuplot2dDataset::LINES_POINTS);
208 EnumValue(UnitConversionCollector::TRANSPARENT));
214 const std::string context = it->second->GetName();
215 plotAggregator->Add2dDataset(context, context);
219 &MagisterGnuplotAggregator::Write2d);
222 NodeContainer uts =
GetSatHelper()->GetBeamHelper()->GetUtNodes();
223 for (NodeContainer::Iterator it = uts.Begin(); it != uts.End(); ++it)
225 InstallProbe(*it, &UnitConversionCollector::TraceSinkUinteger32);
240 Ptr<MagisterGnuplotAggregator> plotAggregator =
242 NS_ASSERT(plotAggregator !=
nullptr);
244 plotAggregator->SetLegend(
"Resources granted (in bytes)",
"Frequency");
245 plotAggregator->Set2dDatasetDefaultStyle(Gnuplot2dDataset::LINES);
249 DistributionCollector::OutputType_t outputType =
250 DistributionCollector::OUTPUT_TYPE_HISTOGRAM;
253 outputType = DistributionCollector::OUTPUT_TYPE_PROBABILITY;
257 outputType = DistributionCollector::OUTPUT_TYPE_CUMULATIVE;
265 const std::string context = it->second->GetName();
266 plotAggregator->Add2dDataset(context, context);
270 &MagisterGnuplotAggregator::Write2d);
273 NodeContainer uts =
GetSatHelper()->GetBeamHelper()->GetUtNodes();
274 for (NodeContainer::Iterator it = uts.Begin(); it != uts.End(); ++it)
276 InstallProbe(*it, &DistributionCollector::TraceSinkUinteger32);
283 NS_FATAL_ERROR(
"SatStatsResourcesGrantedHelper - Invalid output type");
289 template <
typename R,
typename C,
typename P>
293 NS_LOG_FUNCTION(
this << utNode);
295 const int32_t utId =
GetUtId(utNode);
296 NS_ASSERT_MSG(utId > 0,
"Node " << utNode->GetId() <<
" is not a valid UT");
300 std::ostringstream probeName;
302 Ptr<BytesProbe> probe = CreateObject<BytesProbe>();
303 probe->SetName(probeName.str());
306 Ptr<SatNetDevice> satDev = dev->GetObject<
SatNetDevice>();
307 NS_ASSERT(satDev !=
nullptr);
308 Ptr<SatMac> satMac = satDev->GetMac();
309 NS_ASSERT(satMac !=
nullptr);
310 Ptr<SatUtMac> satUtMac = satMac->GetObject<
SatUtMac>();
311 NS_ASSERT(satUtMac !=
nullptr);
314 if (probe->ConnectByObject(
"DaResourcesTrace", satUtMac))
322 NS_LOG_INFO(
this <<
" created probe " << probeName.str() <<
", connected to collector "
324 m_probes.push_back(probe->GetObject<Probe>());
328 NS_LOG_WARN(
this <<
" unable to connect probe " << probeName.str() <<
" to collector "
334 NS_FATAL_ERROR(
"Error connecting to DaResourcesTrace trace source of SatUtMac"
335 <<
" at node ID " << utNode->GetId() <<
" device #" << satDev->GetIfIndex());
SatNetDevice to be utilized in the UT and GW nodes.
Parent abstract class of all satellite statistics helpers.
Ptr< const SatHelper > GetSatHelper() 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
void InstallProbe(Ptr< Node > utNode, R(C::*collectorTraceSink)(P, P))
std::list< Ptr< Probe > > m_probes
Maintains a list of probes created by this helper.
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.
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.