Loading...
Searching...
No Matches
satellite-stats-satellite-queue-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-orbiter-feeder-phy.h"
41#include "ns3/satellite-orbiter-net-device.h"
42#include "ns3/satellite-orbiter-user-phy.h"
43#include "ns3/satellite-phy.h"
44#include "ns3/satellite-topology.h"
45#include "ns3/scalar-collector.h"
46#include "ns3/singleton.h"
47#include "ns3/string.h"
48#include "ns3/unit-conversion-collector.h"
49
50#include <map>
51#include <sstream>
52#include <string>
53#include <utility>
54
55NS_LOG_COMPONENT_DEFINE("SatStatsSatelliteQueueHelper");
56
57namespace ns3
58{
59
60NS_OBJECT_ENSURE_REGISTERED(SatStatsSatelliteQueueHelper);
61
62std::string // static
64{
65 switch (unitType)
66 {
68 return "UNIT_BYTES";
70 return "UNIT_NUMBER_OF_PACKETS";
71 default:
72 NS_FATAL_ERROR("SatStatsSatelliteQueueHelper - Invalid unit type");
73 break;
74 }
75
76 NS_FATAL_ERROR("SatStatsSatelliteQueueHelper - Invalid unit type");
77 return "";
78}
79
81 : SatStatsHelper(satHelper)
82{
83 NS_LOG_FUNCTION(this << satHelper);
84}
85
90
91TypeId // static
93{
94 static TypeId tid = TypeId("ns3::SatStatsSatelliteQueueHelper").SetParent<SatStatsHelper>();
95 return tid;
96}
97
98void
100{
101 NS_LOG_FUNCTION(this << GetUnitTypeName(unitType));
102 m_unitType = unitType;
103
104 // Update presentation-based attributes.
106 {
107 m_shortLabel = "size_bytes";
108 m_longLabel = "Queue size (in bytes)";
109 }
111 {
112 m_shortLabel = "num_packets";
113 m_longLabel = "Queue size (in number of packets)";
114 }
115 else
116 {
117 NS_FATAL_ERROR("SatStatsSatelliteQueueHelper - Invalid unit type");
118 }
119}
120
121void
123{
124 NS_LOG_FUNCTION(this << averagingMode);
125 m_averagingMode = averagingMode;
126}
127
128void
130{
131 NS_LOG_FUNCTION(this);
132
133 switch (GetOutputType())
134 {
136 NS_FATAL_ERROR(GetOutputTypeName(GetOutputType())
137 << " is not a valid output type for this statistics.");
138 break;
139
141 // Setup aggregator.
142 m_aggregator = CreateAggregator("ns3::MultiFileAggregator",
143 "OutputFileName",
144 StringValue(GetOutputFileName()),
145 "MultiFileMode",
146 BooleanValue(false),
147 "EnableContextPrinting",
148 BooleanValue(true),
149 "GeneralHeading",
150 StringValue(GetIdentifierHeading(m_shortLabel)));
151
152 // Setup collectors.
153 m_terminalCollectors.SetType("ns3::ScalarCollector");
154 m_terminalCollectors.SetAttribute("InputDataType",
155 EnumValue(ScalarCollector::INPUT_DATA_TYPE_DOUBLE));
156 m_terminalCollectors.SetAttribute(
157 "OutputType",
158 EnumValue(ScalarCollector::OUTPUT_TYPE_AVERAGE_PER_SAMPLE));
160 m_terminalCollectors.ConnectToAggregator("Output",
162 &MultiFileAggregator::Write1d);
163 break;
164 }
165
167 // Setup aggregator.
168 m_aggregator = CreateAggregator("ns3::MultiFileAggregator",
169 "OutputFileName",
170 StringValue(GetOutputFileName()),
171 "GeneralHeading",
172 StringValue(GetTimeHeading(m_shortLabel)));
173
174 // Setup collectors.
175 m_terminalCollectors.SetType("ns3::UnitConversionCollector");
176 m_terminalCollectors.SetAttribute("ConversionType",
177 EnumValue(UnitConversionCollector::TRANSPARENT));
179 m_terminalCollectors.ConnectToAggregator("OutputTimeValue",
181 &MultiFileAggregator::Write2d);
182 break;
183 }
184
188 if (m_averagingMode)
189 {
190 // Setup aggregator.
191 m_aggregator = CreateAggregator("ns3::MultiFileAggregator",
192 "OutputFileName",
193 StringValue(GetOutputFileName()),
194 "MultiFileMode",
195 BooleanValue(false),
196 "EnableContextPrinting",
197 BooleanValue(false),
198 "GeneralHeading",
200 Ptr<MultiFileAggregator> fileAggregator =
201 m_aggregator->GetObject<MultiFileAggregator>();
202 NS_ASSERT(fileAggregator != nullptr);
203
204 // Setup the final-level collector.
205 m_averagingCollector = CreateObject<DistributionCollector>();
206 DistributionCollector::OutputType_t outputType =
207 DistributionCollector::OUTPUT_TYPE_HISTOGRAM;
209 {
210 outputType = DistributionCollector::OUTPUT_TYPE_PROBABILITY;
211 }
213 {
214 outputType = DistributionCollector::OUTPUT_TYPE_CUMULATIVE;
215 }
216 m_averagingCollector->SetOutputType(outputType);
217 m_averagingCollector->SetName("0");
218 m_averagingCollector->TraceConnect(
219 "Output",
220 "0",
221 MakeCallback(&MultiFileAggregator::Write2d, fileAggregator));
222 m_averagingCollector->TraceConnect(
223 "OutputString",
224 "0",
225 MakeCallback(&MultiFileAggregator::AddContextHeading, fileAggregator));
226 m_averagingCollector->TraceConnect(
227 "Warning",
228 "0",
229 MakeCallback(&MultiFileAggregator::EnableContextWarning, fileAggregator));
230
231 // Setup collectors.
232 m_terminalCollectors.SetType("ns3::ScalarCollector");
233 m_terminalCollectors.SetAttribute("InputDataType",
234 EnumValue(ScalarCollector::INPUT_DATA_TYPE_DOUBLE));
235 m_terminalCollectors.SetAttribute(
236 "OutputType",
237 EnumValue(ScalarCollector::OUTPUT_TYPE_AVERAGE_PER_SAMPLE));
239 Callback<void, double> callback =
240 MakeCallback(&DistributionCollector::TraceSinkDouble1, m_averagingCollector);
241 for (CollectorMap::Iterator it = m_terminalCollectors.Begin();
242 it != m_terminalCollectors.End();
243 ++it)
244 {
245 it->second->TraceConnectWithoutContext("Output", callback);
246 }
247 }
248 else
249 {
250 // Setup aggregator.
251 m_aggregator = CreateAggregator("ns3::MultiFileAggregator",
252 "OutputFileName",
253 StringValue(GetOutputFileName()),
254 "GeneralHeading",
256
257 // Setup collectors.
258 m_terminalCollectors.SetType("ns3::DistributionCollector");
259 DistributionCollector::OutputType_t outputType =
260 DistributionCollector::OUTPUT_TYPE_HISTOGRAM;
262 {
263 outputType = DistributionCollector::OUTPUT_TYPE_PROBABILITY;
264 }
266 {
267 outputType = DistributionCollector::OUTPUT_TYPE_CUMULATIVE;
268 }
269 m_terminalCollectors.SetAttribute("OutputType", EnumValue(outputType));
271 m_terminalCollectors.ConnectToAggregator("Output",
273 &MultiFileAggregator::Write2d);
274 m_terminalCollectors.ConnectToAggregator("OutputString",
276 &MultiFileAggregator::AddContextHeading);
277 m_terminalCollectors.ConnectToAggregator("Warning",
279 &MultiFileAggregator::EnableContextWarning);
280 }
281
282 break;
283 }
284
287 NS_FATAL_ERROR(GetOutputTypeName(GetOutputType())
288 << " is not a valid output type for this statistics.");
289 break;
290
292 // Setup aggregator.
293 m_aggregator = CreateAggregator("ns3::MagisterGnuplotAggregator",
294 "OutputPath",
295 StringValue(GetOutputPath()),
296 "OutputFileName",
297 StringValue(GetName()));
298 Ptr<MagisterGnuplotAggregator> plotAggregator =
299 m_aggregator->GetObject<MagisterGnuplotAggregator>();
300 NS_ASSERT(plotAggregator != nullptr);
301 // plot->SetTitle ("");
302 plotAggregator->SetLegend(m_longLabel, "Frequency");
303 plotAggregator->Set2dDatasetDefaultStyle(Gnuplot2dDataset::LINES);
304
305 // Setup collectors.
306 m_terminalCollectors.SetType("ns3::UnitConversionCollector");
307 m_terminalCollectors.SetAttribute("ConversionType",
308 EnumValue(UnitConversionCollector::TRANSPARENT));
310 for (CollectorMap::Iterator it = m_terminalCollectors.Begin();
311 it != m_terminalCollectors.End();
312 ++it)
313 {
314 const std::string context = it->second->GetName();
315 plotAggregator->Add2dDataset(context, context);
316 }
317 m_terminalCollectors.ConnectToAggregator("OutputTimeValue",
319 &MagisterGnuplotAggregator::Write2d);
320 break;
321 }
322
326 if (m_averagingMode)
327 {
328 // Setup aggregator.
329 m_aggregator = CreateAggregator("ns3::MagisterGnuplotAggregator",
330 "OutputPath",
331 StringValue(GetOutputPath()),
332 "OutputFileName",
333 StringValue(GetName()));
334 Ptr<MagisterGnuplotAggregator> plotAggregator =
335 m_aggregator->GetObject<MagisterGnuplotAggregator>();
336 NS_ASSERT(plotAggregator != nullptr);
337 // plot->SetTitle ("");
338 plotAggregator->SetLegend(m_longLabel, "Frequency");
339 plotAggregator->Set2dDatasetDefaultStyle(Gnuplot2dDataset::LINES);
340 plotAggregator->Add2dDataset(GetName(), GetName());
342
343 // Setup the final-level collector.
344 m_averagingCollector = CreateObject<DistributionCollector>();
345 DistributionCollector::OutputType_t outputType =
346 DistributionCollector::OUTPUT_TYPE_HISTOGRAM;
348 {
349 outputType = DistributionCollector::OUTPUT_TYPE_PROBABILITY;
350 }
352 {
353 outputType = DistributionCollector::OUTPUT_TYPE_CUMULATIVE;
354 }
355 m_averagingCollector->SetOutputType(outputType);
356 m_averagingCollector->SetName("0");
357 m_averagingCollector->TraceConnect(
358 "Output",
359 GetName(),
360 MakeCallback(&MagisterGnuplotAggregator::Write2d, plotAggregator));
362
363 // Setup collectors.
364 m_terminalCollectors.SetType("ns3::ScalarCollector");
365 m_terminalCollectors.SetAttribute("InputDataType",
366 EnumValue(ScalarCollector::INPUT_DATA_TYPE_DOUBLE));
367 m_terminalCollectors.SetAttribute(
368 "OutputType",
369 EnumValue(ScalarCollector::OUTPUT_TYPE_AVERAGE_PER_SAMPLE));
371 Callback<void, double> callback =
372 MakeCallback(&DistributionCollector::TraceSinkDouble1, m_averagingCollector);
373 for (CollectorMap::Iterator it = m_terminalCollectors.Begin();
374 it != m_terminalCollectors.End();
375 ++it)
376 {
377 it->second->TraceConnectWithoutContext("Output", callback);
378 }
379 }
380 else
381 {
382 // Setup aggregator.
383 m_aggregator = CreateAggregator("ns3::MagisterGnuplotAggregator",
384 "OutputPath",
385 StringValue(GetOutputPath()),
386 "OutputFileName",
387 StringValue(GetName()));
388 Ptr<MagisterGnuplotAggregator> plotAggregator =
389 m_aggregator->GetObject<MagisterGnuplotAggregator>();
390 NS_ASSERT(plotAggregator != nullptr);
391 // plot->SetTitle ("");
392 plotAggregator->SetLegend(m_longLabel, "Frequency");
393 plotAggregator->Set2dDatasetDefaultStyle(Gnuplot2dDataset::LINES);
394
395 // Setup collectors.
396 m_terminalCollectors.SetType("ns3::DistributionCollector");
397 DistributionCollector::OutputType_t outputType =
398 DistributionCollector::OUTPUT_TYPE_HISTOGRAM;
400 {
401 outputType = DistributionCollector::OUTPUT_TYPE_PROBABILITY;
402 }
404 {
405 outputType = DistributionCollector::OUTPUT_TYPE_CUMULATIVE;
406 }
407 m_terminalCollectors.SetAttribute("OutputType", EnumValue(outputType));
409 for (CollectorMap::Iterator it = m_terminalCollectors.Begin();
410 it != m_terminalCollectors.End();
411 ++it)
412 {
413 const std::string context = it->second->GetName();
414 plotAggregator->Add2dDataset(context, context);
415 }
416 m_terminalCollectors.ConnectToAggregator("Output",
418 &MagisterGnuplotAggregator::Write2d);
419 }
420
421 break;
422 }
423
424 default:
425 NS_FATAL_ERROR("SatStatsLinkDelayHelper - Invalid output type");
426 break;
427 }
428
429 // Setup probes and connect them to the collectors.
431
432} // end of `void DoInstall ();`
433
434void
435SatStatsSatelliteQueueHelper::QueueSizeCallback(uint32_t size, const Address& from)
436{
437 // NS_LOG_FUNCTION (this << size << from);
438
439 if (from.IsInvalid())
440 {
441 NS_LOG_WARN(this << " discarding a packet" << " from statistics collection because of"
442 << " invalid sender address");
443 }
444 else if (Mac48Address::ConvertFrom(from).IsBroadcast())
445 {
446 for (std::pair<const Address, uint32_t> item : m_identifierMap)
447 {
448 PassSampleToCollector(size, item.second);
449 }
450 }
451 else
452 {
453 // Determine the identifier associated with the sender address.
454 std::map<const Address, uint32_t>::const_iterator it = m_identifierMap.find(from);
455
456 if (it != m_identifierMap.end())
457 {
458 PassSampleToCollector(size, it->second);
459 }
460 else
461 {
462 NS_LOG_WARN(this << " discarding a packet" << " from statistics collection because of"
463 << " unknown sender address " << from);
464 }
465 }
466}
467
468bool
469SatStatsSatelliteQueueHelper::ConnectProbeToCollector(Ptr<Probe> probe, uint32_t identifier)
470{
471 NS_LOG_FUNCTION(this << probe << probe->GetName() << identifier);
472
473 bool ret = false;
474 switch (GetOutputType())
475 {
478 ret = m_terminalCollectors.ConnectWithProbe(probe,
479 "OutputSeconds",
480 identifier,
481 &ScalarCollector::TraceSinkDouble);
482 break;
483
486 ret = m_terminalCollectors.ConnectWithProbe(probe,
487 "OutputSeconds",
488 identifier,
489 &UnitConversionCollector::TraceSinkDouble);
490 break;
491
498 if (m_averagingMode)
499 {
500 ret = m_terminalCollectors.ConnectWithProbe(probe,
501 "OutputSeconds",
502 identifier,
503 &ScalarCollector::TraceSinkDouble);
504 }
505 else
506 {
507 ret = m_terminalCollectors.ConnectWithProbe(probe,
508 "OutputSeconds",
509 identifier,
510 &DistributionCollector::TraceSinkDouble);
511 }
512 break;
513
514 default:
515 NS_FATAL_ERROR(GetOutputTypeName(GetOutputType())
516 << " is not a valid output type for this statistics.");
517 break;
518 }
519
520 if (ret)
521 {
522 NS_LOG_INFO(this << " created probe " << probe->GetName() << ", connected to collector "
523 << identifier);
524 }
525 else
526 {
527 NS_LOG_WARN(this << " unable to connect probe " << probe->GetName() << " to collector "
528 << identifier);
529 }
530
531 return ret;
532}
533
534void
536{
537 // NS_LOG_FUNCTION (this << size << identifier);
538
539 Ptr<DataCollectionObject> collector = m_terminalCollectors.Get(identifier);
540 NS_ASSERT_MSG(collector != nullptr, "Unable to find collector with identifier " << identifier);
541
542 switch (GetOutputType())
543 {
546 Ptr<ScalarCollector> c = collector->GetObject<ScalarCollector>();
547 NS_ASSERT(c != nullptr);
548 c->TraceSinkDouble(0.0, size);
549 break;
550 }
551
554 Ptr<UnitConversionCollector> c = collector->GetObject<UnitConversionCollector>();
555 NS_ASSERT(c != nullptr);
556 c->TraceSinkDouble(0.0, size);
557 break;
558 }
559
566 if (m_averagingMode)
567 {
568 Ptr<ScalarCollector> c = collector->GetObject<ScalarCollector>();
569 NS_ASSERT(c != nullptr);
570 c->TraceSinkDouble(0.0, size);
571 }
572 else
573 {
574 Ptr<DistributionCollector> c = collector->GetObject<DistributionCollector>();
575 NS_ASSERT(c != nullptr);
576 c->TraceSinkDouble(0.0, size);
577 }
578 break;
579
580 default:
581 NS_FATAL_ERROR(GetOutputTypeName(GetOutputType())
582 << " is not a valid output type for this statistics.");
583 break;
584
585 } // end of `switch (GetOutputType ())`
586
587} // end of `void PassSampleToCollector (double, uint32_t)`
588
589void
591{
592 // The method below is supposed to be implemented by the child class.
594}
595
596// RTN FEEDER QUEUE IN BYTES ////////////////////////////////////////////////////////
597
598NS_OBJECT_ENSURE_REGISTERED(SatStatsRtnFeederQueueBytesHelper);
599
602{
603 NS_LOG_FUNCTION(this << satHelper);
605}
606
611
612TypeId // static
614{
615 static TypeId tid =
616 TypeId("ns3::SatStatsRtnFeederQueueBytesHelper").SetParent<SatStatsSatelliteQueueHelper>();
617 return tid;
618}
619
620void
622{
623 NS_LOG_FUNCTION(this);
624
625 NodeContainer uts = Singleton<SatTopology>::Get()->GetUtNodes();
626 for (NodeContainer::Iterator it = uts.Begin(); it != uts.End(); ++it)
627 {
628 // Create a map of UT addresses and identifiers.
630 }
631
632 NodeContainer sats = Singleton<SatTopology>::Get()->GetOrbiterNodes();
633 Callback<void, uint32_t, const Address&> callback =
635
636 for (NodeContainer::Iterator it = sats.Begin(); it != sats.End(); ++it)
637 {
638 Ptr<NetDevice> dev = GetSatSatOrbiterNetDevice(*it);
639 Ptr<SatOrbiterNetDevice> satOrbiterDev = dev->GetObject<SatOrbiterNetDevice>();
640 NS_ASSERT(satOrbiterDev != nullptr);
641 Ptr<SatPhy> satPhy;
642 std::map<uint32_t, Ptr<SatPhy>> satOrbiterFeederPhys = satOrbiterDev->GetFeederPhy();
643 for (std::map<uint32_t, Ptr<SatPhy>>::iterator it2 = satOrbiterFeederPhys.begin();
644 it2 != satOrbiterFeederPhys.end();
645 ++it2)
646 {
647 satPhy = it2->second;
648 NS_ASSERT(satPhy != nullptr);
649 Ptr<SatOrbiterFeederPhy> satOrbiterFeederPhy = satPhy->GetObject<SatOrbiterFeederPhy>();
650 NS_ASSERT(satOrbiterFeederPhy != nullptr);
651
652 if (satOrbiterFeederPhy->TraceConnectWithoutContext("QueueSizeBytes", callback))
653 {
654 NS_LOG_INFO(this << " successfully connected with node ID " << (*it)->GetId()
655 << " device #" << satOrbiterDev->GetIfIndex());
656 }
657 else
658 {
659 NS_FATAL_ERROR("Error connecting to QueueSizeBytes trace source"
660 << " at node ID " << (*it)->GetId() << " device #"
661 << satOrbiterDev->GetIfIndex());
662 }
663 }
664 } // end of `for (it = sats.Begin(); it != sats.End (); ++it)`
665
666} // end of `void DoInstallProbes ();`
667
668// RTN FEEDER QUEUE IN PACKETS ////////////////////////////////////////////////////////
669
670NS_OBJECT_ENSURE_REGISTERED(SatStatsRtnFeederQueuePacketsHelper);
671
673 Ptr<const SatHelper> satHelper)
675{
676 NS_LOG_FUNCTION(this << satHelper);
678}
679
684
685TypeId // static
687{
688 static TypeId tid = TypeId("ns3::SatStatsRtnFeederQueuePacketsHelper")
689 .SetParent<SatStatsSatelliteQueueHelper>();
690 return tid;
691}
692
693void
695{
696 NS_LOG_FUNCTION(this);
697
698 NodeContainer uts = Singleton<SatTopology>::Get()->GetUtNodes();
699 for (NodeContainer::Iterator it = uts.Begin(); it != uts.End(); ++it)
700 {
701 // Create a map of UT addresses and identifiers.
703 }
704
705 NodeContainer sats = Singleton<SatTopology>::Get()->GetOrbiterNodes();
706 Callback<void, uint32_t, const Address&> callback =
708
709 for (NodeContainer::Iterator it = sats.Begin(); it != sats.End(); ++it)
710 {
711 Ptr<NetDevice> dev = GetSatSatOrbiterNetDevice(*it);
712 Ptr<SatOrbiterNetDevice> satOrbiterDev = dev->GetObject<SatOrbiterNetDevice>();
713 NS_ASSERT(satOrbiterDev != nullptr);
714 Ptr<SatPhy> satPhy;
715 std::map<uint32_t, Ptr<SatPhy>> satOrbiterFeederPhys = satOrbiterDev->GetFeederPhy();
716 for (std::map<uint32_t, Ptr<SatPhy>>::iterator it2 = satOrbiterFeederPhys.begin();
717 it2 != satOrbiterFeederPhys.end();
718 ++it2)
719 {
720 satPhy = it2->second;
721 NS_ASSERT(satPhy != nullptr);
722 Ptr<SatOrbiterFeederPhy> satOrbiterFeederPhy = satPhy->GetObject<SatOrbiterFeederPhy>();
723 NS_ASSERT(satOrbiterFeederPhy != nullptr);
724
725 if (satOrbiterFeederPhy->TraceConnectWithoutContext("QueueSizePackets", callback))
726 {
727 NS_LOG_INFO(this << " successfully connected with node ID " << (*it)->GetId()
728 << " device #" << satOrbiterDev->GetIfIndex());
729 }
730 else
731 {
732 NS_FATAL_ERROR("Error connecting to QueueSizePackets trace source"
733 << " at node ID " << (*it)->GetId() << " device #"
734 << satOrbiterDev->GetIfIndex());
735 }
736 }
737 } // end of `for (it = sats.Begin(); it != sats.End (); ++it)`
738
739} // end of `void DoInstallProbes ();`
740
741// FWD USER QUEUE IN BYTES ////////////////////////////////////////////////////////
742
743NS_OBJECT_ENSURE_REGISTERED(SatStatsFwdUserQueueBytesHelper);
744
747{
748 NS_LOG_FUNCTION(this << satHelper);
750}
751
756
757TypeId // static
759{
760 static TypeId tid =
761 TypeId("ns3::SatStatsFwdUserQueueBytesHelper").SetParent<SatStatsSatelliteQueueHelper>();
762 return tid;
763}
764
765void
767{
768 NS_LOG_FUNCTION(this);
769
770 NodeContainer uts = Singleton<SatTopology>::Get()->GetUtNodes();
771 for (NodeContainer::Iterator it = uts.Begin(); it != uts.End(); ++it)
772 {
773 // Create a map of UT addresses and identifiers.
775 }
776
777 NodeContainer sats = Singleton<SatTopology>::Get()->GetOrbiterNodes();
778 Callback<void, uint32_t, const Address&> callback =
780
781 for (NodeContainer::Iterator it = sats.Begin(); it != sats.End(); ++it)
782 {
783 Ptr<NetDevice> dev = GetSatSatOrbiterNetDevice(*it);
784 Ptr<SatOrbiterNetDevice> satOrbiterDev = dev->GetObject<SatOrbiterNetDevice>();
785 NS_ASSERT(satOrbiterDev != nullptr);
786 Ptr<SatPhy> satPhy;
787 std::map<uint32_t, Ptr<SatPhy>> satOrbiterUserPhys = satOrbiterDev->GetUserPhy();
788 for (std::map<uint32_t, Ptr<SatPhy>>::iterator it2 = satOrbiterUserPhys.begin();
789 it2 != satOrbiterUserPhys.end();
790 ++it2)
791 {
792 satPhy = it2->second;
793 NS_ASSERT(satPhy != nullptr);
794 Ptr<SatOrbiterUserPhy> satOrbiterUserPhy = satPhy->GetObject<SatOrbiterUserPhy>();
795 NS_ASSERT(satOrbiterUserPhy != nullptr);
796
797 if (satOrbiterUserPhy->TraceConnectWithoutContext("QueueSizeBytes", callback))
798 {
799 NS_LOG_INFO(this << " successfully connected with node ID " << (*it)->GetId()
800 << " device #" << satOrbiterDev->GetIfIndex());
801 }
802 else
803 {
804 NS_FATAL_ERROR("Error connecting to QueueSizeBytes trace source"
805 << " at node ID " << (*it)->GetId() << " device #"
806 << satOrbiterDev->GetIfIndex());
807 }
808 }
809 } // end of `for (it = sats.Begin(); it != sats.End (); ++it)`
810
811} // end of `void DoInstallProbes ();`
812
813// FWD USER QUEUE IN PACKETS ////////////////////////////////////////////////////////
814
815NS_OBJECT_ENSURE_REGISTERED(SatStatsFwdUserQueuePacketsHelper);
816
819{
820 NS_LOG_FUNCTION(this << satHelper);
822}
823
828
829TypeId // static
831{
832 static TypeId tid =
833 TypeId("ns3::SatStatsFwdUserQueuePacketsHelper").SetParent<SatStatsSatelliteQueueHelper>();
834 return tid;
835}
836
837void
839{
840 NS_LOG_FUNCTION(this);
841
842 NodeContainer uts = Singleton<SatTopology>::Get()->GetUtNodes();
843 for (NodeContainer::Iterator it = uts.Begin(); it != uts.End(); ++it)
844 {
845 // Create a map of UT addresses and identifiers.
847 }
848
849 NodeContainer sats = Singleton<SatTopology>::Get()->GetOrbiterNodes();
850 Callback<void, uint32_t, const Address&> callback =
852
853 for (NodeContainer::Iterator it = sats.Begin(); it != sats.End(); ++it)
854 {
855 Ptr<NetDevice> dev = GetSatSatOrbiterNetDevice(*it);
856 Ptr<SatOrbiterNetDevice> satOrbiterDev = dev->GetObject<SatOrbiterNetDevice>();
857 NS_ASSERT(satOrbiterDev != nullptr);
858 Ptr<SatPhy> satPhy;
859 std::map<uint32_t, Ptr<SatPhy>> satOrbiterUserPhys = satOrbiterDev->GetUserPhy();
860 for (std::map<uint32_t, Ptr<SatPhy>>::iterator it2 = satOrbiterUserPhys.begin();
861 it2 != satOrbiterUserPhys.end();
862 ++it2)
863 {
864 satPhy = it2->second;
865 NS_ASSERT(satPhy != nullptr);
866 Ptr<SatOrbiterUserPhy> satOrbiterUserPhy = satPhy->GetObject<SatOrbiterUserPhy>();
867 NS_ASSERT(satOrbiterUserPhy != nullptr);
868
869 if (satOrbiterUserPhy->TraceConnectWithoutContext("QueueSizePackets", callback))
870 {
871 NS_LOG_INFO(this << " successfully connected with node ID " << (*it)->GetId()
872 << " device #" << satOrbiterDev->GetIfIndex());
873 }
874 else
875 {
876 NS_FATAL_ERROR("Error connecting to QueueSizePackets trace source"
877 << " at node ID " << (*it)->GetId() << " device #"
878 << satOrbiterDev->GetIfIndex());
879 }
880 }
881 } // end of `for (it = sats.Begin(); it != sats.End (); ++it)`
882
883} // end of `void DoInstallProbes ();`
884
885} // end of namespace ns3
The SatOrbiterFeederPhy models the feeder link physical layer of the satellite node.
SatOrbiterNetDevice to be utilized in geostationary satellite.
The SatOrbiterUserPhy models the user link physical layer of the satellite node.
Produce queue size statistics in packets for return feeder link.
static TypeId GetTypeId()
inherited from ObjectBase base class
SatStatsFwdUserQueueBytesHelper(Ptr< const SatHelper > satHelper)
Produce queue size statistics in packets for return feeder link.
static TypeId GetTypeId()
inherited from ObjectBase base class
static Ptr< NetDevice > GetSatSatOrbiterNetDevice(Ptr< Node > satNode)
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.
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
Produce queue size statistics in packets for return feeder link.
static TypeId GetTypeId()
inherited from ObjectBase base class
Produce queue size statistics in packets for return feeder link.
static TypeId GetTypeId()
inherited from ObjectBase base class
Base class for sat queue statistics helpers.
SatStatsSatelliteQueueHelper(Ptr< const SatHelper > satHelper)
void DoInstall()
Install the probes, collectors, and aggregators necessary to produce the statistics output.
bool ConnectProbeToCollector(Ptr< Probe > probe, uint32_t identifier)
Connect the probe to the right collector.
Ptr< DistributionCollector > m_averagingCollector
The final collector utilized in averaged output (histogram, PDF, and CDF).
void InstallProbes()
Set up several probes or other means of listeners and connect them to the collectors.
static TypeId GetTypeId()
inherited from ObjectBase base class
void QueueSizeCallback(uint32_t size, const Address &addr)
Receive inputs from trace sources and forward them to the collector.
CollectorMap m_terminalCollectors
Maintains a list of collectors created by this helper.
static std::string GetUnitTypeName(UnitType_t unitType)
void PassSampleToCollector(uint32_t size, uint32_t identifier)
Find a collector with the right identifier and pass a sample data to it.
Ptr< DataCollectionObject > m_aggregator
The aggregator created by this helper.
SatArqSequenceNumber is handling the sequence numbers for the ARQ process.