Loading...
Searching...
No Matches
satellite-stats-link-sinr-helper.cc
Go to the documentation of this file.
1/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2/*
3 * Copyright (c) 2014 Magister Solutions
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 2 as
7 * published by the Free Software Foundation;
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 *
18 * Author: Bastien Tauran <bastien.tauran@viveris.fr>
19 *
20 */
21
23
24#include "ns3/boolean.h"
25#include "ns3/callback.h"
26#include "ns3/data-collection-object.h"
27#include "ns3/distribution-collector.h"
28#include "ns3/double-probe.h"
29#include "ns3/enum.h"
30#include "ns3/log.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.h"
35#include "ns3/object-map.h"
36#include "ns3/object-vector.h"
37#include "ns3/probe.h"
38#include "ns3/satellite-helper.h"
39#include "ns3/satellite-id-mapper.h"
40#include "ns3/satellite-net-device.h"
41#include "ns3/satellite-orbiter-net-device.h"
42#include "ns3/satellite-phy-rx-carrier.h"
43#include "ns3/satellite-phy-rx.h"
44#include "ns3/satellite-phy.h"
45#include "ns3/satellite-topology.h"
46#include "ns3/scalar-collector.h"
47#include "ns3/singleton.h"
48#include "ns3/string.h"
49#include "ns3/unit-conversion-collector.h"
50
51#include <map>
52#include <sstream>
53#include <string>
54#include <utility>
55
56NS_LOG_COMPONENT_DEFINE("SatStatsLinkSinrHelper");
57
58namespace ns3
59{
60
61NS_OBJECT_ENSURE_REGISTERED(SatStatsLinkSinrHelper);
62
64 : SatStatsHelper(satHelper),
66{
67 NS_LOG_FUNCTION(this << satHelper);
68}
69
71{
72 NS_LOG_FUNCTION(this);
73}
74
75TypeId // static
77{
78 static TypeId tid = TypeId("ns3::SatStatsLinkSinrHelper").SetParent<SatStatsHelper>();
79 return tid;
80}
81
82void
84{
85 NS_LOG_FUNCTION(this << averagingMode);
86 m_averagingMode = averagingMode;
87}
88
89Callback<void, double, const Address&>
94
95void
97{
98 NS_LOG_FUNCTION(this);
99
100 switch (GetOutputType())
101 {
103 NS_FATAL_ERROR(GetOutputTypeName(GetOutputType())
104 << " is not a valid output type for this statistics.");
105 break;
106
108 // Setup aggregator.
109 m_aggregator = CreateAggregator("ns3::MultiFileAggregator",
110 "OutputFileName",
111 StringValue(GetOutputFileName()),
112 "MultiFileMode",
113 BooleanValue(false),
114 "EnableContextPrinting",
115 BooleanValue(true),
116 "GeneralHeading",
117 StringValue(GetIdentifierHeading("sinr_db")));
118
119 // Setup collectors.
120 m_terminalCollectors.SetType("ns3::ScalarCollector");
121 m_terminalCollectors.SetAttribute("InputDataType",
122 EnumValue(ScalarCollector::INPUT_DATA_TYPE_DOUBLE));
123 m_terminalCollectors.SetAttribute(
124 "OutputType",
125 EnumValue(ScalarCollector::OUTPUT_TYPE_AVERAGE_PER_SAMPLE));
127 m_terminalCollectors.ConnectToAggregator("Output",
129 &MultiFileAggregator::Write1d);
130 break;
131 }
132
134 // Setup aggregator.
135 m_aggregator = CreateAggregator("ns3::MultiFileAggregator",
136 "OutputFileName",
137 StringValue(GetOutputFileName()),
138 "GeneralHeading",
139 StringValue(GetTimeHeading("sinr_db")));
140
141 // Setup collectors.
142 m_terminalCollectors.SetType("ns3::UnitConversionCollector");
143 m_terminalCollectors.SetAttribute("ConversionType",
144 EnumValue(UnitConversionCollector::TRANSPARENT));
146 m_terminalCollectors.ConnectToAggregator("OutputTimeValue",
148 &MultiFileAggregator::Write2d);
149 break;
150 }
151
155 if (m_averagingMode)
156 {
157 // Setup aggregator.
158 m_aggregator = CreateAggregator("ns3::MultiFileAggregator",
159 "OutputFileName",
160 StringValue(GetOutputFileName()),
161 "MultiFileMode",
162 BooleanValue(false),
163 "EnableContextPrinting",
164 BooleanValue(false),
165 "GeneralHeading",
166 StringValue(GetDistributionHeading("sinr_db")));
167 Ptr<MultiFileAggregator> fileAggregator =
168 m_aggregator->GetObject<MultiFileAggregator>();
169 NS_ASSERT(fileAggregator != nullptr);
170
171 // Setup the final-level collector.
172 m_averagingCollector = CreateObject<DistributionCollector>();
173 DistributionCollector::OutputType_t outputType =
174 DistributionCollector::OUTPUT_TYPE_HISTOGRAM;
176 {
177 outputType = DistributionCollector::OUTPUT_TYPE_PROBABILITY;
178 }
180 {
181 outputType = DistributionCollector::OUTPUT_TYPE_CUMULATIVE;
182 }
183 m_averagingCollector->SetOutputType(outputType);
184 m_averagingCollector->SetName("0");
185 m_averagingCollector->TraceConnect(
186 "Output",
187 "0",
188 MakeCallback(&MultiFileAggregator::Write2d, fileAggregator));
189 m_averagingCollector->TraceConnect(
190 "OutputString",
191 "0",
192 MakeCallback(&MultiFileAggregator::AddContextHeading, fileAggregator));
193 m_averagingCollector->TraceConnect(
194 "Warning",
195 "0",
196 MakeCallback(&MultiFileAggregator::EnableContextWarning, fileAggregator));
197
198 // Setup collectors.
199 m_terminalCollectors.SetType("ns3::ScalarCollector");
200 m_terminalCollectors.SetAttribute("InputDataType",
201 EnumValue(ScalarCollector::INPUT_DATA_TYPE_DOUBLE));
202 m_terminalCollectors.SetAttribute(
203 "OutputType",
204 EnumValue(ScalarCollector::OUTPUT_TYPE_AVERAGE_PER_SAMPLE));
206 Callback<void, double> callback =
207 MakeCallback(&DistributionCollector::TraceSinkDouble1, m_averagingCollector);
208 for (CollectorMap::Iterator it = m_terminalCollectors.Begin();
209 it != m_terminalCollectors.End();
210 ++it)
211 {
212 it->second->TraceConnectWithoutContext("Output", callback);
213 }
214 }
215 else
216 {
217 // Setup aggregator.
218 m_aggregator = CreateAggregator("ns3::MultiFileAggregator",
219 "OutputFileName",
220 StringValue(GetOutputFileName()),
221 "GeneralHeading",
222 StringValue(GetDistributionHeading("sinr_db")));
223
224 // Setup collectors.
225 m_terminalCollectors.SetType("ns3::DistributionCollector");
226 DistributionCollector::OutputType_t outputType =
227 DistributionCollector::OUTPUT_TYPE_HISTOGRAM;
229 {
230 outputType = DistributionCollector::OUTPUT_TYPE_PROBABILITY;
231 }
233 {
234 outputType = DistributionCollector::OUTPUT_TYPE_CUMULATIVE;
235 }
236 m_terminalCollectors.SetAttribute("OutputType", EnumValue(outputType));
238 m_terminalCollectors.ConnectToAggregator("Output",
240 &MultiFileAggregator::Write2d);
241 m_terminalCollectors.ConnectToAggregator("OutputString",
243 &MultiFileAggregator::AddContextHeading);
244 m_terminalCollectors.ConnectToAggregator("Warning",
246 &MultiFileAggregator::EnableContextWarning);
247 }
248
249 break;
250 }
251
254 NS_FATAL_ERROR(GetOutputTypeName(GetOutputType())
255 << " is not a valid output type for this statistics.");
256 break;
257
259 // Setup aggregator.
260 m_aggregator = CreateAggregator("ns3::MagisterGnuplotAggregator",
261 "OutputPath",
262 StringValue(GetOutputPath()),
263 "OutputFileName",
264 StringValue(GetName()));
265 Ptr<MagisterGnuplotAggregator> plotAggregator =
266 m_aggregator->GetObject<MagisterGnuplotAggregator>();
267 NS_ASSERT(plotAggregator != nullptr);
268 // plot->SetTitle ("");
269 plotAggregator->SetLegend("SINR (in dB)", "Frequency");
270 plotAggregator->Set2dDatasetDefaultStyle(Gnuplot2dDataset::LINES);
271
272 // Setup collectors.
273 m_terminalCollectors.SetType("ns3::UnitConversionCollector");
274 m_terminalCollectors.SetAttribute("ConversionType",
275 EnumValue(UnitConversionCollector::TRANSPARENT));
277 for (CollectorMap::Iterator it = m_terminalCollectors.Begin();
278 it != m_terminalCollectors.End();
279 ++it)
280 {
281 const std::string context = it->second->GetName();
282 plotAggregator->Add2dDataset(context, context);
283 }
284 m_terminalCollectors.ConnectToAggregator("OutputTimeValue",
286 &MagisterGnuplotAggregator::Write2d);
287 break;
288 }
289
293 if (m_averagingMode)
294 {
295 // Setup aggregator.
296 m_aggregator = CreateAggregator("ns3::MagisterGnuplotAggregator",
297 "OutputPath",
298 StringValue(GetOutputPath()),
299 "OutputFileName",
300 StringValue(GetName()));
301 Ptr<MagisterGnuplotAggregator> plotAggregator =
302 m_aggregator->GetObject<MagisterGnuplotAggregator>();
303 NS_ASSERT(plotAggregator != nullptr);
304 // plot->SetTitle ("");
305 plotAggregator->SetLegend("SINR (in dB)", "Frequency");
306 plotAggregator->Set2dDatasetDefaultStyle(Gnuplot2dDataset::LINES);
307 plotAggregator->Add2dDataset(GetName(), GetName());
309
310 // Setup the final-level collector.
311 m_averagingCollector = CreateObject<DistributionCollector>();
312 DistributionCollector::OutputType_t outputType =
313 DistributionCollector::OUTPUT_TYPE_HISTOGRAM;
315 {
316 outputType = DistributionCollector::OUTPUT_TYPE_PROBABILITY;
317 }
319 {
320 outputType = DistributionCollector::OUTPUT_TYPE_CUMULATIVE;
321 }
322 m_averagingCollector->SetOutputType(outputType);
323 m_averagingCollector->SetName("0");
324 m_averagingCollector->TraceConnect(
325 "Output",
326 GetName(),
327 MakeCallback(&MagisterGnuplotAggregator::Write2d, plotAggregator));
329
330 // Setup collectors.
331 m_terminalCollectors.SetType("ns3::ScalarCollector");
332 m_terminalCollectors.SetAttribute("InputDataType",
333 EnumValue(ScalarCollector::INPUT_DATA_TYPE_DOUBLE));
334 m_terminalCollectors.SetAttribute(
335 "OutputType",
336 EnumValue(ScalarCollector::OUTPUT_TYPE_AVERAGE_PER_SAMPLE));
338 Callback<void, double> callback =
339 MakeCallback(&DistributionCollector::TraceSinkDouble1, m_averagingCollector);
340 for (CollectorMap::Iterator it = m_terminalCollectors.Begin();
341 it != m_terminalCollectors.End();
342 ++it)
343 {
344 it->second->TraceConnectWithoutContext("Output", callback);
345 }
346 }
347 else
348 {
349 // Setup aggregator.
350 m_aggregator = CreateAggregator("ns3::MagisterGnuplotAggregator",
351 "OutputPath",
352 StringValue(GetOutputPath()),
353 "OutputFileName",
354 StringValue(GetName()));
355 Ptr<MagisterGnuplotAggregator> plotAggregator =
356 m_aggregator->GetObject<MagisterGnuplotAggregator>();
357 NS_ASSERT(plotAggregator != nullptr);
358 // plot->SetTitle ("");
359 plotAggregator->SetLegend("SINR (in dB)", "Frequency");
360 plotAggregator->Set2dDatasetDefaultStyle(Gnuplot2dDataset::LINES);
361
362 // Setup collectors.
363 m_terminalCollectors.SetType("ns3::DistributionCollector");
364 DistributionCollector::OutputType_t outputType =
365 DistributionCollector::OUTPUT_TYPE_HISTOGRAM;
367 {
368 outputType = DistributionCollector::OUTPUT_TYPE_PROBABILITY;
369 }
371 {
372 outputType = DistributionCollector::OUTPUT_TYPE_CUMULATIVE;
373 }
374 m_terminalCollectors.SetAttribute("OutputType", EnumValue(outputType));
376 for (CollectorMap::Iterator it = m_terminalCollectors.Begin();
377 it != m_terminalCollectors.End();
378 ++it)
379 {
380 const std::string context = it->second->GetName();
381 plotAggregator->Add2dDataset(context, context);
382 }
383 m_terminalCollectors.ConnectToAggregator("Output",
385 &MagisterGnuplotAggregator::Write2d);
386 }
387
388 break;
389 }
390
391 default:
392 NS_FATAL_ERROR("SatStatsLinkDelayHelper - Invalid output type");
393 break;
394 }
395
396 // Setup probes and connect them to the collectors.
398
399} // end of `void DoInstall ();`
400
401void
402SatStatsLinkSinrHelper::SinrCallback(double sinrDb, const Address& from)
403{
404 // NS_LOG_FUNCTION (this << sinrDb << from);
405
406 if (from.IsInvalid())
407 {
408 NS_LOG_WARN(this << " discarding a packet with a sinr of " << sinrDb << "dB"
409 << " from statistics collection because of" << " invalid sender address");
410 }
411 else if (Mac48Address::ConvertFrom(from).IsBroadcast())
412 {
413 for (std::pair<const Address, uint32_t> item : m_identifierMap)
414 {
415 PassSampleToCollector(sinrDb, item.second);
416 }
417 }
418 else
419 {
420 // Determine the identifier associated with the sender address.
421 std::map<const Address, uint32_t>::const_iterator it = m_identifierMap.find(from);
422
423 if (it != m_identifierMap.end())
424 {
425 PassSampleToCollector(sinrDb, it->second);
426 }
427 else
428 {
429 NS_LOG_WARN(this << " discarding a packet with a sinr of " << sinrDb << "dB"
430 << " from statistics collection because of"
431 << " unknown sender address " << from);
432 }
433 }
434}
435
436bool
437SatStatsLinkSinrHelper::ConnectProbeToCollector(Ptr<Probe> probe, uint32_t identifier)
438{
439 NS_LOG_FUNCTION(this << probe << probe->GetName() << identifier);
440
441 bool ret = false;
442 switch (GetOutputType())
443 {
446 ret = m_terminalCollectors.ConnectWithProbe(probe,
447 "OutputSeconds",
448 identifier,
449 &ScalarCollector::TraceSinkDouble);
450 break;
451
454 ret = m_terminalCollectors.ConnectWithProbe(probe,
455 "OutputSeconds",
456 identifier,
457 &UnitConversionCollector::TraceSinkDouble);
458 break;
459
466 if (m_averagingMode)
467 {
468 ret = m_terminalCollectors.ConnectWithProbe(probe,
469 "OutputSeconds",
470 identifier,
471 &ScalarCollector::TraceSinkDouble);
472 }
473 else
474 {
475 ret = m_terminalCollectors.ConnectWithProbe(probe,
476 "OutputSeconds",
477 identifier,
478 &DistributionCollector::TraceSinkDouble);
479 }
480 break;
481
482 default:
483 NS_FATAL_ERROR(GetOutputTypeName(GetOutputType())
484 << " is not a valid output type for this statistics.");
485 break;
486 }
487
488 if (ret)
489 {
490 NS_LOG_INFO(this << " created probe " << probe->GetName() << ", connected to collector "
491 << identifier);
492 }
493 else
494 {
495 NS_LOG_WARN(this << " unable to connect probe " << probe->GetName() << " to collector "
496 << identifier);
497 }
498
499 return ret;
500}
501
502void
503SatStatsLinkSinrHelper::PassSampleToCollector(double sinrDb, uint32_t identifier)
504{
505 // NS_LOG_FUNCTION (this << sinrDb << identifier);
506
507 Ptr<DataCollectionObject> collector = m_terminalCollectors.Get(identifier);
508 NS_ASSERT_MSG(collector != nullptr, "Unable to find collector with identifier " << identifier);
509
510 switch (GetOutputType())
511 {
514 Ptr<ScalarCollector> c = collector->GetObject<ScalarCollector>();
515 NS_ASSERT(c != nullptr);
516 c->TraceSinkDouble(0.0, sinrDb);
517 break;
518 }
519
522 Ptr<UnitConversionCollector> c = collector->GetObject<UnitConversionCollector>();
523 NS_ASSERT(c != nullptr);
524 c->TraceSinkDouble(0.0, sinrDb);
525 break;
526 }
527
534 if (m_averagingMode)
535 {
536 Ptr<ScalarCollector> c = collector->GetObject<ScalarCollector>();
537 NS_ASSERT(c != nullptr);
538 c->TraceSinkDouble(0.0, sinrDb);
539 }
540 else
541 {
542 Ptr<DistributionCollector> c = collector->GetObject<DistributionCollector>();
543 NS_ASSERT(c != nullptr);
544 c->TraceSinkDouble(0.0, sinrDb);
545 }
546 break;
547
548 default:
549 NS_FATAL_ERROR(GetOutputTypeName(GetOutputType())
550 << " is not a valid output type for this statistics.");
551 break;
552
553 } // end of `switch (GetOutputType ())`
554
555} // end of `void PassSampleToCollector (double, uint32_t)`
556
557void
559{
560 // The method below is supposed to be implemented by the child class.
562}
563
564// FORWARD FEEDER LINK ////////////////////////////////////////////////////////
565
566NS_OBJECT_ENSURE_REGISTERED(SatStatsFwdFeederLinkSinrHelper);
567
569 : SatStatsLinkSinrHelper(satHelper)
570{
571 NS_LOG_FUNCTION(this << satHelper);
572}
573
578
579TypeId // static
581{
582 static TypeId tid =
583 TypeId("ns3::SatStatsFwdFeederLinkSinrHelper").SetParent<SatStatsLinkSinrHelper>();
584 return tid;
585}
586
587void
589{
590 NS_LOG_FUNCTION(this);
591
592 NodeContainer uts = Singleton<SatTopology>::Get()->GetUtNodes();
593
594 for (NodeContainer::Iterator it = uts.Begin(); it != uts.End(); ++it)
595 {
596 // Create a map of UT addresses and identifiers.
598 }
599
600 NodeContainer sats = Singleton<SatTopology>::Get()->GetOrbiterNodes();
601
602 for (NodeContainer::Iterator it = sats.Begin(); it != sats.End(); ++it)
603 {
604 Ptr<NetDevice> dev = GetSatSatOrbiterNetDevice(*it);
605 Ptr<SatOrbiterNetDevice> satOrbiterDev = dev->GetObject<SatOrbiterNetDevice>();
606 NS_ASSERT(satOrbiterDev != nullptr);
607 std::map<uint32_t, Ptr<SatPhy>> satOrbiterFeederPhys = satOrbiterDev->GetFeederPhy();
608 ObjectMapValue phy;
609 satOrbiterDev->GetAttribute("FeederPhy", phy);
610 NS_LOG_DEBUG(this << " OrbiterSat Node ID " << (*it)->GetId() << " device #"
611 << dev->GetIfIndex() << " has " << phy.GetN() << " PHY instance(s)");
612
613 for (ObjectMapValue::Iterator itPhy = phy.Begin(); itPhy != phy.End(); ++itPhy)
614 {
615 Ptr<SatPhy> satPhy = itPhy->second->GetObject<SatPhy>();
616 NS_ASSERT(satPhy != nullptr);
617 Ptr<SatPhyRx> satPhyRx = satPhy->GetPhyRx();
618 NS_ASSERT(satPhyRx != nullptr);
619 ObjectVectorValue carriers;
620 satPhyRx->GetAttribute("RxCarrierList", carriers);
621 NS_LOG_DEBUG(this << " PHY #" << itPhy->first << " has " << carriers.GetN()
622 << " RX carrier(s)");
623
624 for (ObjectVectorValue::Iterator itCarrier = carriers.Begin();
625 itCarrier != carriers.End();
626 ++itCarrier)
627 {
628 // NS_ASSERT (itCarrier->second->m_channelType == SatEnums::FORWARD_FEEDER_CH)
629 if (!itCarrier->second->TraceConnectWithoutContext("LinkSinr",
631 {
632 NS_FATAL_ERROR("Error connecting to LinkSinr trace source"
633 << " of SatPhyRxCarrier" << " at OrbiterSat node ID "
634 << (*it)->GetId() << " device #" << dev->GetIfIndex() << " PHY #"
635 << itPhy->first << " RX carrier #" << itCarrier->first);
636 }
637
638 } // end of `for (ObjectVectorValue::Iterator itCarrier = carriers)`
639
640 } // end of `for (ObjectMapValue::Iterator itPhy = phys)`
641 } // end of `for (it = sats.Begin(); it != sats.End (); ++it)`
642
643} // end of `void DoInstallProbes ();`
644
645// FORWARD USER LINK ////////////////////////////////////////////////////////
646
647NS_OBJECT_ENSURE_REGISTERED(SatStatsFwdUserLinkSinrHelper);
648
650 : SatStatsLinkSinrHelper(satHelper)
651{
652 NS_LOG_FUNCTION(this << satHelper);
653}
654
659
660TypeId // static
662{
663 static TypeId tid =
664 TypeId("ns3::SatStatsFwdUserLinkSinrHelper").SetParent<SatStatsLinkSinrHelper>();
665 return tid;
666}
667
668void
670{
671 NS_LOG_FUNCTION(this);
672
673 NodeContainer uts = Singleton<SatTopology>::Get()->GetUtNodes();
674 for (NodeContainer::Iterator it = uts.Begin(); it != uts.End(); ++it)
675 {
676 // Create a map of UT addresses and identifiers.
678
679 // const int32_t utId = GetUtId (*it);
680 // NS_ASSERT_MSG (utId > 0,
681 // "Node " << (*it)->GetId () << " is not a valid UT");
682 // const uint32_t identifier = GetIdentifierForUt (*it);
683 Ptr<NetDevice> dev = GetUtSatNetDevice(*it);
684 Ptr<SatNetDevice> satDev = dev->GetObject<SatNetDevice>();
685 NS_ASSERT(satDev != nullptr);
686 Ptr<SatPhy> satPhy = satDev->GetPhy();
687 NS_ASSERT(satPhy != nullptr);
688 Ptr<SatPhyRx> satPhyRx = satPhy->GetPhyRx();
689 NS_ASSERT(satPhyRx != nullptr);
690 ObjectVectorValue carriers;
691 satPhyRx->GetAttribute("RxCarrierList", carriers);
692 NS_LOG_DEBUG(this << " Node ID " << (*it)->GetId() << " device #" << dev->GetIfIndex()
693 << " has " << carriers.GetN() << " RX carriers");
694
695 for (ObjectVectorValue::Iterator itCarrier = carriers.Begin(); itCarrier != carriers.End();
696 ++itCarrier)
697 {
698 // NS_ASSERT (itCarrier->second->m_channelType == SatEnums::FORWARD_USER_CH)
699 if (!itCarrier->second->TraceConnectWithoutContext("LinkSinr", GetTraceSinkCallback()))
700 {
701 NS_FATAL_ERROR("Error connecting to LinkSinr trace source"
702 << " of SatPhyRxCarrier" << " at node ID " << (*it)->GetId()
703 << " device #" << dev->GetIfIndex() << " RX carrier #"
704 << itCarrier->first);
705 }
706
707 } // end of `for (ObjectVectorValue::Iterator itCarrier = carriers)`
708
709 } // end of `for (it = uts.Begin(); it != uts.End (); ++it)`
710
711} // end of `void DoInstallProbes ();`
712
713// RETURN FEEDER LINK ////////////////////////////////////////////////////////
714
715NS_OBJECT_ENSURE_REGISTERED(SatStatsRtnFeederLinkSinrHelper);
716
718 : SatStatsLinkSinrHelper(satHelper)
719{
720 NS_LOG_FUNCTION(this << satHelper);
721}
722
727
728TypeId // static
730{
731 static TypeId tid =
732 TypeId("ns3::SatStatsRtnFeederLinkSinrHelper").SetParent<SatStatsLinkSinrHelper>();
733 return tid;
734}
735
736void
738{
739 NS_LOG_FUNCTION(this);
740
741 NodeContainer uts = Singleton<SatTopology>::Get()->GetUtNodes();
742 for (NodeContainer::Iterator it = uts.Begin(); it != uts.End(); ++it)
743 {
744 // Create a map of UT addresses and identifiers.
746 }
747
748 NodeContainer gws = Singleton<SatTopology>::Get()->GetGwNodes();
749 for (NodeContainer::Iterator it = gws.Begin(); it != gws.End(); ++it)
750 {
751 NetDeviceContainer devs = GetGwSatNetDevice(*it);
752
753 for (NetDeviceContainer::Iterator itDev = devs.Begin(); itDev != devs.End(); ++itDev)
754 {
755 Ptr<SatNetDevice> satDev = (*itDev)->GetObject<SatNetDevice>();
756 NS_ASSERT(satDev != nullptr);
757 Ptr<SatPhy> satPhy = satDev->GetPhy();
758 NS_ASSERT(satPhy != nullptr);
759 Ptr<SatPhyRx> satPhyRx = satPhy->GetPhyRx();
760 NS_ASSERT(satPhyRx != nullptr);
761 ObjectVectorValue carriers;
762 satPhyRx->GetAttribute("RxCarrierList", carriers);
763 NS_LOG_DEBUG(this << " Node ID " << (*it)->GetId() << " device #"
764 << (*itDev)->GetIfIndex() << " has " << carriers.GetN()
765 << " RX carriers");
766
767 for (ObjectVectorValue::Iterator itCarrier = carriers.Begin();
768 itCarrier != carriers.End();
769 ++itCarrier)
770 {
771 // NS_ASSERT (itCarrier->second->m_channelType == SatEnums::RETURN_FEEDER_CH)
772 if (!itCarrier->second->TraceConnectWithoutContext("LinkSinr",
774 {
775 NS_FATAL_ERROR("Error connecting to LinkSinr trace source"
776 << " of SatPhyRxCarrier" << " at node ID " << (*it)->GetId()
777 << " device #" << (*itDev)->GetIfIndex() << " RX carrier #"
778 << itCarrier->first);
779 }
780
781 } // end of `for (ObjectVectorValue::Iterator itCarrier = carriers)`
782
783 } // end of `for (it = gws.Begin(); it != gws.End (); ++it)`
784
785 } // end of `for (itDev = devs.Begin (); itDev != devs.End (); ++itDev)`
786
787} // end of `void DoInstallProbes ();`
788
789// RETURN USER LINK ////////////////////////////////////////////////////////
790
791NS_OBJECT_ENSURE_REGISTERED(SatStatsRtnUserLinkSinrHelper);
792
794 : SatStatsLinkSinrHelper(satHelper)
795{
796 NS_LOG_FUNCTION(this << satHelper);
797}
798
803
804TypeId // static
806{
807 static TypeId tid =
808 TypeId("ns3::SatStatsRtnUserLinkSinrHelper").SetParent<SatStatsLinkSinrHelper>();
809 return tid;
810}
811
812void
814{
815 NS_LOG_FUNCTION(this);
816
817 NodeContainer uts = Singleton<SatTopology>::Get()->GetUtNodes();
818 for (NodeContainer::Iterator it = uts.Begin(); it != uts.End(); ++it)
819 {
820 // Create a map of UT addresses and identifiers.
822 }
823
824 NodeContainer sats = Singleton<SatTopology>::Get()->GetOrbiterNodes();
825
826 for (NodeContainer::Iterator it = sats.Begin(); it != sats.End(); ++it)
827 {
828 Ptr<NetDevice> dev = GetSatSatOrbiterNetDevice(*it);
829 Ptr<SatOrbiterNetDevice> satOrbiterDev = dev->GetObject<SatOrbiterNetDevice>();
830 NS_ASSERT(satOrbiterDev != nullptr);
831 Ptr<SatPhy> satPhy;
832 std::map<uint32_t, Ptr<SatPhy>> satOrbiterUserPhys = satOrbiterDev->GetUserPhy();
833 for (std::map<uint32_t, Ptr<SatPhy>>::iterator it2 = satOrbiterUserPhys.begin();
834 it2 != satOrbiterUserPhys.end();
835 ++it2)
836 {
837 satPhy = it2->second;
838 NS_ASSERT(satPhy != nullptr);
839 Ptr<SatPhyRx> satPhyRx = satPhy->GetPhyRx();
840 NS_ASSERT(satPhyRx != nullptr);
841 ObjectVectorValue carriers;
842 satPhyRx->GetAttribute("RxCarrierList", carriers);
843 NS_LOG_DEBUG(this << " Node ID " << (*it)->GetId() << " device #"
844 << satOrbiterDev->GetIfIndex() << " has " << carriers.GetN()
845 << " RX carriers");
846
847 for (ObjectVectorValue::Iterator itCarrier = carriers.Begin();
848 itCarrier != carriers.End();
849 ++itCarrier)
850 {
851 // NS_ASSERT (itCarrier->second->m_channelType == SatEnums::RETURN_FEEDER_CH)
852 if (!itCarrier->second->TraceConnectWithoutContext("LinkSinr",
854 {
855 NS_FATAL_ERROR("Error connecting to LinkSinr trace source"
856 << " of SatPhyRxCarrier" << " at node ID " << (*it)->GetId()
857 << " device #" << satOrbiterDev->GetIfIndex() << " RX carrier #"
858 << itCarrier->first);
859 }
860
861 } // end of `for (ObjectVectorValue::Iterator itCarrier = carriers)`
862 }
863 } // end of `for (it = sats.Begin(); it != sats.End (); ++it)`
864
865} // end of `void DoInstallProbes ();`
866
867} // end of namespace ns3
SatNetDevice to be utilized in the UT and GW nodes.
SatOrbiterNetDevice to be utilized in geostationary satellite.
The SatPhy models the basic physical layer of the satellite system.
static Ptr< NetDevice > GetSatSatOrbiterNetDevice(Ptr< Node > satNode)
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)
SatStatsHelper(Ptr< const SatHelper > satHelper)
Creates a new helper instance.
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.
static Ptr< NetDevice > GetUtSatNetDevice(Ptr< Node > utNode)
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
virtual std::string GetDistributionHeading(std::string dataLabel) const
SatArqSequenceNumber is handling the sequence numbers for the ARQ process.