24 #include <ns3/boolean.h>
25 #include <ns3/callback.h>
26 #include <ns3/data-collection-object.h>
28 #include <ns3/fatal-error.h>
30 #include <ns3/multi-file-aggregator.h>
31 #include <ns3/node-container.h>
32 #include <ns3/satellite-beam-helper.h>
33 #include <ns3/satellite-beam-scheduler.h>
34 #include <ns3/satellite-frame-symbol-load-probe.h>
35 #include <ns3/satellite-frame-user-load-probe.h>
36 #include <ns3/satellite-helper.h>
37 #include <ns3/satellite-ncc.h>
38 #include <ns3/scalar-collector.h>
39 #include <ns3/string.h>
43 NS_LOG_COMPONENT_DEFINE(
"SatStatsFrameLoadHelper");
48 NS_OBJECT_ENSURE_REGISTERED(SatStatsFrameLoadHelper);
56 return "UNIT_SYMBOLS";
60 NS_FATAL_ERROR(
"SatStatsFrameLoadHelper - Invalid unit type");
64 NS_FATAL_ERROR(
"SatStatsFrameLoadHelper - Invalid unit type");
73 m_objectTraceSourceName(
""),
74 m_probeTraceSourceName(
"")
76 NS_LOG_FUNCTION(
this << satHelper);
81 NS_LOG_FUNCTION(
this);
87 static TypeId tid = TypeId(
"ns3::SatStatsFrameLoadHelper").SetParent<
SatStatsHelper>();
101 m_longLabel =
"Number of allocated symbols over total number of symbols";
114 NS_FATAL_ERROR(
"SatStatsFrameLoadHelper - Invalid unit type");
127 NS_LOG_FUNCTION(
this);
132 <<
" is not a valid output type for this statistics.");
139 <<
" is not a valid identifier type for this statistics.");
148 "EnableContextPrinting",
154 Ptr<SatBeamHelper> beamHelper =
GetSatHelper()->GetBeamHelper();
155 NS_ASSERT(beamHelper !=
nullptr);
156 Ptr<SatNcc> ncc = beamHelper->GetNcc();
157 NS_ASSERT(ncc !=
nullptr);
158 std::list<std::pair<uint32_t, uint32_t>> beams = beamHelper->GetBeams();
161 for (std::list<std::pair<uint32_t, uint32_t>>::const_iterator it = beams.begin();
167 ret = SetupProbe<SatFrameSymbolLoadProbe>(
168 ncc->GetBeamScheduler(it->first, it->second),
176 SetupProbe<SatFrameUserLoadProbe>(ncc->GetBeamScheduler(it->first, it->second),
183 NS_LOG_INFO(
this <<
" successfully connected"
184 <<
" with beam " << it->second);
188 NS_LOG_WARN(
this <<
" unable to connect to beam " << it->second);
201 return "% global frame_number " + dataLabel;
204 return "% gw_id frame_number " + dataLabel;
207 return "% beam_id frame_number " + dataLabel;
210 NS_FATAL_ERROR(
"SatStatsFrameLoadHelper - Invalid identifier type");
224 Ptr<ScalarCollector> collector =
GetCollector(frameId, context);
225 NS_ASSERT_MSG(collector !=
nullptr,
226 "Unable to get/create collector"
227 <<
" for frame ID " << frameId <<
" and beam " << context);
230 collector->TraceSinkDouble(0, loadRatio);
241 Ptr<ScalarCollector> collector =
GetCollector(frameId, context);
242 NS_ASSERT_MSG(collector !=
nullptr,
243 "Unable to get/create collector"
244 <<
" for frame ID " << frameId <<
" and identifier " << context);
247 collector->TraceSinkUinteger32(0, utCount);
256 std::stringstream ss(identifier);
257 uint32_t identifierNum;
258 if (!(ss >> identifierNum))
260 NS_FATAL_ERROR(
"Cannot convert '" << identifier <<
"' to number");
263 std::map<uint32_t, CollectorMap>::iterator it =
m_collectors.find(frameId);
268 CollectorMap collectorMap;
269 collectorMap.SetType(
"ns3::ScalarCollector");
272 collectorMap.SetAttribute(
"InputDataType",
273 EnumValue(ScalarCollector::INPUT_DATA_TYPE_DOUBLE));
274 collectorMap.SetAttribute(
"OutputType",
275 EnumValue(ScalarCollector::OUTPUT_TYPE_AVERAGE_PER_SAMPLE));
280 collectorMap.SetAttribute(
"InputDataType",
281 EnumValue(ScalarCollector::INPUT_DATA_TYPE_UINTEGER));
282 collectorMap.SetAttribute(
"OutputType", EnumValue(ScalarCollector::OUTPUT_TYPE_SUM));
294 std::ostringstream name;
295 name <<
"0 " << frameId;
296 collectorMap.SetAttribute(
"Name", StringValue(name.str()));
297 collectorMap.Create(0);
303 NodeContainer gws =
GetSatHelper()->GetBeamHelper()->GetGwNodes();
304 for (NodeContainer::Iterator it = gws.Begin(); it != gws.End(); ++it)
306 const uint32_t gwId =
GetGwId(*it);
307 std::ostringstream name;
308 name << gwId <<
" " << frameId;
309 collectorMap.SetAttribute(
"Name", StringValue(name.str()));
310 collectorMap.Create(gwId);
317 std::list<std::pair<uint32_t, uint32_t>> beams =
319 for (std::list<std::pair<uint32_t, uint32_t>>::const_iterator it = beams.begin();
323 const uint32_t satId = (it->first);
324 const uint32_t beamId = (it->second);
325 std::ostringstream name;
326 name << satId <<
"-" << beamId <<
" " << frameId;
327 collectorMap.SetAttribute(
"Name", StringValue(name.str()));
336 NS_FATAL_ERROR(
"SatStatsFrameLoadHelper - Invalid identifier type");
340 collectorMap.ConnectToAggregator(
"Output",
m_aggregator, &MultiFileAggregator::Write1d);
341 NS_LOG_INFO(
this <<
" created " << n <<
" instance(s)"
342 <<
" of " << collectorMap.GetType().GetName() <<
" for "
345 std::pair<std::map<uint32_t, CollectorMap>::iterator,
bool> ret;
346 ret =
m_collectors.insert(std::make_pair(frameId, collectorMap));
347 NS_ASSERT(ret.second);
355 Ptr<DataCollectionObject> collector = it->second.Get(identifierNum);
356 NS_ASSERT_MSG(collector !=
nullptr,
"Unable to find collector with identifier " << identifier);
357 Ptr<ScalarCollector> c = collector->GetObject<ScalarCollector>();
369 NS_LOG_FUNCTION(
this << satHelper);
375 NS_LOG_FUNCTION(
this);
393 NS_LOG_FUNCTION(
this << satHelper);
399 NS_LOG_FUNCTION(
this);
Helper for frame load statistics.
static TypeId GetTypeId()
inherited from ObjectBase base class
std::string m_objectTraceSourceName
std::map< uint32_t, CollectorMap > m_collectors
Two-dimensional map of collectors, indexed by the frame ID and then by the identifier.
Ptr< ScalarCollector > GetCollector(uint32_t frameId, std::string identifier)
static std::string GetUnitTypeName(UnitType_t unitType)
UnitType_t GetUnitType() const
void FrameSymbolLoadCallback(std::string context, uint32_t frameId, double loadRatio)
void SetUnitType(UnitType_t unitType)
virtual ~SatStatsFrameLoadHelper()
/ Destructor.
std::string GetIdentifierHeading(std::string dataLabel) const
void DoInstall()
Install the probes, collectors, and aggregators necessary to produce the statistics output.
void FrameUserLoadCallback(std::string context, uint32_t frameId, uint32_t utCount)
Ptr< DataCollectionObject > m_aggregator
The aggregator created by this helper.
@ UNIT_USERS
Number of scheduled users (i.e., UT).
@ UNIT_SYMBOLS
Number of allocated symbols over total number of symbols in the frame.
SatStatsFrameLoadHelper(Ptr< const SatHelper > satHelper)
std::string m_probeTraceSourceName
Helper for frame symbol load statistics.
static TypeId GetTypeId()
inherited from ObjectBase base class
SatStatsFrameSymbolLoadHelper(Ptr< const SatHelper > satHelper)
virtual ~SatStatsFrameSymbolLoadHelper()
/ Destructor.
Helper for frame user load statistics.
static TypeId GetTypeId()
inherited from ObjectBase base class
virtual ~SatStatsFrameUserLoadHelper()
/ Destructor.
SatStatsFrameUserLoadHelper(Ptr< const SatHelper > satHelper)
Parent abstract class of all satellite statistics helpers.
uint32_t GetIdentifierForBeam(uint32_t satId, uint32_t beamId) const
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
uint32_t GetGwId(Ptr< Node > gwNode) const
constexpr uint32_t MAX_BEAMS_PER_SATELLITE
Maximum number of beams per satellite.
SatArqSequenceNumber is handling the sequence numbers for the ARQ process.