91 NS_LOG_FUNCTION(
this);
96 <<
" is not a valid output type for this statistics.");
103 <<
" is not a valid identifier type for this statistics.");
107 std::string dataLabel;
110 dataLabel =
"usage_percentage";
114 dataLabel =
"usage_count";
122 "EnableContextPrinting",
130 uint32_t frameTypeId = it.second;
132 NS_LOG_INFO(
this <<
" Creating new collectors for frame type ID " << frameTypeId);
134 CollectorMap collectorMap;
135 ScalarCollector::OutputType_t opType;
138 opType = ScalarCollector::OUTPUT_TYPE_AVERAGE_PER_SAMPLE;
142 opType = ScalarCollector::OUTPUT_TYPE_SUM;
145 collectorMap.SetType(
"ns3::ScalarCollector");
146 collectorMap.SetAttribute(
"OutputType", EnumValue(opType));
147 collectorMap.SetAttribute(
"InputDataType",
148 EnumValue(ScalarCollector::INPUT_DATA_TYPE_UINTEGER));
159 std::ostringstream name;
160 name <<
"0 " << frameTypeId;
161 collectorMap.SetAttribute(
"Name", StringValue(name.str()));
162 collectorMap.Create(0);
168 NodeContainer gws = Singleton<SatTopology>::Get()->GetGwNodes();
169 for (NodeContainer::Iterator it = gws.Begin(); it != gws.End(); ++it)
171 const uint32_t gwId =
GetGwId(*it);
172 std::ostringstream name;
173 name << gwId <<
" " << frameTypeId;
174 collectorMap.SetAttribute(
"Name", StringValue(name.str()));
175 collectorMap.Create(gwId);
182 std::list<std::pair<uint32_t, uint32_t>> beams =
184 for (std::list<std::pair<uint32_t, uint32_t>>::const_iterator it = beams.begin();
188 const uint32_t satId = (it->first);
189 const uint32_t beamId = (it->second);
190 std::ostringstream name;
191 name << satId <<
"-" << beamId <<
" " << frameTypeId;
192 collectorMap.SetAttribute(
"Name", StringValue(name.str()));
201 NS_FATAL_ERROR(
"SatStatsWaveformUsageHelper - Invalid identifier type");
205 collectorMap.ConnectToAggregator(
"Output",
m_aggregator, &MultiFileAggregator::Write1d);
207 NS_LOG_INFO(
this <<
" created " << n <<
" instance(s)" <<
" of "
208 << collectorMap.GetType().GetName() <<
" for "
211 std::pair<std::map<uint32_t, CollectorMap>::iterator,
bool> ret;
212 ret =
m_collectors.insert(std::make_pair(frameTypeId, collectorMap));
213 NS_ASSERT(ret.second);
217 Callback<void, std::string, Ptr<SatBbFrame>> frameTypeUsageCallback =
221 NodeContainer gwNodes = Singleton<SatTopology>::Get()->GetGwNodes();
222 for (
auto node = gwNodes.Begin(); node != gwNodes.End(); node++)
224 for (uint32_t i = 0; i < (*node)->GetNDevices(); i++)
226 Ptr<SatNetDevice> dev = DynamicCast<SatNetDevice>((*node)->GetDevice(i));
231 Ptr<SatGwMac> mac = DynamicCast<SatGwMac>(dev->GetMac());
238 uint32_t beamId = mac->GetBeamId();
239 uint32_t satId = mac->GetSatId();
240 std::ostringstream context;
243 mac->TraceConnect(
"BBFrameTxTrace", context.str(), frameTypeUsageCallback);
244 NS_ASSERT_MSG(ret,
"Error connecting to BBFrameTxTrace of beam " << beamId);
245 NS_LOG_INFO(
this <<
" successfully connected" <<
" with beam " << beamId);
289 std::stringstream ss(context);
291 if (!(ss >> identifier))
293 NS_FATAL_ERROR(
"Cannot convert '" << context <<
"' to number");
297 std::map<uint32_t, CollectorMap>::iterator it =
m_collectors.find(frameTypeId);
303 Ptr<DataCollectionObject> collector = it->second.Get(identifier);
304 NS_ASSERT_MSG(collector !=
nullptr,
305 "Unable to find collector with identifier " << identifier);
307 Ptr<ScalarCollector> c = collector->GetObject<ScalarCollector>();
308 NS_ASSERT(c !=
nullptr);
311 c->TraceSinkUinteger32(0, 1);
319 Ptr<DataCollectionObject> collector = it.second.Get(identifier);
320 NS_ASSERT_MSG(collector !=
nullptr,
321 "Unable to find collector with identifier " << identifier);
322 Ptr<ScalarCollector> c = collector->GetObject<ScalarCollector>();
323 NS_ASSERT(c !=
nullptr);
324 if (it.first == frameTypeId)
326 c->TraceSinkUinteger32(0, 1);
330 c->TraceSinkUinteger32(0, 0);
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.