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-geo-net-device.h>
36 #include <ns3/satellite-helper.h>
37 #include <ns3/satellite-id-mapper.h>
38 #include <ns3/satellite-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/scalar-collector.h>
43 #include <ns3/singleton.h>
44 #include <ns3/string.h>
48 NS_LOG_COMPONENT_DEFINE(
"SatStatsPacketCollisionHelper");
55 NS_OBJECT_ENSURE_REGISTERED(SatStatsPacketCollisionHelper);
60 NS_LOG_FUNCTION(
this << satHelper);
65 NS_LOG_FUNCTION(
this);
71 static TypeId tid = TypeId(
"ns3::SatStatsPacketCollisionHelper").SetParent<
SatStatsHelper>();
78 NS_LOG_FUNCTION(
this << traceSourceName);
93 NS_LOG_FUNCTION(
this << nPackets << from << isCollided);
97 NS_LOG_WARN(
this <<
" discarding " << nPackets <<
" packets"
98 <<
" from statistics collection because of"
99 <<
" invalid sender address");
104 std::map<const Address, uint32_t>::const_iterator it =
m_identifierMap.find(from);
108 NS_LOG_WARN(
this <<
" discarding " << nPackets <<
" packets"
109 <<
" from statistics collection because of"
110 <<
" unknown sender address " << from);
116 NS_ASSERT_MSG(collector !=
nullptr,
117 "Unable to find collector with identifier " << it->second);
123 Ptr<ScalarCollector> c = collector->GetObject<ScalarCollector>();
124 NS_ASSERT(c !=
nullptr);
125 c->TraceSinkBoolean(
false, isCollided);
131 Ptr<IntervalRateCollector> c = collector->GetObject<IntervalRateCollector>();
132 NS_ASSERT(c !=
nullptr);
133 c->TraceSinkBoolean(
false, isCollided);
139 <<
" is not a valid output type for this statistics.");
153 NS_LOG_FUNCTION(
this << utNode->GetId());
155 const SatIdMapper* satIdMapper = Singleton<SatIdMapper>::Get();
158 if (addr.IsInvalid())
160 NS_LOG_WARN(
this <<
" Node " << utNode->GetId() <<
" is not a valid UT");
166 NS_LOG_INFO(
this <<
" associated address " << addr <<
" with identifier " << identifier);
175 Ptr<const SatHelper> satHelper)
178 NS_LOG_FUNCTION(
this << satHelper);
183 NS_LOG_FUNCTION(
this);
189 static TypeId tid = TypeId(
"ns3::SatStatsFeederPacketCollisionHelper")
197 NS_LOG_FUNCTION(
this);
203 <<
" is not a valid output type for this statistics.");
213 "EnableContextPrinting",
221 EnumValue(ScalarCollector::INPUT_DATA_TYPE_BOOLEAN));
224 EnumValue(ScalarCollector::OUTPUT_TYPE_AVERAGE_PER_SAMPLE));
228 &MultiFileAggregator::Write1d);
244 EnumValue(IntervalRateCollector::INPUT_DATA_TYPE_BOOLEAN));
247 EnumValue(IntervalRateCollector::OUTPUT_TYPE_AVERAGE_PER_SAMPLE));
251 &MultiFileAggregator::Write2d);
254 &MultiFileAggregator::AddContextHeading);
262 <<
" is not a valid output type for this statistics.");
268 <<
" is not a valid output type for this statistics.");
278 Ptr<MagisterGnuplotAggregator> plotAggregator =
280 NS_ASSERT(plotAggregator !=
nullptr);
282 plotAggregator->SetLegend(
"Time (in seconds)",
"Packet collision rate");
283 plotAggregator->Set2dDatasetDefaultStyle(Gnuplot2dDataset::LINES);
289 EnumValue(IntervalRateCollector::INPUT_DATA_TYPE_BOOLEAN));
292 EnumValue(IntervalRateCollector::OUTPUT_TYPE_AVERAGE_PER_SAMPLE));
298 const std::string context = it->second->GetName();
299 plotAggregator->Add2dDataset(context, context);
303 &MagisterGnuplotAggregator::Write2d);
311 <<
" is not a valid output type for this statistics.");
315 NS_FATAL_ERROR(
"SatStatsUserPacketCollisionHelper - Invalid output type");
320 NodeContainer uts =
GetSatHelper()->GetBeamHelper()->GetUtNodes();
321 for (NodeContainer::Iterator it = uts.Begin(); it != uts.End(); ++it)
328 NodeContainer gws =
GetSatHelper()->GetBeamHelper()->GetGwNodes();
329 Callback<void, uint32_t, const Address&, bool> callback =
332 for (NodeContainer::Iterator it = gws.Begin(); it != gws.End(); ++it)
336 for (NetDeviceContainer::Iterator itDev = devs.Begin(); itDev != devs.End(); ++itDev)
338 Ptr<SatNetDevice> satDev = (*itDev)->GetObject<
SatNetDevice>();
339 NS_ASSERT(satDev !=
nullptr);
340 Ptr<SatPhy> satPhy = satDev->GetPhy();
341 NS_ASSERT(satPhy !=
nullptr);
342 Ptr<SatPhyRx> satPhyRx = satPhy->GetPhyRx();
343 NS_ASSERT(satPhyRx !=
nullptr);
344 ObjectVectorValue carriers;
345 satPhyRx->GetAttribute(
"RxCarrierList", carriers);
346 NS_LOG_DEBUG(
this <<
" Node ID " << (*it)->GetId() <<
" device #"
347 << (*itDev)->GetIfIndex() <<
" has " << carriers.GetN()
350 for (ObjectVectorValue::Iterator itCarrier = carriers.Begin();
351 itCarrier != carriers.End();
355 DynamicCast<SatPhyRxCarrier>(itCarrier->second)->GetCarrierType();
365 NS_LOG_INFO(
this <<
" successfully connected with node ID " << (*it)->GetId()
366 <<
" device #" << (*itDev)->GetIfIndex() <<
" RX carrier #"
367 << itCarrier->first);
372 <<
" of SatPhyRxCarrier"
373 <<
" at node ID " << (*it)->GetId()
374 <<
" device #" << (*itDev)->GetIfIndex()
375 <<
" RX carrier #" << itCarrier->first);
393 NS_LOG_FUNCTION(
this << satHelper);
398 NS_LOG_FUNCTION(
this);
412 NS_LOG_FUNCTION(
this);
418 <<
" is not a valid output type for this statistics.");
428 "EnableContextPrinting",
436 EnumValue(ScalarCollector::INPUT_DATA_TYPE_BOOLEAN));
439 EnumValue(ScalarCollector::OUTPUT_TYPE_AVERAGE_PER_SAMPLE));
443 &MultiFileAggregator::Write1d);
459 EnumValue(IntervalRateCollector::INPUT_DATA_TYPE_BOOLEAN));
462 EnumValue(IntervalRateCollector::OUTPUT_TYPE_AVERAGE_PER_SAMPLE));
466 &MultiFileAggregator::Write2d);
469 &MultiFileAggregator::AddContextHeading);
477 <<
" is not a valid output type for this statistics.");
483 <<
" is not a valid output type for this statistics.");
493 Ptr<MagisterGnuplotAggregator> plotAggregator =
495 NS_ASSERT(plotAggregator !=
nullptr);
497 plotAggregator->SetLegend(
"Time (in seconds)",
"Packet collision rate");
498 plotAggregator->Set2dDatasetDefaultStyle(Gnuplot2dDataset::LINES);
504 EnumValue(IntervalRateCollector::INPUT_DATA_TYPE_BOOLEAN));
507 EnumValue(IntervalRateCollector::OUTPUT_TYPE_AVERAGE_PER_SAMPLE));
513 const std::string context = it->second->GetName();
514 plotAggregator->Add2dDataset(context, context);
518 &MagisterGnuplotAggregator::Write2d);
526 <<
" is not a valid output type for this statistics.");
530 NS_FATAL_ERROR(
"SatStatsFeederPacketCollisionHelper - Invalid output type");
535 NodeContainer uts =
GetSatHelper()->GetBeamHelper()->GetUtNodes();
536 for (NodeContainer::Iterator it = uts.Begin(); it != uts.End(); ++it)
543 NodeContainer sats =
GetSatHelper()->GetBeamHelper()->GetGeoSatNodes();
544 Callback<void, uint32_t, const Address&, bool> callback =
547 for (NodeContainer::Iterator it = sats.Begin(); it != sats.End(); ++it)
553 NS_ASSERT(satGeoDev !=
nullptr);
554 std::map<uint32_t, Ptr<SatPhy>> satGeoUserPhys = satGeoDev->GetUserPhy();
555 for (std::map<uint32_t, Ptr<SatPhy>>::iterator itPhy = satGeoUserPhys.begin();
556 itPhy != satGeoUserPhys.end();
559 satPhy = itPhy->second;
560 NS_ASSERT(satPhy !=
nullptr);
561 Ptr<SatPhyRx> satPhyRx = satPhy->GetPhyRx();
562 NS_ASSERT(satPhyRx !=
nullptr);
564 ObjectVectorValue carriers;
565 satPhyRx->GetAttribute(
"RxCarrierList", carriers);
566 NS_LOG_DEBUG(
this <<
" Node ID " << (*it)->GetId() <<
" device #" << dev->GetIfIndex()
567 <<
" has " << carriers.GetN() <<
" RX carriers");
569 for (ObjectVectorValue::Iterator itCarrier = carriers.Begin();
570 itCarrier != carriers.End();
574 DynamicCast<SatPhyRxCarrier>(itCarrier->second)->GetCarrierType();
584 NS_LOG_INFO(
this <<
" successfully connected with node ID " << (*it)->GetId()
585 <<
" device #" << dev->GetIfIndex() <<
" RX carrier #"
586 << itCarrier->first);
591 <<
" of SatPhyRxCarrier"
592 <<
" at node ID " << (*it)->GetId()
593 <<
" device #" << dev->GetIfIndex()
594 <<
" RX carrier #" << itCarrier->first);
610 Ptr<const SatHelper> satHelper)
613 NS_LOG_FUNCTION(
this << satHelper);
620 NS_LOG_FUNCTION(
this);
626 static TypeId tid = TypeId(
"ns3::SatStatsFeederSlottedAlohaPacketCollisionHelper")
636 Ptr<const SatHelper> satHelper)
639 NS_LOG_FUNCTION(
this << satHelper);
646 NS_LOG_FUNCTION(
this);
652 static TypeId tid = TypeId(
"ns3::SatStatsFeederCrdsaPacketCollisionHelper")
662 Ptr<const SatHelper> satHelper)
665 NS_LOG_FUNCTION(
this << satHelper);
672 NS_LOG_FUNCTION(
this);
678 static TypeId tid = TypeId(
"ns3::SatStatsFeederEssaPacketCollisionHelper")
688 Ptr<const SatHelper> satHelper)
691 NS_LOG_FUNCTION(
this << satHelper);
698 NS_LOG_FUNCTION(
this);
704 static TypeId tid = TypeId(
"ns3::SatStatsUserSlottedAlohaPacketCollisionHelper")
714 Ptr<const SatHelper> satHelper)
717 NS_LOG_FUNCTION(
this << satHelper);
724 NS_LOG_FUNCTION(
this);
730 static TypeId tid = TypeId(
"ns3::SatStatsUserCrdsaPacketCollisionHelper")
740 Ptr<const SatHelper> satHelper)
743 NS_LOG_FUNCTION(
this << satHelper);
750 NS_LOG_FUNCTION(
this);
756 static TypeId tid = TypeId(
"ns3::SatStatsUserEssaPacketCollisionHelper")
SatGeoNetDevice to be utilized in geostationary satellite.
Address GetUtMacWithNode(Ptr< Node > utNode) const
SatNetDevice to be utilized in the UT and GW nodes.
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.
Ptr< const SatHelper > GetSatHelper() const
static NetDeviceContainer GetGwSatNetDevice(Ptr< Node > gwNode)
static std::string GetOutputTypeName(OutputType_t outputType)
static Ptr< NetDevice > GetSatSatGeoNetDevice(Ptr< Node > satNode)
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
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 SaveAddressAndIdentifier(Ptr< Node > utNode)
Save the address and the proper identifier from the given UT node.
void SetValidCarrierType(SatPhyRxCarrier::CarrierType carrierType)
Set valid carrier type for this statistics helper type.
virtual ~SatStatsPacketCollisionHelper()
/ Destructor.
std::map< const Address, uint32_t > m_identifierMap
Map of address and the identifier associated with it (for forward link).
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.