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/satellite-topology.h"
39#include "ns3/scalar-collector.h"
40#include "ns3/singleton.h"
41#include "ns3/string.h"
48NS_LOG_COMPONENT_DEFINE(
"SatStatsBeamServiceTimeHelper");
58 NS_LOG_FUNCTION(
this << satHelper);
63 NS_LOG_FUNCTION(
this);
69 static TypeId tid = TypeId(
"ns3::SatStatsBeamServiceTimeHelper").SetParent<
SatStatsHelper>();
76 NS_LOG_FUNCTION(
this);
81 <<
" is not a valid output type for this statistics.");
87 <<
" is not a valid identifier type for this statistics.");
91 std::string dataLabel =
"service_time";
98 "EnableContextPrinting",
101 StringValue(
"% beam_id service_time"));
104 NS_LOG_INFO(
this <<
" Creating new collectors for beams");
107 m_collectorMap.SetAttribute(
"OutputType", EnumValue(ScalarCollector::OUTPUT_TYPE_SUM));
109 EnumValue(ScalarCollector::INPUT_DATA_TYPE_DOUBLE));
112 Callback<void, std::string, Time> beamServiceCallback =
116 NodeContainer gwNodes = Singleton<SatTopology>::Get()->GetGwNodes();
117 for (
auto node = gwNodes.Begin(); node != gwNodes.End(); node++)
119 for (uint32_t i = 0; i < (*node)->GetNDevices(); i++)
121 Ptr<SatNetDevice> dev = DynamicCast<SatNetDevice>((*node)->GetDevice(i));
126 Ptr<SatMac> mac = dev->GetMac();
133 uint32_t beamId = mac->GetBeamId();
134 std::ostringstream context;
137 mac->TraceConnect(
"BeamServiceTime", context.str(), beamServiceCallback);
138 NS_ASSERT_MSG(ret,
"Error connecting to BeamServiceTime of beam " << beamId);
139 NS_LOG_INFO(
this <<
" successfully connected" <<
" with beam " << beamId);
148 NS_LOG_FUNCTION(
this << context << time.GetSeconds());
151 std::stringstream ss(context);
155 NS_FATAL_ERROR(
"Cannot convert '" << context <<
"' to number");
161 std::ostringstream name;
168 o->TraceConnect(
"Output",
170 MakeCallback(&MultiFileAggregator::Write1d,
175 Ptr<ScalarCollector> s = o->GetObject<ScalarCollector>();
176 NS_ASSERT(s !=
nullptr);
179 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)
IdentifierType_t GetIdentifierType() const
static std::string GetOutputTypeName(OutputType_t outputType)
SatStatsHelper(Ptr< const SatHelper > satHelper)
Creates a new helper instance.
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.