24 #include <ns3/boolean.h>
25 #include <ns3/data-collection-object.h>
26 #include <ns3/distribution-collector.h>
29 #include <ns3/magister-gnuplot-aggregator.h>
30 #include <ns3/multi-file-aggregator.h>
32 #include <ns3/object-map.h>
33 #include <ns3/object-vector.h>
34 #include <ns3/satellite-helper.h>
35 #include <ns3/satellite-orbiter-net-device.h>
36 #include <ns3/satellite-phy-rx-carrier.h>
37 #include <ns3/satellite-phy-rx.h>
38 #include <ns3/satellite-phy.h>
39 #include <ns3/satellite-topology.h>
40 #include <ns3/scalar-collector.h>
41 #include <ns3/singleton.h>
42 #include <ns3/string.h>
43 #include <ns3/unit-conversion-collector.h>
47 NS_LOG_COMPONENT_DEFINE(
"SatStatsWindowLoadHelper");
52 NS_OBJECT_ENSURE_REGISTERED(SatStatsWindowLoadHelper);
58 NS_LOG_FUNCTION(
this << satHelper);
63 NS_LOG_FUNCTION(
this);
69 static TypeId tid = TypeId(
"ns3::SatStatsWindowLoadHelper").SetParent<
SatStatsHelper>();
76 NS_LOG_FUNCTION(
this << windowLoad);
82 Ptr<ScalarCollector> c =
m_collector->GetObject<ScalarCollector>();
83 NS_ASSERT(c !=
nullptr);
84 c->TraceSinkDouble(0.0, windowLoad);
90 Ptr<UnitConversionCollector> c =
m_collector->GetObject<UnitConversionCollector>();
91 NS_ASSERT(c !=
nullptr);
92 c->TraceSinkDouble(0.0, windowLoad);
102 Ptr<DistributionCollector> c =
m_collector->GetObject<DistributionCollector>();
103 NS_ASSERT(c !=
nullptr);
104 c->TraceSinkDouble(0.0, windowLoad);
110 <<
" is not a valid output type for this statistics.");
117 Callback<void, double>
126 NS_LOG_FUNCTION(
this);
132 <<
" is not a valid output type for this statistics.");
142 "EnableContextPrinting",
146 Ptr<MultiFileAggregator> aggregator =
m_aggregator->GetObject<MultiFileAggregator>();
149 Ptr<ScalarCollector> collector = CreateObject<ScalarCollector>();
150 collector->SetName(
"0");
151 collector->SetInputDataType(ScalarCollector::INPUT_DATA_TYPE_DOUBLE);
152 collector->SetOutputType(ScalarCollector::OUTPUT_TYPE_AVERAGE_PER_SAMPLE);
153 collector->TraceConnect(
"Output",
155 MakeCallback(&MultiFileAggregator::Write1d, aggregator));
156 m_collector = collector->GetObject<DataCollectionObject>();
168 Ptr<MultiFileAggregator> aggregator =
m_aggregator->GetObject<MultiFileAggregator>();
171 Ptr<UnitConversionCollector> collector = CreateObject<UnitConversionCollector>();
172 collector->SetName(
"0");
173 collector->SetConversionType(UnitConversionCollector::TRANSPARENT);
174 collector->TraceConnect(
"OutputTimeValue",
176 MakeCallback(&MultiFileAggregator::Write2d, aggregator));
177 m_collector = collector->GetObject<DataCollectionObject>();
191 Ptr<MultiFileAggregator> aggregator =
m_aggregator->GetObject<MultiFileAggregator>();
194 Ptr<DistributionCollector> collector = CreateObject<DistributionCollector>();
195 collector->SetName(
"0");
198 collector->SetOutputType(DistributionCollector::OUTPUT_TYPE_HISTOGRAM);
202 collector->SetOutputType(DistributionCollector::OUTPUT_TYPE_PROBABILITY);
206 collector->SetOutputType(DistributionCollector::OUTPUT_TYPE_CUMULATIVE);
208 collector->TraceConnect(
"Output",
210 MakeCallback(&MultiFileAggregator::Write2d, aggregator));
211 collector->TraceConnect(
"OutputString",
213 MakeCallback(&MultiFileAggregator::AddContextHeading, aggregator));
214 collector->TraceConnect(
217 MakeCallback(&MultiFileAggregator::EnableContextWarning, aggregator));
218 m_collector = collector->GetObject<DataCollectionObject>();
226 <<
" is not a valid output type for this statistics.");
236 Ptr<MagisterGnuplotAggregator> plotAggregator =
238 NS_ASSERT(plotAggregator !=
nullptr);
240 plotAggregator->SetLegend(
"Time (in seconds)",
"Window normalized load (in bps/Hz)");
241 plotAggregator->Add2dDataset(
"0",
"0");
242 plotAggregator->Set2dDatasetDefaultStyle(Gnuplot2dDataset::LINES);
245 Ptr<UnitConversionCollector> collector = CreateObject<UnitConversionCollector>();
246 collector->SetName(
"0");
247 collector->SetConversionType(UnitConversionCollector::TRANSPARENT);
248 collector->TraceConnect(
"OutputTimeValue",
250 MakeCallback(&MagisterGnuplotAggregator::Write2d, plotAggregator));
251 m_collector = collector->GetObject<DataCollectionObject>();
265 Ptr<MagisterGnuplotAggregator> plotAggregator =
267 NS_ASSERT(plotAggregator !=
nullptr);
269 plotAggregator->SetLegend(
"Window normalized load (in bps/Hz)",
"Frequency");
270 plotAggregator->Add2dDataset(
"0",
"0");
271 plotAggregator->Set2dDatasetDefaultStyle(Gnuplot2dDataset::LINES);
274 Ptr<DistributionCollector> collector = CreateObject<DistributionCollector>();
275 collector->SetName(
"0");
278 collector->SetOutputType(DistributionCollector::OUTPUT_TYPE_HISTOGRAM);
282 collector->SetOutputType(DistributionCollector::OUTPUT_TYPE_PROBABILITY);
286 collector->SetOutputType(DistributionCollector::OUTPUT_TYPE_CUMULATIVE);
288 collector->TraceConnect(
"Output",
290 MakeCallback(&MagisterGnuplotAggregator::Write2d, plotAggregator));
291 m_collector = collector->GetObject<DataCollectionObject>();
297 NS_FATAL_ERROR(
"SatStatsWindowLoadHelper - Invalid output type");
320 NS_LOG_FUNCTION(
this << satHelper);
325 NS_LOG_FUNCTION(
this);
339 NS_LOG_FUNCTION(
this);
341 NodeContainer gws = Singleton<SatTopology>::Get()->GetGwNodes();
342 for (NodeContainer::Iterator it = gws.Begin(); it != gws.End(); ++it)
346 for (NetDeviceContainer::Iterator itDev = devs.Begin(); itDev != devs.End(); ++itDev)
348 Ptr<SatNetDevice> satDev = (*itDev)->GetObject<
SatNetDevice>();
349 NS_ASSERT(satDev !=
nullptr);
350 Ptr<SatPhy> satPhy = satDev->GetPhy();
351 NS_ASSERT(satPhy !=
nullptr);
352 Ptr<SatPhyRx> satPhyRx = satPhy->GetPhyRx();
353 NS_ASSERT(satPhyRx !=
nullptr);
354 ObjectVectorValue carriers;
355 satPhyRx->GetAttribute(
"RxCarrierList", carriers);
356 NS_LOG_DEBUG(
this <<
" Node ID " << (*it)->GetId() <<
" device #"
357 << (*itDev)->GetIfIndex() <<
" has " << carriers.GetN()
360 for (ObjectVectorValue::Iterator itCarrier = carriers.Begin();
361 itCarrier != carriers.End();
364 if (DynamicCast<SatPhyRxCarrier>(itCarrier->second)->GetCarrierType() !=
365 SatPhyRxCarrier::CarrierType::RA_ESSA)
370 if (!itCarrier->second->TraceConnectWithoutContext(
"WindowLoad",
373 NS_FATAL_ERROR(
"Error connecting to WindowLoad trace source"
374 <<
" of SatPhyRxCarrier"
375 <<
" at node ID " << (*it)->GetId() <<
" device #"
376 << (*itDev)->GetIfIndex() <<
" RX carrier #"
377 << itCarrier->first);
SatNetDevice to be utilized in the UT and GW nodes.
Parent abstract class of all satellite statistics helpers.
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.
OutputType_t GetOutputType() const
std::string GetName() const
virtual std::string GetTimeHeading(std::string dataLabel) const
virtual std::string GetDistributionHeading(std::string dataLabel) const
Produce return feeder window load statistics from a satellite module simulation.
SatStatsRtnFeederWindowLoadHelper(Ptr< const SatHelper > satHelper)
static TypeId GetTypeId()
inherited from ObjectBase base class
virtual ~SatStatsRtnFeederWindowLoadHelper()
/ Destructor.
Abstract class inherited by SatStatsRtnFeederWindowLoadHelper.
void WindowLoadCallback(double windowLoad)
Receive inputs from trace sources and forward them to the collector.
Ptr< DataCollectionObject > m_aggregator
The aggregator created by this helper.
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.
Callback< void, double > GetTraceSinkCallback() const
Callback< void, double > m_traceSinkCallback
virtual void DoInstallProbes()=0
SatStatsWindowLoadHelper(Ptr< const SatHelper > satHelper)
virtual ~SatStatsWindowLoadHelper()
/ Destructor.
Ptr< DataCollectionObject > m_collector
The collector created by this helper.
static TypeId GetTypeId()
inherited from ObjectBase base class
SatArqSequenceNumber is handling the sequence numbers for the ARQ process.