Loading...
Searching...
No Matches
satellite-stats-link-modcod-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/application-packet-probe.h"
25#include "ns3/application.h"
26#include "ns3/boolean.h"
27#include "ns3/callback.h"
28#include "ns3/data-collection-object.h"
29#include "ns3/distribution-collector.h"
30#include "ns3/enum.h"
31#include "ns3/inet-socket-address.h"
32#include "ns3/ipv4.h"
33#include "ns3/log.h"
34#include "ns3/mac48-address.h"
35#include "ns3/magister-gnuplot-aggregator.h"
36#include "ns3/multi-file-aggregator.h"
37#include "ns3/net-device.h"
38#include "ns3/node-container.h"
39#include "ns3/nstime.h"
40#include "ns3/probe.h"
41#include "ns3/satellite-helper.h"
42#include "ns3/satellite-id-mapper.h"
43#include "ns3/satellite-net-device.h"
44#include "ns3/satellite-orbiter-net-device.h"
45#include "ns3/satellite-phy.h"
46#include "ns3/satellite-topology.h"
47#include "ns3/scalar-collector.h"
48#include "ns3/singleton.h"
49#include "ns3/string.h"
50#include "ns3/traffic-time-tag.h"
51#include "ns3/unit-conversion-collector.h"
52
53#include <map>
54#include <sstream>
55#include <string>
56#include <utility>
57
58NS_LOG_COMPONENT_DEFINE("SatStatsLinkModcodHelper");
59
60namespace ns3
61{
62
63NS_OBJECT_ENSURE_REGISTERED(SatStatsLinkModcodHelper);
64
66 : SatStatsHelper(satHelper),
67 m_averagingMode(false)
68{
69 NS_LOG_FUNCTION(this << satHelper);
70}
71
73{
74 NS_LOG_FUNCTION(this);
75}
76
77TypeId // static
79{
80 static TypeId tid =
81 TypeId("ns3::SatStatsLinkModcodHelper")
82 .SetParent<SatStatsHelper>()
83 .AddAttribute("AveragingMode",
84 "If true, all samples will be averaged before passed to aggregator. "
85 "Only affects histogram, PDF, and CDF output types.",
86 BooleanValue(false),
89 MakeBooleanChecker());
90 return tid;
91}
92
93void
95{
96 NS_LOG_FUNCTION(this << averagingMode);
97 m_averagingMode = averagingMode;
98}
99
100bool
105
106void
108{
109 NS_LOG_FUNCTION(this);
110
111 switch (GetOutputType())
112 {
114 NS_FATAL_ERROR(GetOutputTypeName(GetOutputType())
115 << " is not a valid output type for this statistics.");
116 break;
117
119 // Setup aggregator.
120 m_aggregator = CreateAggregator("ns3::MultiFileAggregator",
121 "OutputFileName",
122 StringValue(GetOutputFileName()),
123 "MultiFileMode",
124 BooleanValue(false),
125 "EnableContextPrinting",
126 BooleanValue(true),
127 "GeneralHeading",
128 StringValue(GetIdentifierHeading("modcod_id")));
129
130 // Setup collectors.
131 m_terminalCollectors.SetType("ns3::ScalarCollector");
132 m_terminalCollectors.SetAttribute("InputDataType",
133 EnumValue(ScalarCollector::INPUT_DATA_TYPE_DOUBLE));
134 m_terminalCollectors.SetAttribute(
135 "OutputType",
136 EnumValue(ScalarCollector::OUTPUT_TYPE_AVERAGE_PER_SAMPLE));
138 m_terminalCollectors.ConnectToAggregator("Output",
140 &MultiFileAggregator::Write1d);
141 break;
142 }
143
145 // Setup aggregator.
146 m_aggregator = CreateAggregator("ns3::MultiFileAggregator",
147 "OutputFileName",
148 StringValue(GetOutputFileName()),
149 "GeneralHeading",
150 StringValue(GetTimeHeading("modcod_id")));
151
152 // Setup collectors.
153 m_terminalCollectors.SetType("ns3::UnitConversionCollector");
154 m_terminalCollectors.SetAttribute("ConversionType",
155 EnumValue(UnitConversionCollector::TRANSPARENT));
157 m_terminalCollectors.ConnectToAggregator("OutputTimeValue",
159 &MultiFileAggregator::Write2d);
160 break;
161 }
162
166 if (m_averagingMode)
167 {
168 // Setup aggregator.
169 m_aggregator = CreateAggregator("ns3::MultiFileAggregator",
170 "OutputFileName",
171 StringValue(GetOutputFileName()),
172 "MultiFileMode",
173 BooleanValue(false),
174 "EnableContextPrinting",
175 BooleanValue(false),
176 "GeneralHeading",
177 StringValue(GetDistributionHeading("modcod_id")));
178 Ptr<MultiFileAggregator> fileAggregator =
179 m_aggregator->GetObject<MultiFileAggregator>();
180 NS_ASSERT(fileAggregator != nullptr);
181
182 // Setup the final-level collector.
183 m_averagingCollector = CreateObject<DistributionCollector>();
184 DistributionCollector::OutputType_t outputType =
185 DistributionCollector::OUTPUT_TYPE_HISTOGRAM;
187 {
188 outputType = DistributionCollector::OUTPUT_TYPE_PROBABILITY;
189 }
191 {
192 outputType = DistributionCollector::OUTPUT_TYPE_CUMULATIVE;
193 }
194 m_averagingCollector->SetOutputType(outputType);
195 m_averagingCollector->SetName("0");
196 m_averagingCollector->TraceConnect(
197 "Output",
198 "0",
199 MakeCallback(&MultiFileAggregator::Write2d, fileAggregator));
200 m_averagingCollector->TraceConnect(
201 "OutputString",
202 "0",
203 MakeCallback(&MultiFileAggregator::AddContextHeading, fileAggregator));
204 m_averagingCollector->TraceConnect(
205 "Warning",
206 "0",
207 MakeCallback(&MultiFileAggregator::EnableContextWarning, fileAggregator));
208
209 // Setup collectors.
210 m_terminalCollectors.SetType("ns3::ScalarCollector");
211 m_terminalCollectors.SetAttribute("InputDataType",
212 EnumValue(ScalarCollector::INPUT_DATA_TYPE_DOUBLE));
213 m_terminalCollectors.SetAttribute(
214 "OutputType",
215 EnumValue(ScalarCollector::OUTPUT_TYPE_AVERAGE_PER_SAMPLE));
217 Callback<void, double> callback =
218 MakeCallback(&DistributionCollector::TraceSinkDouble1, m_averagingCollector);
219 for (CollectorMap::Iterator it = m_terminalCollectors.Begin();
220 it != m_terminalCollectors.End();
221 ++it)
222 {
223 it->second->TraceConnectWithoutContext("Output", callback);
224 }
225 }
226 else
227 {
228 // Setup aggregator.
229 m_aggregator = CreateAggregator("ns3::MultiFileAggregator",
230 "OutputFileName",
231 StringValue(GetOutputFileName()),
232 "GeneralHeading",
233 StringValue(GetDistributionHeading("modcod_id")));
234
235 // Setup collectors.
236 m_terminalCollectors.SetType("ns3::DistributionCollector");
237 DistributionCollector::OutputType_t outputType =
238 DistributionCollector::OUTPUT_TYPE_HISTOGRAM;
240 {
241 outputType = DistributionCollector::OUTPUT_TYPE_PROBABILITY;
242 }
244 {
245 outputType = DistributionCollector::OUTPUT_TYPE_CUMULATIVE;
246 }
247 m_terminalCollectors.SetAttribute("OutputType", EnumValue(outputType));
249 m_terminalCollectors.ConnectToAggregator("Output",
251 &MultiFileAggregator::Write2d);
252 m_terminalCollectors.ConnectToAggregator("OutputString",
254 &MultiFileAggregator::AddContextHeading);
255 m_terminalCollectors.ConnectToAggregator("Warning",
257 &MultiFileAggregator::EnableContextWarning);
258 }
259
260 break;
261 }
262
265 NS_FATAL_ERROR(GetOutputTypeName(GetOutputType())
266 << " is not a valid output type for this statistics.");
267 break;
268
270 // Setup aggregator.
271 m_aggregator = CreateAggregator("ns3::MagisterGnuplotAggregator",
272 "OutputPath",
273 StringValue(GetOutputPath()),
274 "OutputFileName",
275 StringValue(GetName()));
276 Ptr<MagisterGnuplotAggregator> plotAggregator =
277 m_aggregator->GetObject<MagisterGnuplotAggregator>();
278 NS_ASSERT(plotAggregator != nullptr);
279 // plot->SetTitle ("");
280 plotAggregator->SetLegend("Time (in seconds)", "MODCOD ID");
281 plotAggregator->Set2dDatasetDefaultStyle(Gnuplot2dDataset::LINES);
282
283 // Setup collectors.
284 m_terminalCollectors.SetType("ns3::UnitConversionCollector");
285 m_terminalCollectors.SetAttribute("ConversionType",
286 EnumValue(UnitConversionCollector::TRANSPARENT));
288 for (CollectorMap::Iterator it = m_terminalCollectors.Begin();
289 it != m_terminalCollectors.End();
290 ++it)
291 {
292 const std::string context = it->second->GetName();
293 plotAggregator->Add2dDataset(context, context);
294 }
295 m_terminalCollectors.ConnectToAggregator("OutputTimeValue",
297 &MagisterGnuplotAggregator::Write2d);
298 break;
299 }
300
304 if (m_averagingMode)
305 {
306 // Setup aggregator.
307 m_aggregator = CreateAggregator("ns3::MagisterGnuplotAggregator",
308 "OutputPath",
309 StringValue(GetOutputPath()),
310 "OutputFileName",
311 StringValue(GetName()));
312 Ptr<MagisterGnuplotAggregator> plotAggregator =
313 m_aggregator->GetObject<MagisterGnuplotAggregator>();
314 NS_ASSERT(plotAggregator != nullptr);
315 // plot->SetTitle ("");
316 plotAggregator->SetLegend("MODCOD ID", "Frequency");
317 plotAggregator->Set2dDatasetDefaultStyle(Gnuplot2dDataset::LINES);
318 plotAggregator->Add2dDataset(GetName(), GetName());
320
321 // Setup the final-level collector.
322 m_averagingCollector = CreateObject<DistributionCollector>();
323 DistributionCollector::OutputType_t outputType =
324 DistributionCollector::OUTPUT_TYPE_HISTOGRAM;
326 {
327 outputType = DistributionCollector::OUTPUT_TYPE_PROBABILITY;
328 }
330 {
331 outputType = DistributionCollector::OUTPUT_TYPE_CUMULATIVE;
332 }
333 m_averagingCollector->SetOutputType(outputType);
334 m_averagingCollector->SetName("0");
335 m_averagingCollector->TraceConnect(
336 "Output",
337 GetName(),
338 MakeCallback(&MagisterGnuplotAggregator::Write2d, plotAggregator));
340
341 // Setup collectors.
342 m_terminalCollectors.SetType("ns3::ScalarCollector");
343 m_terminalCollectors.SetAttribute("InputDataType",
344 EnumValue(ScalarCollector::INPUT_DATA_TYPE_DOUBLE));
345 m_terminalCollectors.SetAttribute(
346 "OutputType",
347 EnumValue(ScalarCollector::OUTPUT_TYPE_AVERAGE_PER_SAMPLE));
349 Callback<void, double> callback =
350 MakeCallback(&DistributionCollector::TraceSinkDouble1, m_averagingCollector);
351 for (CollectorMap::Iterator it = m_terminalCollectors.Begin();
352 it != m_terminalCollectors.End();
353 ++it)
354 {
355 it->second->TraceConnectWithoutContext("Output", callback);
356 }
357 }
358 else
359 {
360 // Setup aggregator.
361 m_aggregator = CreateAggregator("ns3::MagisterGnuplotAggregator",
362 "OutputPath",
363 StringValue(GetOutputPath()),
364 "OutputFileName",
365 StringValue(GetName()));
366 Ptr<MagisterGnuplotAggregator> plotAggregator =
367 m_aggregator->GetObject<MagisterGnuplotAggregator>();
368 NS_ASSERT(plotAggregator != nullptr);
369 // plot->SetTitle ("");
370 plotAggregator->SetLegend("MODCOD ID", "Frequency");
371 plotAggregator->Set2dDatasetDefaultStyle(Gnuplot2dDataset::LINES);
372
373 // Setup collectors.
374 m_terminalCollectors.SetType("ns3::DistributionCollector");
375 DistributionCollector::OutputType_t outputType =
376 DistributionCollector::OUTPUT_TYPE_HISTOGRAM;
378 {
379 outputType = DistributionCollector::OUTPUT_TYPE_PROBABILITY;
380 }
382 {
383 outputType = DistributionCollector::OUTPUT_TYPE_CUMULATIVE;
384 }
385 m_terminalCollectors.SetAttribute("OutputType", EnumValue(outputType));
387 for (CollectorMap::Iterator it = m_terminalCollectors.Begin();
388 it != m_terminalCollectors.End();
389 ++it)
390 {
391 const std::string context = it->second->GetName();
392 plotAggregator->Add2dDataset(context, context);
393 }
394 m_terminalCollectors.ConnectToAggregator("Output",
396 &MagisterGnuplotAggregator::Write2d);
397 }
398
399 break;
400 }
401
402 default:
403 NS_FATAL_ERROR("SatStatsLinkModcodHelper - Invalid output type");
404 break;
405 }
406
407 // Setup probes and connect them to the collectors.
409
410} // end of `void DoInstall ();`
411
412void
414{
415 // The method below is supposed to be implemented by the child class.
417}
418
419void
420SatStatsLinkModcodHelper::RxLinkModcodCallback(uint32_t modcod, const Address& from)
421{
422 if (from.IsInvalid())
423 {
424 NS_LOG_WARN(this << " discarding a packet MODCOD ID " << modcod
425 << " from statistics collection because of" << " invalid sender address");
426 }
427 else if (Mac48Address::ConvertFrom(from).IsBroadcast())
428 {
429 for (std::pair<const Address, uint32_t> item : m_identifierMap)
430 {
431 PassSampleToCollector(modcod, item.second);
432 }
433 }
434 else
435 {
436 // Determine the identifier associated with the sender address.
437 std::map<const Address, uint32_t>::const_iterator it = m_identifierMap.find(from);
438
439 if (it != m_identifierMap.end())
440 {
441 PassSampleToCollector(modcod, it->second);
442 }
443 else
444 {
445 NS_LOG_WARN(this << " discarding a packet MODCOD ID " << modcod
446 << " from statistics collection because of"
447 << " unknown sender address " << from);
448 }
449 }
450}
451
452bool
453SatStatsLinkModcodHelper::ConnectProbeToCollector(Ptr<Probe> probe, uint32_t identifier)
454{
455 NS_LOG_FUNCTION(this << probe << probe->GetName() << identifier);
456
457 bool ret = false;
458 switch (GetOutputType())
459 {
462 ret = m_terminalCollectors.ConnectWithProbe(probe,
463 "OutputSeconds",
464 identifier,
465 &ScalarCollector::TraceSinkDouble);
466 break;
467
470 ret = m_terminalCollectors.ConnectWithProbe(probe,
471 "OutputSeconds",
472 identifier,
473 &UnitConversionCollector::TraceSinkDouble);
474 break;
475
482 if (m_averagingMode)
483 {
484 ret = m_terminalCollectors.ConnectWithProbe(probe,
485 "OutputSeconds",
486 identifier,
487 &ScalarCollector::TraceSinkDouble);
488 }
489 else
490 {
491 ret = m_terminalCollectors.ConnectWithProbe(probe,
492 "OutputSeconds",
493 identifier,
494 &DistributionCollector::TraceSinkDouble);
495 }
496 break;
497
498 default:
499 NS_FATAL_ERROR(GetOutputTypeName(GetOutputType())
500 << " is not a valid output type for this statistics.");
501 break;
502 }
503
504 if (ret)
505 {
506 NS_LOG_INFO(this << " created probe " << probe->GetName() << ", connected to collector "
507 << identifier);
508 }
509 else
510 {
511 NS_LOG_WARN(this << " unable to connect probe " << probe->GetName() << " to collector "
512 << identifier);
513 }
514
515 return ret;
516}
517
518void
519SatStatsLinkModcodHelper::PassSampleToCollector(uint32_t modcod, uint32_t identifier)
520{
521 Ptr<DataCollectionObject> collector = m_terminalCollectors.Get(identifier);
522 NS_ASSERT_MSG(collector != nullptr, "Unable to find collector with identifier " << identifier);
523
524 switch (GetOutputType())
525 {
528 Ptr<ScalarCollector> c = collector->GetObject<ScalarCollector>();
529 NS_ASSERT(c != nullptr);
530 c->TraceSinkUinteger32(0.0, modcod);
531 break;
532 }
533
536 Ptr<UnitConversionCollector> c = collector->GetObject<UnitConversionCollector>();
537 NS_ASSERT(c != nullptr);
538 c->TraceSinkUinteger32(0.0, modcod);
539 break;
540 }
541
548 if (m_averagingMode)
549 {
550 Ptr<ScalarCollector> c = collector->GetObject<ScalarCollector>();
551 NS_ASSERT(c != nullptr);
552 c->TraceSinkUinteger32(0.0, modcod);
553 }
554 else
555 {
556 Ptr<DistributionCollector> c = collector->GetObject<DistributionCollector>();
557 NS_ASSERT(c != nullptr);
558 c->TraceSinkUinteger32(0.0, modcod);
559 }
560 break;
561
562 default:
563 NS_FATAL_ERROR(GetOutputTypeName(GetOutputType())
564 << " is not a valid output type for this statistics.");
565 break;
566
567 } // end of `switch (GetOutputType ())`
568
569} // end of `void PassSampleToCollector (Time, uint32_t)`
570
571// FORWARD FEEDER LINK /////////////////////////////////////////////////////
572
573NS_OBJECT_ENSURE_REGISTERED(SatStatsFwdFeederLinkModcodHelper);
574
576 : SatStatsLinkModcodHelper(satHelper)
577{
578 NS_LOG_FUNCTION(this << satHelper);
579}
580
585
586TypeId // static
588{
589 static TypeId tid =
590 TypeId("ns3::SatStatsFwdFeederLinkModcodHelper").SetParent<SatStatsLinkModcodHelper>();
591 return tid;
592}
593
594void
596{
597 NS_LOG_FUNCTION(this);
598
599 NodeContainer sats = Singleton<SatTopology>::Get()->GetOrbiterNodes();
600 Callback<void, uint32_t, const Address&> callback =
602
603 for (NodeContainer::Iterator it = sats.Begin(); it != sats.End(); ++it)
604 {
605 Ptr<NetDevice> dev = GetSatSatOrbiterNetDevice(*it);
606 Ptr<SatOrbiterNetDevice> satOrbiterDev = dev->GetObject<SatOrbiterNetDevice>();
607 NS_ASSERT(satOrbiterDev != nullptr);
608 std::map<uint32_t, Ptr<SatPhy>> satOrbiterFeederPhys = satOrbiterDev->GetFeederPhy();
609 Ptr<SatPhy> satPhy;
610 for (std::map<uint32_t, Ptr<SatPhy>>::iterator it2 = satOrbiterFeederPhys.begin();
611 it2 != satOrbiterFeederPhys.end();
612 ++it2)
613 {
614 satPhy = it2->second;
615 NS_ASSERT(satPhy != nullptr);
616 satPhy->SetAttribute("EnableStatisticsTags", BooleanValue(true));
617
618 // Connect the object to the probe.
619 if (satPhy->TraceConnectWithoutContext("RxLinkModcod", callback))
620 {
621 NS_LOG_INFO(this << " successfully connected with node ID " << (*it)->GetId()
622 << " device #" << satOrbiterDev->GetIfIndex());
623
624 // Enable statistics-related tags and trace sources on the device.
625 satPhy->SetAttribute("EnableStatisticsTags", BooleanValue(true));
626 }
627 else
628 {
629 NS_FATAL_ERROR("Error connecting to RxLinkModcod trace source of SatNetDevice"
630 << " at node ID " << (*it)->GetId() << " device #"
631 << satOrbiterDev->GetIfIndex());
632 }
633 }
634 std::map<uint32_t, Ptr<SatPhy>> satOrbiterUserPhys = satOrbiterDev->GetUserPhy();
635 for (std::map<uint32_t, Ptr<SatPhy>>::iterator it2 = satOrbiterUserPhys.begin();
636 it2 != satOrbiterUserPhys.end();
637 ++it2)
638 {
639 satPhy = it2->second;
640 NS_ASSERT(satPhy != nullptr);
641 satPhy->SetAttribute("EnableStatisticsTags", BooleanValue(true));
642 }
643 } // end of `for (it = sats.Begin(); it != sats.End (); ++it)`
644
645 NodeContainer uts = Singleton<SatTopology>::Get()->GetUtNodes();
646
647 for (NodeContainer::Iterator it = uts.Begin(); it != uts.End(); ++it)
648 {
649 // Create a map of UT addresses and identifiers.
651
652 Ptr<NetDevice> dev = GetUtSatNetDevice(*it);
653 Ptr<SatNetDevice> satDev = dev->GetObject<SatNetDevice>();
654 NS_ASSERT(satDev != nullptr);
655 Ptr<SatPhy> satPhy = satDev->GetPhy();
656 NS_ASSERT(satPhy != nullptr);
657
658 satPhy->SetAttribute("EnableStatisticsTags", BooleanValue(true));
659
660 } // end of `for (it = uts.Begin(); it != uts.End (); ++it)`
661
662 // Enable statistics-related tags on the transmitting device.
663 NodeContainer gws = Singleton<SatTopology>::Get()->GetGwNodes();
664 for (NodeContainer::Iterator it = gws.Begin(); it != gws.End(); ++it)
665 {
666 NetDeviceContainer devs = GetGwSatNetDevice(*it);
667
668 for (NetDeviceContainer::Iterator itDev = devs.Begin(); itDev != devs.End(); ++itDev)
669 {
670 Ptr<SatNetDevice> satDev = (*itDev)->GetObject<SatNetDevice>();
671 NS_ASSERT(satDev != nullptr);
672 Ptr<SatPhy> satPhy = satDev->GetPhy();
673 NS_ASSERT(satPhy != nullptr);
674
675 satPhy->SetAttribute("EnableStatisticsTags", BooleanValue(true));
676 }
677 }
678
679} // end of `void DoInstallProbes ();`
680
681// FORWARD USER LINK /////////////////////////////////////////////////////
682
683NS_OBJECT_ENSURE_REGISTERED(SatStatsFwdUserLinkModcodHelper);
684
686 : SatStatsLinkModcodHelper(satHelper)
687{
688 NS_LOG_FUNCTION(this << satHelper);
689}
690
695
696TypeId // static
698{
699 static TypeId tid =
700 TypeId("ns3::SatStatsFwdUserLinkModcodHelper").SetParent<SatStatsLinkModcodHelper>();
701 return tid;
702}
703
704void
706{
707 NS_LOG_FUNCTION(this);
708
709 NodeContainer sats = Singleton<SatTopology>::Get()->GetOrbiterNodes();
710 Callback<void, uint32_t, const Address&> callback =
712
713 for (NodeContainer::Iterator it = sats.Begin(); it != sats.End(); ++it)
714 {
715 Ptr<NetDevice> dev = GetSatSatOrbiterNetDevice(*it);
716 Ptr<SatOrbiterNetDevice> satOrbiterDev = dev->GetObject<SatOrbiterNetDevice>();
717 NS_ASSERT(satOrbiterDev != nullptr);
718 std::map<uint32_t, Ptr<SatPhy>> satOrbiterFeederPhys = satOrbiterDev->GetFeederPhy();
719 Ptr<SatPhy> satPhy;
720 for (std::map<uint32_t, Ptr<SatPhy>>::iterator it2 = satOrbiterFeederPhys.begin();
721 it2 != satOrbiterFeederPhys.end();
722 ++it2)
723 {
724 satPhy = it2->second;
725 NS_ASSERT(satPhy != nullptr);
726 satPhy->SetAttribute("EnableStatisticsTags", BooleanValue(true));
727 }
728 std::map<uint32_t, Ptr<SatPhy>> satOrbiterUserPhys = satOrbiterDev->GetUserPhy();
729 for (std::map<uint32_t, Ptr<SatPhy>>::iterator it2 = satOrbiterUserPhys.begin();
730 it2 != satOrbiterUserPhys.end();
731 ++it2)
732 {
733 satPhy = it2->second;
734 NS_ASSERT(satPhy != nullptr);
735 satPhy->SetAttribute("EnableStatisticsTags", BooleanValue(true));
736 }
737 } // end of `for (it = sats.Begin(); it != sats.End (); ++it)`
738
739 NodeContainer uts = Singleton<SatTopology>::Get()->GetUtNodes();
740
741 for (NodeContainer::Iterator it = uts.Begin(); it != uts.End(); ++it)
742 {
743 // Create a map of UT addresses and identifiers.
745
746 const int32_t utId = GetUtId(*it);
747 NS_ASSERT_MSG(utId > 0, "Node " << (*it)->GetId() << " is not a valid UT");
748
749 Ptr<NetDevice> dev = GetUtSatNetDevice(*it);
750 Ptr<SatNetDevice> satDev = dev->GetObject<SatNetDevice>();
751 NS_ASSERT(satDev != nullptr);
752 Ptr<SatPhy> satPhy = satDev->GetPhy();
753 NS_ASSERT(satPhy != nullptr);
754
755 // Connect the object to the probe.
756 if (satPhy->TraceConnectWithoutContext("RxLinkModcod", callback))
757 {
758 NS_LOG_INFO(this << " successfully connected with node ID " << (*it)->GetId()
759 << " device #2");
760
761 // Enable statistics-related tags and trace sources on the device.
762 satPhy->SetAttribute("EnableStatisticsTags", BooleanValue(true));
763 }
764 else
765 {
766 NS_FATAL_ERROR("Error connecting to RxLinkModcod trace source of SatPhy"
767 << " at node ID " << (*it)->GetId() << " device #2");
768 }
769
770 } // end of `for (it = uts.Begin(); it != uts.End (); ++it)`
771
772 // Enable statistics-related tags on the transmitting device.
773 NodeContainer gws = Singleton<SatTopology>::Get()->GetGwNodes();
774 for (NodeContainer::Iterator it = gws.Begin(); it != gws.End(); ++it)
775 {
776 NetDeviceContainer devs = GetGwSatNetDevice(*it);
777
778 for (NetDeviceContainer::Iterator itDev = devs.Begin(); itDev != devs.End(); ++itDev)
779 {
780 Ptr<SatNetDevice> satDev = (*itDev)->GetObject<SatNetDevice>();
781 NS_ASSERT(satDev != nullptr);
782 Ptr<SatPhy> satPhy = satDev->GetPhy();
783 NS_ASSERT(satPhy != nullptr);
784
785 satPhy->SetAttribute("EnableStatisticsTags", BooleanValue(true));
786 }
787 }
788
789} // end of `void DoInstallProbes ();`
790
791// RETURN FEEDER LINK //////////////////////////////////////////////////////
792
793NS_OBJECT_ENSURE_REGISTERED(SatStatsRtnFeederLinkModcodHelper);
794
796 : SatStatsLinkModcodHelper(satHelper)
797{
798 NS_LOG_FUNCTION(this << satHelper);
799}
800
805
806TypeId // static
808{
809 static TypeId tid =
810 TypeId("ns3::SatStatsRtnFeederLinkModcodHelper").SetParent<SatStatsLinkModcodHelper>();
811 return tid;
812}
813
814void
816{
817 NS_LOG_FUNCTION(this);
818
819 NodeContainer sats = Singleton<SatTopology>::Get()->GetOrbiterNodes();
820
821 for (NodeContainer::Iterator it = sats.Begin(); it != sats.End(); ++it)
822 {
823 Ptr<SatPhy> satPhy;
824 Ptr<NetDevice> dev = GetSatSatOrbiterNetDevice(*it);
825 Ptr<SatOrbiterNetDevice> satOrbiterDev = dev->GetObject<SatOrbiterNetDevice>();
826 NS_ASSERT(satOrbiterDev != nullptr);
827 std::map<uint32_t, Ptr<SatPhy>> satOrbiterFeederPhys = satOrbiterDev->GetFeederPhy();
828 for (std::map<uint32_t, Ptr<SatPhy>>::iterator it2 = satOrbiterFeederPhys.begin();
829 it2 != satOrbiterFeederPhys.end();
830 ++it2)
831 {
832 satPhy = it2->second;
833 NS_ASSERT(satPhy != nullptr);
834 satPhy->SetAttribute("EnableStatisticsTags", BooleanValue(true));
835 }
836 std::map<uint32_t, Ptr<SatPhy>> satOrbiterUserPhys = satOrbiterDev->GetUserPhy();
837 for (std::map<uint32_t, Ptr<SatPhy>>::iterator it2 = satOrbiterUserPhys.begin();
838 it2 != satOrbiterUserPhys.end();
839 ++it2)
840 {
841 satPhy = it2->second;
842 NS_ASSERT(satPhy != nullptr);
843 satPhy->SetAttribute("EnableStatisticsTags", BooleanValue(true));
844 }
845 } // end of `for (it = sats.Begin(); it != sats.End (); ++it)`
846
847 NodeContainer uts = Singleton<SatTopology>::Get()->GetUtNodes();
848 for (NodeContainer::Iterator it = uts.Begin(); it != uts.End(); ++it)
849 {
850 // Create a map of UT addresses and identifiers.
852
853 // Enable statistics-related tags and trace sources on the device.
854 Ptr<NetDevice> dev = GetUtSatNetDevice(*it);
855 Ptr<SatNetDevice> satDev = dev->GetObject<SatNetDevice>();
856 NS_ASSERT(satDev != nullptr);
857 Ptr<SatPhy> satPhy = satDev->GetPhy();
858 NS_ASSERT(satPhy != nullptr);
859 satPhy->SetAttribute("EnableStatisticsTags", BooleanValue(true));
860 }
861
862 // Connect to trace sources at GW nodes.
863
864 NodeContainer gws = Singleton<SatTopology>::Get()->GetGwNodes();
865 Callback<void, uint32_t, const Address&> callback =
867
868 for (NodeContainer::Iterator it = gws.Begin(); it != gws.End(); ++it)
869 {
870 NetDeviceContainer devs = GetGwSatNetDevice(*it);
871
872 for (NetDeviceContainer::Iterator itDev = devs.Begin(); itDev != devs.End(); ++itDev)
873 {
874 Ptr<SatNetDevice> satDev = (*itDev)->GetObject<SatNetDevice>();
875 NS_ASSERT(satDev != nullptr);
876 Ptr<SatPhy> satPhy = satDev->GetPhy();
877 NS_ASSERT(satPhy != nullptr);
878
879 // Connect the object to the probe.
880 if (satPhy->TraceConnectWithoutContext("RxLinkModcod", callback))
881 {
882 NS_LOG_INFO(this << " successfully connected with node ID " << (*it)->GetId()
883 << " device #" << satDev->GetIfIndex());
884
885 // Enable statistics-related tags and trace sources on the device.
886 satPhy->SetAttribute("EnableStatisticsTags", BooleanValue(true));
887 }
888 else
889 {
890 NS_FATAL_ERROR("Error connecting to RxLinkModcod trace source of SatNetDevice"
891 << " at node ID " << (*it)->GetId() << " device #"
892 << satDev->GetIfIndex());
893 }
894
895 } // end of `for (NetDeviceContainer::Iterator itDev = devs)`
896
897 } // end of `for (NodeContainer::Iterator it = gws)`
898
899} // end of `void DoInstallProbes ();`
900
901// RETURN USER LINK //////////////////////////////////////////////////////
902
903NS_OBJECT_ENSURE_REGISTERED(SatStatsRtnUserLinkModcodHelper);
904
906 : SatStatsLinkModcodHelper(satHelper)
907{
908 NS_LOG_FUNCTION(this << satHelper);
909}
910
915
916TypeId // static
918{
919 static TypeId tid =
920 TypeId("ns3::SatStatsRtnUserLinkModcodHelper").SetParent<SatStatsLinkModcodHelper>();
921 return tid;
922}
923
924void
926{
927 NS_LOG_FUNCTION(this);
928
929 NodeContainer sats = Singleton<SatTopology>::Get()->GetOrbiterNodes();
930 Callback<void, uint32_t, const Address&> callback =
932
933 for (NodeContainer::Iterator it = sats.Begin(); it != sats.End(); ++it)
934 {
935 Ptr<NetDevice> dev = GetSatSatOrbiterNetDevice(*it);
936 Ptr<SatOrbiterNetDevice> satOrbiterDev = dev->GetObject<SatOrbiterNetDevice>();
937 NS_ASSERT(satOrbiterDev != nullptr);
938 std::map<uint32_t, Ptr<SatPhy>> satOrbiterFeederPhys = satOrbiterDev->GetFeederPhy();
939 Ptr<SatPhy> satPhy;
940 for (std::map<uint32_t, Ptr<SatPhy>>::iterator it2 = satOrbiterFeederPhys.begin();
941 it2 != satOrbiterFeederPhys.end();
942 ++it2)
943 {
944 satPhy = it2->second;
945 NS_ASSERT(satPhy != nullptr);
946 satPhy->SetAttribute("EnableStatisticsTags", BooleanValue(true));
947 }
948 std::map<uint32_t, Ptr<SatPhy>> satOrbiterUserPhys = satOrbiterDev->GetUserPhy();
949 for (std::map<uint32_t, Ptr<SatPhy>>::iterator it2 = satOrbiterUserPhys.begin();
950 it2 != satOrbiterUserPhys.end();
951 ++it2)
952 {
953 satPhy = it2->second;
954 NS_ASSERT(satPhy != nullptr);
955 satPhy->SetAttribute("EnableStatisticsTags", BooleanValue(true));
956
957 // Connect the object to the probe.
958 if (satPhy->TraceConnectWithoutContext("RxLinkModcod", callback))
959 {
960 NS_LOG_INFO(this << " successfully connected with node ID " << (*it)->GetId()
961 << " device #" << satOrbiterDev->GetIfIndex());
962 }
963 else
964 {
965 NS_FATAL_ERROR("Error connecting to RxLinkModcod trace source of SatNetDevice"
966 << " at node ID " << (*it)->GetId() << " device #"
967 << satOrbiterDev->GetIfIndex());
968 }
969 }
970 } // end of `for (it = sats.Begin(); it != sats.End (); ++it)`
971
972 NodeContainer uts = Singleton<SatTopology>::Get()->GetUtNodes();
973 for (NodeContainer::Iterator it = uts.Begin(); it != uts.End(); ++it)
974 {
975 // Create a map of UT addresses and identifiers.
977
978 // Enable statistics-related tags and trace sources on the device.
979 Ptr<NetDevice> dev = GetUtSatNetDevice(*it);
980 Ptr<SatNetDevice> satDev = dev->GetObject<SatNetDevice>();
981 NS_ASSERT(satDev != nullptr);
982 Ptr<SatPhy> satPhy = satDev->GetPhy();
983 NS_ASSERT(satPhy != nullptr);
984 satPhy->SetAttribute("EnableStatisticsTags", BooleanValue(true));
985 }
986
987 // Connect to trace sources at GW nodes.
988
989 NodeContainer gws = Singleton<SatTopology>::Get()->GetGwNodes();
990
991 for (NodeContainer::Iterator it = gws.Begin(); it != gws.End(); ++it)
992 {
993 NetDeviceContainer devs = GetGwSatNetDevice(*it);
994
995 for (NetDeviceContainer::Iterator itDev = devs.Begin(); itDev != devs.End(); ++itDev)
996 {
997 Ptr<SatNetDevice> satDev = (*itDev)->GetObject<SatNetDevice>();
998 NS_ASSERT(satDev != nullptr);
999 Ptr<SatPhy> satPhy = satDev->GetPhy();
1000 NS_ASSERT(satPhy != nullptr);
1001
1002 satPhy->SetAttribute("EnableStatisticsTags", BooleanValue(true));
1003 } // end of `for (NetDeviceContainer::Iterator itDev = devs)`
1004
1005 } // end of `for (NodeContainer::Iterator it = gws)`
1006
1007} // end of `void DoInstallProbes ();`
1008
1009} // end of namespace ns3
SatNetDevice to be utilized in the UT and GW nodes.
SatOrbiterNetDevice to be utilized in geostationary satellite.
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 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
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.