26 #include <ns3/boolean.h>
27 #include <ns3/callback.h>
28 #include <ns3/data-collection-object.h>
30 #include <ns3/interval-rate-collector.h>
32 #include <ns3/mac48-address.h>
33 #include <ns3/magister-gnuplot-aggregator.h>
34 #include <ns3/multi-file-aggregator.h>
35 #include <ns3/node-container.h>
36 #include <ns3/object-vector.h>
37 #include <ns3/satellite-helper.h>
38 #include <ns3/satellite-id-mapper.h>
39 #include <ns3/satellite-net-device.h>
40 #include <ns3/satellite-orbiter-net-device.h>
41 #include <ns3/satellite-phy-rx-carrier.h>
42 #include <ns3/satellite-phy-rx.h>
43 #include <ns3/satellite-phy.h>
44 #include <ns3/satellite-topology.h>
45 #include <ns3/scalar-collector.h>
46 #include <ns3/singleton.h>
47 #include <ns3/string.h>
54 NS_LOG_COMPONENT_DEFINE(
"SatStatsPacketErrorHelper");
61 NS_OBJECT_ENSURE_REGISTERED(SatStatsPacketErrorHelper);
65 m_traceSourceName(
""),
68 NS_LOG_FUNCTION(
this << satHelper);
73 NS_LOG_FUNCTION(
this);
79 static TypeId tid = TypeId(
"ns3::SatStatsPacketErrorHelper").SetParent<
SatStatsHelper>();
86 NS_LOG_FUNCTION(
this << traceSourceName);
112 NS_LOG_FUNCTION(
this);
118 <<
" is not a valid output type for this statistics.");
128 "EnableContextPrinting",
136 EnumValue(ScalarCollector::INPUT_DATA_TYPE_BOOLEAN));
139 EnumValue(ScalarCollector::OUTPUT_TYPE_AVERAGE_PER_SAMPLE));
143 &MultiFileAggregator::Write1d);
159 EnumValue(IntervalRateCollector::INPUT_DATA_TYPE_BOOLEAN));
162 EnumValue(IntervalRateCollector::OUTPUT_TYPE_AVERAGE_PER_SAMPLE));
166 &MultiFileAggregator::Write2d);
169 &MultiFileAggregator::AddContextHeading);
177 <<
" is not a valid output type for this statistics.");
183 <<
" is not a valid output type for this statistics.");
193 Ptr<MagisterGnuplotAggregator> plotAggregator =
195 NS_ASSERT(plotAggregator !=
nullptr);
197 plotAggregator->SetLegend(
"Time (in seconds)",
"Packet error rate");
198 plotAggregator->Set2dDatasetDefaultStyle(Gnuplot2dDataset::LINES);
204 EnumValue(IntervalRateCollector::INPUT_DATA_TYPE_BOOLEAN));
207 EnumValue(IntervalRateCollector::OUTPUT_TYPE_AVERAGE_PER_SAMPLE));
213 const std::string context = it->second->GetName();
214 plotAggregator->Add2dDataset(context, context);
218 &MagisterGnuplotAggregator::Write2d);
226 <<
" is not a valid output type for this statistics.");
230 NS_FATAL_ERROR(
"SatStatsPacketErrorHelper - Invalid output type");
238 NodeContainer uts = Singleton<SatTopology>::Get()->GetUtNodes();
239 for (NodeContainer::Iterator it = uts.Begin(); it != uts.End(); ++it)
249 NodeContainer uts = Singleton<SatTopology>::Get()->GetUtNodes();
250 for (NodeContainer::Iterator it = uts.Begin(); it != uts.End(); ++it)
256 NodeContainer sats = Singleton<SatTopology>::Get()->GetOrbiterNodes();
257 for (NodeContainer::Iterator it = sats.Begin(); it != sats.End(); ++it)
267 NodeContainer uts = Singleton<SatTopology>::Get()->GetUtNodes();
268 for (NodeContainer::Iterator it = uts.Begin(); it != uts.End(); ++it)
274 NodeContainer gws = Singleton<SatTopology>::Get()->GetGwNodes();
275 for (NodeContainer::Iterator it = gws.Begin(); it != gws.End(); ++it)
285 NodeContainer uts = Singleton<SatTopology>::Get()->GetUtNodes();
286 for (NodeContainer::Iterator it = uts.Begin(); it != uts.End(); ++it)
292 NodeContainer sats = Singleton<SatTopology>::Get()->GetOrbiterNodes();
293 for (NodeContainer::Iterator it = sats.Begin(); it != sats.End(); ++it)
302 NS_FATAL_ERROR(
"SatStatsPacketErrorHelper - Invalid link");
311 NS_LOG_FUNCTION(
this << nPackets << fromOrTo << isError);
313 if (fromOrTo.IsInvalid())
315 NS_LOG_WARN(
this <<
" discarding " << nPackets <<
" packets"
316 <<
" from statistics collection because of"
317 <<
" invalid sender/destination address");
319 else if (Mac48Address::ConvertFrom(fromOrTo).IsBroadcast())
325 NS_ASSERT_MSG(collector !=
nullptr,
326 "Unable to find collector with identifier " << item.second);
332 Ptr<ScalarCollector> c = collector->GetObject<ScalarCollector>();
333 NS_ASSERT(c !=
nullptr);
334 c->TraceSinkBoolean(
false, isError);
340 Ptr<IntervalRateCollector> c = collector->GetObject<IntervalRateCollector>();
341 NS_ASSERT(c !=
nullptr);
342 c->TraceSinkBoolean(
false, isError);
348 <<
" is not a valid output type for this statistics.");
357 std::map<const Address, uint32_t>::const_iterator it =
m_identifierMap.find(fromOrTo);
361 NS_LOG_WARN(
this <<
" discarding " << nPackets <<
" packets"
362 <<
" from statistics collection because of"
363 <<
" unknown sender/destination address " << fromOrTo);
369 NS_ASSERT_MSG(collector !=
nullptr,
370 "Unable to find collector with identifier " << it->second);
376 Ptr<ScalarCollector> c = collector->GetObject<ScalarCollector>();
377 NS_ASSERT(c !=
nullptr);
378 c->TraceSinkBoolean(
false, isError);
384 Ptr<IntervalRateCollector> c = collector->GetObject<IntervalRateCollector>();
385 NS_ASSERT(c !=
nullptr);
386 c->TraceSinkBoolean(
false, isError);
392 <<
" is not a valid output type for this statistics.");
406 NS_LOG_FUNCTION(
this << probe << probe->GetName() << identifier);
417 &ScalarCollector::TraceSinkBoolean);
425 &IntervalRateCollector::TraceSinkBoolean);
430 <<
" is not a valid output type for this statistics.");
437 NS_LOG_INFO(
this <<
" created probe " << probe->GetName() <<
", connected to collector "
442 NS_LOG_WARN(
this <<
" unable to connect probe " << probe->GetName() <<
" to collector "
452 NS_LOG_FUNCTION(
this << probe << probe->GetName() << identifier);
463 &ScalarCollector::TraceSinkBoolean);
471 &IntervalRateCollector::TraceSinkBoolean);
476 <<
" is not a valid output type for this statistics.");
483 NS_LOG_INFO(
this <<
" probe " << probe->GetName() <<
", disconnected from collector "
488 NS_LOG_WARN(
this <<
" unable to disconnect probe " << probe->GetName() <<
" from collector "
498 NS_LOG_FUNCTION(
this);
500 std::map<Ptr<Probe>, std::pair<Ptr<Node>, uint32_t>>::iterator it;
504 Ptr<Probe> probe = it->first;
505 Ptr<Node> node = it->second.first;
506 uint32_t identifier = it->second.second;
510 NS_FATAL_ERROR(
"Error disconnecting trace file on handover");
517 NS_FATAL_ERROR(
"Error connecting trace file on handover");
520 it->second.second = identifier;
527 NS_LOG_FUNCTION(
this << gwNode->GetId());
530 Callback<void, uint32_t, const Address&, bool> callback =
533 for (NetDeviceContainer::Iterator itDev = devs.Begin(); itDev != devs.End(); ++itDev)
535 Ptr<SatNetDevice> satDev = (*itDev)->GetObject<
SatNetDevice>();
536 NS_ASSERT(satDev !=
nullptr);
537 Ptr<SatPhy> satPhy = satDev->GetPhy();
538 NS_ASSERT(satPhy !=
nullptr);
539 Ptr<SatPhyRx> satPhyRx = satPhy->GetPhyRx();
540 NS_ASSERT(satPhyRx !=
nullptr);
541 ObjectVectorValue carriers;
542 satPhyRx->GetAttribute(
"RxCarrierList", carriers);
543 NS_LOG_DEBUG(
this <<
" Node ID " << gwNode->GetId() <<
" device #" << (*itDev)->GetIfIndex()
544 <<
" has " << carriers.GetN() <<
" RX carriers");
546 for (ObjectVectorValue::Iterator itCarrier = carriers.Begin(); itCarrier != carriers.End();
549 if (DynamicCast<SatPhyRxCarrier>(itCarrier->second)->GetCarrierType() !=
558 NS_LOG_INFO(
this <<
" successfully connected with node ID " << gwNode->GetId()
559 <<
" device #" << (*itDev)->GetIfIndex() <<
" RX carrier #"
560 << itCarrier->first);
565 <<
" of SatPhyRxCarrier"
566 <<
" at node ID " << gwNode->GetId()
567 <<
" device #" << (*itDev)->GetIfIndex()
568 <<
" RX carrier #" << itCarrier->first);
580 NS_LOG_FUNCTION(
this << satNode->GetId());
583 Callback<void, uint32_t, const Address&, bool> callback =
588 NS_ASSERT(satOrbiterDev !=
nullptr);
589 std::map<uint32_t, Ptr<SatPhy>> satOrbiterFeederPhys = satOrbiterDev->GetFeederPhy();
590 for (std::map<uint32_t, Ptr<SatPhy>>::iterator itPhy = satOrbiterFeederPhys.begin();
591 itPhy != satOrbiterFeederPhys.end();
594 satPhy = itPhy->second;
595 NS_ASSERT(satPhy !=
nullptr);
596 Ptr<SatPhyRx> satPhyRx = satPhy->GetPhyRx();
597 NS_ASSERT(satPhyRx !=
nullptr);
599 ObjectVectorValue carriers;
600 satPhyRx->GetAttribute(
"RxCarrierList", carriers);
601 NS_LOG_DEBUG(
this <<
" Node ID " << satNode->GetId() <<
" device #" << dev->GetIfIndex()
602 <<
" has " << carriers.GetN() <<
" RX carriers");
604 for (ObjectVectorValue::Iterator itCarrier = carriers.Begin(); itCarrier != carriers.End();
607 if (DynamicCast<SatPhyRxCarrier>(itCarrier->second)->GetCarrierType() !=
616 NS_LOG_INFO(
this <<
" successfully connected with node ID " << satNode->GetId()
617 <<
" device #" << dev->GetIfIndex() <<
" RX carrier #"
618 << itCarrier->first);
623 <<
" of SatPhyRxCarrier"
624 <<
" at node ID " << satNode->GetId()
625 <<
" device #" << dev->GetIfIndex()
626 <<
" RX carrier #" << itCarrier->first);
638 NS_LOG_FUNCTION(
this << satNode->GetId());
641 Callback<void, uint32_t, const Address&, bool> callback =
646 NS_ASSERT(satOrbiterDev !=
nullptr);
647 std::map<uint32_t, Ptr<SatPhy>> satOrbiterUserPhys = satOrbiterDev->GetUserPhy();
648 for (std::map<uint32_t, Ptr<SatPhy>>::iterator itPhy = satOrbiterUserPhys.begin();
649 itPhy != satOrbiterUserPhys.end();
652 satPhy = itPhy->second;
653 NS_ASSERT(satPhy !=
nullptr);
654 Ptr<SatPhyRx> satPhyRx = satPhy->GetPhyRx();
655 NS_ASSERT(satPhyRx !=
nullptr);
657 ObjectVectorValue carriers;
658 satPhyRx->GetAttribute(
"RxCarrierList", carriers);
659 NS_LOG_DEBUG(
this <<
" Node ID " << satNode->GetId() <<
" device #" << dev->GetIfIndex()
660 <<
" has " << carriers.GetN() <<
" RX carriers");
662 for (ObjectVectorValue::Iterator itCarrier = carriers.Begin(); itCarrier != carriers.End();
665 if (DynamicCast<SatPhyRxCarrier>(itCarrier->second)->GetCarrierType() !=
674 NS_LOG_INFO(
this <<
" successfully connected with node ID " << satNode->GetId()
675 <<
" device #" << dev->GetIfIndex() <<
" RX carrier #"
676 << itCarrier->first);
681 <<
" of SatPhyRxCarrier"
682 <<
" at node ID " << satNode->GetId()
683 <<
" device #" << dev->GetIfIndex()
684 <<
" RX carrier #" << itCarrier->first);
696 NS_LOG_FUNCTION(
this << utNode->GetId());
698 const int32_t utId =
GetUtId(utNode);
699 NS_ASSERT_MSG(utId > 0,
"Node " << utNode->GetId() <<
" is not a valid UT");
703 std::ostringstream probeName;
705 Ptr<SatPhyRxCarrierPacketProbe> probe = CreateObject<SatPhyRxCarrierPacketProbe>();
706 probe->SetName(probeName.str());
709 Ptr<SatNetDevice> satDev = dev->GetObject<
SatNetDevice>();
710 NS_ASSERT(satDev !=
nullptr);
711 Ptr<SatPhy> satPhy = satDev->GetPhy();
712 NS_ASSERT(satPhy !=
nullptr);
713 Ptr<SatPhyRx> satPhyRx = satPhy->GetPhyRx();
714 NS_ASSERT(satPhyRx !=
nullptr);
715 ObjectVectorValue carriers;
716 satPhyRx->GetAttribute(
"RxCarrierList", carriers);
717 NS_LOG_DEBUG(
this <<
" Node ID " << utNode->GetId() <<
" device #" << dev->GetIfIndex()
718 <<
" has " << carriers.GetN() <<
" RX carriers");
720 for (ObjectVectorValue::Iterator itCarrier = carriers.Begin(); itCarrier != carriers.End();
723 if (DynamicCast<SatPhyRxCarrier>(itCarrier->second)->GetCarrierType() !=
733 std::make_pair(probe->GetObject<Probe>(), std::make_pair(utNode, identifier)));
739 <<
" of SatPhyRxCarrier"
740 <<
" at node ID " << utNode->GetId()
741 <<
" device #" << dev->GetIfIndex()
742 <<
" RX carrier #" << itCarrier->first);
754 Ptr<const SatHelper> satHelper)
757 NS_LOG_FUNCTION(
this << satHelper);
765 NS_LOG_FUNCTION(
this);
781 Ptr<const SatHelper> satHelper)
784 NS_LOG_FUNCTION(
this << satHelper);
792 NS_LOG_FUNCTION(
this);
808 Ptr<const SatHelper> satHelper)
811 NS_LOG_FUNCTION(
this << satHelper);
819 NS_LOG_FUNCTION(
this);
835 Ptr<const SatHelper> satHelper)
838 NS_LOG_FUNCTION(
this << satHelper);
846 NS_LOG_FUNCTION(
this);
862 Ptr<const SatHelper> satHelper)
865 NS_LOG_FUNCTION(
this << satHelper);
873 NS_LOG_FUNCTION(
this);
879 static TypeId tid = TypeId(
"ns3::SatStatsFeederSlottedAlohaPacketErrorHelper")
889 Ptr<const SatHelper> satHelper)
892 NS_LOG_FUNCTION(
this << satHelper);
900 NS_LOG_FUNCTION(
this);
906 static TypeId tid = TypeId(
"ns3::SatStatsUserSlottedAlohaPacketErrorHelper")
916 Ptr<const SatHelper> satHelper)
919 NS_LOG_FUNCTION(
this << satHelper);
927 NS_LOG_FUNCTION(
this);
943 Ptr<const SatHelper> satHelper)
946 NS_LOG_FUNCTION(
this << satHelper);
954 NS_LOG_FUNCTION(
this);
970 Ptr<const SatHelper> satHelper)
973 NS_LOG_FUNCTION(
this << satHelper);
981 NS_LOG_FUNCTION(
this);
999 NS_LOG_FUNCTION(
this << satHelper);
1007 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)
SatNetDevice to be utilized in the UT and GW nodes.
SatOrbiterNetDevice to be utilized in geostationary satellite.
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.
static Ptr< NetDevice > GetSatSatOrbiterNetDevice(Ptr< Node > satNode)
uint32_t GetIdentifierForUtUser(Ptr< Node > utUserNode) const
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 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::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
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
virtual void UpdateIdentifierOnProbes()
Change identifier used on probes, when handovers occur.
void InstallProbeOnGw(Ptr< Node > gwNode)
Set up several listeners on a GW node and connect them to the collectors.
std::map< Ptr< Probe >, std::pair< Ptr< Node >, uint32_t > > m_probes
Maintains a list of probes created by this helper (for forward link).
Ptr< DataCollectionObject > m_aggregator
The aggregator created by this helper.
SatPhyRxCarrier::CarrierType GetValidCarrierType() const
Get the valid carrier type.
bool DisconnectProbeFromCollector(Ptr< Probe > probe, uint32_t identifier)
Disconnect the probe from the right collector.
SatStatsPacketErrorHelper(Ptr< const SatHelper > satHelper)
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)
bool ConnectProbeToCollector(Ptr< Probe > probe, uint32_t identifier)
Connect the probe to the right collector.
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.