24 #include <ns3/application-packet-probe.h>
25 #include <ns3/boolean.h>
26 #include <ns3/callback.h>
27 #include <ns3/data-collection-object.h>
29 #include <ns3/interval-rate-collector.h>
31 #include <ns3/mac48-address.h>
32 #include <ns3/magister-gnuplot-aggregator.h>
33 #include <ns3/multi-file-aggregator.h>
34 #include <ns3/node-container.h>
35 #include <ns3/packet.h>
36 #include <ns3/probe.h>
37 #include <ns3/satellite-helper.h>
38 #include <ns3/satellite-id-mapper.h>
39 #include <ns3/satellite-net-device.h>
40 #include <ns3/satellite-topology.h>
41 #include <ns3/scalar-collector.h>
42 #include <ns3/singleton.h>
43 #include <ns3/string.h>
44 #include <ns3/unit-conversion-collector.h>
51 NS_LOG_COMPONENT_DEFINE(
"SatStatsSignallingLoadHelper");
56 NS_OBJECT_ENSURE_REGISTERED(SatStatsSignallingLoadHelper);
61 NS_LOG_FUNCTION(
this << satHelper);
66 NS_LOG_FUNCTION(
this);
72 static TypeId tid = TypeId(
"ns3::SatStatsSignallingLoadHelper").SetParent<
SatStatsHelper>();
79 NS_LOG_FUNCTION(
this);
85 <<
" is not a valid output type for this statistics.");
95 "EnableContextPrinting",
103 EnumValue(ScalarCollector::INPUT_DATA_TYPE_DOUBLE));
106 EnumValue(ScalarCollector::OUTPUT_TYPE_AVERAGE_PER_SECOND));
110 &MultiFileAggregator::Write1d);
115 EnumValue(UnitConversionCollector::FROM_BYTES_TO_KBIT));
119 &ScalarCollector::TraceSinkDouble);
134 EnumValue(IntervalRateCollector::INPUT_DATA_TYPE_DOUBLE));
138 &MultiFileAggregator::Write2d);
141 &MultiFileAggregator::AddContextHeading);
146 EnumValue(UnitConversionCollector::FROM_BYTES_TO_KBIT));
150 &IntervalRateCollector::TraceSinkDouble);
158 <<
" is not a valid output type for this statistics.");
164 <<
" is not a valid output type for this statistics.");
174 Ptr<MagisterGnuplotAggregator> plotAggregator =
176 NS_ASSERT(plotAggregator !=
nullptr);
178 plotAggregator->SetLegend(
"Time (in seconds)",
"Signalling load (in kilobits per second)");
179 plotAggregator->Set2dDatasetDefaultStyle(Gnuplot2dDataset::LINES);
184 EnumValue(IntervalRateCollector::INPUT_DATA_TYPE_DOUBLE));
190 const std::string context = it->second->GetName();
191 plotAggregator->Add2dDataset(context, context);
195 &MagisterGnuplotAggregator::Write2d);
200 EnumValue(UnitConversionCollector::FROM_BYTES_TO_KBIT));
204 &IntervalRateCollector::TraceSinkDouble);
212 <<
" is not a valid output type for this statistics.");
216 NS_FATAL_ERROR(
"SatStatsSignallingLoadHelper - Invalid output type");
228 NS_LOG_FUNCTION(
this);
241 NS_LOG_WARN(
this <<
" discarding packet " << packet <<
" (" << packet->GetSize()
243 <<
" from statistics collection because of"
244 <<
" invalid sender address");
248 const Mac48Address addr = Mac48Address::ConvertFrom(to);
250 if (addr.IsBroadcast())
252 NS_LOG_INFO(
this <<
" broadcast control message packet");
259 Ptr<UnitConversionCollector> c = it->second->GetObject<UnitConversionCollector>();
260 NS_ASSERT(c !=
nullptr);
261 c->TraceSinkUinteger32(0, packet->GetSize());
267 std::map<const Address, uint32_t>::const_iterator it =
m_identifierMap.find(addr);
271 NS_LOG_WARN(
this <<
" discarding packet " << packet <<
" (" << packet->GetSize()
273 <<
" from statistics collection because of"
274 <<
" unknown sender address " << addr);
280 NS_ASSERT_MSG(collector !=
nullptr,
281 "Unable to find collector with identifier " << it->second);
282 Ptr<UnitConversionCollector> c = collector->GetObject<UnitConversionCollector>();
283 NS_ASSERT(c !=
nullptr);
286 c->TraceSinkUinteger32(0, packet->GetSize());
300 NS_LOG_FUNCTION(
this << satHelper);
305 NS_LOG_FUNCTION(
this);
319 NS_LOG_FUNCTION(
this);
322 NodeContainer uts = Singleton<SatTopology>::Get()->GetUtNodes();
323 for (NodeContainer::Iterator it = uts.Begin(); it != uts.End(); ++it)
330 NodeContainer gws = Singleton<SatTopology>::Get()->GetGwNodes();
331 Callback<void, Ptr<const Packet>,
const Address&> callback =
334 for (NodeContainer::Iterator it = gws.Begin(); it != gws.End(); ++it)
338 for (NetDeviceContainer::Iterator itDev = devs.Begin(); itDev != devs.End(); ++itDev)
340 NS_ASSERT((*itDev)->GetObject<
SatNetDevice>() !=
nullptr);
342 if ((*itDev)->TraceConnectWithoutContext(
"SignallingTx", callback))
344 NS_LOG_INFO(
this <<
" successfully connected with node ID " << (*it)->GetId()
345 <<
" device #" << (*itDev)->GetIfIndex());
349 NS_FATAL_ERROR(
"Error connecting to SignallingTx trace source"
350 <<
" of SatNetDevice"
351 <<
" at node ID " << (*it)->GetId() <<
" device #"
352 << (*itDev)->GetIfIndex());
368 NS_LOG_FUNCTION(
this << satHelper);
373 NS_LOG_FUNCTION(
this);
387 NS_LOG_FUNCTION(
this);
388 NodeContainer uts = Singleton<SatTopology>::Get()->GetUtNodes();
390 for (NodeContainer::Iterator it = uts.Begin(); it != uts.End(); ++it)
392 const int32_t utId =
GetUtId(*it);
393 NS_ASSERT_MSG(utId > 0,
"Node " << (*it)->GetId() <<
" is not a valid UT");
397 std::ostringstream probeName;
399 Ptr<ApplicationPacketProbe> probe = CreateObject<ApplicationPacketProbe>();
400 probe->SetName(probeName.str());
405 if (probe->ConnectByObject(
"SignallingTx", dev))
409 probe->GetObject<Probe>(),
412 &UnitConversionCollector::TraceSinkUinteger32))
414 NS_LOG_INFO(
this <<
" created probe " << probeName.str()
415 <<
", connected to collector " << identifier);
417 std::make_pair(probe->GetObject<Probe>(), std::make_pair(*it, identifier)));
421 NS_LOG_WARN(
this <<
" unable to connect probe " << probeName.str()
422 <<
" to collector " << identifier);
428 NS_FATAL_ERROR(
"Error connecting to SignallingTx trace source of SatNetDevice"
429 <<
" at node ID " << (*it)->GetId() <<
" device #2");
439 NS_LOG_FUNCTION(
this);
441 std::map<Ptr<Probe>, std::pair<Ptr<Node>, uint32_t>>::iterator it;
445 Ptr<Probe> probe = it->first;
446 Ptr<Node> node = it->second.first;
447 uint32_t identifier = it->second.second;
450 probe->GetObject<Probe>(),
453 &UnitConversionCollector::TraceSinkUinteger32))
455 NS_FATAL_ERROR(
"Error disconnecting trace file on handover");
463 &UnitConversionCollector::TraceSinkUinteger32))
465 NS_FATAL_ERROR(
"Error connecting trace file on handover");
468 it->second.second = identifier;
SatNetDevice to be utilized in the UT and GW nodes.
Produce forward link signalling load statistics from a satellite module simulation.
SatStatsFwdSignallingLoadHelper(Ptr< const SatHelper > satHelper)
virtual ~SatStatsFwdSignallingLoadHelper()
/ Destructor.
static TypeId GetTypeId()
inherited from ObjectBase base class
Parent abstract class of all satellite statistics helpers.
uint32_t GetIdentifierForUtUser(Ptr< Node > utUserNode) const
static NetDeviceContainer GetGwSatNetDevice(Ptr< Node > gwNode)
virtual void SaveAddressAndIdentifier(Ptr< Node > utNode)
Save the address and the proper identifier from the given UT node.
static std::string GetOutputTypeName(OutputType_t outputType)
virtual std::string GetIdentifierHeading(std::string dataLabel) const
virtual std::string GetOutputPath() const
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.
uint32_t GetUtId(Ptr< Node > utNode) const
uint32_t CreateCollectorPerIdentifier(CollectorMap &collectorMap) const
Create one collector instance for each identifier in the simulation.
static Ptr< NetDevice > GetUtSatNetDevice(Ptr< Node > utNode)
OutputType_t GetOutputType() const
uint32_t GetIdentifierForUt(Ptr< Node > utNode) const
std::map< const Address, uint32_t > m_identifierMap
Map of address and the identifier associated with it.
std::string GetName() const
virtual std::string GetTimeHeading(std::string dataLabel) const
Produce return link signalling load statistics from a satellite module simulation.
SatStatsRtnSignallingLoadHelper(Ptr< const SatHelper > satHelper)
std::map< Ptr< Probe >, std::pair< Ptr< Node >, uint32_t > > m_probes
Maintains a list of probes created by this helper.
static TypeId GetTypeId()
inherited from ObjectBase base class
virtual void UpdateIdentifierOnProbes()
Change identifier used on probes, when handovers occur.
virtual ~SatStatsRtnSignallingLoadHelper()
/ Destructor.
Abstract class inherited by SatStatsFwdSignallingLoadHelper and SatStatsRtnSignallingLoadHelper.
virtual void DoInstallProbes()=0
Ptr< DataCollectionObject > m_aggregator
The aggregator created by this helper.
virtual ~SatStatsSignallingLoadHelper()
/ Destructor.
void DoInstall()
Install the probes, collectors, and aggregators necessary to produce the statistics output.
void InstallProbes()
Set up several probes or other means of listeners and connect them to the first-level collectors.
CollectorMap m_terminalCollectors
Maintains a list of second-level collectors created by this helper.
void SignallingTxCallback(Ptr< const Packet > packet, const Address &to)
Receive inputs from trace sources and determine the right collector to forward the inputs to.
static TypeId GetTypeId()
inherited from ObjectBase base class
SatStatsSignallingLoadHelper(Ptr< const SatHelper > satHelper)
CollectorMap m_conversionCollectors
Maintains a list of first-level collectors created by this helper.
SatArqSequenceNumber is handling the sequence numbers for the ARQ process.