24 #include <ns3/boolean.h>
25 #include <ns3/callback.h>
26 #include <ns3/data-collection-object.h>
28 #include <ns3/interval-rate-collector.h>
30 #include <ns3/mac48-address.h>
31 #include <ns3/magister-gnuplot-aggregator.h>
32 #include <ns3/multi-file-aggregator.h>
33 #include <ns3/node-container.h>
34 #include <ns3/object-vector.h>
35 #include <ns3/satellite-helper.h>
36 #include <ns3/satellite-id-mapper.h>
37 #include <ns3/satellite-net-device.h>
38 #include <ns3/satellite-orbiter-net-device.h>
39 #include <ns3/satellite-phy-rx-carrier.h>
40 #include <ns3/satellite-phy-rx.h>
41 #include <ns3/satellite-phy.h>
42 #include <ns3/satellite-topology.h>
43 #include <ns3/scalar-collector.h>
44 #include <ns3/singleton.h>
45 #include <ns3/string.h>
51 NS_LOG_COMPONENT_DEFINE(
"SatStatsPacketCollisionHelper");
58 NS_OBJECT_ENSURE_REGISTERED(SatStatsPacketCollisionHelper);
63 NS_LOG_FUNCTION(
this << satHelper);
68 NS_LOG_FUNCTION(
this);
74 static TypeId tid = TypeId(
"ns3::SatStatsPacketCollisionHelper").SetParent<
SatStatsHelper>();
81 NS_LOG_FUNCTION(
this << traceSourceName);
96 NS_LOG_FUNCTION(
this << nPackets << from << isCollided);
100 NS_LOG_WARN(
this <<
" discarding " << nPackets <<
" packets"
101 <<
" from statistics collection because of"
102 <<
" invalid sender address");
107 std::map<const Address, uint32_t>::const_iterator it =
m_identifierMap.find(from);
111 NS_LOG_WARN(
this <<
" discarding " << nPackets <<
" packets"
112 <<
" from statistics collection because of"
113 <<
" unknown sender address " << from);
119 NS_ASSERT_MSG(collector !=
nullptr,
120 "Unable to find collector with identifier " << it->second);
126 Ptr<ScalarCollector> c = collector->GetObject<ScalarCollector>();
127 NS_ASSERT(c !=
nullptr);
128 c->TraceSinkBoolean(
false, isCollided);
134 Ptr<IntervalRateCollector> c = collector->GetObject<IntervalRateCollector>();
135 NS_ASSERT(c !=
nullptr);
136 c->TraceSinkBoolean(
false, isCollided);
142 <<
" is not a valid output type for this statistics.");
158 Ptr<const SatHelper> satHelper)
161 NS_LOG_FUNCTION(
this << satHelper);
166 NS_LOG_FUNCTION(
this);
172 static TypeId tid = TypeId(
"ns3::SatStatsFeederPacketCollisionHelper")
180 NS_LOG_FUNCTION(
this);
186 <<
" is not a valid output type for this statistics.");
196 "EnableContextPrinting",
204 EnumValue(ScalarCollector::INPUT_DATA_TYPE_BOOLEAN));
207 EnumValue(ScalarCollector::OUTPUT_TYPE_AVERAGE_PER_SAMPLE));
211 &MultiFileAggregator::Write1d);
227 EnumValue(IntervalRateCollector::INPUT_DATA_TYPE_BOOLEAN));
230 EnumValue(IntervalRateCollector::OUTPUT_TYPE_AVERAGE_PER_SAMPLE));
234 &MultiFileAggregator::Write2d);
237 &MultiFileAggregator::AddContextHeading);
245 <<
" is not a valid output type for this statistics.");
251 <<
" is not a valid output type for this statistics.");
261 Ptr<MagisterGnuplotAggregator> plotAggregator =
263 NS_ASSERT(plotAggregator !=
nullptr);
265 plotAggregator->SetLegend(
"Time (in seconds)",
"Packet collision rate");
266 plotAggregator->Set2dDatasetDefaultStyle(Gnuplot2dDataset::LINES);
272 EnumValue(IntervalRateCollector::INPUT_DATA_TYPE_BOOLEAN));
275 EnumValue(IntervalRateCollector::OUTPUT_TYPE_AVERAGE_PER_SAMPLE));
281 const std::string context = it->second->GetName();
282 plotAggregator->Add2dDataset(context, context);
286 &MagisterGnuplotAggregator::Write2d);
294 <<
" is not a valid output type for this statistics.");
298 NS_FATAL_ERROR(
"SatStatsUserPacketCollisionHelper - Invalid output type");
303 NodeContainer uts = Singleton<SatTopology>::Get()->GetUtNodes();
304 for (NodeContainer::Iterator it = uts.Begin(); it != uts.End(); ++it)
311 NodeContainer gws = Singleton<SatTopology>::Get()->GetGwNodes();
312 Callback<void, uint32_t, const Address&, bool> callback =
315 for (NodeContainer::Iterator it = gws.Begin(); it != gws.End(); ++it)
319 for (NetDeviceContainer::Iterator itDev = devs.Begin(); itDev != devs.End(); ++itDev)
321 Ptr<SatNetDevice> satDev = (*itDev)->GetObject<
SatNetDevice>();
322 NS_ASSERT(satDev !=
nullptr);
323 Ptr<SatPhy> satPhy = satDev->GetPhy();
324 NS_ASSERT(satPhy !=
nullptr);
325 Ptr<SatPhyRx> satPhyRx = satPhy->GetPhyRx();
326 NS_ASSERT(satPhyRx !=
nullptr);
327 ObjectVectorValue carriers;
328 satPhyRx->GetAttribute(
"RxCarrierList", carriers);
329 NS_LOG_DEBUG(
this <<
" Node ID " << (*it)->GetId() <<
" device #"
330 << (*itDev)->GetIfIndex() <<
" has " << carriers.GetN()
333 for (ObjectVectorValue::Iterator itCarrier = carriers.Begin();
334 itCarrier != carriers.End();
338 DynamicCast<SatPhyRxCarrier>(itCarrier->second)->GetCarrierType();
348 NS_LOG_INFO(
this <<
" successfully connected with node ID " << (*it)->GetId()
349 <<
" device #" << (*itDev)->GetIfIndex() <<
" RX carrier #"
350 << itCarrier->first);
355 <<
" of SatPhyRxCarrier"
356 <<
" at node ID " << (*it)->GetId()
357 <<
" device #" << (*itDev)->GetIfIndex()
358 <<
" RX carrier #" << itCarrier->first);
376 NS_LOG_FUNCTION(
this << satHelper);
381 NS_LOG_FUNCTION(
this);
395 NS_LOG_FUNCTION(
this);
401 <<
" is not a valid output type for this statistics.");
411 "EnableContextPrinting",
419 EnumValue(ScalarCollector::INPUT_DATA_TYPE_BOOLEAN));
422 EnumValue(ScalarCollector::OUTPUT_TYPE_AVERAGE_PER_SAMPLE));
426 &MultiFileAggregator::Write1d);
442 EnumValue(IntervalRateCollector::INPUT_DATA_TYPE_BOOLEAN));
445 EnumValue(IntervalRateCollector::OUTPUT_TYPE_AVERAGE_PER_SAMPLE));
449 &MultiFileAggregator::Write2d);
452 &MultiFileAggregator::AddContextHeading);
460 <<
" is not a valid output type for this statistics.");
466 <<
" is not a valid output type for this statistics.");
476 Ptr<MagisterGnuplotAggregator> plotAggregator =
478 NS_ASSERT(plotAggregator !=
nullptr);
480 plotAggregator->SetLegend(
"Time (in seconds)",
"Packet collision rate");
481 plotAggregator->Set2dDatasetDefaultStyle(Gnuplot2dDataset::LINES);
487 EnumValue(IntervalRateCollector::INPUT_DATA_TYPE_BOOLEAN));
490 EnumValue(IntervalRateCollector::OUTPUT_TYPE_AVERAGE_PER_SAMPLE));
496 const std::string context = it->second->GetName();
497 plotAggregator->Add2dDataset(context, context);
501 &MagisterGnuplotAggregator::Write2d);
509 <<
" is not a valid output type for this statistics.");
513 NS_FATAL_ERROR(
"SatStatsFeederPacketCollisionHelper - Invalid output type");
518 NodeContainer uts = Singleton<SatTopology>::Get()->GetUtNodes();
519 for (NodeContainer::Iterator it = uts.Begin(); it != uts.End(); ++it)
526 NodeContainer sats = Singleton<SatTopology>::Get()->GetOrbiterNodes();
527 Callback<void, uint32_t, const Address&, bool> callback =
530 for (NodeContainer::Iterator it = sats.Begin(); it != sats.End(); ++it)
536 NS_ASSERT(satOrbiterDev !=
nullptr);
537 std::map<uint32_t, Ptr<SatPhy>> satOrbiterUserPhys = satOrbiterDev->GetUserPhy();
538 for (std::map<uint32_t, Ptr<SatPhy>>::iterator itPhy = satOrbiterUserPhys.begin();
539 itPhy != satOrbiterUserPhys.end();
542 satPhy = itPhy->second;
543 NS_ASSERT(satPhy !=
nullptr);
544 Ptr<SatPhyRx> satPhyRx = satPhy->GetPhyRx();
545 NS_ASSERT(satPhyRx !=
nullptr);
547 ObjectVectorValue carriers;
548 satPhyRx->GetAttribute(
"RxCarrierList", carriers);
549 NS_LOG_DEBUG(
this <<
" Node ID " << (*it)->GetId() <<
" device #" << dev->GetIfIndex()
550 <<
" has " << carriers.GetN() <<
" RX carriers");
552 for (ObjectVectorValue::Iterator itCarrier = carriers.Begin();
553 itCarrier != carriers.End();
557 DynamicCast<SatPhyRxCarrier>(itCarrier->second)->GetCarrierType();
567 NS_LOG_INFO(
this <<
" successfully connected with node ID " << (*it)->GetId()
568 <<
" device #" << dev->GetIfIndex() <<
" RX carrier #"
569 << itCarrier->first);
574 <<
" of SatPhyRxCarrier"
575 <<
" at node ID " << (*it)->GetId()
576 <<
" device #" << dev->GetIfIndex()
577 <<
" RX carrier #" << itCarrier->first);
593 Ptr<const SatHelper> satHelper)
596 NS_LOG_FUNCTION(
this << satHelper);
603 NS_LOG_FUNCTION(
this);
609 static TypeId tid = TypeId(
"ns3::SatStatsFeederSlottedAlohaPacketCollisionHelper")
619 Ptr<const SatHelper> satHelper)
622 NS_LOG_FUNCTION(
this << satHelper);
629 NS_LOG_FUNCTION(
this);
635 static TypeId tid = TypeId(
"ns3::SatStatsFeederCrdsaPacketCollisionHelper")
645 Ptr<const SatHelper> satHelper)
648 NS_LOG_FUNCTION(
this << satHelper);
655 NS_LOG_FUNCTION(
this);
661 static TypeId tid = TypeId(
"ns3::SatStatsFeederEssaPacketCollisionHelper")
671 Ptr<const SatHelper> satHelper)
674 NS_LOG_FUNCTION(
this << satHelper);
681 NS_LOG_FUNCTION(
this);
687 static TypeId tid = TypeId(
"ns3::SatStatsUserSlottedAlohaPacketCollisionHelper")
697 Ptr<const SatHelper> satHelper)
700 NS_LOG_FUNCTION(
this << satHelper);
707 NS_LOG_FUNCTION(
this);
713 static TypeId tid = TypeId(
"ns3::SatStatsUserCrdsaPacketCollisionHelper")
723 Ptr<const SatHelper> satHelper)
726 NS_LOG_FUNCTION(
this << satHelper);
733 NS_LOG_FUNCTION(
this);
739 static TypeId tid = TypeId(
"ns3::SatStatsUserEssaPacketCollisionHelper")
SatNetDevice to be utilized in the UT and GW nodes.
SatOrbiterNetDevice to be utilized in geostationary satellite.
CarrierType
Possible carrier types.
Produce packet collision statistics of Random Access CRDSA from a satellite module simulation.
virtual ~SatStatsFeederCrdsaPacketCollisionHelper()
/ Destructor.
static TypeId GetTypeId()
inherited from ObjectBase base class
SatStatsFeederCrdsaPacketCollisionHelper(Ptr< const SatHelper > satHelper)
Produce packet collision statistics of Random Access E-SSA from a satellite module simulation.
static TypeId GetTypeId()
inherited from ObjectBase base class
SatStatsFeederEssaPacketCollisionHelper(Ptr< const SatHelper > satHelper)
virtual ~SatStatsFeederEssaPacketCollisionHelper()
/ Destructor.
Ptr< DataCollectionObject > m_aggregator
The aggregator created by this helper.
virtual ~SatStatsFeederPacketCollisionHelper()
/ Destructor.
static TypeId GetTypeId()
inherited from ObjectBase base class
void DoInstall()
Install the probes, collectors, and aggregators necessary to produce the statistics output.
SatStatsFeederPacketCollisionHelper(Ptr< const SatHelper > satHelper)
Produce packet collision statistics of Random Access Slotted ALOHA from a satellite module simulation...
virtual ~SatStatsFeederSlottedAlohaPacketCollisionHelper()
/ Destructor.
SatStatsFeederSlottedAlohaPacketCollisionHelper(Ptr< const SatHelper > satHelper)
static TypeId GetTypeId()
inherited from ObjectBase base class
Parent abstract class of all satellite statistics helpers.
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)
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
void CollisionRxCallback(uint32_t nPackets, const Address &from, bool isCollided)
Receive inputs from trace sources and determine the right collector to forward the inputs to.
void SetTraceSourceName(std::string traceSourceName)
void SetValidCarrierType(SatPhyRxCarrier::CarrierType carrierType)
Set valid carrier type for this statistics helper type.
virtual ~SatStatsPacketCollisionHelper()
/ Destructor.
SatStatsPacketCollisionHelper(Ptr< const SatHelper > satHelper)
std::string m_traceSourceName
SatPhyRxCarrier::CarrierType GetValidCarrierType() const
Get the valid carrier type.
CollectorMap m_terminalCollectors
Maintains a list of collectors created by this helper.
std::string GetTraceSourceName() const
static TypeId GetTypeId()
inherited from ObjectBase base class
Produce packet collision statistics of Random Access CRDSA from a satellite module simulation.
static TypeId GetTypeId()
inherited from ObjectBase base class
virtual ~SatStatsUserCrdsaPacketCollisionHelper()
/ Destructor.
SatStatsUserCrdsaPacketCollisionHelper(Ptr< const SatHelper > satHelper)
Produce packet collision statistics of Random Access E-SSA from a satellite module simulation.
SatStatsUserEssaPacketCollisionHelper(Ptr< const SatHelper > satHelper)
static TypeId GetTypeId()
inherited from ObjectBase base class
virtual ~SatStatsUserEssaPacketCollisionHelper()
/ Destructor.
SatStatsUserPacketCollisionHelper(Ptr< const SatHelper > satHelper)
void DoInstall()
Install the probes, collectors, and aggregators necessary to produce the statistics output.
virtual ~SatStatsUserPacketCollisionHelper()
/ Destructor.
Ptr< DataCollectionObject > m_aggregator
The aggregator created by this helper.
static TypeId GetTypeId()
inherited from ObjectBase base class
Produce packet collision statistics of Random Access Slotted ALOHA from a satellite module simulation...
static TypeId GetTypeId()
inherited from ObjectBase base class
virtual ~SatStatsUserSlottedAlohaPacketCollisionHelper()
/ Destructor.
SatStatsUserSlottedAlohaPacketCollisionHelper(Ptr< const SatHelper > satHelper)
SatArqSequenceNumber is handling the sequence numbers for the ARQ process.