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(
"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);
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(
"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" <<
" 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 with a sinr of " << sinrDb <<
"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, sinrDb);
522 Ptr<UnitConversionCollector> c = collector->GetObject<UnitConversionCollector>();
523 NS_ASSERT(c !=
nullptr);
524 c->TraceSinkDouble(0.0, sinrDb);
536 Ptr<ScalarCollector> c = collector->GetObject<ScalarCollector>();
537 NS_ASSERT(c !=
nullptr);
538 c->TraceSinkDouble(0.0, sinrDb);
542 Ptr<DistributionCollector> c = collector->GetObject<DistributionCollector>();
543 NS_ASSERT(c !=
nullptr);
544 c->TraceSinkDouble(0.0, sinrDb);
550 <<
" is not a valid output type for this statistics.");
571 NS_LOG_FUNCTION(
this << satHelper);
576 NS_LOG_FUNCTION(
this);
590 NS_LOG_FUNCTION(
this);
592 NodeContainer uts = Singleton<SatTopology>::Get()->GetUtNodes();
594 for (NodeContainer::Iterator it = uts.Begin(); it != uts.End(); ++it)
600 NodeContainer sats = Singleton<SatTopology>::Get()->GetOrbiterNodes();
602 for (NodeContainer::Iterator it = sats.Begin(); it != sats.End(); ++it)
606 NS_ASSERT(satOrbiterDev !=
nullptr);
607 std::map<uint32_t, Ptr<SatPhy>> satOrbiterFeederPhys = satOrbiterDev->GetFeederPhy();
609 satOrbiterDev->GetAttribute(
"FeederPhy", phy);
610 NS_LOG_DEBUG(
this <<
" OrbiterSat Node ID " << (*it)->GetId() <<
" device #"
611 << dev->GetIfIndex() <<
" has " << phy.GetN() <<
" PHY instance(s)");
613 for (ObjectMapValue::Iterator itPhy = phy.Begin(); itPhy != phy.End(); ++itPhy)
615 Ptr<SatPhy> satPhy = itPhy->second->GetObject<
SatPhy>();
616 NS_ASSERT(satPhy !=
nullptr);
617 Ptr<SatPhyRx> satPhyRx = satPhy->GetPhyRx();
618 NS_ASSERT(satPhyRx !=
nullptr);
619 ObjectVectorValue carriers;
620 satPhyRx->GetAttribute(
"RxCarrierList", carriers);
621 NS_LOG_DEBUG(
this <<
" PHY #" << itPhy->first <<
" has " << carriers.GetN()
622 <<
" RX carrier(s)");
624 for (ObjectVectorValue::Iterator itCarrier = carriers.Begin();
625 itCarrier != carriers.End();
629 if (!itCarrier->second->TraceConnectWithoutContext(
"LinkSinr",
632 NS_FATAL_ERROR(
"Error connecting to LinkSinr trace source"
633 <<
" of SatPhyRxCarrier" <<
" at OrbiterSat node ID "
634 << (*it)->GetId() <<
" device #" << dev->GetIfIndex() <<
" PHY #"
635 << itPhy->first <<
" RX carrier #" << itCarrier->first);
652 NS_LOG_FUNCTION(
this << satHelper);
657 NS_LOG_FUNCTION(
this);
671 NS_LOG_FUNCTION(
this);
673 NodeContainer uts = Singleton<SatTopology>::Get()->GetUtNodes();
674 for (NodeContainer::Iterator it = uts.Begin(); it != uts.End(); ++it)
684 Ptr<SatNetDevice> satDev = dev->GetObject<
SatNetDevice>();
685 NS_ASSERT(satDev !=
nullptr);
686 Ptr<SatPhy> satPhy = satDev->GetPhy();
687 NS_ASSERT(satPhy !=
nullptr);
688 Ptr<SatPhyRx> satPhyRx = satPhy->GetPhyRx();
689 NS_ASSERT(satPhyRx !=
nullptr);
690 ObjectVectorValue carriers;
691 satPhyRx->GetAttribute(
"RxCarrierList", carriers);
692 NS_LOG_DEBUG(
this <<
" Node ID " << (*it)->GetId() <<
" device #" << dev->GetIfIndex()
693 <<
" has " << carriers.GetN() <<
" RX carriers");
695 for (ObjectVectorValue::Iterator itCarrier = carriers.Begin(); itCarrier != carriers.End();
701 NS_FATAL_ERROR(
"Error connecting to LinkSinr trace source"
702 <<
" of SatPhyRxCarrier" <<
" at node ID " << (*it)->GetId()
703 <<
" device #" << dev->GetIfIndex() <<
" RX carrier #"
704 << itCarrier->first);
720 NS_LOG_FUNCTION(
this << satHelper);
725 NS_LOG_FUNCTION(
this);
739 NS_LOG_FUNCTION(
this);
741 NodeContainer uts = Singleton<SatTopology>::Get()->GetUtNodes();
742 for (NodeContainer::Iterator it = uts.Begin(); it != uts.End(); ++it)
748 NodeContainer gws = Singleton<SatTopology>::Get()->GetGwNodes();
749 for (NodeContainer::Iterator it = gws.Begin(); it != gws.End(); ++it)
753 for (NetDeviceContainer::Iterator itDev = devs.Begin(); itDev != devs.End(); ++itDev)
755 Ptr<SatNetDevice> satDev = (*itDev)->GetObject<
SatNetDevice>();
756 NS_ASSERT(satDev !=
nullptr);
757 Ptr<SatPhy> satPhy = satDev->GetPhy();
758 NS_ASSERT(satPhy !=
nullptr);
759 Ptr<SatPhyRx> satPhyRx = satPhy->GetPhyRx();
760 NS_ASSERT(satPhyRx !=
nullptr);
761 ObjectVectorValue carriers;
762 satPhyRx->GetAttribute(
"RxCarrierList", carriers);
763 NS_LOG_DEBUG(
this <<
" Node ID " << (*it)->GetId() <<
" device #"
764 << (*itDev)->GetIfIndex() <<
" has " << carriers.GetN()
767 for (ObjectVectorValue::Iterator itCarrier = carriers.Begin();
768 itCarrier != carriers.End();
772 if (!itCarrier->second->TraceConnectWithoutContext(
"LinkSinr",
775 NS_FATAL_ERROR(
"Error connecting to LinkSinr trace source"
776 <<
" of SatPhyRxCarrier" <<
" at node ID " << (*it)->GetId()
777 <<
" device #" << (*itDev)->GetIfIndex() <<
" RX carrier #"
778 << itCarrier->first);
796 NS_LOG_FUNCTION(
this << satHelper);
801 NS_LOG_FUNCTION(
this);
815 NS_LOG_FUNCTION(
this);
817 NodeContainer uts = Singleton<SatTopology>::Get()->GetUtNodes();
818 for (NodeContainer::Iterator it = uts.Begin(); it != uts.End(); ++it)
824 NodeContainer sats = Singleton<SatTopology>::Get()->GetOrbiterNodes();
826 for (NodeContainer::Iterator it = sats.Begin(); it != sats.End(); ++it)
830 NS_ASSERT(satOrbiterDev !=
nullptr);
832 std::map<uint32_t, Ptr<SatPhy>> satOrbiterUserPhys = satOrbiterDev->GetUserPhy();
833 for (std::map<uint32_t, Ptr<SatPhy>>::iterator it2 = satOrbiterUserPhys.begin();
834 it2 != satOrbiterUserPhys.end();
837 satPhy = it2->second;
838 NS_ASSERT(satPhy !=
nullptr);
839 Ptr<SatPhyRx> satPhyRx = satPhy->GetPhyRx();
840 NS_ASSERT(satPhyRx !=
nullptr);
841 ObjectVectorValue carriers;
842 satPhyRx->GetAttribute(
"RxCarrierList", carriers);
843 NS_LOG_DEBUG(
this <<
" Node ID " << (*it)->GetId() <<
" device #"
844 << satOrbiterDev->GetIfIndex() <<
" has " << carriers.GetN()
847 for (ObjectVectorValue::Iterator itCarrier = carriers.Begin();
848 itCarrier != carriers.End();
852 if (!itCarrier->second->TraceConnectWithoutContext(
"LinkSinr",
855 NS_FATAL_ERROR(
"Error connecting to LinkSinr trace source"
856 <<
" of SatPhyRxCarrier" <<
" at node ID " << (*it)->GetId()
857 <<
" device #" << satOrbiterDev->GetIfIndex() <<
" RX carrier #"
858 << 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
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 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.