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-helper.h>
36 #include <ns3/satellite-ut-handover-module.h>
37 #include <ns3/scalar-collector.h>
38 #include <ns3/singleton.h>
39 #include <ns3/string.h>
40 #include <ns3/unit-conversion-collector.h>
44 NS_LOG_COMPONENT_DEFINE(
"SatStatsPacketDropRateHelper");
49 NS_OBJECT_ENSURE_REGISTERED(SatStatsPacketDropRateHelper);
54 NS_LOG_FUNCTION(
this << satHelper);
59 NS_LOG_FUNCTION(
this);
65 static TypeId tid = TypeId(
"ns3::SatStatsPacketDropRateHelper").SetParent<
SatStatsHelper>();
75 NS_LOG_FUNCTION(
this << nPackets << satSrc << satDst << isError);
81 NS_ASSERT_MSG(collector !=
nullptr,
"Unable to find collector with identifier " << identifier);
87 Ptr<ScalarCollector> c = collector->GetObject<ScalarCollector>();
88 NS_ASSERT(c !=
nullptr);
89 c->TraceSinkBoolean(
false, isError);
95 Ptr<IntervalRateCollector> c = collector->GetObject<IntervalRateCollector>();
96 NS_ASSERT(c !=
nullptr);
97 c->TraceSinkBoolean(
false, isError);
103 <<
" is not a valid output type for this statistics.");
112 NS_LOG_FUNCTION(
this);
118 <<
" is not a valid output type for this statistics.");
128 "EnableContextPrinting",
136 EnumValue(ScalarCollector::INPUT_DATA_TYPE_BOOLEAN));
139 EnumValue(ScalarCollector::OUTPUT_TYPE_AVERAGE_PER_SAMPLE));
143 &MultiFileAggregator::Write1d);
159 EnumValue(IntervalRateCollector::INPUT_DATA_TYPE_BOOLEAN));
162 EnumValue(IntervalRateCollector::OUTPUT_TYPE_AVERAGE_PER_SAMPLE));
166 &MultiFileAggregator::Write2d);
169 &MultiFileAggregator::AddContextHeading);
177 <<
" is not a valid output type for this statistics.");
183 <<
" is not a valid output type for this statistics.");
193 Ptr<MagisterGnuplotAggregator> plotAggregator =
195 NS_ASSERT(plotAggregator !=
nullptr);
197 plotAggregator->SetLegend(
"Time (in seconds)",
"Packet drop rate");
198 plotAggregator->Set2dDatasetDefaultStyle(Gnuplot2dDataset::LINES);
204 EnumValue(IntervalRateCollector::INPUT_DATA_TYPE_BOOLEAN));
207 EnumValue(IntervalRateCollector::OUTPUT_TYPE_AVERAGE_PER_SAMPLE));
213 const std::string context = it->second->GetName();
214 plotAggregator->Add2dDataset(context, context);
218 &MagisterGnuplotAggregator::Write2d);
226 <<
" is not a valid output type for this statistics.");
230 NS_FATAL_ERROR(
"SatStatsPacketErrorHelper - Invalid output type");
240 NS_LOG_FUNCTION(
this);
242 Callback<void, uint32_t, Ptr<Node>, Ptr<Node>,
bool> callback =
245 NodeContainer sats =
GetSatHelper()->GetBeamHelper()->GetGeoSatNodes();
246 for (NodeContainer::Iterator it = sats.Begin(); it != sats.End(); ++it)
248 Ptr<SatGeoNetDevice> satGeoNetDevice =
250 std::vector<Ptr<PointToPointIslNetDevice>> islNetDevices =
251 satGeoNetDevice->GetIslsNetDevices();
252 for (std::vector<Ptr<PointToPointIslNetDevice>>::iterator itIsl = islNetDevices.begin();
253 itIsl != islNetDevices.end();
256 std::ostringstream oss;
259 if ((*itIsl)->TraceConnectWithoutContext(
"PacketDropRateTrace", callback))
261 NS_LOG_INFO(
this <<
" successfully connected with ISL " << oss.str());
265 NS_LOG_WARN(
this <<
" unable to connect to ISL " << oss.str());
Parent abstract class of all satellite statistics helpers.
Ptr< const SatHelper > GetSatHelper() const
static std::string GetOutputTypeName(OutputType_t outputType)
static Ptr< NetDevice > GetSatSatGeoNetDevice(Ptr< Node > satNode)
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.