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/satellite-topology.h>
43 #include <ns3/scalar-collector.h>
44 #include <ns3/simulator.h>
45 #include <ns3/singleton.h>
46 #include <ns3/string.h>
47 #include <ns3/unit-conversion-collector.h>
53 NS_LOG_COMPONENT_DEFINE(
"SatStatsQueueHelper");
60 NS_OBJECT_ENSURE_REGISTERED(SatStatsQueueHelper);
70 return "UNIT_NUMBER_OF_PACKETS";
72 NS_FATAL_ERROR(
"SatStatsQueueHelper - Invalid unit type");
76 NS_FATAL_ERROR(
"SatStatsQueueHelper - Invalid unit type");
82 m_pollInterval(MilliSeconds(10)),
87 NS_LOG_FUNCTION(
this << satHelper);
92 NS_LOG_FUNCTION(
this);
98 static TypeId tid = TypeId(
"ns3::SatStatsQueueHelper")
100 .AddAttribute(
"PollInterval",
102 TimeValue(MilliSeconds(10)),
128 NS_FATAL_ERROR(
"SatStatsQueueHelper - Invalid unit type");
141 NS_LOG_FUNCTION(
this << pollInterval.GetSeconds());
154 NS_LOG_FUNCTION(
this);
160 <<
" is not a valid output type for this statistics.");
170 "EnableContextPrinting",
178 EnumValue(ScalarCollector::INPUT_DATA_TYPE_UINTEGER));
181 EnumValue(ScalarCollector::OUTPUT_TYPE_AVERAGE_PER_SAMPLE));
185 &MultiFileAggregator::Write1d);
201 EnumValue(IntervalRateCollector::INPUT_DATA_TYPE_UINTEGER));
205 &MultiFileAggregator::Write2d);
208 &MultiFileAggregator::AddContextHeading);
225 DistributionCollector::OutputType_t outputType =
226 DistributionCollector::OUTPUT_TYPE_HISTOGRAM;
229 outputType = DistributionCollector::OUTPUT_TYPE_PROBABILITY;
233 outputType = DistributionCollector::OUTPUT_TYPE_CUMULATIVE;
239 &MultiFileAggregator::Write2d);
242 &MultiFileAggregator::AddContextHeading);
245 &MultiFileAggregator::EnableContextWarning);
252 <<
" is not a valid output type for this statistics.");
262 Ptr<MagisterGnuplotAggregator> plotAggregator =
264 NS_ASSERT(plotAggregator !=
nullptr);
266 plotAggregator->SetLegend(
"Time (in seconds)",
"Queued packets");
267 plotAggregator->Set2dDatasetDefaultStyle(Gnuplot2dDataset::STEPS);
273 EnumValue(IntervalRateCollector::INPUT_DATA_TYPE_UINTEGER));
279 const std::string context = it->second->GetName();
280 plotAggregator->Add2dDataset(context, context);
284 &MagisterGnuplotAggregator::Write2d);
298 Ptr<MagisterGnuplotAggregator> plotAggregator =
300 NS_ASSERT(plotAggregator !=
nullptr);
302 plotAggregator->SetLegend(
m_longLabel,
"Frequency");
303 plotAggregator->Set2dDatasetDefaultStyle(Gnuplot2dDataset::LINES);
307 DistributionCollector::OutputType_t outputType =
308 DistributionCollector::OUTPUT_TYPE_HISTOGRAM;
311 outputType = DistributionCollector::OUTPUT_TYPE_PROBABILITY;
315 outputType = DistributionCollector::OUTPUT_TYPE_CUMULATIVE;
323 const std::string context = it->second->GetName();
324 plotAggregator->Add2dDataset(context, context);
328 &MagisterGnuplotAggregator::Write2d);
333 NS_FATAL_ERROR(
"SatStatsQueueHelper - Invalid output type");
348 NS_LOG_FUNCTION(
this);
357 NS_LOG_FUNCTION(
this);
373 NS_ASSERT_MSG(collector !=
nullptr,
"Unable to find collector with identifier " << identifier);
379 Ptr<ScalarCollector> c = collector->GetObject<ScalarCollector>();
380 NS_ASSERT(c !=
nullptr);
381 c->TraceSinkUinteger32(0, value);
387 Ptr<IntervalRateCollector> c = collector->GetObject<IntervalRateCollector>();
388 NS_ASSERT(c !=
nullptr);
389 c->TraceSinkUinteger32(0, value);
399 Ptr<DistributionCollector> c = collector->GetObject<DistributionCollector>();
400 NS_ASSERT(c !=
nullptr);
401 c->TraceSinkUinteger32(0, value);
407 <<
" is not a valid output type for this statistics.");
421 NS_LOG_FUNCTION(
this << satHelper);
426 NS_LOG_FUNCTION(
this);
432 static TypeId tid = TypeId(
"ns3::SatStatsFwdQueueHelper").SetParent<
SatStatsQueueHelper>();
439 NS_LOG_FUNCTION(
this);
441 const SatIdMapper* satIdMapper = Singleton<SatIdMapper>::Get();
443 NodeContainer gws = Singleton<SatTopology>::Get()->GetGwNodes();
444 for (NodeContainer::Iterator it1 = gws.Begin(); it1 != gws.End(); ++it1)
448 for (NetDeviceContainer::Iterator itDev = devs.Begin(); itDev != devs.End(); ++itDev)
450 Ptr<SatNetDevice> satDev = (*itDev)->GetObject<
SatNetDevice>();
451 NS_ASSERT(satDev !=
nullptr);
454 Ptr<SatPhy> satPhy = satDev->GetPhy();
455 NS_ASSERT(satPhy !=
nullptr);
456 Ptr<SatPhyRx> satPhyRx = satPhy->GetPhyRx();
457 NS_ASSERT(satPhyRx !=
nullptr);
458 const uint32_t satId = satPhyRx->GetSatId();
459 const uint32_t beamId = satPhyRx->GetBeamId();
460 NS_LOG_DEBUG(
this <<
" enlisting UT from sat ID " << satId <<
" and beam ID "
465 NodeContainer uts =
GetSatHelper()->GetBeamHelper()->GetUtNodes(satId, beamId);
466 for (NodeContainer::Iterator it2 = uts.Begin(); it2 != uts.End(); ++it2)
469 const Mac48Address mac48Addr = Mac48Address::ConvertFrom(addr);
471 if (addr.IsInvalid())
473 NS_LOG_WARN(
this <<
" Node " << (*it2)->GetId() <<
" is not a valid UT");
478 listOfUt.push_back(std::make_pair(mac48Addr, identifier));
483 Ptr<SatLlc> satLlc = satDev->GetLlc();
484 NS_ASSERT(satLlc !=
nullptr);
485 m_llc.push_back(std::make_pair(satLlc, listOfUt));
499 std::list<std::pair<Ptr<SatLlc>,
ListOfUt_t>>::const_iterator it1;
500 for (it1 =
m_llc.begin(); it1 !=
m_llc.end(); ++it1)
502 for (ListOfUt_t::const_iterator it2 = it1->second.begin(); it2 != it1->second.end(); ++it2)
504 const Mac48Address addr = it2->first;
505 const uint32_t identifier = it2->second;
526 NS_LOG_FUNCTION(
this << satHelper);
532 NS_LOG_FUNCTION(
this);
550 NS_LOG_FUNCTION(
this << satHelper);
556 NS_LOG_FUNCTION(
this);
574 NS_LOG_FUNCTION(
this << satHelper);
579 NS_LOG_FUNCTION(
this);
585 static TypeId tid = TypeId(
"ns3::SatStatsRtnQueueHelper").SetParent<
SatStatsQueueHelper>();
592 NS_LOG_FUNCTION(
this);
594 NodeContainer uts = Singleton<SatTopology>::Get()->GetUtNodes();
595 for (NodeContainer::Iterator it = uts.Begin(); it != uts.End(); ++it)
599 Ptr<SatNetDevice> satDev = dev->GetObject<
SatNetDevice>();
600 NS_ASSERT(satDev !=
nullptr);
601 Ptr<SatLlc> satLlc = satDev->GetLlc();
602 NS_ASSERT(satLlc !=
nullptr);
603 m_llc.push_back(std::make_pair(satLlc, identifier));
614 std::list<std::pair<Ptr<SatLlc>, uint32_t>>::const_iterator it;
615 for (it =
m_llc.begin(); it !=
m_llc.end(); ++it)
636 NS_LOG_FUNCTION(
this << satHelper);
642 NS_LOG_FUNCTION(
this);
660 NS_LOG_FUNCTION(
this << satHelper);
666 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.