24 #include <ns3/boolean.h>
25 #include <ns3/callback.h>
26 #include <ns3/data-collection-object.h>
27 #include <ns3/distribution-collector.h>
29 #include <ns3/fatal-error.h>
31 #include <ns3/multi-file-aggregator.h>
32 #include <ns3/node-container.h>
33 #include <ns3/satellite-beam-helper.h>
34 #include <ns3/satellite-beam-scheduler.h>
35 #include <ns3/satellite-gw-mac.h>
36 #include <ns3/satellite-helper.h>
37 #include <ns3/satellite-ncc.h>
38 #include <ns3/scalar-collector.h>
39 #include <ns3/string.h>
45 NS_LOG_COMPONENT_DEFINE(
"SatStatsBeamServiceTimeHelper");
50 NS_OBJECT_ENSURE_REGISTERED(SatStatsBeamServiceTimeHelper);
55 NS_LOG_FUNCTION(
this << satHelper);
60 NS_LOG_FUNCTION(
this);
66 static TypeId tid = TypeId(
"ns3::SatStatsBeamServiceTimeHelper").SetParent<
SatStatsHelper>();
73 NS_LOG_FUNCTION(
this);
78 <<
" is not a valid output type for this statistics.");
84 <<
" is not a valid identifier type for this statistics.");
88 std::string dataLabel =
"service_time";
95 "EnableContextPrinting",
98 StringValue(
"% beam_id service_time"));
101 NS_LOG_INFO(
this <<
" Creating new collectors for beams");
104 m_collectorMap.SetAttribute(
"OutputType", EnumValue(ScalarCollector::OUTPUT_TYPE_SUM));
106 EnumValue(ScalarCollector::INPUT_DATA_TYPE_DOUBLE));
109 Callback<void, std::string, Time> beamServiceCallback =
113 NodeContainer gwNodes =
GetSatHelper()->GetBeamHelper()->GetGwNodes();
114 for (
auto node = gwNodes.Begin(); node != gwNodes.End(); node++)
116 for (uint32_t i = 0; i < (*node)->GetNDevices(); i++)
118 Ptr<SatNetDevice> dev = DynamicCast<SatNetDevice>((*node)->GetDevice(i));
121 Ptr<SatMac> mac = dev->GetMac();
126 uint32_t beamId = mac->GetBeamId();
127 std::ostringstream context;
130 mac->TraceConnect(
"BeamServiceTime", context.str(), beamServiceCallback);
131 NS_ASSERT_MSG(ret,
"Error connecting to BeamServiceTime of beam " << beamId);
132 NS_LOG_INFO(
this <<
" successfully connected"
133 <<
" with beam " << beamId);
142 NS_LOG_FUNCTION(
this << context << time.GetSeconds());
145 std::stringstream ss(context);
149 NS_FATAL_ERROR(
"Cannot convert '" << context <<
"' to number");
155 std::ostringstream name;
162 o->TraceConnect(
"Output",
164 MakeCallback(&MultiFileAggregator::Write1d,
169 Ptr<ScalarCollector> s = o->GetObject<ScalarCollector>();
170 NS_ASSERT(s !=
nullptr);
173 s->TraceSinkDouble(0, time.GetSeconds());
void DoInstall()
Install the probes, collectors, and aggregators necessary to produce the statistics output.
static TypeId GetTypeId()
inherited from ObjectBase base class
CollectorMap m_collectorMap
Two-dimensional map of collectors, indexed first by the the frame type identifier and second by the g...
SatStatsBeamServiceTimeHelper(Ptr< const SatHelper > satHelper)
Constructor.
virtual ~SatStatsBeamServiceTimeHelper()
/ Destructor.
Ptr< DataCollectionObject > m_aggregator
The aggregator created by this helper.
void BeamServiceCallback(std::string context, Time time)
Parent abstract class of all satellite statistics helpers.
Ptr< const SatHelper > GetSatHelper() const
IdentifierType_t GetIdentifierType() const
static std::string GetOutputTypeName(OutputType_t 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.
OutputType_t GetOutputType() const
SatArqSequenceNumber is handling the sequence numbers for the ARQ process.