24 #include <ns3/address.h>
25 #include <ns3/collector-map.h>
26 #include <ns3/data-collection-object.h>
29 #include <ns3/mac48-address.h>
30 #include <ns3/node-container.h>
31 #include <ns3/object-factory.h>
32 #include <ns3/satellite-beam-helper.h>
33 #include <ns3/satellite-const-variables.h>
34 #include <ns3/satellite-env-variables.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-user-helper.h>
39 #include <ns3/singleton.h>
40 #include <ns3/string.h>
41 #include <ns3/type-id.h>
45 NS_LOG_COMPONENT_DEFINE(
"SatStatsHelper");
50 NS_OBJECT_ENSURE_REGISTERED(SatStatsHelper);
55 switch (identifierType)
58 return "IDENTIFIER_GLOBAL";
60 return "IDENTIFIER_GW";
62 return "IDENTIFIER_BEAM";
64 return "IDENTIFIER_UT";
66 return "IDENTIFIER_UT_USER";
68 return "IDENTIFIER_SLICE";
70 return "IDENTIFIER_GROUP";
72 return "IDENTIFIER_SAT";
74 return "IDENTIFIER_ISL";
76 NS_FATAL_ERROR(
"SatStatsHelper - Invalid identifier type");
80 NS_FATAL_ERROR(
"SatStatsHelper - Invalid identifier type");
92 return "OUTPUT_SCALAR_FILE";
94 return "OUTPUT_SCATTER_FILE";
96 return "OUTPUT_HISTOGRAM_FILE";
98 return "OUTPUT_PDF_FILE";
100 return "OUTPUT_CDF_FILE";
102 return "OUTPUT_SCALAR_PLOT";
104 return "OUTPUT_SCATTER_PLOT";
106 return "OUTPUT_HISTOGRAM_PLOT";
108 return "OUTPUT_PDF_PLOT";
110 return "OUTPUT_CDF_PLOT";
112 NS_FATAL_ERROR(
"SatStatsHelper - Invalid output type");
116 NS_FATAL_ERROR(
"SatStatsHelper - Invalid output type");
124 m_isInstalled(false),
125 m_satHelper(satHelper)
127 NS_LOG_FUNCTION(
this << satHelper);
132 NS_LOG_FUNCTION(
this);
139 TypeId(
"ns3::SatStatsHelper")
141 .AddAttribute(
"Name",
142 "String to be prepended on every output file name.",
146 .AddAttribute(
"IdentifierType",
147 "Determines how the statistics are categorized.",
171 "Determines the type and format of the output.",
200 NS_LOG_FUNCTION(
this);
204 NS_LOG_WARN(
this <<
" Skipping statistics installation"
205 <<
" because OUTPUT_NONE output type is selected.");
217 NS_LOG_FUNCTION(
this << name);
220 for (
size_t pos = name.find_first_of(
" /"); pos != std::string::npos;
221 pos = name.find_first_of(
" /", pos + 1, 1))
242 NS_LOG_WARN(
this <<
" cannot modify the current identifier type"
244 <<
" because this instance have already been installed");
265 NS_LOG_WARN(
this <<
" cannot modify the current output type"
267 <<
" because this instance have already been installed");
293 Ptr<DataCollectionObject>
296 const AttributeValue& v1,
298 const AttributeValue& v2,
300 const AttributeValue& v3,
302 const AttributeValue& v4,
304 const AttributeValue& v5)
306 NS_LOG_FUNCTION(
this << aggregatorTypeId);
308 TypeId tid = TypeId::LookupByName(aggregatorTypeId);
309 ObjectFactory factory;
310 factory.SetTypeId(tid);
316 return factory.Create()->GetObject<DataCollectionObject>();
322 NS_LOG_FUNCTION(
this);
328 collectorMap.SetAttribute(
"Name", StringValue(
"0"));
329 collectorMap.Create(0);
335 NodeContainer gws =
m_satHelper->GetBeamHelper()->GetGwNodes();
336 for (NodeContainer::Iterator it = gws.Begin(); it != gws.End(); ++it)
338 const uint32_t gwId =
GetGwId(*it);
339 std::ostringstream name;
341 collectorMap.SetAttribute(
"Name", StringValue(name.str()));
342 collectorMap.Create(gwId);
349 std::list<std::pair<uint32_t, uint32_t>> beams =
m_satHelper->GetBeamHelper()->GetBeams();
350 for (std::list<std::pair<uint32_t, uint32_t>>::const_iterator it = beams.begin();
354 const uint32_t satId = (it->first);
355 const uint32_t beamId = (it->second);
356 std::ostringstream name;
357 name << (satId + 1) <<
"-" << beamId;
358 collectorMap.SetAttribute(
"Name", StringValue(name.str()));
366 std::list<uint32_t> groups =
m_satHelper->GetGroupHelper()->GetGroups();
368 for (std::list<uint32_t>::const_iterator it = groups.begin(); it != groups.end(); ++it)
370 const uint32_t groupId = (*it);
371 std::ostringstream name;
373 collectorMap.SetAttribute(
"Name", StringValue(name.str()));
374 collectorMap.Create(groupId);
381 NodeContainer uts =
m_satHelper->GetBeamHelper()->GetUtNodes();
382 for (NodeContainer::Iterator it = uts.Begin(); it != uts.End(); ++it)
384 const uint32_t utId =
GetUtId(*it);
385 std::ostringstream name;
387 collectorMap.SetAttribute(
"Name", StringValue(name.str()));
388 collectorMap.Create(utId);
396 for (NodeContainer::Iterator it = utUsers.Begin(); it != utUsers.End(); ++it)
399 std::ostringstream name;
401 collectorMap.SetAttribute(
"Name", StringValue(name.str()));
402 collectorMap.Create(utUserId);
409 for (uint32_t sliceId = 0; sliceId < 256; sliceId++)
411 std::ostringstream name;
413 collectorMap.SetAttribute(
"Name", StringValue(name.str()));
414 collectorMap.Create(sliceId);
421 NodeContainer sats =
GetSatHelper()->GetBeamHelper()->GetGeoSatNodes();
423 for (NodeContainer::Iterator it = sats.Begin(); it != sats.End(); ++it)
425 const uint32_t satId =
GetSatId(*it);
426 std::ostringstream name;
428 collectorMap.SetAttribute(
"Name", StringValue(name.str()));
429 collectorMap.Create(satId);
436 NodeContainer sats =
GetSatHelper()->GetBeamHelper()->GetGeoSatNodes();
438 for (NodeContainer::Iterator it = sats.Begin(); it != sats.End(); ++it)
440 Ptr<SatGeoNetDevice> satGeoNetDevice =
442 const uint32_t satSrcId =
GetSatId(*it);
443 std::vector<Ptr<PointToPointIslNetDevice>> islNetDevices =
444 satGeoNetDevice->GetIslsNetDevices();
445 for (std::vector<Ptr<PointToPointIslNetDevice>>::iterator itIsl = islNetDevices.begin();
446 itIsl != islNetDevices.end();
449 Ptr<PointToPointIslNetDevice> islNetDevice = *itIsl;
450 const uint32_t satDstId =
GetSatId(islNetDevice->GetDestinationNode());
451 std::ostringstream name;
452 name << satSrcId <<
"-" << satDstId;
453 collectorMap.SetAttribute(
"Name", StringValue(name.str()));
462 NS_FATAL_ERROR(
"SatStatsHelper - Invalid identifier type");
466 NS_LOG_INFO(
this <<
" created " << n <<
" instance(s)"
467 <<
" of " << collectorMap.GetType().GetName() <<
" for "
477 return Singleton<SatEnvVariables>::Get()->GetOutputPath();
492 return "% global " + dataLabel;
495 return "% gw_id " + dataLabel;
498 return "% beam_id " + dataLabel;
501 return "% group_id " + dataLabel;
504 return "% ut_id " + dataLabel;
507 return "% ut_user_id " + dataLabel;
510 return "% slice_id " + dataLabel;
513 return "% sat_id " + dataLabel;
516 return "% isl_id " + dataLabel;
519 NS_FATAL_ERROR(
"SatStatsHelper - Invalid identifier type");
528 return "% time_sec " + dataLabel;
534 return "% " + dataLabel +
" freq";
543 const SatIdMapper* satIdMapper = Singleton<SatIdMapper>::Get();
546 if (addr.IsInvalid())
548 NS_LOG_WARN(
this <<
" Node " << utUserNode->GetId()
549 <<
" does not have any valid Mac48Address");
557 NS_LOG_WARN(
this <<
" Node " << utUserNode->GetId()
558 <<
" is not found in the global list of UT users");
573 const SatIdMapper* satIdMapper = Singleton<SatIdMapper>::Get();
576 if (addr.IsInvalid())
578 NS_LOG_WARN(
this <<
" Node " << utNode->GetId() <<
" does not have any valid Mac48Address");
586 NS_LOG_WARN(
this <<
" Node " << utNode->GetId()
587 <<
" is not found in the global list of UTs");
602 const SatIdMapper* satIdMapper = Singleton<SatIdMapper>::Get();
605 if (addr.IsInvalid())
607 NS_LOG_WARN(
this <<
" Node " << gwNode->GetId() <<
" does not have any valid Mac48Address");
615 NS_LOG_WARN(
this <<
" Node " << gwNode->GetId()
616 <<
" is not found in the global list of GWs");
631 const SatIdMapper* satIdMapper = Singleton<SatIdMapper>::Get();
634 if (addr.IsInvalid())
636 NS_LOG_WARN(
this <<
" Node " << satNode->GetId()
637 <<
" does not have any valid Mac48Address");
645 NS_LOG_WARN(
this <<
" Node " << satNode->GetId()
646 <<
" is not found in the global list of SATs");
669 Ptr<Node> utNode =
m_satHelper->GetUserHelper()->GetUtNode(utUserNode);
671 if (utNode ==
nullptr)
673 NS_LOG_WARN(
this <<
" UT user node " << utUserNode->GetId()
674 <<
" is not attached to any UT node");
678 const SatIdMapper* satIdMapper = Singleton<SatIdMapper>::Get();
681 if (!utMac.IsInvalid())
685 NS_ASSERT_MSG(satId != -1,
686 "UT user node " << utUserNode->GetId()
687 <<
" is not attached to any sat");
688 NS_ASSERT_MSG(beamId != -1,
689 "UT user node " << utUserNode->GetId()
690 <<
" is not attached to any beam");
691 const uint32_t gwId =
m_satHelper->GetBeamHelper()->GetGwId(satId - 1, beamId);
692 NS_ASSERT_MSG(gwId != 0,
693 "UT user node " << utUserNode->GetId()
694 <<
" is not attached to any GW");
703 Ptr<Node> utNode =
m_satHelper->GetUserHelper()->GetUtNode(utUserNode);
705 const SatIdMapper* satIdMapper = Singleton<SatIdMapper>::Get();
708 if (!utMac.IsInvalid())
711 NS_ASSERT_MSG(satId != -1,
712 "UT node " << utNode->GetId() <<
" is not attached to any sat");
720 Ptr<Node> utNode =
m_satHelper->GetUserHelper()->GetUtNode(utUserNode);
722 if (utNode ==
nullptr)
724 NS_LOG_WARN(
this <<
" UT user node " << utUserNode->GetId()
725 <<
" is not attached to any UT node");
729 const SatIdMapper* satIdMapper = Singleton<SatIdMapper>::Get();
732 if (!utMac.IsInvalid())
736 NS_ASSERT_MSG(satId != -1,
737 "UT user node " << utUserNode->GetId()
738 <<
" is not attached to any sat");
739 NS_ASSERT_MSG(beamId != -1,
740 "UT user node " << utUserNode->GetId()
741 <<
" is not attached to any beam");
750 Ptr<Node> utNode =
m_satHelper->GetUserHelper()->GetUtNode(utUserNode);
752 if (utNode ==
nullptr)
754 NS_LOG_WARN(
this <<
" UT user node " << utUserNode->GetId()
755 <<
" is not attached to any UT node");
759 const SatIdMapper* satIdMapper = Singleton<SatIdMapper>::Get();
762 if (!utMac.IsInvalid())
773 Ptr<Node> utNode =
m_satHelper->GetUserHelper()->GetUtNode(utUserNode);
775 if (utNode ==
nullptr)
777 NS_LOG_WARN(
this <<
" UT user node " << utUserNode->GetId()
778 <<
" is not attached to any UT node");
794 <<
" is not valid for a UT user."
795 <<
" Assigning identifier 0 to this UT user.");
814 const SatIdMapper* satIdMapper = Singleton<SatIdMapper>::Get();
817 if (!utMac.IsInvalid())
821 NS_ASSERT_MSG(satId != -1,
822 "UT user node " << utNode->GetId() <<
" is not attached to any sat");
823 NS_ASSERT_MSG(beamId != -1,
824 "UT node " << utNode->GetId() <<
" is not attached to any beam");
825 const uint32_t gwId =
m_satHelper->GetBeamHelper()->GetGwId(satId - 1, beamId);
826 NS_ASSERT_MSG(gwId != 0,
"UT node " << utNode->GetId() <<
" is not attached to any GW");
834 const SatIdMapper* satIdMapper = Singleton<SatIdMapper>::Get();
837 if (!utMac.IsInvalid())
840 NS_ASSERT_MSG(satId != -1,
841 "UT node " << utNode->GetId() <<
" is not attached to any sat");
849 const SatIdMapper* satIdMapper = Singleton<SatIdMapper>::Get();
852 if (!utMac.IsInvalid())
856 NS_ASSERT_MSG(satId != -1,
857 "UT node " << utNode->GetId() <<
" is not attached to any sat");
858 NS_ASSERT_MSG(beamId != -1,
859 "UT node " << utNode->GetId() <<
" is not attached to any beam");
867 const SatIdMapper* satIdMapper = Singleton<SatIdMapper>::Get();
870 if (!utMac.IsInvalid())
885 <<
" is not valid for a UT."
886 <<
" Assigning identifier 0 to this UT.");
905 const uint32_t gwId =
m_satHelper->GetBeamHelper()->GetGwId(satId, beamId);
906 NS_ASSERT_MSG(gwId != 0,
"Beam " << beamId <<
" is not attached to any GW");
923 <<
" is not valid for a beam."
924 <<
" Assigning identifier 0 to this beam.");
948 <<
" is not valid for a group."
949 <<
" Assigning identifier 0 to this group.");
970 <<
" is not valid for a GW."
971 <<
" Assigning identifier 0 to this GW.");
990 <<
" is not valid for a SAT."
991 <<
" Assigning identifier 0 to this SAT.");
1010 <<
" is not valid for a ISL."
1011 <<
" Assigning identifier 0 to this ISL.");
1019 NetDeviceContainer ret;
1021 NS_LOG_DEBUG(
"Node ID " << gwNode->GetId() <<
" has " << gwNode->GetNDevices() <<
" devices");
1028 for (uint32_t i = 0; i < gwNode->GetNDevices(); i++)
1030 Ptr<SatNetDevice> dev = DynamicCast<SatNetDevice>(gwNode->GetDevice(i));
1048 NS_ASSERT(utNode->GetNDevices() >= 3);
1049 Ptr<NetDevice> dev = utNode->GetDevice(2);
1053 NS_FATAL_ERROR(
"Node " << utNode->GetId() <<
" is not a valid UT");
1062 NS_ASSERT(satNode->GetNDevices() > 0);
1063 Ptr<NetDevice> dev = satNode->GetDevice(0);
1067 NS_FATAL_ERROR(
"Node " << satNode->GetId() <<
" is not a valid SAT");
SatGeoNetDevice to be utilized in geostationary satellite.
int32_t GetBeamIdWithMac(Address mac) const
Function for getting the beam ID with MAC.
int32_t GetUtUserIdWithMac(Address mac) const
Function for getting the UT user ID with MAC.
int32_t GetSatIdWithMac(Address mac) const
Function for getting the SAT ID with MAC.
Address GetSatMacWithNode(Ptr< Node > satNode) const
int32_t GetGwIdWithMac(Address mac) const
Function for getting the GW ID with MAC.
int32_t GetUtIdWithMac(Address mac) const
Function for getting the UT ID with MAC.
Address GetGwMacWithNode(Ptr< Node > gwNode) const
Address GetUtMacWithNode(Ptr< Node > utNode) const
Address GetUtUserMacWithNode(Ptr< Node > utUserNode) const
int32_t GetGroupIdWithMac(Address mac) const
Function for getting the group ID with MAC.
SatNetDevice to be utilized in the UT and GW nodes.
Parent abstract class of all satellite statistics helpers.
Ptr< const SatHelper > m_satHelper
uint32_t GetIdentifierForBeam(uint32_t satId, uint32_t beamId) const
uint32_t GetIdentifierForGw(Ptr< Node > gwNode) const
uint32_t GetSatId(Ptr< Node > satNode) const
Ptr< const SatHelper > GetSatHelper() const
uint32_t GetIdentifierForUtUser(Ptr< Node > utUserNode) const
static NetDeviceContainer GetGwSatNetDevice(Ptr< Node > gwNode)
IdentifierType_t m_identifierType
void SetIdentifierType(IdentifierType_t identifierType)
void SetName(std::string name)
IdentifierType_t GetIdentifierType() const
virtual ~SatStatsHelper()
/ Destructor.
static std::string GetOutputTypeName(OutputType_t outputType)
SatStatsHelper(Ptr< const SatHelper > satHelper)
Creates a new helper instance.
static Ptr< NetDevice > GetSatSatGeoNetDevice(Ptr< Node > satNode)
virtual std::string GetIdentifierHeading(std::string dataLabel) const
virtual std::string GetOutputPath() const
OutputType_t m_outputType
static std::string GetIdentifierTypeName(IdentifierType_t identifierType)
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.
static TypeId GetTypeId()
inherited from ObjectBase base class
uint32_t GetIdentifierForGroup(uint32_t groupId) const
uint32_t GetUtId(Ptr< Node > utNode) const
void SetOutputType(OutputType_t outputType)
uint32_t CreateCollectorPerIdentifier(CollectorMap &collectorMap) const
Create one collector instance for each identifier in the simulation.
virtual void DoInstall()=0
Install the probes, collectors, and aggregators necessary to produce the statistics output.
OutputType_t
Possible types and formats of statistics output.
uint32_t GetIdentifierForSat(Ptr< Node > satNode) const
static Ptr< NetDevice > GetUtSatNetDevice(Ptr< Node > utNode)
void Install()
Install the probes, collectors, and aggregators necessary to produce the statistics output.
uint32_t GetIdentifierForIsl(Ptr< Node > satNodeSrc, Ptr< Node > satNodeDst) const
OutputType_t GetOutputType() const
uint32_t GetIdentifierForUt(Ptr< Node > utNode) const
IdentifierType_t
Possible categorization of statistics output.
uint32_t GetUtUserId(Ptr< Node > utUserNode) const
std::string GetName() const
uint32_t GetGwId(Ptr< Node > gwNode) const
virtual std::string GetTimeHeading(std::string dataLabel) const
virtual std::string GetDistributionHeading(std::string dataLabel) const
constexpr uint32_t MAX_BEAMS_PER_SATELLITE
Maximum number of beams per satellite.
constexpr uint32_t MAX_SATELLITES
Maximum number of satellites in constellation.
SatArqSequenceNumber is handling the sequence numbers for the ARQ process.