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"
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"
56NS_LOG_COMPONENT_DEFINE(
"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);
89Callback<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" <<
" invalid sender address");
411 else if (Mac48Address::ConvertFrom(from).IsBroadcast())
421 std::map<const Address, uint32_t>::const_iterator it =
m_identifierMap.find(from);
429 NS_LOG_WARN(
this <<
" discarding a packet RX power of " << rxPowerDb <<
"dB"
430 <<
" from statistics collection because of"
431 <<
" unknown sender address " << from);
439 NS_LOG_FUNCTION(
this << probe << probe->GetName() << identifier);
449 &ScalarCollector::TraceSinkDouble);
457 &UnitConversionCollector::TraceSinkDouble);
471 &ScalarCollector::TraceSinkDouble);
478 &DistributionCollector::TraceSinkDouble);
484 <<
" is not a valid output type for this statistics.");
490 NS_LOG_INFO(
this <<
" created probe " << probe->GetName() <<
", connected to collector "
495 NS_LOG_WARN(
this <<
" unable to connect probe " << probe->GetName() <<
" to collector "
508 NS_ASSERT_MSG(collector !=
nullptr,
"Unable to find collector with identifier " << identifier);
514 Ptr<ScalarCollector> c = collector->GetObject<ScalarCollector>();
515 NS_ASSERT(c !=
nullptr);
516 c->TraceSinkDouble(0.0, rxPowerDb);
522 Ptr<UnitConversionCollector> c = collector->GetObject<UnitConversionCollector>();
523 NS_ASSERT(c !=
nullptr);
524 c->TraceSinkDouble(0.0, rxPowerDb);
536 Ptr<ScalarCollector> c = collector->GetObject<ScalarCollector>();
537 NS_ASSERT(c !=
nullptr);
538 c->TraceSinkDouble(0.0, rxPowerDb);
542 Ptr<DistributionCollector> c = collector->GetObject<DistributionCollector>();
543 NS_ASSERT(c !=
nullptr);
544 c->TraceSinkDouble(0.0, rxPowerDb);
550 <<
" is not a valid output type for this statistics.");
569 Ptr<const SatHelper> satHelper)
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(
"RxPowerTrace",
633 NS_FATAL_ERROR(
"Error connecting to RxPowerTrace trace source"
634 <<
" of SatPhyRxCarrier" <<
" at OrbiterSat node ID "
635 << (*it)->GetId() <<
" device #" << dev->GetIfIndex() <<
" PHY #"
636 << itPhy->first <<
" RX carrier #" << itCarrier->first);
653 NS_LOG_FUNCTION(
this << satHelper);
658 NS_LOG_FUNCTION(
this);
672 NS_LOG_FUNCTION(
this);
674 NodeContainer uts = Singleton<SatTopology>::Get()->GetUtNodes();
675 for (NodeContainer::Iterator it = uts.Begin(); it != uts.End(); ++it)
685 Ptr<SatNetDevice> satDev = dev->GetObject<
SatNetDevice>();
686 NS_ASSERT(satDev !=
nullptr);
687 Ptr<SatPhy> satPhy = satDev->GetPhy();
688 NS_ASSERT(satPhy !=
nullptr);
689 Ptr<SatPhyRx> satPhyRx = satPhy->GetPhyRx();
690 NS_ASSERT(satPhyRx !=
nullptr);
691 ObjectVectorValue carriers;
692 satPhyRx->GetAttribute(
"RxCarrierList", carriers);
693 NS_LOG_DEBUG(
this <<
" Node ID " << (*it)->GetId() <<
" device #" << dev->GetIfIndex()
694 <<
" has " << carriers.GetN() <<
" RX carriers");
696 for (ObjectVectorValue::Iterator itCarrier = carriers.Begin(); itCarrier != carriers.End();
700 if (!itCarrier->second->TraceConnectWithoutContext(
"RxPowerTrace",
703 NS_FATAL_ERROR(
"Error connecting to RxPowerTrace trace source"
704 <<
" of SatPhyRxCarrier" <<
" at node ID " << (*it)->GetId()
705 <<
" device #" << dev->GetIfIndex() <<
" RX carrier #"
706 << itCarrier->first);
720 Ptr<const SatHelper> satHelper)
723 NS_LOG_FUNCTION(
this << satHelper);
728 NS_LOG_FUNCTION(
this);
742 NS_LOG_FUNCTION(
this);
744 NodeContainer uts = Singleton<SatTopology>::Get()->GetUtNodes();
745 for (NodeContainer::Iterator it = uts.Begin(); it != uts.End(); ++it)
751 NodeContainer gws = Singleton<SatTopology>::Get()->GetGwNodes();
752 for (NodeContainer::Iterator it = gws.Begin(); it != gws.End(); ++it)
756 for (NetDeviceContainer::Iterator itDev = devs.Begin(); itDev != devs.End(); ++itDev)
758 Ptr<SatNetDevice> satDev = (*itDev)->GetObject<
SatNetDevice>();
759 NS_ASSERT(satDev !=
nullptr);
760 Ptr<SatPhy> satPhy = satDev->GetPhy();
761 NS_ASSERT(satPhy !=
nullptr);
762 Ptr<SatPhyRx> satPhyRx = satPhy->GetPhyRx();
763 NS_ASSERT(satPhyRx !=
nullptr);
764 ObjectVectorValue carriers;
765 satPhyRx->GetAttribute(
"RxCarrierList", carriers);
766 NS_LOG_DEBUG(
this <<
" Node ID " << (*it)->GetId() <<
" device #"
767 << (*itDev)->GetIfIndex() <<
" has " << carriers.GetN()
770 for (ObjectVectorValue::Iterator itCarrier = carriers.Begin();
771 itCarrier != carriers.End();
775 if (!itCarrier->second->TraceConnectWithoutContext(
"RxPowerTrace",
778 NS_FATAL_ERROR(
"Error connecting to RxPowerTrace trace source"
779 <<
" of SatPhyRxCarrier" <<
" at node ID " << (*it)->GetId()
780 <<
" device #" << (*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(
"RxPowerTrace",
858 NS_FATAL_ERROR(
"Error connecting to RxPowerTrace trace source"
859 <<
" of SatPhyRxCarrier" <<
" at node ID " << (*it)->GetId()
860 <<
" device #" << satOrbiterDev->GetIfIndex() <<
" RX carrier #"
861 << 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.
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)
SatStatsHelper(Ptr< const SatHelper > satHelper)
Creates a new helper instance.
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.