24 #include <ns3/boolean.h>
25 #include <ns3/data-collection-object.h>
26 #include <ns3/distribution-collector.h>
28 #include <ns3/fatal-error.h>
29 #include <ns3/interval-rate-collector.h>
31 #include <ns3/mac48-address.h>
32 #include <ns3/magister-gnuplot-aggregator.h>
33 #include <ns3/multi-file-aggregator.h>
34 #include <ns3/net-device.h>
35 #include <ns3/node-container.h>
36 #include <ns3/satellite-helper.h>
37 #include <ns3/satellite-id-mapper.h>
38 #include <ns3/satellite-llc.h>
39 #include <ns3/satellite-net-device.h>
40 #include <ns3/satellite-phy-rx.h>
41 #include <ns3/satellite-phy.h>
42 #include <ns3/scalar-collector.h>
43 #include <ns3/simulator.h>
44 #include <ns3/singleton.h>
45 #include <ns3/string.h>
46 #include <ns3/unit-conversion-collector.h>
48 NS_LOG_COMPONENT_DEFINE(
"SatStatsQueueHelper");
55 NS_OBJECT_ENSURE_REGISTERED(SatStatsQueueHelper);
65 return "UNIT_NUMBER_OF_PACKETS";
67 NS_FATAL_ERROR(
"SatStatsQueueHelper - Invalid unit type");
71 NS_FATAL_ERROR(
"SatStatsQueueHelper - Invalid unit type");
77 m_pollInterval(MilliSeconds(10)),
82 NS_LOG_FUNCTION(
this << satHelper);
87 NS_LOG_FUNCTION(
this);
93 static TypeId tid = TypeId(
"ns3::SatStatsQueueHelper")
95 .AddAttribute(
"PollInterval",
97 TimeValue(MilliSeconds(10)),
123 NS_FATAL_ERROR(
"SatStatsQueueHelper - Invalid unit type");
136 NS_LOG_FUNCTION(
this << pollInterval.GetSeconds());
149 NS_LOG_FUNCTION(
this);
155 <<
" is not a valid output type for this statistics.");
165 "EnableContextPrinting",
173 EnumValue(ScalarCollector::INPUT_DATA_TYPE_UINTEGER));
176 EnumValue(ScalarCollector::OUTPUT_TYPE_AVERAGE_PER_SAMPLE));
180 &MultiFileAggregator::Write1d);
196 EnumValue(IntervalRateCollector::INPUT_DATA_TYPE_UINTEGER));
200 &MultiFileAggregator::Write2d);
203 &MultiFileAggregator::AddContextHeading);
220 DistributionCollector::OutputType_t outputType =
221 DistributionCollector::OUTPUT_TYPE_HISTOGRAM;
224 outputType = DistributionCollector::OUTPUT_TYPE_PROBABILITY;
228 outputType = DistributionCollector::OUTPUT_TYPE_CUMULATIVE;
234 &MultiFileAggregator::Write2d);
237 &MultiFileAggregator::AddContextHeading);
240 &MultiFileAggregator::EnableContextWarning);
247 <<
" is not a valid output type for this statistics.");
257 Ptr<MagisterGnuplotAggregator> plotAggregator =
259 NS_ASSERT(plotAggregator !=
nullptr);
261 plotAggregator->SetLegend(
"Time (in seconds)",
"Queued packets");
262 plotAggregator->Set2dDatasetDefaultStyle(Gnuplot2dDataset::STEPS);
268 EnumValue(IntervalRateCollector::INPUT_DATA_TYPE_UINTEGER));
274 const std::string context = it->second->GetName();
275 plotAggregator->Add2dDataset(context, context);
279 &MagisterGnuplotAggregator::Write2d);
293 Ptr<MagisterGnuplotAggregator> plotAggregator =
295 NS_ASSERT(plotAggregator !=
nullptr);
297 plotAggregator->SetLegend(
m_longLabel,
"Frequency");
298 plotAggregator->Set2dDatasetDefaultStyle(Gnuplot2dDataset::LINES);
302 DistributionCollector::OutputType_t outputType =
303 DistributionCollector::OUTPUT_TYPE_HISTOGRAM;
306 outputType = DistributionCollector::OUTPUT_TYPE_PROBABILITY;
310 outputType = DistributionCollector::OUTPUT_TYPE_CUMULATIVE;
318 const std::string context = it->second->GetName();
319 plotAggregator->Add2dDataset(context, context);
323 &MagisterGnuplotAggregator::Write2d);
328 NS_FATAL_ERROR(
"SatStatsQueueHelper - Invalid output type");
343 NS_LOG_FUNCTION(
this);
352 NS_LOG_FUNCTION(
this);
368 NS_ASSERT_MSG(collector !=
nullptr,
"Unable to find collector with identifier " << identifier);
374 Ptr<ScalarCollector> c = collector->GetObject<ScalarCollector>();
375 NS_ASSERT(c !=
nullptr);
376 c->TraceSinkUinteger32(0, value);
382 Ptr<IntervalRateCollector> c = collector->GetObject<IntervalRateCollector>();
383 NS_ASSERT(c !=
nullptr);
384 c->TraceSinkUinteger32(0, value);
394 Ptr<DistributionCollector> c = collector->GetObject<DistributionCollector>();
395 NS_ASSERT(c !=
nullptr);
396 c->TraceSinkUinteger32(0, value);
402 <<
" is not a valid output type for this statistics.");
416 NS_LOG_FUNCTION(
this << satHelper);
421 NS_LOG_FUNCTION(
this);
427 static TypeId tid = TypeId(
"ns3::SatStatsFwdQueueHelper").SetParent<
SatStatsQueueHelper>();
434 NS_LOG_FUNCTION(
this);
436 const SatIdMapper* satIdMapper = Singleton<SatIdMapper>::Get();
438 NodeContainer gws =
GetSatHelper()->GetBeamHelper()->GetGwNodes();
439 for (NodeContainer::Iterator it1 = gws.Begin(); it1 != gws.End(); ++it1)
443 for (NetDeviceContainer::Iterator itDev = devs.Begin(); itDev != devs.End(); ++itDev)
445 Ptr<SatNetDevice> satDev = (*itDev)->GetObject<
SatNetDevice>();
446 NS_ASSERT(satDev !=
nullptr);
449 Ptr<SatPhy> satPhy = satDev->GetPhy();
450 NS_ASSERT(satPhy !=
nullptr);
451 Ptr<SatPhyRx> satPhyRx = satPhy->GetPhyRx();
452 NS_ASSERT(satPhyRx !=
nullptr);
453 const uint32_t satId = satPhyRx->GetSatId();
454 const uint32_t beamId = satPhyRx->GetBeamId();
455 NS_LOG_DEBUG(
this <<
" enlisting UT from sat ID " << satId <<
" and beam ID "
460 NodeContainer uts =
GetSatHelper()->GetBeamHelper()->GetUtNodes(satId, beamId);
461 for (NodeContainer::Iterator it2 = uts.Begin(); it2 != uts.End(); ++it2)
464 const Mac48Address mac48Addr = Mac48Address::ConvertFrom(addr);
466 if (addr.IsInvalid())
468 NS_LOG_WARN(
this <<
" Node " << (*it2)->GetId() <<
" is not a valid UT");
473 listOfUt.push_back(std::make_pair(mac48Addr, identifier));
478 Ptr<SatLlc> satLlc = satDev->GetLlc();
479 NS_ASSERT(satLlc !=
nullptr);
480 m_llc.push_back(std::make_pair(satLlc, listOfUt));
494 std::list<std::pair<Ptr<SatLlc>,
ListOfUt_t>>::const_iterator it1;
495 for (it1 =
m_llc.begin(); it1 !=
m_llc.end(); ++it1)
497 for (ListOfUt_t::const_iterator it2 = it1->second.begin(); it2 != it1->second.end(); ++it2)
499 const Mac48Address addr = it2->first;
500 const uint32_t identifier = it2->second;
521 NS_LOG_FUNCTION(
this << satHelper);
527 NS_LOG_FUNCTION(
this);
545 NS_LOG_FUNCTION(
this << satHelper);
551 NS_LOG_FUNCTION(
this);
569 NS_LOG_FUNCTION(
this << satHelper);
574 NS_LOG_FUNCTION(
this);
580 static TypeId tid = TypeId(
"ns3::SatStatsRtnQueueHelper").SetParent<
SatStatsQueueHelper>();
587 NS_LOG_FUNCTION(
this);
589 NodeContainer uts =
GetSatHelper()->GetBeamHelper()->GetUtNodes();
590 for (NodeContainer::Iterator it = uts.Begin(); it != uts.End(); ++it)
594 Ptr<SatNetDevice> satDev = dev->GetObject<
SatNetDevice>();
595 NS_ASSERT(satDev !=
nullptr);
596 Ptr<SatLlc> satLlc = satDev->GetLlc();
597 NS_ASSERT(satLlc !=
nullptr);
598 m_llc.push_back(std::make_pair(satLlc, identifier));
609 std::list<std::pair<Ptr<SatLlc>, uint32_t>>::const_iterator it;
610 for (it =
m_llc.begin(); it !=
m_llc.end(); ++it)
631 NS_LOG_FUNCTION(
this << satHelper);
637 NS_LOG_FUNCTION(
this);
655 NS_LOG_FUNCTION(
this << satHelper);
661 NS_LOG_FUNCTION(
this);
Address GetUtMacWithNode(Ptr< Node > utNode) const
SatNetDevice to be utilized in the UT and GW nodes.
Helper for forward link queue statistics using byte as unit.
SatStatsFwdQueueBytesHelper(Ptr< const SatHelper > satHelper)
virtual ~SatStatsFwdQueueBytesHelper()
/ Destructor.
static TypeId GetTypeId()
inherited from ObjectBase base class
Helper for forward link queue statistics.
SatStatsFwdQueueHelper(Ptr< const SatHelper > satHelper)
void DoPoll()
Retrieve the queue size of every relevant encapsulator and push the values to the right collectors.
virtual ~SatStatsFwdQueueHelper()
/ Destructor.
std::list< std::pair< Mac48Address, uint32_t > > ListOfUt_t
std::list< std::pair< Ptr< SatLlc >, ListOfUt_t > > m_llc
Maintains a list of GW LLC, its UT address, and its identifier.
static TypeId GetTypeId()
inherited from ObjectBase base class
Helper for forward link queue statistics using packet as unit.
virtual ~SatStatsFwdQueuePacketsHelper()
/ Destructor.
static TypeId GetTypeId()
inherited from ObjectBase base class
SatStatsFwdQueuePacketsHelper(Ptr< const SatHelper > satHelper)
Parent abstract class of all satellite statistics helpers.
Ptr< const SatHelper > GetSatHelper() const
static NetDeviceContainer GetGwSatNetDevice(Ptr< Node > gwNode)
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
Helper for queue statistics.
static std::string GetUnitTypeName(UnitType_t unitType)
virtual void DoEnlistSource()=0
CollectorMap m_terminalCollectors
Maintains a list of collectors created by this helper.
void DoInstall()
Install the probes, collectors, and aggregators necessary to produce the statistics output.
void Poll()
Retrieve the queue size of every relevant encapsulator and push the values to the right collectors.
virtual ~SatStatsQueueHelper()
/ Destructor.
void EnlistSource()
Identify the list of source of queue events.
void SetPollInterval(Time pollInterval)
void PushToCollector(uint32_t identifier, uint32_t value)
static TypeId GetTypeId()
inherited from ObjectBase base class
void SetUnitType(UnitType_t unitType)
Ptr< DataCollectionObject > m_aggregator
The aggregator created by this helper.
Time GetPollInterval() const
SatStatsQueueHelper(Ptr< const SatHelper > satHelper)
UnitType_t GetUnitType() const
Time m_pollInterval
PollInterval attribute.
virtual void DoPoll()=0
Retrieve the queue size of every relevant encapsulator and push the values to the right collectors.
Helper for return link queue statistics using byte as unit.
static TypeId GetTypeId()
inherited from ObjectBase base class
virtual ~SatStatsRtnQueueBytesHelper()
/ Destructor.
SatStatsRtnQueueBytesHelper(Ptr< const SatHelper > satHelper)
Helper for return link queue statistics.
virtual ~SatStatsRtnQueueHelper()
/ Destructor.
std::list< std::pair< Ptr< SatLlc >, uint32_t > > m_llc
Maintains a list of UT LLC and its identifier.
SatStatsRtnQueueHelper(Ptr< const SatHelper > satHelper)
void DoPoll()
Retrieve the queue size of every relevant encapsulator and push the values to the right collectors.
static TypeId GetTypeId()
inherited from ObjectBase base class
Helper for return link queue statistics using packet as unit.
virtual ~SatStatsRtnQueuePacketsHelper()
/ Destructor.
static TypeId GetTypeId()
inherited from ObjectBase base class
SatStatsRtnQueuePacketsHelper(Ptr< const SatHelper > satHelper)
SatArqSequenceNumber is handling the sequence numbers for the ARQ process.