23 #include <ns3/boolean.h>
24 #include <ns3/callback.h>
25 #include <ns3/data-collection-object.h>
26 #include <ns3/distribution-collector.h>
28 #include <ns3/interval-rate-collector.h>
30 #include <ns3/magister-gnuplot-aggregator.h>
31 #include <ns3/multi-file-aggregator.h>
32 #include <ns3/node-container.h>
33 #include <ns3/nstime.h>
34 #include <ns3/probe.h>
35 #include <ns3/satellite-handover-module.h>
36 #include <ns3/satellite-helper.h>
37 #include <ns3/satellite-orbiter-net-device.h>
38 #include <ns3/satellite-topology.h>
39 #include <ns3/scalar-collector.h>
40 #include <ns3/singleton.h>
41 #include <ns3/string.h>
42 #include <ns3/unit-conversion-collector.h>
48 NS_LOG_COMPONENT_DEFINE(
"SatStatsPacketDropRateHelper");
53 NS_OBJECT_ENSURE_REGISTERED(SatStatsPacketDropRateHelper);
58 NS_LOG_FUNCTION(
this << satHelper);
63 NS_LOG_FUNCTION(
this);
69 static TypeId tid = TypeId(
"ns3::SatStatsPacketDropRateHelper").SetParent<
SatStatsHelper>();
79 NS_LOG_FUNCTION(
this << nPackets << satSrc << satDst << isError);
85 NS_ASSERT_MSG(collector !=
nullptr,
"Unable to find collector with identifier " << identifier);
91 Ptr<ScalarCollector> c = collector->GetObject<ScalarCollector>();
92 NS_ASSERT(c !=
nullptr);
93 c->TraceSinkBoolean(
false, isError);
99 Ptr<IntervalRateCollector> c = collector->GetObject<IntervalRateCollector>();
100 NS_ASSERT(c !=
nullptr);
101 c->TraceSinkBoolean(
false, isError);
107 <<
" is not a valid output type for this statistics.");
116 NS_LOG_FUNCTION(
this);
122 <<
" is not a valid output type for this statistics.");
132 "EnableContextPrinting",
140 EnumValue(ScalarCollector::INPUT_DATA_TYPE_BOOLEAN));
143 EnumValue(ScalarCollector::OUTPUT_TYPE_AVERAGE_PER_SAMPLE));
147 &MultiFileAggregator::Write1d);
163 EnumValue(IntervalRateCollector::INPUT_DATA_TYPE_BOOLEAN));
166 EnumValue(IntervalRateCollector::OUTPUT_TYPE_AVERAGE_PER_SAMPLE));
170 &MultiFileAggregator::Write2d);
173 &MultiFileAggregator::AddContextHeading);
181 <<
" is not a valid output type for this statistics.");
187 <<
" is not a valid output type for this statistics.");
197 Ptr<MagisterGnuplotAggregator> plotAggregator =
199 NS_ASSERT(plotAggregator !=
nullptr);
201 plotAggregator->SetLegend(
"Time (in seconds)",
"Packet drop rate");
202 plotAggregator->Set2dDatasetDefaultStyle(Gnuplot2dDataset::LINES);
208 EnumValue(IntervalRateCollector::INPUT_DATA_TYPE_BOOLEAN));
211 EnumValue(IntervalRateCollector::OUTPUT_TYPE_AVERAGE_PER_SAMPLE));
217 const std::string context = it->second->GetName();
218 plotAggregator->Add2dDataset(context, context);
222 &MagisterGnuplotAggregator::Write2d);
230 <<
" is not a valid output type for this statistics.");
234 NS_FATAL_ERROR(
"SatStatsPacketErrorHelper - Invalid output type");
244 NS_LOG_FUNCTION(
this);
246 Callback<void, uint32_t, Ptr<Node>, Ptr<Node>,
bool> callback =
249 NodeContainer sats = Singleton<SatTopology>::Get()->GetOrbiterNodes();
250 for (NodeContainer::Iterator it = sats.Begin(); it != sats.End(); ++it)
252 Ptr<SatOrbiterNetDevice> satOrbiterNetDevice =
254 std::vector<Ptr<PointToPointIslNetDevice>> islNetDevices =
255 satOrbiterNetDevice->GetIslsNetDevices();
256 for (std::vector<Ptr<PointToPointIslNetDevice>>::iterator itIsl = islNetDevices.begin();
257 itIsl != islNetDevices.end();
260 std::ostringstream oss;
263 if ((*itIsl)->TraceConnectWithoutContext(
"PacketDropRateTrace", callback))
265 NS_LOG_INFO(
this <<
" successfully connected with ISL " << oss.str());
269 NS_LOG_WARN(
this <<
" unable to connect to ISL " << oss.str());
Parent abstract class of all satellite statistics helpers.
static Ptr< NetDevice > GetSatSatOrbiterNetDevice(Ptr< Node > satNode)
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 CreateCollectorPerIdentifier(CollectorMap &collectorMap) const
Create one collector instance for each identifier in the simulation.
uint32_t GetIdentifierForIsl(Ptr< Node > satNodeSrc, Ptr< Node > satNodeDst) const
OutputType_t GetOutputType() const
std::string GetName() const
virtual std::string GetTimeHeading(std::string dataLabel) const
static TypeId GetTypeId()
inherited from ObjectBase base class
void PacketDropRateCallback(uint32_t nPackets, Ptr< Node > satSrc, Ptr< Node > satDst, bool isError)
Receive inputs from trace sources and determine the right collector to forward the inputs to.
void DoInstall()
Install the probes, collectors, and aggregators necessary to produce the statistics output.
Ptr< DataCollectionObject > m_aggregator
The aggregator created by this helper.
CollectorMap m_terminalCollectors
Maintains a list of collectors created by this helper.
virtual ~SatStatsPacketDropRateHelper()
/ Destructor.
void InstallProbes()
Set up several probes or other means of listeners and connect them to the collectors.
SatStatsPacketDropRateHelper(Ptr< const SatHelper > satHelper)
SatArqSequenceNumber is handling the sequence numbers for the ARQ process.