24 #include <ns3/boolean.h>
25 #include <ns3/callback.h>
26 #include <ns3/data-collection-object.h>
27 #include <ns3/distribution-collector.h>
28 #include <ns3/double-probe.h>
31 #include <ns3/mac48-address.h>
32 #include <ns3/magister-gnuplot-aggregator.h>
33 #include <ns3/multi-file-aggregator.h>
35 #include <ns3/object-map.h>
36 #include <ns3/object-vector.h>
37 #include <ns3/probe.h>
38 #include <ns3/satellite-helper.h>
39 #include <ns3/satellite-id-mapper.h>
40 #include <ns3/satellite-net-device.h>
41 #include <ns3/satellite-orbiter-net-device.h>
42 #include <ns3/satellite-phy-rx-carrier.h>
43 #include <ns3/satellite-phy-rx.h>
44 #include <ns3/satellite-phy.h>
45 #include <ns3/satellite-topology.h>
46 #include <ns3/scalar-collector.h>
47 #include <ns3/singleton.h>
48 #include <ns3/string.h>
49 #include <ns3/unit-conversion-collector.h>
56 NS_LOG_COMPONENT_DEFINE(
"SatStatsLinkSinrHelper");
61 NS_OBJECT_ENSURE_REGISTERED(SatStatsLinkSinrHelper);
67 NS_LOG_FUNCTION(
this << satHelper);
72 NS_LOG_FUNCTION(
this);
78 static TypeId tid = TypeId(
"ns3::SatStatsLinkSinrHelper").SetParent<
SatStatsHelper>();
85 NS_LOG_FUNCTION(
this << averagingMode);
89 Callback<void, double, const Address&>
98 NS_LOG_FUNCTION(
this);
104 <<
" is not a valid output type for this statistics.");
114 "EnableContextPrinting",
122 EnumValue(ScalarCollector::INPUT_DATA_TYPE_DOUBLE));
125 EnumValue(ScalarCollector::OUTPUT_TYPE_AVERAGE_PER_SAMPLE));
129 &MultiFileAggregator::Write1d);
144 EnumValue(UnitConversionCollector::TRANSPARENT));
148 &MultiFileAggregator::Write2d);
163 "EnableContextPrinting",
167 Ptr<MultiFileAggregator> fileAggregator =
169 NS_ASSERT(fileAggregator !=
nullptr);
173 DistributionCollector::OutputType_t outputType =
174 DistributionCollector::OUTPUT_TYPE_HISTOGRAM;
177 outputType = DistributionCollector::OUTPUT_TYPE_PROBABILITY;
181 outputType = DistributionCollector::OUTPUT_TYPE_CUMULATIVE;
188 MakeCallback(&MultiFileAggregator::Write2d, fileAggregator));
192 MakeCallback(&MultiFileAggregator::AddContextHeading, fileAggregator));
196 MakeCallback(&MultiFileAggregator::EnableContextWarning, fileAggregator));
201 EnumValue(ScalarCollector::INPUT_DATA_TYPE_DOUBLE));
204 EnumValue(ScalarCollector::OUTPUT_TYPE_AVERAGE_PER_SAMPLE));
206 Callback<void, double> callback =
212 it->second->TraceConnectWithoutContext(
"Output", callback);
226 DistributionCollector::OutputType_t outputType =
227 DistributionCollector::OUTPUT_TYPE_HISTOGRAM;
230 outputType = DistributionCollector::OUTPUT_TYPE_PROBABILITY;
234 outputType = DistributionCollector::OUTPUT_TYPE_CUMULATIVE;
240 &MultiFileAggregator::Write2d);
243 &MultiFileAggregator::AddContextHeading);
246 &MultiFileAggregator::EnableContextWarning);
255 <<
" is not a valid output type for this statistics.");
265 Ptr<MagisterGnuplotAggregator> plotAggregator =
267 NS_ASSERT(plotAggregator !=
nullptr);
269 plotAggregator->SetLegend(
"SINR (in dB)",
"Frequency");
270 plotAggregator->Set2dDatasetDefaultStyle(Gnuplot2dDataset::LINES);
275 EnumValue(UnitConversionCollector::TRANSPARENT));
281 const std::string context = it->second->GetName();
282 plotAggregator->Add2dDataset(context, context);
286 &MagisterGnuplotAggregator::Write2d);
301 Ptr<MagisterGnuplotAggregator> plotAggregator =
303 NS_ASSERT(plotAggregator !=
nullptr);
305 plotAggregator->SetLegend(
"SINR (in dB)",
"Frequency");
306 plotAggregator->Set2dDatasetDefaultStyle(Gnuplot2dDataset::LINES);
312 DistributionCollector::OutputType_t outputType =
313 DistributionCollector::OUTPUT_TYPE_HISTOGRAM;
316 outputType = DistributionCollector::OUTPUT_TYPE_PROBABILITY;
320 outputType = DistributionCollector::OUTPUT_TYPE_CUMULATIVE;
327 MakeCallback(&MagisterGnuplotAggregator::Write2d, plotAggregator));
333 EnumValue(ScalarCollector::INPUT_DATA_TYPE_DOUBLE));
336 EnumValue(ScalarCollector::OUTPUT_TYPE_AVERAGE_PER_SAMPLE));
338 Callback<void, double> callback =
344 it->second->TraceConnectWithoutContext(
"Output", callback);
355 Ptr<MagisterGnuplotAggregator> plotAggregator =
357 NS_ASSERT(plotAggregator !=
nullptr);
359 plotAggregator->SetLegend(
"SINR (in dB)",
"Frequency");
360 plotAggregator->Set2dDatasetDefaultStyle(Gnuplot2dDataset::LINES);
364 DistributionCollector::OutputType_t outputType =
365 DistributionCollector::OUTPUT_TYPE_HISTOGRAM;
368 outputType = DistributionCollector::OUTPUT_TYPE_PROBABILITY;
372 outputType = DistributionCollector::OUTPUT_TYPE_CUMULATIVE;
380 const std::string context = it->second->GetName();
381 plotAggregator->Add2dDataset(context, context);
385 &MagisterGnuplotAggregator::Write2d);
392 NS_FATAL_ERROR(
"SatStatsLinkDelayHelper - Invalid output type");
406 if (from.IsInvalid())
408 NS_LOG_WARN(
this <<
" discarding a packet with a sinr of " << sinrDb <<
"dB"
409 <<
" from statistics collection because of"
410 <<
" invalid sender address");
412 else if (Mac48Address::ConvertFrom(from).IsBroadcast())
422 std::map<const Address, uint32_t>::const_iterator it =
m_identifierMap.find(from);
430 NS_LOG_WARN(
this <<
" discarding a packet with a sinr of " << sinrDb <<
"dB"
431 <<
" from statistics collection because of"
432 <<
" unknown sender address " << from);
440 NS_LOG_FUNCTION(
this << probe << probe->GetName() << identifier);
450 &ScalarCollector::TraceSinkDouble);
458 &UnitConversionCollector::TraceSinkDouble);
472 &ScalarCollector::TraceSinkDouble);
479 &DistributionCollector::TraceSinkDouble);
485 <<
" is not a valid output type for this statistics.");
491 NS_LOG_INFO(
this <<
" created probe " << probe->GetName() <<
", connected to collector "
496 NS_LOG_WARN(
this <<
" unable to connect probe " << probe->GetName() <<
" to collector "
509 NS_ASSERT_MSG(collector !=
nullptr,
"Unable to find collector with identifier " << identifier);
515 Ptr<ScalarCollector> c = collector->GetObject<ScalarCollector>();
516 NS_ASSERT(c !=
nullptr);
517 c->TraceSinkDouble(0.0, sinrDb);
523 Ptr<UnitConversionCollector> c = collector->GetObject<UnitConversionCollector>();
524 NS_ASSERT(c !=
nullptr);
525 c->TraceSinkDouble(0.0, sinrDb);
537 Ptr<ScalarCollector> c = collector->GetObject<ScalarCollector>();
538 NS_ASSERT(c !=
nullptr);
539 c->TraceSinkDouble(0.0, sinrDb);
543 Ptr<DistributionCollector> c = collector->GetObject<DistributionCollector>();
544 NS_ASSERT(c !=
nullptr);
545 c->TraceSinkDouble(0.0, sinrDb);
551 <<
" is not a valid output type for this statistics.");
572 NS_LOG_FUNCTION(
this << satHelper);
577 NS_LOG_FUNCTION(
this);
591 NS_LOG_FUNCTION(
this);
593 NodeContainer uts = Singleton<SatTopology>::Get()->GetUtNodes();
595 for (NodeContainer::Iterator it = uts.Begin(); it != uts.End(); ++it)
601 NodeContainer sats = Singleton<SatTopology>::Get()->GetOrbiterNodes();
603 for (NodeContainer::Iterator it = sats.Begin(); it != sats.End(); ++it)
607 NS_ASSERT(satOrbiterDev !=
nullptr);
608 std::map<uint32_t, Ptr<SatPhy>> satOrbiterFeederPhys = satOrbiterDev->GetFeederPhy();
610 satOrbiterDev->GetAttribute(
"FeederPhy", phy);
611 NS_LOG_DEBUG(
this <<
" OrbiterSat Node ID " << (*it)->GetId() <<
" device #"
612 << dev->GetIfIndex() <<
" has " << phy.GetN() <<
" PHY instance(s)");
614 for (ObjectMapValue::Iterator itPhy = phy.Begin(); itPhy != phy.End(); ++itPhy)
616 Ptr<SatPhy> satPhy = itPhy->second->GetObject<
SatPhy>();
617 NS_ASSERT(satPhy !=
nullptr);
618 Ptr<SatPhyRx> satPhyRx = satPhy->GetPhyRx();
619 NS_ASSERT(satPhyRx !=
nullptr);
620 ObjectVectorValue carriers;
621 satPhyRx->GetAttribute(
"RxCarrierList", carriers);
622 NS_LOG_DEBUG(
this <<
" PHY #" << itPhy->first <<
" has " << carriers.GetN()
623 <<
" RX carrier(s)");
625 for (ObjectVectorValue::Iterator itCarrier = carriers.Begin();
626 itCarrier != carriers.End();
630 if (!itCarrier->second->TraceConnectWithoutContext(
"LinkSinr",
633 NS_FATAL_ERROR(
"Error connecting to LinkSinr trace source"
634 <<
" of SatPhyRxCarrier"
635 <<
" at OrbiterSat node ID " << (*it)->GetId() <<
" device #"
636 << dev->GetIfIndex() <<
" PHY #" << itPhy->first
637 <<
" RX carrier #" << itCarrier->first);
654 NS_LOG_FUNCTION(
this << satHelper);
659 NS_LOG_FUNCTION(
this);
673 NS_LOG_FUNCTION(
this);
675 NodeContainer uts = Singleton<SatTopology>::Get()->GetUtNodes();
676 for (NodeContainer::Iterator it = uts.Begin(); it != uts.End(); ++it)
686 Ptr<SatNetDevice> satDev = dev->GetObject<
SatNetDevice>();
687 NS_ASSERT(satDev !=
nullptr);
688 Ptr<SatPhy> satPhy = satDev->GetPhy();
689 NS_ASSERT(satPhy !=
nullptr);
690 Ptr<SatPhyRx> satPhyRx = satPhy->GetPhyRx();
691 NS_ASSERT(satPhyRx !=
nullptr);
692 ObjectVectorValue carriers;
693 satPhyRx->GetAttribute(
"RxCarrierList", carriers);
694 NS_LOG_DEBUG(
this <<
" Node ID " << (*it)->GetId() <<
" device #" << dev->GetIfIndex()
695 <<
" has " << carriers.GetN() <<
" RX carriers");
697 for (ObjectVectorValue::Iterator itCarrier = carriers.Begin(); itCarrier != carriers.End();
703 NS_FATAL_ERROR(
"Error connecting to LinkSinr trace source"
704 <<
" of SatPhyRxCarrier"
705 <<
" at node ID " << (*it)->GetId() <<
" device #"
706 << dev->GetIfIndex() <<
" RX carrier #" << itCarrier->first);
722 NS_LOG_FUNCTION(
this << satHelper);
727 NS_LOG_FUNCTION(
this);
741 NS_LOG_FUNCTION(
this);
743 NodeContainer uts = Singleton<SatTopology>::Get()->GetUtNodes();
744 for (NodeContainer::Iterator it = uts.Begin(); it != uts.End(); ++it)
750 NodeContainer gws = Singleton<SatTopology>::Get()->GetGwNodes();
751 for (NodeContainer::Iterator it = gws.Begin(); it != gws.End(); ++it)
755 for (NetDeviceContainer::Iterator itDev = devs.Begin(); itDev != devs.End(); ++itDev)
757 Ptr<SatNetDevice> satDev = (*itDev)->GetObject<
SatNetDevice>();
758 NS_ASSERT(satDev !=
nullptr);
759 Ptr<SatPhy> satPhy = satDev->GetPhy();
760 NS_ASSERT(satPhy !=
nullptr);
761 Ptr<SatPhyRx> satPhyRx = satPhy->GetPhyRx();
762 NS_ASSERT(satPhyRx !=
nullptr);
763 ObjectVectorValue carriers;
764 satPhyRx->GetAttribute(
"RxCarrierList", carriers);
765 NS_LOG_DEBUG(
this <<
" Node ID " << (*it)->GetId() <<
" device #"
766 << (*itDev)->GetIfIndex() <<
" has " << carriers.GetN()
769 for (ObjectVectorValue::Iterator itCarrier = carriers.Begin();
770 itCarrier != carriers.End();
774 if (!itCarrier->second->TraceConnectWithoutContext(
"LinkSinr",
777 NS_FATAL_ERROR(
"Error connecting to LinkSinr trace source"
778 <<
" of SatPhyRxCarrier"
779 <<
" at node ID " << (*it)->GetId() <<
" device #"
780 << (*itDev)->GetIfIndex() <<
" RX carrier #"
781 << itCarrier->first);
799 NS_LOG_FUNCTION(
this << satHelper);
804 NS_LOG_FUNCTION(
this);
818 NS_LOG_FUNCTION(
this);
820 NodeContainer uts = Singleton<SatTopology>::Get()->GetUtNodes();
821 for (NodeContainer::Iterator it = uts.Begin(); it != uts.End(); ++it)
827 NodeContainer sats = Singleton<SatTopology>::Get()->GetOrbiterNodes();
829 for (NodeContainer::Iterator it = sats.Begin(); it != sats.End(); ++it)
833 NS_ASSERT(satOrbiterDev !=
nullptr);
835 std::map<uint32_t, Ptr<SatPhy>> satOrbiterUserPhys = satOrbiterDev->GetUserPhy();
836 for (std::map<uint32_t, Ptr<SatPhy>>::iterator it2 = satOrbiterUserPhys.begin();
837 it2 != satOrbiterUserPhys.end();
840 satPhy = it2->second;
841 NS_ASSERT(satPhy !=
nullptr);
842 Ptr<SatPhyRx> satPhyRx = satPhy->GetPhyRx();
843 NS_ASSERT(satPhyRx !=
nullptr);
844 ObjectVectorValue carriers;
845 satPhyRx->GetAttribute(
"RxCarrierList", carriers);
846 NS_LOG_DEBUG(
this <<
" Node ID " << (*it)->GetId() <<
" device #"
847 << satOrbiterDev->GetIfIndex() <<
" has " << carriers.GetN()
850 for (ObjectVectorValue::Iterator itCarrier = carriers.Begin();
851 itCarrier != carriers.End();
855 if (!itCarrier->second->TraceConnectWithoutContext(
"LinkSinr",
858 NS_FATAL_ERROR(
"Error connecting to LinkSinr trace source"
859 <<
" of SatPhyRxCarrier"
860 <<
" at node ID " << (*it)->GetId() <<
" device #"
861 << satOrbiterDev->GetIfIndex() <<
" RX carrier #"
862 << itCarrier->first);
SatNetDevice to be utilized in the UT and GW nodes.
SatOrbiterNetDevice to be utilized in geostationary satellite.
The SatPhy models the basic physical layer of the satellite system.
Produce forward feeder link SINR statistics from a satellite module simulation.
static TypeId GetTypeId()
inherited from ObjectBase base class
SatStatsFwdFeederLinkSinrHelper(Ptr< const SatHelper > satHelper)
virtual ~SatStatsFwdFeederLinkSinrHelper()
/ Destructor.
Produce forward user link SINR statistics from a satellite module simulation.
SatStatsFwdUserLinkSinrHelper(Ptr< const SatHelper > satHelper)
virtual ~SatStatsFwdUserLinkSinrHelper()
/ Destructor.
static TypeId GetTypeId()
inherited from ObjectBase base class
Parent abstract class of all satellite statistics helpers.
static Ptr< NetDevice > GetSatSatOrbiterNetDevice(Ptr< Node > satNode)
static NetDeviceContainer GetGwSatNetDevice(Ptr< Node > gwNode)
virtual void SaveAddressAndIdentifier(Ptr< Node > utNode)
Save the address and the proper identifier from the given UT node.
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
std::map< const Address, uint32_t > m_identifierMap
Map of address and the identifier associated with it.
std::string GetName() const
virtual std::string GetTimeHeading(std::string dataLabel) const
virtual std::string GetDistributionHeading(std::string dataLabel) const
Base class for link SINR statistics helpers.
Ptr< DistributionCollector > m_averagingCollector
The final collector utilized in averaged output (histogram, PDF, and CDF).
virtual ~SatStatsLinkSinrHelper()
/ Destructor.
Callback< void, double, const Address & > m_traceSinkCallback
Ptr< DataCollectionObject > m_aggregator
The aggregator created by this helper.
bool ConnectProbeToCollector(Ptr< Probe > probe, uint32_t identifier)
Connect the probe to the right collector.
virtual void DoInstallProbes()=0
void PassSampleToCollector(double sinrDb, uint32_t identifier)
Find a collector with the right identifier and pass a sample data to it.
bool m_averagingMode
AveragingMode attribute.
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 SinrCallback(double sinrDb, const Address &addr)
Receive inputs from trace sources and forward them to the collector.
Callback< void, double, const Address & > GetTraceSinkCallback() const
void SetAveragingMode(bool averagingMode)
void InstallProbes()
Set up several probes or other means of listeners and connect them to the collectors.
static TypeId GetTypeId()
inherited from ObjectBase base class
SatStatsLinkSinrHelper(Ptr< const SatHelper > satHelper)
Produce return feeder link SINR statistics from a satellite module simulation.
SatStatsRtnFeederLinkSinrHelper(Ptr< const SatHelper > satHelper)
static TypeId GetTypeId()
inherited from ObjectBase base class
virtual ~SatStatsRtnFeederLinkSinrHelper()
/ Destructor.
Produce return user link SINR statistics from a satellite module simulation.
static TypeId GetTypeId()
inherited from ObjectBase base class
virtual ~SatStatsRtnUserLinkSinrHelper()
/ Destructor.
SatStatsRtnUserLinkSinrHelper(Ptr< const SatHelper > satHelper)
SatArqSequenceNumber is handling the sequence numbers for the ARQ process.