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-packet-probe.h>
40 #include <ns3/satellite-phy-rx-carrier.h>
41 #include <ns3/satellite-phy-rx.h>
42 #include <ns3/satellite-phy.h>
43 #include <ns3/scalar-collector.h>
44 #include <ns3/singleton.h>
45 #include <ns3/string.h>
49 NS_LOG_COMPONENT_DEFINE(
"SatStatsPacketErrorHelper");
56 NS_OBJECT_ENSURE_REGISTERED(SatStatsPacketErrorHelper);
60 m_traceSourceName(
""),
63 NS_LOG_FUNCTION(
this << satHelper);
68 NS_LOG_FUNCTION(
this);
74 static TypeId tid = TypeId(
"ns3::SatStatsPacketErrorHelper").SetParent<
SatStatsHelper>();
81 NS_LOG_FUNCTION(
this << traceSourceName);
107 NS_LOG_FUNCTION(
this);
113 <<
" is not a valid output type for this statistics.");
123 "EnableContextPrinting",
131 EnumValue(ScalarCollector::INPUT_DATA_TYPE_BOOLEAN));
134 EnumValue(ScalarCollector::OUTPUT_TYPE_AVERAGE_PER_SAMPLE));
138 &MultiFileAggregator::Write1d);
154 EnumValue(IntervalRateCollector::INPUT_DATA_TYPE_BOOLEAN));
157 EnumValue(IntervalRateCollector::OUTPUT_TYPE_AVERAGE_PER_SAMPLE));
161 &MultiFileAggregator::Write2d);
164 &MultiFileAggregator::AddContextHeading);
172 <<
" is not a valid output type for this statistics.");
178 <<
" is not a valid output type for this statistics.");
188 Ptr<MagisterGnuplotAggregator> plotAggregator =
190 NS_ASSERT(plotAggregator !=
nullptr);
192 plotAggregator->SetLegend(
"Time (in seconds)",
"Packet error rate");
193 plotAggregator->Set2dDatasetDefaultStyle(Gnuplot2dDataset::LINES);
199 EnumValue(IntervalRateCollector::INPUT_DATA_TYPE_BOOLEAN));
202 EnumValue(IntervalRateCollector::OUTPUT_TYPE_AVERAGE_PER_SAMPLE));
208 const std::string context = it->second->GetName();
209 plotAggregator->Add2dDataset(context, context);
213 &MagisterGnuplotAggregator::Write2d);
221 <<
" is not a valid output type for this statistics.");
225 NS_FATAL_ERROR(
"SatStatsPacketErrorHelper - Invalid output type");
233 NodeContainer uts =
GetSatHelper()->GetBeamHelper()->GetUtNodes();
234 for (NodeContainer::Iterator it = uts.Begin(); it != uts.End(); ++it)
244 NodeContainer uts =
GetSatHelper()->GetBeamHelper()->GetUtNodes();
245 for (NodeContainer::Iterator it = uts.Begin(); it != uts.End(); ++it)
251 NodeContainer sats =
GetSatHelper()->GetBeamHelper()->GetGeoSatNodes();
252 for (NodeContainer::Iterator it = sats.Begin(); it != sats.End(); ++it)
262 NodeContainer uts =
GetSatHelper()->GetBeamHelper()->GetUtNodes();
263 for (NodeContainer::Iterator it = uts.Begin(); it != uts.End(); ++it)
269 NodeContainer gws =
GetSatHelper()->GetBeamHelper()->GetGwNodes();
270 for (NodeContainer::Iterator it = gws.Begin(); it != gws.End(); ++it)
280 NodeContainer uts =
GetSatHelper()->GetBeamHelper()->GetUtNodes();
281 for (NodeContainer::Iterator it = uts.Begin(); it != uts.End(); ++it)
287 NodeContainer sats =
GetSatHelper()->GetBeamHelper()->GetGeoSatNodes();
288 for (NodeContainer::Iterator it = sats.Begin(); it != sats.End(); ++it)
297 NS_FATAL_ERROR(
"SatStatsPacketErrorHelper - Invalid link");
306 NS_LOG_FUNCTION(
this << nPackets << fromOrTo << isError);
308 if (fromOrTo.IsInvalid())
310 NS_LOG_WARN(
this <<
" discarding " << nPackets <<
" packets"
311 <<
" from statistics collection because of"
312 <<
" invalid sender/destination address");
314 else if (Mac48Address::ConvertFrom(fromOrTo).IsBroadcast())
320 NS_ASSERT_MSG(collector !=
nullptr,
321 "Unable to find collector with identifier " << item.second);
327 Ptr<ScalarCollector> c = collector->GetObject<ScalarCollector>();
328 NS_ASSERT(c !=
nullptr);
329 c->TraceSinkBoolean(
false, isError);
335 Ptr<IntervalRateCollector> c = collector->GetObject<IntervalRateCollector>();
336 NS_ASSERT(c !=
nullptr);
337 c->TraceSinkBoolean(
false, isError);
343 <<
" is not a valid output type for this statistics.");
352 std::map<const Address, uint32_t>::const_iterator it =
m_identifierMap.find(fromOrTo);
356 NS_LOG_WARN(
this <<
" discarding " << nPackets <<
" packets"
357 <<
" from statistics collection because of"
358 <<
" unknown sender/destination address " << fromOrTo);
364 NS_ASSERT_MSG(collector !=
nullptr,
365 "Unable to find collector with identifier " << it->second);
371 Ptr<ScalarCollector> c = collector->GetObject<ScalarCollector>();
372 NS_ASSERT(c !=
nullptr);
373 c->TraceSinkBoolean(
false, isError);
379 Ptr<IntervalRateCollector> c = collector->GetObject<IntervalRateCollector>();
380 NS_ASSERT(c !=
nullptr);
381 c->TraceSinkBoolean(
false, isError);
387 <<
" is not a valid output type for this statistics.");
401 NS_LOG_FUNCTION(
this << utNode->GetId());
403 const SatIdMapper* satIdMapper = Singleton<SatIdMapper>::Get();
406 if (addr.IsInvalid())
408 NS_LOG_WARN(
this <<
" Node " << utNode->GetId() <<
" is not a valid UT");
414 NS_LOG_INFO(
this <<
" associated address " << addr <<
" with identifier " << identifier);
421 NS_LOG_FUNCTION(
this << gwNode->GetId());
424 Callback<void, uint32_t, const Address&, bool> callback =
427 for (NetDeviceContainer::Iterator itDev = devs.Begin(); itDev != devs.End(); ++itDev)
429 Ptr<SatNetDevice> satDev = (*itDev)->GetObject<
SatNetDevice>();
430 NS_ASSERT(satDev !=
nullptr);
431 Ptr<SatPhy> satPhy = satDev->GetPhy();
432 NS_ASSERT(satPhy !=
nullptr);
433 Ptr<SatPhyRx> satPhyRx = satPhy->GetPhyRx();
434 NS_ASSERT(satPhyRx !=
nullptr);
435 ObjectVectorValue carriers;
436 satPhyRx->GetAttribute(
"RxCarrierList", carriers);
437 NS_LOG_DEBUG(
this <<
" Node ID " << gwNode->GetId() <<
" device #" << (*itDev)->GetIfIndex()
438 <<
" has " << carriers.GetN() <<
" RX carriers");
440 for (ObjectVectorValue::Iterator itCarrier = carriers.Begin(); itCarrier != carriers.End();
443 if (DynamicCast<SatPhyRxCarrier>(itCarrier->second)->GetCarrierType() !=
452 NS_LOG_INFO(
this <<
" successfully connected with node ID " << gwNode->GetId()
453 <<
" device #" << (*itDev)->GetIfIndex() <<
" RX carrier #"
454 << itCarrier->first);
459 <<
" of SatPhyRxCarrier"
460 <<
" at node ID " << gwNode->GetId()
461 <<
" device #" << (*itDev)->GetIfIndex()
462 <<
" RX carrier #" << itCarrier->first);
474 NS_LOG_FUNCTION(
this << satNode->GetId());
477 Callback<void, uint32_t, const Address&, bool> callback =
482 NS_ASSERT(satGeoDev !=
nullptr);
483 std::map<uint32_t, Ptr<SatPhy>> satGeoFeederPhys = satGeoDev->GetFeederPhy();
484 for (std::map<uint32_t, Ptr<SatPhy>>::iterator itPhy = satGeoFeederPhys.begin();
485 itPhy != satGeoFeederPhys.end();
488 satPhy = itPhy->second;
489 NS_ASSERT(satPhy !=
nullptr);
490 Ptr<SatPhyRx> satPhyRx = satPhy->GetPhyRx();
491 NS_ASSERT(satPhyRx !=
nullptr);
493 ObjectVectorValue carriers;
494 satPhyRx->GetAttribute(
"RxCarrierList", carriers);
495 NS_LOG_DEBUG(
this <<
" Node ID " << satNode->GetId() <<
" device #" << dev->GetIfIndex()
496 <<
" has " << carriers.GetN() <<
" RX carriers");
498 for (ObjectVectorValue::Iterator itCarrier = carriers.Begin(); itCarrier != carriers.End();
501 if (DynamicCast<SatPhyRxCarrier>(itCarrier->second)->GetCarrierType() !=
510 NS_LOG_INFO(
this <<
" successfully connected with node ID " << satNode->GetId()
511 <<
" device #" << dev->GetIfIndex() <<
" RX carrier #"
512 << itCarrier->first);
517 <<
" of SatPhyRxCarrier"
518 <<
" at node ID " << satNode->GetId()
519 <<
" device #" << dev->GetIfIndex()
520 <<
" RX carrier #" << itCarrier->first);
532 NS_LOG_FUNCTION(
this << satNode->GetId());
535 Callback<void, uint32_t, const Address&, bool> callback =
540 NS_ASSERT(satGeoDev !=
nullptr);
541 std::map<uint32_t, Ptr<SatPhy>> satGeoUserPhys = satGeoDev->GetUserPhy();
542 for (std::map<uint32_t, Ptr<SatPhy>>::iterator itPhy = satGeoUserPhys.begin();
543 itPhy != satGeoUserPhys.end();
546 satPhy = itPhy->second;
547 NS_ASSERT(satPhy !=
nullptr);
548 Ptr<SatPhyRx> satPhyRx = satPhy->GetPhyRx();
549 NS_ASSERT(satPhyRx !=
nullptr);
551 ObjectVectorValue carriers;
552 satPhyRx->GetAttribute(
"RxCarrierList", carriers);
553 NS_LOG_DEBUG(
this <<
" Node ID " << satNode->GetId() <<
" device #" << dev->GetIfIndex()
554 <<
" has " << carriers.GetN() <<
" RX carriers");
556 for (ObjectVectorValue::Iterator itCarrier = carriers.Begin(); itCarrier != carriers.End();
559 if (DynamicCast<SatPhyRxCarrier>(itCarrier->second)->GetCarrierType() !=
568 NS_LOG_INFO(
this <<
" successfully connected with node ID " << satNode->GetId()
569 <<
" device #" << dev->GetIfIndex() <<
" RX carrier #"
570 << itCarrier->first);
575 <<
" of SatPhyRxCarrier"
576 <<
" at node ID " << satNode->GetId()
577 <<
" device #" << dev->GetIfIndex()
578 <<
" RX carrier #" << itCarrier->first);
590 NS_LOG_FUNCTION(
this << utNode->GetId());
592 const int32_t utId =
GetUtId(utNode);
593 NS_ASSERT_MSG(utId > 0,
"Node " << utNode->GetId() <<
" is not a valid UT");
597 std::ostringstream probeName;
599 Ptr<SatPhyRxCarrierPacketProbe> probe = CreateObject<SatPhyRxCarrierPacketProbe>();
600 probe->SetName(probeName.str());
603 Ptr<SatNetDevice> satDev = dev->GetObject<
SatNetDevice>();
604 NS_ASSERT(satDev !=
nullptr);
605 Ptr<SatPhy> satPhy = satDev->GetPhy();
606 NS_ASSERT(satPhy !=
nullptr);
607 Ptr<SatPhyRx> satPhyRx = satPhy->GetPhyRx();
608 NS_ASSERT(satPhyRx !=
nullptr);
609 ObjectVectorValue carriers;
610 satPhyRx->GetAttribute(
"RxCarrierList", carriers);
611 NS_LOG_DEBUG(
this <<
" Node ID " << utNode->GetId() <<
" device #" << dev->GetIfIndex()
612 <<
" has " << carriers.GetN() <<
" RX carriers");
614 for (ObjectVectorValue::Iterator itCarrier = carriers.Begin(); itCarrier != carriers.End();
617 if (DynamicCast<SatPhyRxCarrier>(itCarrier->second)->GetCarrierType() !=
634 &ScalarCollector::TraceSinkBoolean);
643 &IntervalRateCollector::TraceSinkBoolean);
648 <<
" is not a valid output type for this statistics.");
655 NS_LOG_INFO(
this <<
" created probe " << probeName.str()
656 <<
", connected to collector " << identifier);
657 m_probes.push_back(probe->GetObject<Probe>());
661 NS_LOG_WARN(
this <<
" unable to connect probe " << probeName.str()
662 <<
" to collector " << identifier);
669 <<
" of SatPhyRxCarrier"
670 <<
" at node ID " << utNode->GetId()
671 <<
" device #" << dev->GetIfIndex()
672 <<
" RX carrier #" << itCarrier->first);
684 Ptr<const SatHelper> satHelper)
687 NS_LOG_FUNCTION(
this << satHelper);
695 NS_LOG_FUNCTION(
this);
711 Ptr<const SatHelper> satHelper)
714 NS_LOG_FUNCTION(
this << satHelper);
722 NS_LOG_FUNCTION(
this);
738 Ptr<const SatHelper> satHelper)
741 NS_LOG_FUNCTION(
this << satHelper);
749 NS_LOG_FUNCTION(
this);
765 Ptr<const SatHelper> satHelper)
768 NS_LOG_FUNCTION(
this << satHelper);
776 NS_LOG_FUNCTION(
this);
792 Ptr<const SatHelper> satHelper)
795 NS_LOG_FUNCTION(
this << satHelper);
803 NS_LOG_FUNCTION(
this);
809 static TypeId tid = TypeId(
"ns3::SatStatsFeederSlottedAlohaPacketErrorHelper")
819 Ptr<const SatHelper> satHelper)
822 NS_LOG_FUNCTION(
this << satHelper);
830 NS_LOG_FUNCTION(
this);
836 static TypeId tid = TypeId(
"ns3::SatStatsUserSlottedAlohaPacketErrorHelper")
846 Ptr<const SatHelper> satHelper)
849 NS_LOG_FUNCTION(
this << satHelper);
857 NS_LOG_FUNCTION(
this);
873 Ptr<const SatHelper> satHelper)
876 NS_LOG_FUNCTION(
this << satHelper);
884 NS_LOG_FUNCTION(
this);
900 Ptr<const SatHelper> satHelper)
903 NS_LOG_FUNCTION(
this << satHelper);
911 NS_LOG_FUNCTION(
this);
929 NS_LOG_FUNCTION(
this << satHelper);
937 NS_LOG_FUNCTION(
this);
SatEnums class is for simplifying the use of enumerators in the satellite module.
ChannelType_t
Types of channel.
static std::string GetChannelTypeName(ChannelType_t channelType)
SatGeoNetDevice to be utilized in geostationary satellite.
Address GetUtMacWithNode(Ptr< Node > utNode) const
SatNetDevice to be utilized in the UT and GW nodes.
Produce packet error statistics of Random Access CRDSA on feeder link from a satellite module simulat...
virtual ~SatStatsFeederCrdsaPacketErrorHelper()
/ Destructor.
SatStatsFeederCrdsaPacketErrorHelper(Ptr< const SatHelper > satHelper)
static TypeId GetTypeId()
inherited from ObjectBase base class
Produce packet error statistics of Random Access E-SSA on feeder link from a satellite module simulat...
virtual ~SatStatsFeederEssaPacketErrorHelper()
/ Destructor.
static TypeId GetTypeId()
inherited from ObjectBase base class
SatStatsFeederEssaPacketErrorHelper(Ptr< const SatHelper > satHelper)
Produce packet error statistics of Random Access Slotted ALOHA on feeder link from a satellite module...
static TypeId GetTypeId()
inherited from ObjectBase base class
SatStatsFeederSlottedAlohaPacketErrorHelper(Ptr< const SatHelper > satHelper)
virtual ~SatStatsFeederSlottedAlohaPacketErrorHelper()
/ Destructor.
Produce packet error statistics of Dedicated Access in forward feeder link from a satellite module si...
SatStatsFwdFeederDaPacketErrorHelper(Ptr< const SatHelper > satHelper)
static TypeId GetTypeId()
inherited from ObjectBase base class
virtual ~SatStatsFwdFeederDaPacketErrorHelper()
/ Destructor.
Produce packet error statistics of Dedicated Access in forward user link from a satellite module simu...
SatStatsFwdUserDaPacketErrorHelper(Ptr< const SatHelper > satHelper)
static TypeId GetTypeId()
inherited from ObjectBase base class
virtual ~SatStatsFwdUserDaPacketErrorHelper()
/ Destructor.
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 GetUtId(Ptr< Node > utNode) const
uint32_t CreateCollectorPerIdentifier(CollectorMap &collectorMap) const
Create one collector instance for each identifier in the simulation.
static Ptr< NetDevice > GetUtSatNetDevice(Ptr< Node > utNode)
OutputType_t GetOutputType() const
uint32_t GetIdentifierForUt(Ptr< Node > utNode) const
std::string GetName() const
virtual std::string GetTimeHeading(std::string dataLabel) const
Base class for packet error statistics helpers.
static TypeId GetTypeId()
inherited from ObjectBase base class
void DoInstall()
Install the probes, collectors, and aggregators necessary to produce the statistics output.
std::string m_traceSourceName
Name of trace source of PHY RX carrier to listen to.
std::string GetTraceSourceName() const
SatEnums::ChannelType_t GetChannelType() const
void InstallProbeOnGw(Ptr< Node > gwNode)
Set up several listeners on a GW node and connect them to the collectors.
Ptr< DataCollectionObject > m_aggregator
The aggregator created by this helper.
SatPhyRxCarrier::CarrierType GetValidCarrierType() const
Get the valid carrier type.
SatStatsPacketErrorHelper(Ptr< const SatHelper > satHelper)
void SaveAddressAndIdentifier(Ptr< Node > utNode)
Save the address and the proper identifier from the given UT node.
CollectorMap m_terminalCollectors
Maintains a list of collectors created by this helper.
void InstallProbeOnUt(Ptr< Node > utNode)
Set up several probes on a UT node and connect them to the collectors.
SatEnums::ChannelType_t m_channelType
Link where statistics are gathered from.
void InstallProbeOnSatUser(Ptr< Node > satNode)
Set up several listeners on a SAT user node and connect them to the collectors.
void SetChannelType(SatEnums::ChannelType_t channelType)
std::map< const Address, uint32_t > m_identifierMap
Map of address and the identifier associated with it (for return link).
std::list< Ptr< Probe > > m_probes
Maintains a list of probes created by this helper (for forward link).
void SetValidCarrierType(SatPhyRxCarrier::CarrierType carrierType)
Set valid carrier type for this statistics helper type.
void SetTraceSourceName(std::string traceSourceName)
void ErrorRxCallback(uint32_t nPackets, const Address &fromOrTo, bool isError)
Receive inputs from trace sources and determine the right collector to forward the inputs to.
virtual ~SatStatsPacketErrorHelper()
/ Destructor.
void InstallProbeOnSatFeeder(Ptr< Node > satNode)
Set up several listeners on a SAT feeder node and connect them to the collectors.
Produce packet error statistics of Dedicated Access in return feeder link from a satellite module sim...
static TypeId GetTypeId()
inherited from ObjectBase base class
virtual ~SatStatsRtnFeederDaPacketErrorHelper()
/ Destructor.
SatStatsRtnFeederDaPacketErrorHelper(Ptr< const SatHelper > satHelper)
Produce packet error statistics of Dedicated Access in return user link from a satellite module simul...
SatStatsRtnUserDaPacketErrorHelper(Ptr< const SatHelper > satHelper)
static TypeId GetTypeId()
inherited from ObjectBase base class
virtual ~SatStatsRtnUserDaPacketErrorHelper()
/ Destructor.
Produce packet error statistics of Random Access CRDSA on user link from a satellite module simulatio...
SatStatsUserCrdsaPacketErrorHelper(Ptr< const SatHelper > satHelper)
static TypeId GetTypeId()
inherited from ObjectBase base class
virtual ~SatStatsUserCrdsaPacketErrorHelper()
/ Destructor.
Produce packet error statistics of Random Access E-SSA on user link from a satellite module simulatio...
virtual ~SatStatsUserEssaPacketErrorHelper()
/ Destructor.
static TypeId GetTypeId()
inherited from ObjectBase base class
SatStatsUserEssaPacketErrorHelper(Ptr< const SatHelper > satHelper)
Produce packet error statistics of Random Access Slotted ALOHA on user link from a satellite module s...
virtual ~SatStatsUserSlottedAlohaPacketErrorHelper()
/ Destructor.
SatStatsUserSlottedAlohaPacketErrorHelper(Ptr< const SatHelper > satHelper)
static TypeId GetTypeId()
inherited from ObjectBase base class
SatArqSequenceNumber is handling the sequence numbers for the ARQ process.