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(
"SatStatsLinkRxPowerHelper");
61 NS_OBJECT_ENSURE_REGISTERED(SatStatsLinkRxPowerHelper);
67 NS_LOG_FUNCTION(
this << satHelper);
72 NS_LOG_FUNCTION(
this);
78 static TypeId tid = TypeId(
"ns3::SatStatsLinkRxPowerHelper").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(
"RX Power (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(
"RX Power (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(
"RX Power (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 RX power of " << rxPowerDb <<
"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 RX power of " << rxPowerDb <<
"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, rxPowerDb);
523 Ptr<UnitConversionCollector> c = collector->GetObject<UnitConversionCollector>();
524 NS_ASSERT(c !=
nullptr);
525 c->TraceSinkDouble(0.0, rxPowerDb);
537 Ptr<ScalarCollector> c = collector->GetObject<ScalarCollector>();
538 NS_ASSERT(c !=
nullptr);
539 c->TraceSinkDouble(0.0, rxPowerDb);
543 Ptr<DistributionCollector> c = collector->GetObject<DistributionCollector>();
544 NS_ASSERT(c !=
nullptr);
545 c->TraceSinkDouble(0.0, rxPowerDb);
551 <<
" is not a valid output type for this statistics.");
570 Ptr<const SatHelper> satHelper)
573 NS_LOG_FUNCTION(
this << satHelper);
578 NS_LOG_FUNCTION(
this);
592 NS_LOG_FUNCTION(
this);
594 NodeContainer uts = Singleton<SatTopology>::Get()->GetUtNodes();
596 for (NodeContainer::Iterator it = uts.Begin(); it != uts.End(); ++it)
602 NodeContainer sats = Singleton<SatTopology>::Get()->GetOrbiterNodes();
604 for (NodeContainer::Iterator it = sats.Begin(); it != sats.End(); ++it)
608 NS_ASSERT(satOrbiterDev !=
nullptr);
609 std::map<uint32_t, Ptr<SatPhy>> satOrbiterFeederPhys = satOrbiterDev->GetFeederPhy();
611 satOrbiterDev->GetAttribute(
"FeederPhy", phy);
612 NS_LOG_DEBUG(
this <<
" OrbiterSat Node ID " << (*it)->GetId() <<
" device #"
613 << dev->GetIfIndex() <<
" has " << phy.GetN() <<
" PHY instance(s)");
615 for (ObjectMapValue::Iterator itPhy = phy.Begin(); itPhy != phy.End(); ++itPhy)
617 Ptr<SatPhy> satPhy = itPhy->second->GetObject<
SatPhy>();
618 NS_ASSERT(satPhy !=
nullptr);
619 Ptr<SatPhyRx> satPhyRx = satPhy->GetPhyRx();
620 NS_ASSERT(satPhyRx !=
nullptr);
621 ObjectVectorValue carriers;
622 satPhyRx->GetAttribute(
"RxCarrierList", carriers);
623 NS_LOG_DEBUG(
this <<
" PHY #" << itPhy->first <<
" has " << carriers.GetN()
624 <<
" RX carrier(s)");
626 for (ObjectVectorValue::Iterator itCarrier = carriers.Begin();
627 itCarrier != carriers.End();
631 if (!itCarrier->second->TraceConnectWithoutContext(
"RxPowerTrace",
634 NS_FATAL_ERROR(
"Error connecting to RxPowerTrace trace source"
635 <<
" of SatPhyRxCarrier"
636 <<
" at OrbiterSat node ID " << (*it)->GetId() <<
" device #"
637 << dev->GetIfIndex() <<
" PHY #" << itPhy->first
638 <<
" RX carrier #" << itCarrier->first);
655 NS_LOG_FUNCTION(
this << satHelper);
660 NS_LOG_FUNCTION(
this);
674 NS_LOG_FUNCTION(
this);
676 NodeContainer uts = Singleton<SatTopology>::Get()->GetUtNodes();
677 for (NodeContainer::Iterator it = uts.Begin(); it != uts.End(); ++it)
687 Ptr<SatNetDevice> satDev = dev->GetObject<
SatNetDevice>();
688 NS_ASSERT(satDev !=
nullptr);
689 Ptr<SatPhy> satPhy = satDev->GetPhy();
690 NS_ASSERT(satPhy !=
nullptr);
691 Ptr<SatPhyRx> satPhyRx = satPhy->GetPhyRx();
692 NS_ASSERT(satPhyRx !=
nullptr);
693 ObjectVectorValue carriers;
694 satPhyRx->GetAttribute(
"RxCarrierList", carriers);
695 NS_LOG_DEBUG(
this <<
" Node ID " << (*it)->GetId() <<
" device #" << dev->GetIfIndex()
696 <<
" has " << carriers.GetN() <<
" RX carriers");
698 for (ObjectVectorValue::Iterator itCarrier = carriers.Begin(); itCarrier != carriers.End();
702 if (!itCarrier->second->TraceConnectWithoutContext(
"RxPowerTrace",
705 NS_FATAL_ERROR(
"Error connecting to RxPowerTrace trace source"
706 <<
" of SatPhyRxCarrier"
707 <<
" at node ID " << (*it)->GetId() <<
" device #"
708 << dev->GetIfIndex() <<
" RX carrier #" << itCarrier->first);
722 Ptr<const SatHelper> satHelper)
725 NS_LOG_FUNCTION(
this << satHelper);
730 NS_LOG_FUNCTION(
this);
744 NS_LOG_FUNCTION(
this);
746 NodeContainer uts = Singleton<SatTopology>::Get()->GetUtNodes();
747 for (NodeContainer::Iterator it = uts.Begin(); it != uts.End(); ++it)
753 NodeContainer gws = Singleton<SatTopology>::Get()->GetGwNodes();
754 for (NodeContainer::Iterator it = gws.Begin(); it != gws.End(); ++it)
758 for (NetDeviceContainer::Iterator itDev = devs.Begin(); itDev != devs.End(); ++itDev)
760 Ptr<SatNetDevice> satDev = (*itDev)->GetObject<
SatNetDevice>();
761 NS_ASSERT(satDev !=
nullptr);
762 Ptr<SatPhy> satPhy = satDev->GetPhy();
763 NS_ASSERT(satPhy !=
nullptr);
764 Ptr<SatPhyRx> satPhyRx = satPhy->GetPhyRx();
765 NS_ASSERT(satPhyRx !=
nullptr);
766 ObjectVectorValue carriers;
767 satPhyRx->GetAttribute(
"RxCarrierList", carriers);
768 NS_LOG_DEBUG(
this <<
" Node ID " << (*it)->GetId() <<
" device #"
769 << (*itDev)->GetIfIndex() <<
" has " << carriers.GetN()
772 for (ObjectVectorValue::Iterator itCarrier = carriers.Begin();
773 itCarrier != carriers.End();
777 if (!itCarrier->second->TraceConnectWithoutContext(
"RxPowerTrace",
780 NS_FATAL_ERROR(
"Error connecting to RxPowerTrace trace source"
781 <<
" of SatPhyRxCarrier"
782 <<
" at node ID " << (*it)->GetId() <<
" device #"
783 << (*itDev)->GetIfIndex() <<
" RX carrier #"
784 << itCarrier->first);
802 NS_LOG_FUNCTION(
this << satHelper);
807 NS_LOG_FUNCTION(
this);
821 NS_LOG_FUNCTION(
this);
823 NodeContainer uts = Singleton<SatTopology>::Get()->GetUtNodes();
824 for (NodeContainer::Iterator it = uts.Begin(); it != uts.End(); ++it)
830 NodeContainer sats = Singleton<SatTopology>::Get()->GetOrbiterNodes();
832 for (NodeContainer::Iterator it = sats.Begin(); it != sats.End(); ++it)
836 NS_ASSERT(satOrbiterDev !=
nullptr);
838 std::map<uint32_t, Ptr<SatPhy>> satOrbiterUserPhys = satOrbiterDev->GetUserPhy();
839 for (std::map<uint32_t, Ptr<SatPhy>>::iterator it2 = satOrbiterUserPhys.begin();
840 it2 != satOrbiterUserPhys.end();
843 satPhy = it2->second;
844 NS_ASSERT(satPhy !=
nullptr);
845 Ptr<SatPhyRx> satPhyRx = satPhy->GetPhyRx();
846 NS_ASSERT(satPhyRx !=
nullptr);
847 ObjectVectorValue carriers;
848 satPhyRx->GetAttribute(
"RxCarrierList", carriers);
849 NS_LOG_DEBUG(
this <<
" Node ID " << (*it)->GetId() <<
" device #"
850 << satOrbiterDev->GetIfIndex() <<
" has " << carriers.GetN()
853 for (ObjectVectorValue::Iterator itCarrier = carriers.Begin();
854 itCarrier != carriers.End();
858 if (!itCarrier->second->TraceConnectWithoutContext(
"RxPowerTrace",
861 NS_FATAL_ERROR(
"Error connecting to RxPowerTrace trace source"
862 <<
" of SatPhyRxCarrier"
863 <<
" at node ID " << (*it)->GetId() <<
" device #"
864 << satOrbiterDev->GetIfIndex() <<
" RX carrier #"
865 << 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 RX power statistics from a satellite module simulation.
static TypeId GetTypeId()
inherited from ObjectBase base class
virtual ~SatStatsFwdFeederLinkRxPowerHelper()
/ Destructor.
SatStatsFwdFeederLinkRxPowerHelper(Ptr< const SatHelper > satHelper)
Produce forward user link RX power statistics from a satellite module simulation.
SatStatsFwdUserLinkRxPowerHelper(Ptr< const SatHelper > satHelper)
static TypeId GetTypeId()
inherited from ObjectBase base class
virtual ~SatStatsFwdUserLinkRxPowerHelper()
/ Destructor.
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 RX power statistics helpers.
SatStatsLinkRxPowerHelper(Ptr< const SatHelper > satHelper)
virtual void DoInstallProbes()=0
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.
bool ConnectProbeToCollector(Ptr< Probe > probe, uint32_t identifier)
Connect the probe to the right collector.
static TypeId GetTypeId()
inherited from ObjectBase base class
Ptr< DataCollectionObject > m_aggregator
The aggregator created by this helper.
void SetAveragingMode(bool averagingMode)
virtual ~SatStatsLinkRxPowerHelper()
/ Destructor.
bool m_averagingMode
AveragingMode attribute.
void PassSampleToCollector(double rxPowerDb, uint32_t identifier)
Find a collector with the right identifier and pass a sample data to it.
Ptr< DistributionCollector > m_averagingCollector
The final collector utilized in averaged output (histogram, PDF, and CDF).
void InstallProbes()
Set up several probes or other means of listeners and connect them to the collectors.
Callback< void, double, const Address & > m_traceSinkCallback
Callback< void, double, const Address & > GetTraceSinkCallback() const
void RxPowerCallback(double rxPowerDb, const Address &addr)
Receive inputs from trace sources and forward them to the collector.
Produce return feeder link RX power statistics from a satellite module simulation.
SatStatsRtnFeederLinkRxPowerHelper(Ptr< const SatHelper > satHelper)
virtual ~SatStatsRtnFeederLinkRxPowerHelper()
/ Destructor.
static TypeId GetTypeId()
inherited from ObjectBase base class
Produce return user link RX power statistics from a satellite module simulation.
static TypeId GetTypeId()
inherited from ObjectBase base class
SatStatsRtnUserLinkRxPowerHelper(Ptr< const SatHelper > satHelper)
virtual ~SatStatsRtnUserLinkRxPowerHelper()
/ Destructor.
SatArqSequenceNumber is handling the sequence numbers for the ARQ process.