24 #include <ns3/boolean.h>
25 #include <ns3/callback.h>
26 #include <ns3/data-collection-object.h>
27 #include <ns3/distribution-collector.h>
30 #include <ns3/mac48-address.h>
31 #include <ns3/magister-gnuplot-aggregator.h>
32 #include <ns3/multi-file-aggregator.h>
33 #include <ns3/node-container.h>
34 #include <ns3/object-vector.h>
35 #include <ns3/probe.h>
36 #include <ns3/satellite-helper.h>
37 #include <ns3/satellite-id-mapper.h>
38 #include <ns3/satellite-net-device.h>
39 #include <ns3/satellite-phy-rx-carrier.h>
40 #include <ns3/satellite-phy-rx.h>
41 #include <ns3/satellite-phy.h>
42 #include <ns3/satellite-sinr-probe.h>
43 #include <ns3/scalar-collector.h>
44 #include <ns3/singleton.h>
45 #include <ns3/string.h>
46 #include <ns3/unit-conversion-collector.h>
50 NS_LOG_COMPONENT_DEFINE(
"SatStatsCompositeSinrHelper");
55 NS_OBJECT_ENSURE_REGISTERED(SatStatsCompositeSinrHelper);
60 NS_LOG_FUNCTION(
this << satHelper);
65 NS_LOG_FUNCTION(
this);
71 static TypeId tid = TypeId(
"ns3::SatStatsCompositeSinrHelper").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_DOUBLE));
105 EnumValue(ScalarCollector::OUTPUT_TYPE_AVERAGE_PER_SAMPLE));
109 &MultiFileAggregator::Write1d);
124 EnumValue(UnitConversionCollector::TRANSPARENT));
128 &MultiFileAggregator::Write2d);
144 DistributionCollector::OutputType_t outputType =
145 DistributionCollector::OUTPUT_TYPE_HISTOGRAM;
148 outputType = DistributionCollector::OUTPUT_TYPE_PROBABILITY;
152 outputType = DistributionCollector::OUTPUT_TYPE_CUMULATIVE;
158 &MultiFileAggregator::Write2d);
161 &MultiFileAggregator::AddContextHeading);
164 &MultiFileAggregator::EnableContextWarning);
171 <<
" is not a valid output type for this statistics.");
181 Ptr<MagisterGnuplotAggregator> plotAggregator =
183 NS_ASSERT(plotAggregator !=
nullptr);
185 plotAggregator->SetLegend(
"Time (in seconds)",
"SINR (in dB)");
186 plotAggregator->Set2dDatasetDefaultStyle(Gnuplot2dDataset::LINES);
191 EnumValue(UnitConversionCollector::TRANSPARENT));
197 const std::string context = it->second->GetName();
198 plotAggregator->Add2dDataset(context, context);
202 &MagisterGnuplotAggregator::Write2d);
215 Ptr<MagisterGnuplotAggregator> plotAggregator =
217 NS_ASSERT(plotAggregator !=
nullptr);
219 plotAggregator->SetLegend(
"SINR (in dB)",
"Frequency");
220 plotAggregator->Set2dDatasetDefaultStyle(Gnuplot2dDataset::LINES);
224 DistributionCollector::OutputType_t outputType =
225 DistributionCollector::OUTPUT_TYPE_HISTOGRAM;
228 outputType = DistributionCollector::OUTPUT_TYPE_PROBABILITY;
232 outputType = DistributionCollector::OUTPUT_TYPE_CUMULATIVE;
240 const std::string context = it->second->GetName();
241 plotAggregator->Add2dDataset(context, context);
245 &MagisterGnuplotAggregator::Write2d);
250 NS_FATAL_ERROR(
"SatStatsCompositeSinrHelper - Invalid output type");
273 NS_LOG_FUNCTION(
this << satHelper);
278 NS_LOG_FUNCTION(
this);
292 NS_LOG_FUNCTION(
this);
293 NodeContainer uts =
GetSatHelper()->GetBeamHelper()->GetUtNodes();
295 for (NodeContainer::Iterator it = uts.Begin(); it != uts.End(); ++it)
297 const int32_t utId =
GetUtId(*it);
298 NS_ASSERT_MSG(utId > 0,
"Node " << (*it)->GetId() <<
" is not a valid UT");
302 std::ostringstream probeName;
304 Ptr<SatSinrProbe> probe = CreateObject<SatSinrProbe>();
305 probe->SetName(probeName.str());
308 Ptr<SatNetDevice> satDev = dev->GetObject<
SatNetDevice>();
309 NS_ASSERT(satDev !=
nullptr);
310 Ptr<SatPhy> satPhy = satDev->GetPhy();
311 NS_ASSERT(satPhy !=
nullptr);
312 Ptr<SatPhyRx> satPhyRx = satPhy->GetPhyRx();
313 NS_ASSERT(satPhyRx !=
nullptr);
314 ObjectVectorValue carriers;
315 satPhyRx->GetAttribute(
"RxCarrierList", carriers);
316 NS_LOG_DEBUG(
this <<
" Node ID " << (*it)->GetId() <<
" device #" << dev->GetIfIndex()
317 <<
" has " << carriers.GetN() <<
" RX carriers");
319 for (ObjectVectorValue::Iterator itCarrier = carriers.Begin(); itCarrier != carriers.End();
323 if (probe->ConnectByObject(
"Sinr", itCarrier->second))
334 &ScalarCollector::TraceSinkDouble);
340 probe->GetObject<Probe>(),
343 &UnitConversionCollector::TraceSinkDouble);
353 probe->GetObject<Probe>(),
356 &DistributionCollector::TraceSinkDouble);
361 <<
" is not a valid output type for this statistics.");
368 NS_LOG_INFO(
this <<
" created probe " << probeName.str()
369 <<
", connected to collector " << identifier);
370 m_probes.push_back(probe->GetObject<Probe>());
374 NS_LOG_WARN(
this <<
" unable to connect probe " << probeName.str()
375 <<
" to collector " << identifier);
381 NS_FATAL_ERROR(
"Error connecting to Sinr trace source"
382 <<
" of SatPhyRxCarrier"
383 <<
" at node ID " << (*it)->GetId() <<
" device #"
384 << dev->GetIfIndex() <<
" RX carrier #" << itCarrier->first);
400 NS_LOG_FUNCTION(
this << satHelper);
405 NS_LOG_FUNCTION(
this);
419 NS_LOG_FUNCTION(
this);
421 NodeContainer uts =
GetSatHelper()->GetBeamHelper()->GetUtNodes();
422 for (NodeContainer::Iterator it = uts.Begin(); it != uts.End(); ++it)
430 NodeContainer gws =
GetSatHelper()->GetBeamHelper()->GetGwNodes();
431 Callback<void, double, const Address&> callback =
434 for (NodeContainer::Iterator it = gws.Begin(); it != gws.End(); ++it)
438 for (NetDeviceContainer::Iterator itDev = devs.Begin(); itDev != devs.End(); ++itDev)
440 Ptr<SatNetDevice> satDev = (*itDev)->GetObject<
SatNetDevice>();
441 NS_ASSERT(satDev !=
nullptr);
442 Ptr<SatPhy> satPhy = satDev->GetPhy();
443 NS_ASSERT(satPhy !=
nullptr);
444 Ptr<SatPhyRx> satPhyRx = satPhy->GetPhyRx();
445 NS_ASSERT(satPhyRx !=
nullptr);
446 ObjectVectorValue carriers;
447 satPhyRx->GetAttribute(
"RxCarrierList", carriers);
448 NS_LOG_DEBUG(
this <<
" Node ID " << (*it)->GetId() <<
" device #"
449 << (*itDev)->GetIfIndex() <<
" has " << carriers.GetN()
452 for (ObjectVectorValue::Iterator itCarrier = carriers.Begin();
453 itCarrier != carriers.End();
456 if (itCarrier->second->TraceConnectWithoutContext(
"Sinr", callback))
458 NS_LOG_INFO(
this <<
" successfully connected with node ID " << (*it)->GetId()
459 <<
" device #" << (*itDev)->GetIfIndex() <<
" RX carrier #"
460 << itCarrier->first);
464 NS_FATAL_ERROR(
"Error connecting to Sinr trace source"
465 <<
" of SatPhyRxCarrier"
466 <<
" at node ID " << (*it)->GetId() <<
" device #"
467 << (*itDev)->GetIfIndex() <<
" RX carrier #"
468 << itCarrier->first);
484 if (from.IsInvalid())
486 NS_LOG_WARN(
this <<
" discarding a SINR trace of " << sinrDb <<
" dB"
487 <<
" from statistics collection because of"
488 <<
" invalid sender address");
493 std::map<const Address, uint32_t>::const_iterator it =
m_identifierMap.find(from);
497 NS_LOG_WARN(
this <<
" discarding a SINR trace of " << sinrDb <<
" dB"
498 <<
" from statistics collection because of"
499 <<
" unknown sender address " << from);
505 NS_ASSERT_MSG(collector !=
nullptr,
506 "Unable to find collector with identifier " << it->second);
512 Ptr<ScalarCollector> c = collector->GetObject<ScalarCollector>();
513 NS_ASSERT(c !=
nullptr);
514 c->TraceSinkDouble(0.0, sinrDb);
520 Ptr<UnitConversionCollector> c = collector->GetObject<UnitConversionCollector>();
521 NS_ASSERT(c !=
nullptr);
522 c->TraceSinkDouble(0.0, sinrDb);
532 Ptr<DistributionCollector> c = collector->GetObject<DistributionCollector>();
533 NS_ASSERT(c !=
nullptr);
534 c->TraceSinkDouble(0.0, sinrDb);
540 <<
" is not a valid output type for this statistics.");
554 NS_LOG_FUNCTION(
this << utNode->GetId());
556 const SatIdMapper* satIdMapper = Singleton<SatIdMapper>::Get();
559 if (addr.IsInvalid())
561 NS_LOG_WARN(
this <<
" Node " << utNode->GetId() <<
" is not a valid UT");
567 NS_LOG_INFO(
this <<
" associated address " << addr <<
" with identifier " << identifier);
Address GetUtMacWithNode(Ptr< Node > utNode) const
SatNetDevice to be utilized in the UT and GW nodes.
Abstract class inherited by SatStatsFwdCompositeSinrHelper and SatStatsRtnCompositeSinrHelper.
static TypeId GetTypeId()
inherited from ObjectBase base class
void InstallProbes()
Set up several probes or other means of listeners and connect them to the collectors.
void DoInstall()
Install the probes, collectors, and aggregators necessary to produce the statistics output.
CollectorMap m_terminalCollectors
Maintains a list of collectors created by this helper.
Ptr< DataCollectionObject > m_aggregator
The aggregator created by this helper.
virtual void DoInstallProbes()=0
virtual ~SatStatsCompositeSinrHelper()
/ Destructor.
SatStatsCompositeSinrHelper(Ptr< const SatHelper > satHelper)
Produce forward link composite SINR statistics from a satellite module simulation.
std::list< Ptr< Probe > > m_probes
Maintains a list of probes created by this helper.
static TypeId GetTypeId()
inherited from ObjectBase base class
virtual ~SatStatsFwdCompositeSinrHelper()
/ Destructor.
SatStatsFwdCompositeSinrHelper(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 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
Produce return link composite SINR statistics from a satellite module simulation.
void SaveAddressAndIdentifier(Ptr< Node > utNode)
Save the address and the proper identifier from the given UT node.
SatStatsRtnCompositeSinrHelper(Ptr< const SatHelper > satHelper)
std::map< const Address, uint32_t > m_identifierMap
Map of address and the identifier associated with it (for return link).
void SinrCallback(double sinrDb, const Address &from)
Receive inputs from trace sources and determine the right collector to forward the inputs to.
static TypeId GetTypeId()
inherited from ObjectBase base class
virtual ~SatStatsRtnCompositeSinrHelper()
/ Destructor.
SatArqSequenceNumber is handling the sequence numbers for the ARQ process.