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/scalar-collector.h>
41 #include <ns3/singleton.h>
42 #include <ns3/string.h>
43 #include <ns3/unit-conversion-collector.h>
47 NS_LOG_COMPONENT_DEFINE(
"SatStatsSignallingLoadHelper");
52 NS_OBJECT_ENSURE_REGISTERED(SatStatsSignallingLoadHelper);
57 NS_LOG_FUNCTION(
this << satHelper);
62 NS_LOG_FUNCTION(
this);
68 static TypeId tid = TypeId(
"ns3::SatStatsSignallingLoadHelper").SetParent<
SatStatsHelper>();
75 NS_LOG_FUNCTION(
this);
81 <<
" is not a valid output type for this statistics.");
91 "EnableContextPrinting",
99 EnumValue(ScalarCollector::INPUT_DATA_TYPE_DOUBLE));
102 EnumValue(ScalarCollector::OUTPUT_TYPE_AVERAGE_PER_SECOND));
106 &MultiFileAggregator::Write1d);
111 EnumValue(UnitConversionCollector::FROM_BYTES_TO_KBIT));
115 &ScalarCollector::TraceSinkDouble);
130 EnumValue(IntervalRateCollector::INPUT_DATA_TYPE_DOUBLE));
134 &MultiFileAggregator::Write2d);
137 &MultiFileAggregator::AddContextHeading);
142 EnumValue(UnitConversionCollector::FROM_BYTES_TO_KBIT));
146 &IntervalRateCollector::TraceSinkDouble);
154 <<
" is not a valid output type for this statistics.");
160 <<
" is not a valid output type for this statistics.");
170 Ptr<MagisterGnuplotAggregator> plotAggregator =
172 NS_ASSERT(plotAggregator !=
nullptr);
174 plotAggregator->SetLegend(
"Time (in seconds)",
"Signalling load (in kilobits per second)");
175 plotAggregator->Set2dDatasetDefaultStyle(Gnuplot2dDataset::LINES);
180 EnumValue(IntervalRateCollector::INPUT_DATA_TYPE_DOUBLE));
186 const std::string context = it->second->GetName();
187 plotAggregator->Add2dDataset(context, context);
191 &MagisterGnuplotAggregator::Write2d);
196 EnumValue(UnitConversionCollector::FROM_BYTES_TO_KBIT));
200 &IntervalRateCollector::TraceSinkDouble);
208 <<
" is not a valid output type for this statistics.");
212 NS_FATAL_ERROR(
"SatStatsSignallingLoadHelper - Invalid output type");
224 NS_LOG_FUNCTION(
this);
237 NS_LOG_WARN(
this <<
" discarding packet " << packet <<
" (" << packet->GetSize()
239 <<
" from statistics collection because of"
240 <<
" invalid sender address");
244 const Mac48Address addr = Mac48Address::ConvertFrom(to);
246 if (addr.IsBroadcast())
248 NS_LOG_INFO(
this <<
" broadcast control message packet");
255 Ptr<UnitConversionCollector> c = it->second->GetObject<UnitConversionCollector>();
256 NS_ASSERT(c !=
nullptr);
257 c->TraceSinkUinteger32(0, packet->GetSize());
263 std::map<const Address, uint32_t>::const_iterator it =
m_identifierMap.find(addr);
267 NS_LOG_WARN(
this <<
" discarding packet " << packet <<
" (" << packet->GetSize()
269 <<
" from statistics collection because of"
270 <<
" unknown sender address " << addr);
276 NS_ASSERT_MSG(collector !=
nullptr,
277 "Unable to find collector with identifier " << it->second);
278 Ptr<UnitConversionCollector> c = collector->GetObject<UnitConversionCollector>();
279 NS_ASSERT(c !=
nullptr);
282 c->TraceSinkUinteger32(0, packet->GetSize());
292 NS_LOG_FUNCTION(
this << utNode->GetId());
294 const SatIdMapper* satIdMapper = Singleton<SatIdMapper>::Get();
297 if (addr.IsInvalid())
299 NS_LOG_WARN(
this <<
" Node " << utNode->GetId() <<
" is not a valid UT");
305 NS_LOG_INFO(
this <<
" associated address " << addr <<
" with identifier " << identifier);
316 NS_LOG_FUNCTION(
this << satHelper);
321 NS_LOG_FUNCTION(
this);
335 NS_LOG_FUNCTION(
this);
338 NodeContainer uts =
GetSatHelper()->GetBeamHelper()->GetUtNodes();
339 for (NodeContainer::Iterator it = uts.Begin(); it != uts.End(); ++it)
346 NodeContainer gws =
GetSatHelper()->GetBeamHelper()->GetGwNodes();
347 Callback<void, Ptr<const Packet>,
const Address&> callback =
350 for (NodeContainer::Iterator it = gws.Begin(); it != gws.End(); ++it)
354 for (NetDeviceContainer::Iterator itDev = devs.Begin(); itDev != devs.End(); ++itDev)
356 NS_ASSERT((*itDev)->GetObject<
SatNetDevice>() !=
nullptr);
358 if ((*itDev)->TraceConnectWithoutContext(
"SignallingTx", callback))
360 NS_LOG_INFO(
this <<
" successfully connected with node ID " << (*it)->GetId()
361 <<
" device #" << (*itDev)->GetIfIndex());
365 NS_FATAL_ERROR(
"Error connecting to SignallingTx trace source"
366 <<
" of SatNetDevice"
367 <<
" at node ID " << (*it)->GetId() <<
" device #"
368 << (*itDev)->GetIfIndex());
384 NS_LOG_FUNCTION(
this << satHelper);
389 NS_LOG_FUNCTION(
this);
403 NS_LOG_FUNCTION(
this);
404 NodeContainer uts =
GetSatHelper()->GetBeamHelper()->GetUtNodes();
406 for (NodeContainer::Iterator it = uts.Begin(); it != uts.End(); ++it)
408 const int32_t utId =
GetUtId(*it);
409 NS_ASSERT_MSG(utId > 0,
"Node " << (*it)->GetId() <<
" is not a valid UT");
413 std::ostringstream probeName;
415 Ptr<ApplicationPacketProbe> probe = CreateObject<ApplicationPacketProbe>();
416 probe->SetName(probeName.str());
421 if (probe->ConnectByObject(
"SignallingTx", dev))
425 probe->GetObject<Probe>(),
428 &UnitConversionCollector::TraceSinkUinteger32))
430 NS_LOG_INFO(
this <<
" created probe " << probeName.str()
431 <<
", connected to collector " << identifier);
432 m_probes.push_back(probe->GetObject<Probe>());
436 NS_LOG_WARN(
this <<
" unable to connect probe " << probeName.str()
437 <<
" to collector " << identifier);
443 NS_FATAL_ERROR(
"Error connecting to SignallingTx trace source of SatNetDevice"
444 <<
" at node ID " << (*it)->GetId() <<
" device #2");
Address GetUtMacWithNode(Ptr< Node > utNode) const
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.
Ptr< const SatHelper > GetSatHelper() const
static NetDeviceContainer GetGwSatNetDevice(Ptr< Node > gwNode)
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::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::list< Ptr< Probe > > m_probes
Maintains a list of probes created by this helper.
static TypeId GetTypeId()
inherited from ObjectBase base class
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 SaveAddressAndIdentifier(Ptr< Node > utNode)
Save the address and the proper identifier from the given UT node.
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)
std::map< const Address, uint32_t > m_identifierMap
Map of address and the identifier associated with it (for forward link).
CollectorMap m_conversionCollectors
Maintains a list of first-level collectors created by this helper.
SatArqSequenceNumber is handling the sequence numbers for the ARQ process.