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/scalar-collector.h>
42 #include <ns3/singleton.h>
43 #include <ns3/string.h>
47 NS_LOG_COMPONENT_DEFINE(
"SatStatsCarrierIdHelper");
54 NS_OBJECT_ENSURE_REGISTERED(SatStatsCarrierIdHelper);
59 NS_LOG_FUNCTION(
this << satHelper);
66 NS_LOG_FUNCTION(
this);
72 static TypeId tid = TypeId(
"ns3::SatStatsCarrierIdHelper").SetParent<
SatStatsHelper>();
79 NS_LOG_FUNCTION(
this << traceSourceName);
92 NS_LOG_FUNCTION(
this);
98 <<
" is not a valid output type for this statistics.");
108 "EnableContextPrinting",
116 EnumValue(ScalarCollector::INPUT_DATA_TYPE_UINTEGER));
119 EnumValue(ScalarCollector::OUTPUT_TYPE_AVERAGE_PER_SAMPLE));
123 &MultiFileAggregator::Write1d);
139 EnumValue(IntervalRateCollector::INPUT_DATA_TYPE_UINTEGER));
142 EnumValue(IntervalRateCollector::OUTPUT_TYPE_AVERAGE_PER_SAMPLE));
147 &MultiFileAggregator::Write2d);
150 &MultiFileAggregator::AddContextHeading);
158 <<
" is not a valid output type for this statistics.");
164 <<
" is not a valid output type for this statistics.");
174 Ptr<MagisterGnuplotAggregator> plotAggregator =
176 NS_ASSERT(plotAggregator !=
nullptr);
178 plotAggregator->SetLegend(
"Time (in seconds)",
"Correlations");
179 plotAggregator->Set2dDatasetDefaultStyle(Gnuplot2dDataset::LINES);
185 EnumValue(IntervalRateCollector::INPUT_DATA_TYPE_UINTEGER));
188 EnumValue(IntervalRateCollector::OUTPUT_TYPE_AVERAGE_PER_SAMPLE));
194 const std::string context = it->second->GetName();
195 plotAggregator->Add2dDataset(context, context);
199 &MagisterGnuplotAggregator::Write2d);
207 <<
" is not a valid output type for this statistics.");
211 NS_FATAL_ERROR(
"SatStatsCarrierIdHelper - Invalid output type");
216 NodeContainer uts =
GetSatHelper()->GetBeamHelper()->GetUtNodes();
217 for (NodeContainer::Iterator it = uts.Begin(); it != uts.End(); ++it)
224 NodeContainer gws =
GetSatHelper()->GetBeamHelper()->GetGwNodes();
225 Callback<void, uint32_t, const Address&> callback =
228 for (NodeContainer::Iterator it = gws.Begin(); it != gws.End(); ++it)
232 for (NetDeviceContainer::Iterator itDev = devs.Begin(); itDev != devs.End(); ++itDev)
234 Ptr<SatNetDevice> satDev = (*itDev)->GetObject<
SatNetDevice>();
235 NS_ASSERT(satDev !=
nullptr);
236 Ptr<SatPhy> satPhy = satDev->GetPhy();
237 NS_ASSERT(satPhy !=
nullptr);
238 Ptr<SatPhyRx> satPhyRx = satPhy->GetPhyRx();
239 NS_ASSERT(satPhyRx !=
nullptr);
240 ObjectVectorValue carriers;
241 satPhyRx->GetAttribute(
"RxCarrierList", carriers);
242 NS_LOG_DEBUG(
this <<
" Node ID " << (*it)->GetId() <<
" device #"
243 << (*itDev)->GetIfIndex() <<
" has " << carriers.GetN()
246 for (ObjectVectorValue::Iterator itCarrier = carriers.Begin();
247 itCarrier != carriers.End();
250 Ptr<SatPhyRxCarrierPerSlot> c =
251 DynamicCast<SatPhyRxCarrierPerSlot>(itCarrier->second);
258 DynamicCast<SatPhyRxCarrier>(itCarrier->second)->GetCarrierType();
268 NS_LOG_INFO(
this <<
" successfully connected with node ID " << (*it)->GetId()
269 <<
" device #" << (*itDev)->GetIfIndex() <<
" RX carrier #"
270 << itCarrier->first);
275 <<
" of SatPhyRxCarrier"
276 <<
" at node ID " << (*it)->GetId()
277 <<
" device #" << (*itDev)->GetIfIndex()
278 <<
" RX carrier #" << itCarrier->first);
292 NS_LOG_FUNCTION(
this << carrierId << from);
294 if (from.IsInvalid())
296 NS_LOG_WARN(
this <<
" discarding a packet"
297 <<
" from statistics collection because of"
298 <<
" invalid sender address");
303 std::map<const Address, uint32_t>::const_iterator it =
m_identifierMap.find(from);
307 NS_LOG_WARN(
this <<
" discarding a packet"
308 <<
" from statistics collection because of"
309 <<
" unknown sender address " << from);
315 NS_ASSERT_MSG(collector !=
nullptr,
"Unable to find collector with identifier " << it->second);
321 Ptr<ScalarCollector> c = collector->GetObject<ScalarCollector>();
322 NS_ASSERT(c !=
nullptr);
323 c->TraceSinkUinteger32(0, carrierId);
329 Ptr<IntervalRateCollector> c = collector->GetObject<IntervalRateCollector>();
330 NS_ASSERT(c !=
nullptr);
331 c->TraceSinkUinteger32(0, carrierId);
337 <<
" is not a valid output type for this statistics.");
345 NS_LOG_FUNCTION(
this << utNode->GetId());
347 const SatIdMapper* satIdMapper = Singleton<SatIdMapper>::Get();
350 if (addr.IsInvalid())
352 NS_LOG_WARN(
this <<
" Node " << utNode->GetId() <<
" is not a valid UT");
358 NS_LOG_INFO(
this <<
" associated address " << addr <<
" with identifier " << identifier);
Address GetUtMacWithNode(Ptr< Node > utNode) const
SatNetDevice to be utilized in the UT and GW nodes.
CarrierType
Possible carrier types.
std::map< const Address, uint32_t > m_identifierMap
Map of address and the identifier associated with it (for forward link).
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 SaveAddressAndIdentifier(Ptr< Node > utNode)
Save the address and the proper identifier from the given UT node.
void SetTraceSourceName(std::string traceSourceName)
Parent abstract class of all satellite statistics helpers.
Ptr< const SatHelper > GetSatHelper() const
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.
uint32_t CreateCollectorPerIdentifier(CollectorMap &collectorMap) const
Create one collector instance for each identifier in the simulation.
OutputType_t GetOutputType() const
uint32_t GetIdentifierForUt(Ptr< Node > utNode) const
std::string GetName() const
virtual std::string GetTimeHeading(std::string dataLabel) const
SatArqSequenceNumber is handling the sequence numbers for the ARQ process.