27 #include <ns3/boolean.h>
28 #include <ns3/callback.h>
29 #include <ns3/data-collection-object.h>
31 #include <ns3/fatal-error.h>
33 #include <ns3/multi-file-aggregator.h>
34 #include <ns3/node-container.h>
35 #include <ns3/satellite-beam-helper.h>
36 #include <ns3/satellite-beam-scheduler.h>
37 #include <ns3/satellite-helper.h>
38 #include <ns3/satellite-ncc.h>
39 #include <ns3/satellite-topology.h>
40 #include <ns3/scalar-collector.h>
41 #include <ns3/singleton.h>
42 #include <ns3/string.h>
50 NS_LOG_COMPONENT_DEFINE(
"SatStatsFrameLoadHelper");
55 NS_OBJECT_ENSURE_REGISTERED(SatStatsFrameLoadHelper);
63 return "UNIT_SYMBOLS";
67 NS_FATAL_ERROR(
"SatStatsFrameLoadHelper - Invalid unit type");
71 NS_FATAL_ERROR(
"SatStatsFrameLoadHelper - Invalid unit type");
80 m_objectTraceSourceName(
""),
81 m_probeTraceSourceName(
"")
83 NS_LOG_FUNCTION(
this << satHelper);
88 NS_LOG_FUNCTION(
this);
94 static TypeId tid = TypeId(
"ns3::SatStatsFrameLoadHelper").SetParent<
SatStatsHelper>();
108 m_longLabel =
"Number of allocated symbols over total number of symbols";
121 NS_FATAL_ERROR(
"SatStatsFrameLoadHelper - Invalid unit type");
134 NS_LOG_FUNCTION(
this);
139 <<
" is not a valid output type for this statistics.");
146 <<
" is not a valid identifier type for this statistics.");
155 "EnableContextPrinting",
161 Ptr<SatBeamHelper> beamHelper =
GetSatHelper()->GetBeamHelper();
162 NS_ASSERT(beamHelper !=
nullptr);
163 Ptr<SatNcc> ncc = beamHelper->GetNcc();
164 NS_ASSERT(ncc !=
nullptr);
165 std::list<std::pair<uint32_t, uint32_t>> beams = beamHelper->GetBeams();
168 for (std::list<std::pair<uint32_t, uint32_t>>::const_iterator it = beams.begin();
174 ret = SetupProbe<SatFrameSymbolLoadProbe>(
175 ncc->GetBeamScheduler(it->first, it->second),
183 SetupProbe<SatFrameUserLoadProbe>(ncc->GetBeamScheduler(it->first, it->second),
190 NS_LOG_INFO(
this <<
" successfully connected"
191 <<
" with beam " << it->second);
195 NS_LOG_WARN(
this <<
" unable to connect to beam " << it->second);
208 return "% global frame_number " + dataLabel;
211 return "% gw_id frame_number " + dataLabel;
214 return "% beam_id frame_number " + dataLabel;
217 NS_FATAL_ERROR(
"SatStatsFrameLoadHelper - Invalid identifier type");
231 Ptr<ScalarCollector> collector =
GetCollector(frameId, context);
232 NS_ASSERT_MSG(collector !=
nullptr,
233 "Unable to get/create collector"
234 <<
" for frame ID " << frameId <<
" and beam " << context);
237 collector->TraceSinkDouble(0, loadRatio);
248 Ptr<ScalarCollector> collector =
GetCollector(frameId, context);
249 NS_ASSERT_MSG(collector !=
nullptr,
250 "Unable to get/create collector"
251 <<
" for frame ID " << frameId <<
" and identifier " << context);
254 collector->TraceSinkUinteger32(0, utCount);
263 std::stringstream ss(identifier);
264 uint32_t identifierNum;
265 if (!(ss >> identifierNum))
267 NS_FATAL_ERROR(
"Cannot convert '" << identifier <<
"' to number");
270 std::map<uint32_t, CollectorMap>::iterator it =
m_collectors.find(frameId);
275 CollectorMap collectorMap;
276 collectorMap.SetType(
"ns3::ScalarCollector");
279 collectorMap.SetAttribute(
"InputDataType",
280 EnumValue(ScalarCollector::INPUT_DATA_TYPE_DOUBLE));
281 collectorMap.SetAttribute(
"OutputType",
282 EnumValue(ScalarCollector::OUTPUT_TYPE_AVERAGE_PER_SAMPLE));
287 collectorMap.SetAttribute(
"InputDataType",
288 EnumValue(ScalarCollector::INPUT_DATA_TYPE_UINTEGER));
289 collectorMap.SetAttribute(
"OutputType", EnumValue(ScalarCollector::OUTPUT_TYPE_SUM));
301 std::ostringstream name;
302 name <<
"0 " << frameId;
303 collectorMap.SetAttribute(
"Name", StringValue(name.str()));
304 collectorMap.Create(0);
310 NodeContainer gws = Singleton<SatTopology>::Get()->GetGwNodes();
311 for (NodeContainer::Iterator it = gws.Begin(); it != gws.End(); ++it)
313 const uint32_t gwId =
GetGwId(*it);
314 std::ostringstream name;
315 name << gwId <<
" " << frameId;
316 collectorMap.SetAttribute(
"Name", StringValue(name.str()));
317 collectorMap.Create(gwId);
324 std::list<std::pair<uint32_t, uint32_t>> beams =
326 for (std::list<std::pair<uint32_t, uint32_t>>::const_iterator it = beams.begin();
330 const uint32_t satId = (it->first);
331 const uint32_t beamId = (it->second);
332 std::ostringstream name;
333 name << satId <<
"-" << beamId <<
" " << frameId;
334 collectorMap.SetAttribute(
"Name", StringValue(name.str()));
343 NS_FATAL_ERROR(
"SatStatsFrameLoadHelper - Invalid identifier type");
347 collectorMap.ConnectToAggregator(
"Output",
m_aggregator, &MultiFileAggregator::Write1d);
348 NS_LOG_INFO(
this <<
" created " << n <<
" instance(s)"
349 <<
" of " << collectorMap.GetType().GetName() <<
" for "
352 std::pair<std::map<uint32_t, CollectorMap>::iterator,
bool> ret;
353 ret =
m_collectors.insert(std::make_pair(frameId, collectorMap));
354 NS_ASSERT(ret.second);
362 Ptr<DataCollectionObject> collector = it->second.Get(identifierNum);
363 NS_ASSERT_MSG(collector !=
nullptr,
"Unable to find collector with identifier " << identifier);
364 Ptr<ScalarCollector> c = collector->GetObject<ScalarCollector>();
376 NS_LOG_FUNCTION(
this << satHelper);
382 NS_LOG_FUNCTION(
this);
400 NS_LOG_FUNCTION(
this << satHelper);
406 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.