23 #include <ns3/boolean.h>
24 #include <ns3/callback.h>
25 #include <ns3/data-collection-object.h>
27 #include <ns3/interval-rate-collector.h>
29 #include <ns3/mac48-address.h>
30 #include <ns3/magister-gnuplot-aggregator.h>
31 #include <ns3/multi-file-aggregator.h>
32 #include <ns3/node-container.h>
33 #include <ns3/object-vector.h>
34 #include <ns3/satellite-helper.h>
35 #include <ns3/satellite-id-mapper.h>
36 #include <ns3/satellite-net-device.h>
37 #include <ns3/satellite-phy-rx-carrier-marsala.h>
38 #include <ns3/satellite-phy-rx-carrier.h>
39 #include <ns3/satellite-phy-rx.h>
40 #include <ns3/satellite-phy.h>
41 #include <ns3/satellite-topology.h>
42 #include <ns3/scalar-collector.h>
43 #include <ns3/singleton.h>
44 #include <ns3/string.h>
50 NS_LOG_COMPONENT_DEFINE(
"SatStatsCarrierIdHelper");
57 NS_OBJECT_ENSURE_REGISTERED(SatStatsCarrierIdHelper);
62 NS_LOG_FUNCTION(
this << satHelper);
69 NS_LOG_FUNCTION(
this);
75 static TypeId tid = TypeId(
"ns3::SatStatsCarrierIdHelper").SetParent<
SatStatsHelper>();
82 NS_LOG_FUNCTION(
this << traceSourceName);
95 NS_LOG_FUNCTION(
this);
101 <<
" is not a valid output type for this statistics.");
111 "EnableContextPrinting",
119 EnumValue(ScalarCollector::INPUT_DATA_TYPE_UINTEGER));
122 EnumValue(ScalarCollector::OUTPUT_TYPE_AVERAGE_PER_SAMPLE));
126 &MultiFileAggregator::Write1d);
142 EnumValue(IntervalRateCollector::INPUT_DATA_TYPE_UINTEGER));
145 EnumValue(IntervalRateCollector::OUTPUT_TYPE_AVERAGE_PER_SAMPLE));
150 &MultiFileAggregator::Write2d);
153 &MultiFileAggregator::AddContextHeading);
161 <<
" is not a valid output type for this statistics.");
167 <<
" is not a valid output type for this statistics.");
177 Ptr<MagisterGnuplotAggregator> plotAggregator =
179 NS_ASSERT(plotAggregator !=
nullptr);
181 plotAggregator->SetLegend(
"Time (in seconds)",
"Correlations");
182 plotAggregator->Set2dDatasetDefaultStyle(Gnuplot2dDataset::LINES);
188 EnumValue(IntervalRateCollector::INPUT_DATA_TYPE_UINTEGER));
191 EnumValue(IntervalRateCollector::OUTPUT_TYPE_AVERAGE_PER_SAMPLE));
197 const std::string context = it->second->GetName();
198 plotAggregator->Add2dDataset(context, context);
202 &MagisterGnuplotAggregator::Write2d);
210 <<
" is not a valid output type for this statistics.");
214 NS_FATAL_ERROR(
"SatStatsCarrierIdHelper - Invalid output type");
219 NodeContainer uts = Singleton<SatTopology>::Get()->GetUtNodes();
220 for (NodeContainer::Iterator it = uts.Begin(); it != uts.End(); ++it)
227 NodeContainer gws = Singleton<SatTopology>::Get()->GetGwNodes();
228 Callback<void, uint32_t, const Address&> callback =
231 for (NodeContainer::Iterator it = gws.Begin(); it != gws.End(); ++it)
235 for (NetDeviceContainer::Iterator itDev = devs.Begin(); itDev != devs.End(); ++itDev)
237 Ptr<SatNetDevice> satDev = (*itDev)->GetObject<
SatNetDevice>();
238 NS_ASSERT(satDev !=
nullptr);
239 Ptr<SatPhy> satPhy = satDev->GetPhy();
240 NS_ASSERT(satPhy !=
nullptr);
241 Ptr<SatPhyRx> satPhyRx = satPhy->GetPhyRx();
242 NS_ASSERT(satPhyRx !=
nullptr);
243 ObjectVectorValue carriers;
244 satPhyRx->GetAttribute(
"RxCarrierList", carriers);
245 NS_LOG_DEBUG(
this <<
" Node ID " << (*it)->GetId() <<
" device #"
246 << (*itDev)->GetIfIndex() <<
" has " << carriers.GetN()
249 for (ObjectVectorValue::Iterator itCarrier = carriers.Begin();
250 itCarrier != carriers.End();
253 Ptr<SatPhyRxCarrierPerSlot> c =
254 DynamicCast<SatPhyRxCarrierPerSlot>(itCarrier->second);
261 DynamicCast<SatPhyRxCarrier>(itCarrier->second)->GetCarrierType();
271 NS_LOG_INFO(
this <<
" successfully connected with node ID " << (*it)->GetId()
272 <<
" device #" << (*itDev)->GetIfIndex() <<
" RX carrier #"
273 << itCarrier->first);
278 <<
" of SatPhyRxCarrier"
279 <<
" at node ID " << (*it)->GetId()
280 <<
" device #" << (*itDev)->GetIfIndex()
281 <<
" RX carrier #" << itCarrier->first);
295 NS_LOG_FUNCTION(
this << carrierId << from);
297 if (from.IsInvalid())
299 NS_LOG_WARN(
this <<
" discarding a packet"
300 <<
" from statistics collection because of"
301 <<
" invalid sender address");
306 std::map<const Address, uint32_t>::const_iterator it =
m_identifierMap.find(from);
310 NS_LOG_WARN(
this <<
" discarding a packet"
311 <<
" from statistics collection because of"
312 <<
" unknown sender address " << from);
318 NS_ASSERT_MSG(collector !=
nullptr,
"Unable to find collector with identifier " << it->second);
324 Ptr<ScalarCollector> c = collector->GetObject<ScalarCollector>();
325 NS_ASSERT(c !=
nullptr);
326 c->TraceSinkUinteger32(0, carrierId);
332 Ptr<IntervalRateCollector> c = collector->GetObject<IntervalRateCollector>();
333 NS_ASSERT(c !=
nullptr);
334 c->TraceSinkUinteger32(0, carrierId);
340 <<
" is not a valid output type for this statistics.");
SatNetDevice to be utilized in the UT and GW nodes.
CarrierType
Possible carrier types.
SatStatsCarrierIdHelper(Ptr< const SatHelper > satHelper)
SatPhyRxCarrier::CarrierType GetValidCarrierType() const
Get the valid carrier type.
std::string m_traceSourceName
Ptr< DataCollectionObject > m_aggregator
The aggregator created by this helper.
std::string GetTraceSourceName() const
void SetValidCarrierType(SatPhyRxCarrier::CarrierType carrierType)
Set valid carrier type for this statistics helper type.
static TypeId GetTypeId()
inherited from ObjectBase base class
virtual ~SatStatsCarrierIdHelper()
/ Destructor.
void CarrierIdRxCallback(uint32_t carrierId, const Address &from)
Receive inputs from trace sources and determine the right collector to forward the inputs to.
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.
void SetTraceSourceName(std::string traceSourceName)
Parent abstract class of all satellite statistics helpers.
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.
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
SatArqSequenceNumber is handling the sequence numbers for the ARQ process.