23 #include <ns3/boolean.h>
24 #include <ns3/callback.h>
25 #include <ns3/data-collection-object.h>
27 #include <ns3/interval-rate-collector.h>
29 #include <ns3/mac48-address.h>
30 #include <ns3/magister-gnuplot-aggregator.h>
31 #include <ns3/multi-file-aggregator.h>
32 #include <ns3/node-container.h>
33 #include <ns3/object-vector.h>
34 #include <ns3/satellite-helper.h>
35 #include <ns3/satellite-id-mapper.h>
36 #include <ns3/satellite-net-device.h>
37 #include <ns3/satellite-phy-rx-carrier-marsala.h>
38 #include <ns3/satellite-phy-rx-carrier.h>
39 #include <ns3/satellite-phy-rx.h>
40 #include <ns3/satellite-phy.h>
41 #include <ns3/satellite-topology.h>
42 #include <ns3/scalar-collector.h>
43 #include <ns3/singleton.h>
44 #include <ns3/string.h>
50 NS_LOG_COMPONENT_DEFINE(
"SatStatsMarsalaCorrelationHelper");
57 NS_OBJECT_ENSURE_REGISTERED(SatStatsMarsalaCorrelationHelper);
62 NS_LOG_FUNCTION(
this << satHelper);
69 NS_LOG_FUNCTION(
this);
75 static TypeId tid = TypeId(
"ns3::SatStatsMarsalaCorrelationHelper").SetParent<
SatStatsHelper>();
82 NS_LOG_FUNCTION(
this << traceSourceName);
95 NS_LOG_FUNCTION(
this);
101 <<
" is not a valid output type for this statistics.");
111 "EnableContextPrinting",
119 EnumValue(ScalarCollector::INPUT_DATA_TYPE_UINTEGER));
122 EnumValue(ScalarCollector::OUTPUT_TYPE_AVERAGE_PER_SAMPLE));
126 &MultiFileAggregator::Write1d);
142 EnumValue(IntervalRateCollector::INPUT_DATA_TYPE_UINTEGER));
145 EnumValue(IntervalRateCollector::OUTPUT_TYPE_AVERAGE_PER_SAMPLE));
149 &MultiFileAggregator::Write2d);
152 &MultiFileAggregator::AddContextHeading);
160 <<
" is not a valid output type for this statistics.");
166 <<
" is not a valid output type for this statistics.");
176 Ptr<MagisterGnuplotAggregator> plotAggregator =
178 NS_ASSERT(plotAggregator !=
nullptr);
180 plotAggregator->SetLegend(
"Time (in seconds)",
"Correlations");
181 plotAggregator->Set2dDatasetDefaultStyle(Gnuplot2dDataset::LINES);
187 EnumValue(IntervalRateCollector::INPUT_DATA_TYPE_UINTEGER));
190 EnumValue(IntervalRateCollector::OUTPUT_TYPE_AVERAGE_PER_SAMPLE));
196 const std::string context = it->second->GetName();
197 plotAggregator->Add2dDataset(context, context);
201 &MagisterGnuplotAggregator::Write2d);
209 <<
" is not a valid output type for this statistics.");
213 NS_FATAL_ERROR(
"SatStatsMarsalaCorrelationHelper - Invalid output type");
218 NodeContainer uts = Singleton<SatTopology>::Get()->GetUtNodes();
219 for (NodeContainer::Iterator it = uts.Begin(); it != uts.End(); ++it)
226 NodeContainer gws = Singleton<SatTopology>::Get()->GetGwNodes();
227 Callback<void, uint32_t, const Address&, bool> callback =
230 for (NodeContainer::Iterator it = gws.Begin(); it != gws.End(); ++it)
234 for (NetDeviceContainer::Iterator itDev = devs.Begin(); itDev != devs.End(); ++itDev)
236 Ptr<SatNetDevice> satDev = (*itDev)->GetObject<
SatNetDevice>();
237 NS_ASSERT(satDev !=
nullptr);
238 Ptr<SatPhy> satPhy = satDev->GetPhy();
239 NS_ASSERT(satPhy !=
nullptr);
240 Ptr<SatPhyRx> satPhyRx = satPhy->GetPhyRx();
241 NS_ASSERT(satPhyRx !=
nullptr);
242 ObjectVectorValue carriers;
243 satPhyRx->GetAttribute(
"RxCarrierList", carriers);
244 NS_LOG_DEBUG(
this <<
" Node ID " << (*it)->GetId() <<
" device #"
245 << (*itDev)->GetIfIndex() <<
" has " << carriers.GetN()
248 for (ObjectVectorValue::Iterator itCarrier = carriers.Begin();
249 itCarrier != carriers.End();
252 Ptr<SatPhyRxCarrierMarsala> c =
253 DynamicCast<SatPhyRxCarrierMarsala>(itCarrier->second);
260 DynamicCast<SatPhyRxCarrier>(itCarrier->second)->GetCarrierType();
270 NS_LOG_INFO(
this <<
" successfully connected with node ID " << (*it)->GetId()
271 <<
" device #" << (*itDev)->GetIfIndex() <<
" RX carrier #"
272 << itCarrier->first);
277 <<
" of SatPhyRxCarrier"
278 <<
" at node ID " << (*it)->GetId()
279 <<
" device #" << (*itDev)->GetIfIndex()
280 <<
" RX carrier #" << itCarrier->first);
296 NS_LOG_FUNCTION(
this << nCorrelations << from << isCollided);
298 if (from.IsInvalid())
300 NS_LOG_WARN(
this <<
" discarding " << nCorrelations <<
" packets"
301 <<
" from statistics collection because of"
302 <<
" invalid sender address");
307 std::map<const Address, uint32_t>::const_iterator it =
m_identifierMap.find(from);
311 NS_LOG_WARN(
this <<
" discarding " << nCorrelations <<
" packets"
312 <<
" from statistics collection because of"
313 <<
" unknown sender address " << from);
319 NS_ASSERT_MSG(collector !=
nullptr,
"Unable to find collector with identifier " << it->second);
325 Ptr<ScalarCollector> c = collector->GetObject<ScalarCollector>();
326 NS_ASSERT(c !=
nullptr);
327 c->TraceSinkUinteger32(0, nCorrelations);
333 Ptr<IntervalRateCollector> c = collector->GetObject<IntervalRateCollector>();
334 NS_ASSERT(c !=
nullptr);
335 c->TraceSinkUinteger32(0, nCorrelations);
341 <<
" is not a valid output type for this statistics.");
SatNetDevice to be utilized in the UT and GW nodes.
CarrierType
Possible carrier types.
Parent abstract class of all satellite statistics helpers.
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 CreateCollectorPerIdentifier(CollectorMap &collectorMap) const
Create one collector instance for each identifier in the simulation.
OutputType_t GetOutputType() 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
void CorrelationRxCallback(uint32_t nPackets, const Address &from, bool isCollided)
Receive inputs from trace sources and determine the right collector to forward the inputs to.
SatStatsMarsalaCorrelationHelper(Ptr< const SatHelper > satHelper)
SatPhyRxCarrier::CarrierType GetValidCarrierType() const
Get the valid carrier type.
std::string GetTraceSourceName() const
void SetTraceSourceName(std::string traceSourceName)
void SetValidCarrierType(SatPhyRxCarrier::CarrierType carrierType)
Set valid carrier type for this statistics helper type.
CollectorMap m_terminalCollectors
Maintains a list of collectors created by this helper.
Ptr< DataCollectionObject > m_aggregator
The aggregator created by this helper.
virtual ~SatStatsMarsalaCorrelationHelper()
/ Destructor.
void DoInstall()
Install the probes, collectors, and aggregators necessary to produce the statistics output.
std::string m_traceSourceName
static TypeId GetTypeId()
inherited from ObjectBase base class
SatArqSequenceNumber is handling the sequence numbers for the ARQ process.