Loading...
Searching...
No Matches
satellite-stats-throughput-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: Budiarto Herman <budiarto.herman@magister.fi>
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/interval-rate-collector.h"
33#include "ns3/ipv4.h"
34#include "ns3/log.h"
35#include "ns3/mac48-address.h"
36#include "ns3/magister-gnuplot-aggregator.h"
37#include "ns3/multi-file-aggregator.h"
38#include "ns3/net-device.h"
39#include "ns3/node-container.h"
40#include "ns3/packet.h"
41#include "ns3/probe.h"
42#include "ns3/satellite-helper.h"
43#include "ns3/satellite-id-mapper.h"
44#include "ns3/satellite-mac.h"
45#include "ns3/satellite-net-device.h"
46#include "ns3/satellite-orbiter-net-device.h"
47#include "ns3/satellite-phy.h"
48#include "ns3/satellite-topology.h"
49#include "ns3/scalar-collector.h"
50#include "ns3/singleton.h"
51#include "ns3/string.h"
52#include "ns3/unit-conversion-collector.h"
53
54#include <map>
55#include <sstream>
56#include <string>
57#include <utility>
58
59NS_LOG_COMPONENT_DEFINE("SatStatsThroughputHelper");
60
61namespace ns3
62{
63
64NS_OBJECT_ENSURE_REGISTERED(SatStatsThroughputHelper);
65
67 : SatStatsHelper(satHelper),
68 m_averagingMode(false)
69{
70 NS_LOG_FUNCTION(this << satHelper);
71}
72
74{
75 NS_LOG_FUNCTION(this);
76}
77
78TypeId // static
80{
81 static TypeId tid =
82 TypeId("ns3::SatStatsThroughputHelper")
83 .SetParent<SatStatsHelper>()
84 .AddAttribute("AveragingMode",
85 "If true, all samples will be averaged before passed to aggregator. "
86 "Only affects histogram, PDF, and CDF output types.",
87 BooleanValue(false),
90 MakeBooleanChecker());
91 return tid;
92}
93
94void
96{
97 NS_LOG_FUNCTION(this << averagingMode);
98 m_averagingMode = averagingMode;
99}
100
101bool
106
107void
109{
110 NS_LOG_FUNCTION(this);
111
112 switch (GetOutputType())
113 {
115 NS_FATAL_ERROR(GetOutputTypeName(GetOutputType())
116 << " is not a valid output type for this statistics.");
117 break;
118
120 // Setup aggregator.
121 m_aggregator = CreateAggregator("ns3::MultiFileAggregator",
122 "OutputFileName",
123 StringValue(GetOutputFileName()),
124 "MultiFileMode",
125 BooleanValue(false),
126 "EnableContextPrinting",
127 BooleanValue(true),
128 "GeneralHeading",
129 StringValue(GetIdentifierHeading("throughput_kbps")));
130
131 // Setup second-level collectors.
132 m_terminalCollectors.SetType("ns3::ScalarCollector");
133 m_terminalCollectors.SetAttribute("InputDataType",
134 EnumValue(ScalarCollector::INPUT_DATA_TYPE_DOUBLE));
135 m_terminalCollectors.SetAttribute(
136 "OutputType",
137 EnumValue(ScalarCollector::OUTPUT_TYPE_AVERAGE_PER_SECOND));
139 m_terminalCollectors.ConnectToAggregator("Output",
141 &MultiFileAggregator::Write1d);
142
143 // Setup first-level collectors.
144 m_conversionCollectors.SetType("ns3::UnitConversionCollector");
145 m_conversionCollectors.SetAttribute("ConversionType",
146 EnumValue(UnitConversionCollector::FROM_BYTES_TO_KBIT));
148 m_conversionCollectors.ConnectToCollector("Output",
150 &ScalarCollector::TraceSinkDouble);
151 break;
152 }
153
155 // Setup aggregator.
156 m_aggregator = CreateAggregator("ns3::MultiFileAggregator",
157 "OutputFileName",
158 StringValue(GetOutputFileName()),
159 "GeneralHeading",
160 StringValue(GetTimeHeading("throughput_kbps")));
161
162 // Setup second-level collectors.
163 m_terminalCollectors.SetType("ns3::IntervalRateCollector");
164 m_terminalCollectors.SetAttribute("InputDataType",
165 EnumValue(IntervalRateCollector::INPUT_DATA_TYPE_DOUBLE));
167 m_terminalCollectors.ConnectToAggregator("OutputWithTime",
169 &MultiFileAggregator::Write2d);
170 m_terminalCollectors.ConnectToAggregator("OutputString",
172 &MultiFileAggregator::AddContextHeading);
173
174 // Setup first-level collectors.
175 m_conversionCollectors.SetType("ns3::UnitConversionCollector");
176 m_conversionCollectors.SetAttribute("ConversionType",
177 EnumValue(UnitConversionCollector::FROM_BYTES_TO_KBIT));
179 m_conversionCollectors.ConnectToCollector("Output",
181 &IntervalRateCollector::TraceSinkDouble);
182 break;
183 }
184
188 if (!m_averagingMode)
189 {
190 NS_FATAL_ERROR("This statistics require AveragingMode to be enabled");
191 }
192
193 // Setup aggregator.
194 m_aggregator = CreateAggregator("ns3::MultiFileAggregator",
195 "OutputFileName",
196 StringValue(GetOutputFileName()),
197 "MultiFileMode",
198 BooleanValue(false),
199 "EnableContextPrinting",
200 BooleanValue(false),
201 "GeneralHeading",
202 StringValue(GetDistributionHeading("throughput_kbps")));
203 Ptr<MultiFileAggregator> fileAggregator = m_aggregator->GetObject<MultiFileAggregator>();
204 NS_ASSERT(fileAggregator != nullptr);
205
206 // Setup the final-level collector.
207 m_averagingCollector = CreateObject<DistributionCollector>();
208 DistributionCollector::OutputType_t outputType =
209 DistributionCollector::OUTPUT_TYPE_HISTOGRAM;
211 {
212 outputType = DistributionCollector::OUTPUT_TYPE_PROBABILITY;
213 }
215 {
216 outputType = DistributionCollector::OUTPUT_TYPE_CUMULATIVE;
217 }
218 m_averagingCollector->SetOutputType(outputType);
219 m_averagingCollector->SetName("0");
220 m_averagingCollector->TraceConnect(
221 "Output",
222 "0",
223 MakeCallback(&MultiFileAggregator::Write2d, fileAggregator));
224 m_averagingCollector->TraceConnect(
225 "OutputString",
226 "0",
227 MakeCallback(&MultiFileAggregator::AddContextHeading, fileAggregator));
228 m_averagingCollector->TraceConnect(
229 "Warning",
230 "0",
231 MakeCallback(&MultiFileAggregator::EnableContextWarning, fileAggregator));
232
233 // Setup second-level collectors.
234 m_terminalCollectors.SetType("ns3::ScalarCollector");
235 m_terminalCollectors.SetAttribute("InputDataType",
236 EnumValue(ScalarCollector::INPUT_DATA_TYPE_DOUBLE));
237 m_terminalCollectors.SetAttribute(
238 "OutputType",
239 EnumValue(ScalarCollector::OUTPUT_TYPE_AVERAGE_PER_SECOND));
241 Callback<void, double> callback =
242 MakeCallback(&DistributionCollector::TraceSinkDouble1, m_averagingCollector);
243 for (CollectorMap::Iterator it = m_terminalCollectors.Begin();
244 it != m_terminalCollectors.End();
245 ++it)
246 {
247 it->second->TraceConnectWithoutContext("Output", callback);
248 }
249
250 // Setup first-level collectors.
251 m_conversionCollectors.SetType("ns3::UnitConversionCollector");
252 m_conversionCollectors.SetAttribute("ConversionType",
253 EnumValue(UnitConversionCollector::FROM_BYTES_TO_KBIT));
255 m_conversionCollectors.ConnectToCollector("Output",
257 &ScalarCollector::TraceSinkDouble);
258 break;
259 }
260
263 NS_FATAL_ERROR(GetOutputTypeName(GetOutputType())
264 << " is not a valid output type for this statistics.");
265 break;
266
268 // Setup aggregator.
269 m_aggregator = CreateAggregator("ns3::MagisterGnuplotAggregator",
270 "OutputPath",
271 StringValue(GetOutputPath()),
272 "OutputFileName",
273 StringValue(GetName()));
274 Ptr<MagisterGnuplotAggregator> plotAggregator =
275 m_aggregator->GetObject<MagisterGnuplotAggregator>();
276 NS_ASSERT(plotAggregator != nullptr);
277 // plot->SetTitle ("");
278 plotAggregator->SetLegend("Time (in seconds)",
279 "Received throughput (in kilobits per second)");
280 plotAggregator->Set2dDatasetDefaultStyle(Gnuplot2dDataset::LINES);
281
282 // Setup second-level collectors.
283 m_terminalCollectors.SetType("ns3::IntervalRateCollector");
284 m_terminalCollectors.SetAttribute("InputDataType",
285 EnumValue(IntervalRateCollector::INPUT_DATA_TYPE_DOUBLE));
287 for (CollectorMap::Iterator it = m_terminalCollectors.Begin();
288 it != m_terminalCollectors.End();
289 ++it)
290 {
291 const std::string context = it->second->GetName();
292 plotAggregator->Add2dDataset(context, context);
293 }
294 m_terminalCollectors.ConnectToAggregator("OutputWithTime",
296 &MagisterGnuplotAggregator::Write2d);
297
298 // Setup first-level collectors.
299 m_conversionCollectors.SetType("ns3::UnitConversionCollector");
300 m_conversionCollectors.SetAttribute("ConversionType",
301 EnumValue(UnitConversionCollector::FROM_BYTES_TO_KBIT));
303 m_conversionCollectors.ConnectToCollector("Output",
305 &IntervalRateCollector::TraceSinkDouble);
306 break;
307 }
308
312 if (!m_averagingMode)
313 {
314 NS_FATAL_ERROR("This statistics require AveragingMode to be enabled");
315 }
316
317 // Setup aggregator.
318 m_aggregator = CreateAggregator("ns3::MagisterGnuplotAggregator",
319 "OutputPath",
320 StringValue(GetOutputPath()),
321 "OutputFileName",
322 StringValue(GetName()));
323 Ptr<MagisterGnuplotAggregator> plotAggregator =
324 m_aggregator->GetObject<MagisterGnuplotAggregator>();
325 NS_ASSERT(plotAggregator != nullptr);
326 // plot->SetTitle ("");
327 plotAggregator->SetLegend("Received throughput (in kilobits per second)", "Frequency");
328 plotAggregator->Set2dDatasetDefaultStyle(Gnuplot2dDataset::LINES);
329 plotAggregator->Add2dDataset(GetName(), GetName());
331
332 // Setup the final-level collector.
333 m_averagingCollector = CreateObject<DistributionCollector>();
334 DistributionCollector::OutputType_t outputType =
335 DistributionCollector::OUTPUT_TYPE_HISTOGRAM;
337 {
338 outputType = DistributionCollector::OUTPUT_TYPE_PROBABILITY;
339 }
341 {
342 outputType = DistributionCollector::OUTPUT_TYPE_CUMULATIVE;
343 }
344 m_averagingCollector->SetOutputType(outputType);
345 m_averagingCollector->SetName("0");
346 m_averagingCollector->TraceConnect(
347 "Output",
348 GetName(),
349 MakeCallback(&MagisterGnuplotAggregator::Write2d, plotAggregator));
351
352 // Setup second-level collectors.
353 m_terminalCollectors.SetType("ns3::ScalarCollector");
354 m_terminalCollectors.SetAttribute("InputDataType",
355 EnumValue(ScalarCollector::INPUT_DATA_TYPE_DOUBLE));
356 m_terminalCollectors.SetAttribute(
357 "OutputType",
358 EnumValue(ScalarCollector::OUTPUT_TYPE_AVERAGE_PER_SECOND));
360 Callback<void, double> callback =
361 MakeCallback(&DistributionCollector::TraceSinkDouble1, m_averagingCollector);
362 for (CollectorMap::Iterator it = m_terminalCollectors.Begin();
363 it != m_terminalCollectors.End();
364 ++it)
365 {
366 it->second->TraceConnectWithoutContext("Output", callback);
367 }
368
369 // Setup first-level collectors.
370 m_conversionCollectors.SetType("ns3::UnitConversionCollector");
371 m_conversionCollectors.SetAttribute("ConversionType",
372 EnumValue(UnitConversionCollector::FROM_BYTES_TO_KBIT));
374 m_conversionCollectors.ConnectToCollector("Output",
376 &ScalarCollector::TraceSinkDouble);
377 break;
378 }
379
380 default:
381 NS_FATAL_ERROR("SatStatsThroughputHelper - Invalid output type");
382 break;
383 }
384
385 // Setup probes and connect them to conversion collectors.
387
388} // end of `void DoInstall ();`
389
390void
392{
393 NS_LOG_FUNCTION(this);
394
395 // The method below is supposed to be implemented by the child class.
397}
398
399void
400SatStatsThroughputHelper::RxCallback(Ptr<const Packet> packet, const Address& from)
401{
402 NS_LOG_FUNCTION(this << packet->GetSize() << from);
403
404 if (from.IsInvalid())
405 {
406 NS_LOG_WARN(this << " discarding packet " << packet << " (" << packet->GetSize()
407 << " bytes)" << " from statistics collection because of"
408 << " invalid sender address");
409 }
410 else
411 {
412 // Determine the identifier associated with the sender address.
413 std::map<const Address, uint32_t>::const_iterator it = m_identifierMap.find(from);
414
415 if (it == m_identifierMap.end())
416 {
417 NS_LOG_WARN(this << " discarding packet " << packet << " (" << packet->GetSize()
418 << " bytes)" << " from statistics collection because of"
419 << " unknown sender address " << from);
420 }
421 else
422 {
423 // Find the first-level collector with the right identifier.
424 Ptr<DataCollectionObject> collector = m_conversionCollectors.Get(it->second);
425 NS_ASSERT_MSG(collector != nullptr,
426 "Unable to find collector with identifier " << it->second);
427 Ptr<UnitConversionCollector> c = collector->GetObject<UnitConversionCollector>();
428 NS_ASSERT(c != nullptr);
429
430 // Pass the sample to the collector.
431 c->TraceSinkUinteger32(0, packet->GetSize());
432 }
433 }
434
435} // end of `void RxCallback (Ptr<const Packet>, const Address);`
436
437// FORWARD LINK APPLICATION-LEVEL /////////////////////////////////////////////
438
439NS_OBJECT_ENSURE_REGISTERED(SatStatsFwdAppThroughputHelper);
440
442 : SatStatsThroughputHelper(satHelper)
443{
444 NS_LOG_FUNCTION(this << satHelper);
445}
446
451
452TypeId // static
454{
455 static TypeId tid =
456 TypeId("ns3::SatStatsFwdAppThroughputHelper").SetParent<SatStatsThroughputHelper>();
457 return tid;
458}
459
460void
462{
463 NS_LOG_FUNCTION(this);
464 NodeContainer utUsers = Singleton<SatTopology>::Get()->GetUtUserNodes();
465
466 for (NodeContainer::Iterator it = utUsers.Begin(); it != utUsers.End(); ++it)
467 {
468 const int32_t utUserId = GetUtUserId(*it);
469 NS_ASSERT_MSG(utUserId > 0, "Node " << (*it)->GetId() << " is not a valid UT user");
470 const uint32_t identifier = GetIdentifierForUtUser(*it);
471
472 for (uint32_t i = 0; i < (*it)->GetNApplications(); i++)
473 {
474 // Create the probe.
475 std::ostringstream probeName;
476 probeName << utUserId << "-" << i;
477 Ptr<ApplicationPacketProbe> probe = CreateObject<ApplicationPacketProbe>();
478 probe->SetName(probeName.str());
479
480 // Connect the object to the probe.
481 if (probe->ConnectByObject("Rx", (*it)->GetApplication(i)))
482 {
483 // Connect the probe to the right collector.
484 if (m_conversionCollectors.ConnectWithProbe(
485 probe->GetObject<Probe>(),
486 "OutputBytes",
487 identifier,
488 &UnitConversionCollector::TraceSinkUinteger32))
489 {
490 NS_LOG_INFO(this << " created probe " << probeName.str()
491 << ", connected to collector " << identifier);
492 m_probes.insert(
493 std::make_pair(probe->GetObject<Probe>(), std::make_pair(*it, identifier)));
494 }
495 else
496 {
497 NS_LOG_WARN(this << " unable to connect probe " << probeName.str()
498 << " to collector " << identifier);
499 }
500 }
501 else
502 {
503 /*
504 * We're being tolerant here by only logging a warning, because
505 * not every kind of Application is equipped with the expected
506 * Rx trace source.
507 */
508 NS_LOG_WARN(this << " unable to connect probe " << probeName.str()
509 << " with node ID " << (*it)->GetId() << " application #" << i);
510 }
511
512 } // end of `for (i = 0; i < (*it)->GetNApplications (); i++)`
513
514 } // end of `for (it = utUsers.Begin(); it != utUsers.End (); ++it)`
515
516} // end of `void DoInstallProbes ();`
517
518void
520{
521 NS_LOG_FUNCTION(this);
522
523 std::map<Ptr<Probe>, std::pair<Ptr<Node>, uint32_t>>::iterator it;
524
525 for (it = m_probes.begin(); it != m_probes.end(); it++)
526 {
527 Ptr<Probe> probe = it->first;
528 Ptr<Node> node = it->second.first;
529 uint32_t identifier = it->second.second;
530 m_conversionCollectors.DisconnectWithProbe(probe->GetObject<Probe>(),
531 "OutputBytes",
532 identifier,
533 &UnitConversionCollector::TraceSinkUinteger32);
534
535 identifier = GetIdentifierForUtUser(node);
536
537 m_conversionCollectors.ConnectWithProbe(probe->GetObject<Probe>(),
538 "OutputBytes",
539 identifier,
540 &UnitConversionCollector::TraceSinkUinteger32);
541
542 it->second.second = identifier;
543 }
544} // end of `void UpdateIdentifierOnProbes ();`
545
546// FORWARD FEEDER LINK DEVICE-LEVEL //////////////////////////////////////////////////
547
548NS_OBJECT_ENSURE_REGISTERED(SatStatsFwdFeederDevThroughputHelper);
549
551 Ptr<const SatHelper> satHelper)
552 : SatStatsThroughputHelper(satHelper)
553{
554 NS_LOG_FUNCTION(this << satHelper);
555}
556
561
562TypeId // static
564{
565 static TypeId tid =
566 TypeId("ns3::SatStatsFwdFeederDevThroughputHelper").SetParent<SatStatsThroughputHelper>();
567 return tid;
568}
569
570void
572{
573 NS_LOG_FUNCTION(this);
574
575 NodeContainer sats = Singleton<SatTopology>::Get()->GetOrbiterNodes();
576 Callback<void, Ptr<const Packet>, const Address&> callback =
578
579 for (NodeContainer::Iterator it = sats.Begin(); it != sats.End(); ++it)
580 {
581 Ptr<NetDevice> dev = GetSatSatOrbiterNetDevice(*it);
582 Ptr<SatOrbiterNetDevice> satOrbiterDev = dev->GetObject<SatOrbiterNetDevice>();
583 NS_ASSERT(satOrbiterDev != nullptr);
584 satOrbiterDev->SetAttribute("EnableStatisticsTags", BooleanValue(true));
585
586 if (satOrbiterDev->TraceConnectWithoutContext("RxFeeder", callback))
587 {
588 NS_LOG_INFO(this << " successfully connected with node ID " << (*it)->GetId()
589 << " device #" << satOrbiterDev->GetIfIndex());
590
591 // Enable statistics-related tags and trace sources on the device.
592 satOrbiterDev->SetAttribute("EnableStatisticsTags", BooleanValue(true));
593 }
594 else
595 {
596 NS_FATAL_ERROR("Error connecting to Rx trace source of SatNetDevice"
597 << " at node ID " << (*it)->GetId() << " device #"
598 << satOrbiterDev->GetIfIndex());
599 }
600 } // end of `for (it = sats.Begin(); it != sats.End (); ++it)`
601
602 NodeContainer uts = Singleton<SatTopology>::Get()->GetUtNodes();
603
604 for (NodeContainer::Iterator it = uts.Begin(); it != uts.End(); ++it)
605 {
606 // Create a map of UT addresses and identifiers.
608
609 Ptr<NetDevice> dev = GetUtSatNetDevice(*it);
610 Ptr<SatNetDevice> satDev = dev->GetObject<SatNetDevice>();
611 NS_ASSERT(satDev != nullptr);
612
613 satDev->SetAttribute("EnableStatisticsTags", BooleanValue(true));
614
615 } // end of `for (it = uts.Begin(); it != uts.End (); ++it)`
616
617 // Enable statistics-related tags on the transmitting device.
618 NodeContainer gws = Singleton<SatTopology>::Get()->GetGwNodes();
619 for (NodeContainer::Iterator it = gws.Begin(); it != gws.End(); ++it)
620 {
621 NetDeviceContainer devs = GetGwSatNetDevice(*it);
622
623 for (NetDeviceContainer::Iterator itDev = devs.Begin(); itDev != devs.End(); ++itDev)
624 {
625 Ptr<SatNetDevice> satDev = (*itDev)->GetObject<SatNetDevice>();
626 NS_ASSERT(satDev != nullptr);
627
628 satDev->SetAttribute("EnableStatisticsTags", BooleanValue(true));
629 }
630 }
631} // end of `void DoInstallProbes ();`
632
633// FORWARD USER LINK DEVICE-LEVEL //////////////////////////////////////////////////
634
635NS_OBJECT_ENSURE_REGISTERED(SatStatsFwdUserDevThroughputHelper);
636
638 Ptr<const SatHelper> satHelper)
639 : SatStatsThroughputHelper(satHelper)
640{
641 NS_LOG_FUNCTION(this << satHelper);
642}
643
648
649TypeId // static
651{
652 static TypeId tid =
653 TypeId("ns3::SatStatsFwdUserDevThroughputHelper").SetParent<SatStatsThroughputHelper>();
654 return tid;
655}
656
657void
659{
660 NS_LOG_FUNCTION(this);
661 NodeContainer uts = Singleton<SatTopology>::Get()->GetUtNodes();
662
663 for (NodeContainer::Iterator it = uts.Begin(); it != uts.End(); ++it)
664 {
665 const int32_t utId = GetUtId(*it);
666 NS_ASSERT_MSG(utId > 0, "Node " << (*it)->GetId() << " is not a valid UT");
667 const uint32_t identifier = GetIdentifierForUt(*it);
668
669 // Create the probe.
670 std::ostringstream probeName;
671 probeName << utId;
672 Ptr<ApplicationPacketProbe> probe = CreateObject<ApplicationPacketProbe>();
673 probe->SetName(probeName.str());
674
675 Ptr<NetDevice> dev = GetUtSatNetDevice(*it);
676
677 // Connect the object to the probe.
678 if (probe->ConnectByObject("Rx", dev))
679 {
680 // Connect the probe to the right collector.
681 if (m_conversionCollectors.ConnectWithProbe(
682 probe->GetObject<Probe>(),
683 "OutputBytes",
684 identifier,
685 &UnitConversionCollector::TraceSinkUinteger32))
686 {
687 NS_LOG_INFO(this << " created probe " << probeName.str()
688 << ", connected to collector " << identifier);
689 m_probes.insert(
690 std::make_pair(probe->GetObject<Probe>(), std::make_pair(*it, identifier)));
691
692 // Enable statistics-related tags and trace sources on the device.
693 dev->SetAttribute("EnableStatisticsTags", BooleanValue(true));
694 }
695 else
696 {
697 NS_LOG_WARN(this << " unable to connect probe " << probeName.str()
698 << " to collector " << identifier);
699 }
700
701 } // end of `if (probe->ConnectByObject ("Rx", dev))`
702 else
703 {
704 NS_FATAL_ERROR("Error connecting to Rx trace source of SatNetDevice"
705 << " at node ID " << (*it)->GetId() << " device #2");
706 }
707
708 } // end of `for (it = uts.Begin(); it != uts.End (); ++it)`
709
710 // Enable statistics-related tags on the transmitting device.
711 NodeContainer gws = Singleton<SatTopology>::Get()->GetGwNodes();
712 for (NodeContainer::Iterator it = gws.Begin(); it != gws.End(); ++it)
713 {
714 NetDeviceContainer devs = GetGwSatNetDevice(*it);
715
716 for (NetDeviceContainer::Iterator itDev = devs.Begin(); itDev != devs.End(); ++itDev)
717 {
718 NS_ASSERT((*itDev)->GetObject<SatNetDevice>() != nullptr);
719 (*itDev)->SetAttribute("EnableStatisticsTags", BooleanValue(true));
720 }
721 }
722
723} // end of `void DoInstallProbes ();`
724
725void
727{
728 NS_LOG_FUNCTION(this);
729
730 std::map<Ptr<Probe>, std::pair<Ptr<Node>, uint32_t>>::iterator it;
731
732 for (it = m_probes.begin(); it != m_probes.end(); it++)
733 {
734 Ptr<Probe> probe = it->first;
735 Ptr<Node> node = it->second.first;
736 uint32_t identifier = it->second.second;
737 m_conversionCollectors.DisconnectWithProbe(probe->GetObject<Probe>(),
738 "OutputBytes",
739 identifier,
740 &UnitConversionCollector::TraceSinkUinteger32);
741
742 identifier = GetIdentifierForUt(node);
743
744 m_conversionCollectors.ConnectWithProbe(probe->GetObject<Probe>(),
745 "OutputBytes",
746 identifier,
747 &UnitConversionCollector::TraceSinkUinteger32);
748
749 it->second.second = identifier;
750 }
751} // end of `void UpdateIdentifierOnProbes ();`
752
753// FORWARD FEEDER LINK MAC-LEVEL /////////////////////////////////////////////////////
754
755NS_OBJECT_ENSURE_REGISTERED(SatStatsFwdFeederMacThroughputHelper);
756
758 Ptr<const SatHelper> satHelper)
759 : SatStatsThroughputHelper(satHelper)
760{
761 NS_LOG_FUNCTION(this << satHelper);
762}
763
768
769TypeId // static
771{
772 static TypeId tid =
773 TypeId("ns3::SatStatsFwdFeederMacThroughputHelper").SetParent<SatStatsThroughputHelper>();
774 return tid;
775}
776
777void
779{
780 NS_LOG_FUNCTION(this);
781
782 NodeContainer sats = Singleton<SatTopology>::Get()->GetOrbiterNodes();
783 Callback<void, Ptr<const Packet>, const Address&> callback =
785
786 for (NodeContainer::Iterator it = sats.Begin(); it != sats.End(); ++it)
787 {
788 Ptr<NetDevice> dev = GetSatSatOrbiterNetDevice(*it);
789 Ptr<SatOrbiterNetDevice> satOrbiterDev = dev->GetObject<SatOrbiterNetDevice>();
790 NS_ASSERT(satOrbiterDev != nullptr);
791 satOrbiterDev->SetAttribute("EnableStatisticsTags", BooleanValue(true));
792 std::map<uint32_t, Ptr<SatMac>> satOrbiterFeederMacs = satOrbiterDev->GetAllFeederMac();
793 Ptr<SatMac> satMac;
794 for (std::map<uint32_t, Ptr<SatMac>>::iterator it2 = satOrbiterFeederMacs.begin();
795 it2 != satOrbiterFeederMacs.end();
796 ++it2)
797 {
798 satMac = it2->second;
799 NS_ASSERT(satMac != nullptr);
800 satMac->SetAttribute("EnableStatisticsTags", BooleanValue(true));
801
802 // Connect the object to the probe.
803 if (satMac->TraceConnectWithoutContext("Rx", callback))
804 {
805 NS_LOG_INFO(this << " successfully connected with node ID " << (*it)->GetId()
806 << " device #" << satOrbiterDev->GetIfIndex());
807 }
808 else
809 {
810 NS_FATAL_ERROR("Error connecting to Rx trace source of SatMac"
811 << " at node ID " << (*it)->GetId() << " device #"
812 << satOrbiterDev->GetIfIndex());
813 }
814 }
815 std::map<uint32_t, Ptr<SatMac>> satOrbiterUserMacs = satOrbiterDev->GetUserMac();
816 for (std::map<uint32_t, Ptr<SatMac>>::iterator it2 = satOrbiterUserMacs.begin();
817 it2 != satOrbiterUserMacs.end();
818 ++it2)
819 {
820 satMac = it2->second;
821 NS_ASSERT(satMac != nullptr);
822 satMac->SetAttribute("EnableStatisticsTags", BooleanValue(true));
823 }
824 } // end of `for (it = sats.Begin(); it != sats.End (); ++it)`
825
826 NodeContainer uts = Singleton<SatTopology>::Get()->GetUtNodes();
827
828 for (NodeContainer::Iterator it = uts.Begin(); it != uts.End(); ++it)
829 {
830 // Create a map of UT addresses and identifiers.
832
833 Ptr<NetDevice> dev = GetUtSatNetDevice(*it);
834 Ptr<SatNetDevice> satDev = dev->GetObject<SatNetDevice>();
835 NS_ASSERT(satDev != nullptr);
836 Ptr<SatMac> satMac = satDev->GetMac();
837 NS_ASSERT(satMac != nullptr);
838
839 satDev->SetAttribute("EnableStatisticsTags", BooleanValue(true));
840 satMac->SetAttribute("EnableStatisticsTags", BooleanValue(true));
841
842 } // end of `for (it = uts.Begin(); it != uts.End (); ++it)`
843
844 // Enable statistics-related tags on the transmitting device.
845 NodeContainer gws = Singleton<SatTopology>::Get()->GetGwNodes();
846 for (NodeContainer::Iterator it = gws.Begin(); it != gws.End(); ++it)
847 {
848 NetDeviceContainer devs = GetGwSatNetDevice(*it);
849
850 for (NetDeviceContainer::Iterator itDev = devs.Begin(); itDev != devs.End(); ++itDev)
851 {
852 Ptr<SatNetDevice> satDev = (*itDev)->GetObject<SatNetDevice>();
853 NS_ASSERT(satDev != nullptr);
854 Ptr<SatMac> satMac = satDev->GetMac();
855 NS_ASSERT(satMac != nullptr);
856
857 satDev->SetAttribute("EnableStatisticsTags", BooleanValue(true));
858 satMac->SetAttribute("EnableStatisticsTags", BooleanValue(true));
859 }
860 }
861
862} // end of `void DoInstallProbes ();`
863
864// FORWARD USER LINK MAC-LEVEL /////////////////////////////////////////////////////
865
866NS_OBJECT_ENSURE_REGISTERED(SatStatsFwdUserMacThroughputHelper);
867
869 Ptr<const SatHelper> satHelper)
870 : SatStatsThroughputHelper(satHelper)
871{
872 NS_LOG_FUNCTION(this << satHelper);
873}
874
879
880TypeId // static
882{
883 static TypeId tid =
884 TypeId("ns3::SatStatsFwdUserMacThroughputHelper").SetParent<SatStatsThroughputHelper>();
885 return tid;
886}
887
888void
890{
891 NS_LOG_FUNCTION(this);
892
893 NodeContainer sats = Singleton<SatTopology>::Get()->GetOrbiterNodes();
894
895 for (NodeContainer::Iterator it = sats.Begin(); it != sats.End(); ++it)
896 {
897 Ptr<NetDevice> dev = GetSatSatOrbiterNetDevice(*it);
898 Ptr<SatOrbiterNetDevice> satOrbiterDev = dev->GetObject<SatOrbiterNetDevice>();
899 NS_ASSERT(satOrbiterDev != nullptr);
900 satOrbiterDev->SetAttribute("EnableStatisticsTags", BooleanValue(true));
901 std::map<uint32_t, Ptr<SatMac>> satOrbiterFeederMacs = satOrbiterDev->GetAllFeederMac();
902 Ptr<SatMac> satMac;
903 for (std::map<uint32_t, Ptr<SatMac>>::iterator it2 = satOrbiterFeederMacs.begin();
904 it2 != satOrbiterFeederMacs.end();
905 ++it2)
906 {
907 satMac = it2->second;
908 NS_ASSERT(satMac != nullptr);
909 satMac->SetAttribute("EnableStatisticsTags", BooleanValue(true));
910 }
911 std::map<uint32_t, Ptr<SatMac>> satOrbiterUserMacs = satOrbiterDev->GetUserMac();
912 for (std::map<uint32_t, Ptr<SatMac>>::iterator it2 = satOrbiterUserMacs.begin();
913 it2 != satOrbiterUserMacs.end();
914 ++it2)
915 {
916 satMac = it2->second;
917 NS_ASSERT(satMac != nullptr);
918 satMac->SetAttribute("EnableStatisticsTags", BooleanValue(true));
919 }
920 } // end of `for (it = sats.Begin(); it != sats.End (); ++it)`
921
922 NodeContainer uts = Singleton<SatTopology>::Get()->GetUtNodes();
923
924 for (NodeContainer::Iterator it = uts.Begin(); it != uts.End(); ++it)
925 {
926 const int32_t utId = GetUtId(*it);
927 NS_ASSERT_MSG(utId > 0, "Node " << (*it)->GetId() << " is not a valid UT");
928 const uint32_t identifier = GetIdentifierForUt(*it);
929
930 // Create the probe.
931 std::ostringstream probeName;
932 probeName << utId;
933 Ptr<ApplicationPacketProbe> probe = CreateObject<ApplicationPacketProbe>();
934 probe->SetName(probeName.str());
935
936 Ptr<NetDevice> dev = GetUtSatNetDevice(*it);
937 Ptr<SatNetDevice> satDev = dev->GetObject<SatNetDevice>();
938 NS_ASSERT(satDev != nullptr);
939 Ptr<SatMac> satMac = satDev->GetMac();
940 NS_ASSERT(satMac != nullptr);
941
942 // Connect the object to the probe.
943 if (probe->ConnectByObject("Rx", satMac))
944 {
945 // Connect the probe to the right collector.
946 if (m_conversionCollectors.ConnectWithProbe(
947 probe->GetObject<Probe>(),
948 "OutputBytes",
949 identifier,
950 &UnitConversionCollector::TraceSinkUinteger32))
951 {
952 m_probes.insert(
953 std::make_pair(probe->GetObject<Probe>(), std::make_pair(*it, identifier)));
954
955 // Enable statistics-related tags and trace sources on the device.
956 satDev->SetAttribute("EnableStatisticsTags", BooleanValue(true));
957 satMac->SetAttribute("EnableStatisticsTags", BooleanValue(true));
958 }
959 else
960 {
961 NS_LOG_WARN(this << " unable to connect probe " << probeName.str()
962 << " to collector " << identifier);
963 }
964 }
965 else
966 {
967 NS_FATAL_ERROR("Error connecting to Rx trace source of SatMac"
968 << " at node ID " << (*it)->GetId() << " device #2");
969 }
970 } // end of `for (it = uts.Begin(); it != uts.End (); ++it)`
971
972 // Enable statistics-related tags on the transmitting device.
973 NodeContainer gws = Singleton<SatTopology>::Get()->GetGwNodes();
974 for (NodeContainer::Iterator it = gws.Begin(); it != gws.End(); ++it)
975 {
976 NetDeviceContainer devs = GetGwSatNetDevice(*it);
977
978 for (NetDeviceContainer::Iterator itDev = devs.Begin(); itDev != devs.End(); ++itDev)
979 {
980 Ptr<SatNetDevice> satDev = (*itDev)->GetObject<SatNetDevice>();
981 NS_ASSERT(satDev != nullptr);
982 Ptr<SatMac> satMac = satDev->GetMac();
983 NS_ASSERT(satMac != nullptr);
984
985 satDev->SetAttribute("EnableStatisticsTags", BooleanValue(true));
986 satMac->SetAttribute("EnableStatisticsTags", BooleanValue(true));
987 }
988 }
989
990} // end of `void DoInstallProbes ();`
991
992void
994{
995 NS_LOG_FUNCTION(this);
996
997 std::map<Ptr<Probe>, std::pair<Ptr<Node>, uint32_t>>::iterator it;
998
999 for (it = m_probes.begin(); it != m_probes.end(); it++)
1000 {
1001 Ptr<Probe> probe = it->first;
1002 Ptr<Node> node = it->second.first;
1003 uint32_t identifier = it->second.second;
1004 m_conversionCollectors.DisconnectWithProbe(probe->GetObject<Probe>(),
1005 "OutputBytes",
1006 identifier,
1007 &UnitConversionCollector::TraceSinkUinteger32);
1008
1009 identifier = GetIdentifierForUt(node);
1010
1011 m_conversionCollectors.ConnectWithProbe(probe->GetObject<Probe>(),
1012 "OutputBytes",
1013 identifier,
1014 &UnitConversionCollector::TraceSinkUinteger32);
1015
1016 it->second.second = identifier;
1017 }
1018} // end of `void UpdateIdentifierOnProbes ();`
1019
1020// FORWARD FEEDER LINK PHY-LEVEL /////////////////////////////////////////////////////
1021
1022NS_OBJECT_ENSURE_REGISTERED(SatStatsFwdFeederPhyThroughputHelper);
1023
1025 Ptr<const SatHelper> satHelper)
1026 : SatStatsThroughputHelper(satHelper)
1027{
1028 NS_LOG_FUNCTION(this << satHelper);
1029}
1030
1035
1036TypeId // static
1038{
1039 static TypeId tid =
1040 TypeId("ns3::SatStatsFwdFeederPhyThroughputHelper").SetParent<SatStatsThroughputHelper>();
1041 return tid;
1042}
1043
1044void
1046{
1047 NS_LOG_FUNCTION(this);
1048
1049 NodeContainer sats = Singleton<SatTopology>::Get()->GetOrbiterNodes();
1050 Callback<void, Ptr<const Packet>, const Address&> callback =
1052
1053 for (NodeContainer::Iterator it = sats.Begin(); it != sats.End(); ++it)
1054 {
1055 Ptr<NetDevice> dev = GetSatSatOrbiterNetDevice(*it);
1056 Ptr<SatOrbiterNetDevice> satOrbiterDev = dev->GetObject<SatOrbiterNetDevice>();
1057 NS_ASSERT(satOrbiterDev != nullptr);
1058 satOrbiterDev->SetAttribute("EnableStatisticsTags", BooleanValue(true));
1059 std::map<uint32_t, Ptr<SatPhy>> satOrbiterFeederPhys = satOrbiterDev->GetFeederPhy();
1060 Ptr<SatPhy> satPhy;
1061 for (std::map<uint32_t, Ptr<SatPhy>>::iterator it2 = satOrbiterFeederPhys.begin();
1062 it2 != satOrbiterFeederPhys.end();
1063 ++it2)
1064 {
1065 satPhy = it2->second;
1066 NS_ASSERT(satPhy != nullptr);
1067 satPhy->SetAttribute("EnableStatisticsTags", BooleanValue(true));
1068
1069 // Connect the object to the probe.
1070 if (satPhy->TraceConnectWithoutContext("Rx", callback))
1071 {
1072 NS_LOG_INFO(this << " successfully connected with node ID " << (*it)->GetId()
1073 << " device #" << satOrbiterDev->GetIfIndex());
1074
1075 // Enable statistics-related tags and trace sources on the device.
1076 satPhy->SetAttribute("EnableStatisticsTags", BooleanValue(true));
1077 }
1078 else
1079 {
1080 NS_FATAL_ERROR("Error connecting to Rx trace source of SatPhy"
1081 << " at node ID " << (*it)->GetId() << " device #"
1082 << satOrbiterDev->GetIfIndex());
1083 }
1084 }
1085 std::map<uint32_t, Ptr<SatPhy>> satOrbiterUserPhys = satOrbiterDev->GetUserPhy();
1086 for (std::map<uint32_t, Ptr<SatPhy>>::iterator it2 = satOrbiterUserPhys.begin();
1087 it2 != satOrbiterUserPhys.end();
1088 ++it2)
1089 {
1090 satPhy = it2->second;
1091 NS_ASSERT(satPhy != nullptr);
1092 satPhy->SetAttribute("EnableStatisticsTags", BooleanValue(true));
1093 }
1094 } // end of `for (it = sats.Begin(); it != sats.End (); ++it)`
1095
1096 NodeContainer uts = Singleton<SatTopology>::Get()->GetUtNodes();
1097
1098 for (NodeContainer::Iterator it = uts.Begin(); it != uts.End(); ++it)
1099 {
1100 // Create a map of UT addresses and identifiers.
1102
1103 Ptr<NetDevice> dev = GetUtSatNetDevice(*it);
1104 Ptr<SatNetDevice> satDev = dev->GetObject<SatNetDevice>();
1105 NS_ASSERT(satDev != nullptr);
1106 Ptr<SatPhy> satPhy = satDev->GetPhy();
1107 NS_ASSERT(satPhy != nullptr);
1108
1109 satDev->SetAttribute("EnableStatisticsTags", BooleanValue(true));
1110 satPhy->SetAttribute("EnableStatisticsTags", BooleanValue(true));
1111
1112 } // end of `for (it = uts.Begin(); it != uts.End (); ++it)`
1113
1114 // Enable statistics-related tags on the transmitting device.
1115 NodeContainer gws = Singleton<SatTopology>::Get()->GetGwNodes();
1116 for (NodeContainer::Iterator it = gws.Begin(); it != gws.End(); ++it)
1117 {
1118 NetDeviceContainer devs = GetGwSatNetDevice(*it);
1119
1120 for (NetDeviceContainer::Iterator itDev = devs.Begin(); itDev != devs.End(); ++itDev)
1121 {
1122 Ptr<SatNetDevice> satDev = (*itDev)->GetObject<SatNetDevice>();
1123 NS_ASSERT(satDev != nullptr);
1124 Ptr<SatPhy> satPhy = satDev->GetPhy();
1125 NS_ASSERT(satPhy != nullptr);
1126
1127 satDev->SetAttribute("EnableStatisticsTags", BooleanValue(true));
1128 satPhy->SetAttribute("EnableStatisticsTags", BooleanValue(true));
1129 }
1130 }
1131
1132} // end of `void DoInstallProbes ();`
1133
1134// FORWARD USER LINK PHY-LEVEL /////////////////////////////////////////////////////
1135
1136NS_OBJECT_ENSURE_REGISTERED(SatStatsFwdUserPhyThroughputHelper);
1137
1139 Ptr<const SatHelper> satHelper)
1140 : SatStatsThroughputHelper(satHelper)
1141{
1142 NS_LOG_FUNCTION(this << satHelper);
1143}
1144
1149
1150TypeId // static
1152{
1153 static TypeId tid =
1154 TypeId("ns3::SatStatsFwdUserPhyThroughputHelper").SetParent<SatStatsThroughputHelper>();
1155 return tid;
1156}
1157
1158void
1160{
1161 NS_LOG_FUNCTION(this);
1162
1163 NodeContainer sats = Singleton<SatTopology>::Get()->GetOrbiterNodes();
1164
1165 for (NodeContainer::Iterator it = sats.Begin(); it != sats.End(); ++it)
1166 {
1167 Ptr<NetDevice> dev = GetSatSatOrbiterNetDevice(*it);
1168 Ptr<SatOrbiterNetDevice> satOrbiterDev = dev->GetObject<SatOrbiterNetDevice>();
1169 NS_ASSERT(satOrbiterDev != nullptr);
1170 satOrbiterDev->SetAttribute("EnableStatisticsTags", BooleanValue(true));
1171 std::map<uint32_t, Ptr<SatPhy>> satOrbiterFeederPhys = satOrbiterDev->GetFeederPhy();
1172 Ptr<SatPhy> satPhy;
1173 for (std::map<uint32_t, Ptr<SatPhy>>::iterator it2 = satOrbiterFeederPhys.begin();
1174 it2 != satOrbiterFeederPhys.end();
1175 ++it2)
1176 {
1177 satPhy = it2->second;
1178 NS_ASSERT(satPhy != nullptr);
1179 satPhy->SetAttribute("EnableStatisticsTags", BooleanValue(true));
1180 }
1181 std::map<uint32_t, Ptr<SatPhy>> satOrbiterUserPhys = satOrbiterDev->GetUserPhy();
1182 for (std::map<uint32_t, Ptr<SatPhy>>::iterator it2 = satOrbiterUserPhys.begin();
1183 it2 != satOrbiterUserPhys.end();
1184 ++it2)
1185 {
1186 satPhy = it2->second;
1187 NS_ASSERT(satPhy != nullptr);
1188 satPhy->SetAttribute("EnableStatisticsTags", BooleanValue(true));
1189 }
1190 } // end of `for (it = sats.Begin(); it != sats.End (); ++it)`
1191
1192 NodeContainer uts = Singleton<SatTopology>::Get()->GetUtNodes();
1193
1194 for (NodeContainer::Iterator it = uts.Begin(); it != uts.End(); ++it)
1195 {
1196 const int32_t utId = GetUtId(*it);
1197 NS_ASSERT_MSG(utId > 0, "Node " << (*it)->GetId() << " is not a valid UT");
1198 const uint32_t identifier = GetIdentifierForUt(*it);
1199
1200 // Create the probe.
1201 std::ostringstream probeName;
1202 probeName << utId;
1203 Ptr<ApplicationPacketProbe> probe = CreateObject<ApplicationPacketProbe>();
1204 probe->SetName(probeName.str());
1205
1206 Ptr<NetDevice> dev = GetUtSatNetDevice(*it);
1207 Ptr<SatNetDevice> satDev = dev->GetObject<SatNetDevice>();
1208 NS_ASSERT(satDev != nullptr);
1209 Ptr<SatPhy> satPhy = satDev->GetPhy();
1210 NS_ASSERT(satPhy != nullptr);
1211
1212 // Connect the object to the probe.
1213 if (probe->ConnectByObject("Rx", satPhy))
1214 { // Connect the probe to the right collector.
1215 if (m_conversionCollectors.ConnectWithProbe(
1216 probe->GetObject<Probe>(),
1217 "OutputBytes",
1218 identifier,
1219 &UnitConversionCollector::TraceSinkUinteger32))
1220 {
1221 m_probes.insert(
1222 std::make_pair(probe->GetObject<Probe>(), std::make_pair(*it, identifier)));
1223
1224 // Enable statistics-related tags and trace sources on the device.
1225 satDev->SetAttribute("EnableStatisticsTags", BooleanValue(true));
1226 satPhy->SetAttribute("EnableStatisticsTags", BooleanValue(true));
1227 }
1228 else
1229 {
1230 NS_LOG_WARN(this << " unable to connect probe " << probeName.str()
1231 << " to collector " << identifier);
1232 }
1233 }
1234 else
1235 {
1236 NS_FATAL_ERROR("Error connecting to Rx trace source of SatPhy"
1237 << " at node ID " << (*it)->GetId() << " device #2");
1238 }
1239 } // end of `for (it = uts.Begin(); it != uts.End (); ++it)`
1240
1241 // Enable statistics-related tags on the transmitting device.
1242 NodeContainer gws = Singleton<SatTopology>::Get()->GetGwNodes();
1243 for (NodeContainer::Iterator it = gws.Begin(); it != gws.End(); ++it)
1244 {
1245 NetDeviceContainer devs = GetGwSatNetDevice(*it);
1246
1247 for (NetDeviceContainer::Iterator itDev = devs.Begin(); itDev != devs.End(); ++itDev)
1248 {
1249 Ptr<SatNetDevice> satDev = (*itDev)->GetObject<SatNetDevice>();
1250 NS_ASSERT(satDev != nullptr);
1251 Ptr<SatPhy> satPhy = satDev->GetPhy();
1252 NS_ASSERT(satPhy != nullptr);
1253
1254 satDev->SetAttribute("EnableStatisticsTags", BooleanValue(true));
1255 satPhy->SetAttribute("EnableStatisticsTags", BooleanValue(true));
1256 }
1257 }
1258
1259} // end of `void DoInstallProbes ();`
1260
1261void
1263{
1264 NS_LOG_FUNCTION(this);
1265
1266 std::map<Ptr<Probe>, std::pair<Ptr<Node>, uint32_t>>::iterator it;
1267
1268 for (it = m_probes.begin(); it != m_probes.end(); it++)
1269 {
1270 Ptr<Probe> probe = it->first;
1271 Ptr<Node> node = it->second.first;
1272 uint32_t identifier = it->second.second;
1273 m_conversionCollectors.DisconnectWithProbe(probe->GetObject<Probe>(),
1274 "OutputBytes",
1275 identifier,
1276 &UnitConversionCollector::TraceSinkUinteger32);
1277
1278 identifier = GetIdentifierForUt(node);
1279
1280 m_conversionCollectors.ConnectWithProbe(probe->GetObject<Probe>(),
1281 "OutputBytes",
1282 identifier,
1283 &UnitConversionCollector::TraceSinkUinteger32);
1284
1285 it->second.second = identifier;
1286 }
1287} // end of `void UpdateIdentifierOnProbes ();`
1288
1289// RETURN LINK APPLICATION-LEVEL //////////////////////////////////////////////
1290
1291NS_OBJECT_ENSURE_REGISTERED(SatStatsRtnAppThroughputHelper);
1292
1294 : SatStatsThroughputHelper(satHelper)
1295{
1296 NS_LOG_FUNCTION(this << satHelper);
1297}
1298
1303
1304TypeId // static
1306{
1307 static TypeId tid =
1308 TypeId("ns3::SatStatsRtnAppThroughputHelper").SetParent<SatStatsThroughputHelper>();
1309 return tid;
1310}
1311
1312void
1314{
1315 NS_LOG_FUNCTION(this);
1316
1317 // Create a map of UT user addresses and identifiers.
1318 NodeContainer utUsers = Singleton<SatTopology>::Get()->GetUtUserNodes();
1319 for (NodeContainer::Iterator it = utUsers.Begin(); it != utUsers.End(); ++it)
1320 {
1322 }
1323
1324 // Connect to trace sources at GW user node's applications.
1325
1326 NodeContainer gwUsers = Singleton<SatTopology>::Get()->GetGwUserNodes();
1327 Callback<void, Ptr<const Packet>, const Address&> callback =
1329
1330 for (NodeContainer::Iterator it = gwUsers.Begin(); it != gwUsers.End(); ++it)
1331 {
1332 for (uint32_t i = 0; i < (*it)->GetNApplications(); i++)
1333 {
1334 Ptr<Application> app = (*it)->GetApplication(i);
1335
1336 if (app->TraceConnectWithoutContext("Rx", callback))
1337 {
1338 NS_LOG_INFO(this << " successfully connected with node ID " << (*it)->GetId()
1339 << " application #" << i);
1340 }
1341 else
1342 {
1343 /*
1344 * We're being tolerant here by only logging a warning, because
1345 * not every kind of Application is equipped with the expected
1346 * Rx trace source.
1347 */
1348 NS_LOG_WARN(this << " unable to connect with node ID " << (*it)->GetId()
1349 << " application #" << i);
1350 }
1351 }
1352 }
1353
1354} // end of `void DoInstallProbes ();`
1355
1356void
1357SatStatsRtnAppThroughputHelper::Ipv4Callback(Ptr<const Packet> packet, const Address& from)
1358{
1359 // NS_LOG_FUNCTION (this << packet->GetSize () << from);
1360
1361 if (InetSocketAddress::IsMatchingType(from))
1362 {
1363 // Determine the identifier associated with the sender address.
1364 const Address ipv4Addr = InetSocketAddress::ConvertFrom(from).GetIpv4();
1365 std::map<const Address, uint32_t>::const_iterator it1 = m_identifierMap.find(ipv4Addr);
1366
1367 if (it1 == m_identifierMap.end())
1368 {
1369 NS_LOG_WARN(this << " discarding packet " << packet << " (" << packet->GetSize()
1370 << " bytes)" << " from statistics collection because of"
1371 << " unknown sender IPv4 address " << ipv4Addr);
1372 }
1373 else
1374 {
1375 // Find the collector with the right identifier.
1376 Ptr<DataCollectionObject> collector = m_conversionCollectors.Get(it1->second);
1377 NS_ASSERT_MSG(collector != nullptr,
1378 "Unable to find collector with identifier " << it1->second);
1379 Ptr<UnitConversionCollector> c = collector->GetObject<UnitConversionCollector>();
1380 NS_ASSERT(c != nullptr);
1381
1382 // Pass the sample to the collector.
1383 c->TraceSinkUinteger32(0, packet->GetSize());
1384 }
1385 }
1386 else
1387 {
1388 NS_LOG_WARN(this << " discarding packet " << packet << " (" << packet->GetSize()
1389 << " bytes)" << " from statistics collection"
1390 << " because it comes from sender " << from
1391 << " without valid InetSocketAddress");
1392 }
1393
1394} // end of `void Ipv4Callback (Ptr<const Packet>, const Address);`
1395
1396void
1398{
1399 NS_LOG_FUNCTION(this << utUserNode->GetId());
1400
1401 Ptr<Ipv4> ipv4 = utUserNode->GetObject<Ipv4>();
1402
1403 if (ipv4 == nullptr)
1404 {
1405 NS_LOG_INFO(this << " Node " << utUserNode->GetId() << " does not support IPv4 protocol");
1406 }
1407 else if (ipv4->GetNInterfaces() >= 2)
1408 {
1409 const uint32_t identifier = GetIdentifierForUtUser(utUserNode);
1410
1411 /*
1412 * Assuming that #0 is for loopback interface and #1 is for subscriber
1413 * network interface.
1414 */
1415 for (uint32_t i = 0; i < ipv4->GetNAddresses(1); i++)
1416 {
1417 const Address addr = ipv4->GetAddress(1, i).GetLocal();
1418 m_identifierMap[addr] = identifier;
1419 NS_LOG_INFO(this << " associated address " << addr << " with identifier "
1420 << identifier);
1421 }
1422 }
1423 else
1424 {
1425 NS_LOG_WARN(this << " Node " << utUserNode->GetId() << " is not a valid UT user");
1426 }
1427}
1428
1429// RETURN FEEDER LINK DEVICE-LEVEL ///////////////////////////////////////////////////
1430
1431NS_OBJECT_ENSURE_REGISTERED(SatStatsRtnFeederDevThroughputHelper);
1432
1434 Ptr<const SatHelper> satHelper)
1435 : SatStatsThroughputHelper(satHelper)
1436{
1437 NS_LOG_FUNCTION(this << satHelper);
1438}
1439
1444
1445TypeId // static
1447{
1448 static TypeId tid =
1449 TypeId("ns3::SatStatsRtnFeederDevThroughputHelper").SetParent<SatStatsThroughputHelper>();
1450 return tid;
1451}
1452
1453void
1455{
1456 NS_LOG_FUNCTION(this);
1457
1458 NodeContainer uts = Singleton<SatTopology>::Get()->GetUtNodes();
1459 for (NodeContainer::Iterator it = uts.Begin(); it != uts.End(); ++it)
1460 {
1461 // Create a map of UT addresses and identifiers.
1463
1464 // Enable statistics-related tags and trace sources on the device.
1465 Ptr<NetDevice> dev = GetUtSatNetDevice(*it);
1466 dev->SetAttribute("EnableStatisticsTags", BooleanValue(true));
1467 }
1468
1469 // Connect to trace sources at GW nodes.
1470
1471 NodeContainer gws = Singleton<SatTopology>::Get()->GetGwNodes();
1472 Callback<void, Ptr<const Packet>, const Address&> callback =
1474
1475 for (NodeContainer::Iterator it = gws.Begin(); it != gws.End(); ++it)
1476 {
1477 NetDeviceContainer devs = GetGwSatNetDevice(*it);
1478
1479 for (NetDeviceContainer::Iterator itDev = devs.Begin(); itDev != devs.End(); ++itDev)
1480 {
1481 NS_ASSERT((*itDev)->GetObject<SatNetDevice>() != nullptr);
1482
1483 if ((*itDev)->TraceConnectWithoutContext("Rx", callback))
1484 {
1485 NS_LOG_INFO(this << " successfully connected with node ID " << (*it)->GetId()
1486 << " device #" << (*itDev)->GetIfIndex());
1487
1488 // Enable statistics-related tags and trace sources on the device.
1489 (*itDev)->SetAttribute("EnableStatisticsTags", BooleanValue(true));
1490 }
1491 else
1492 {
1493 NS_FATAL_ERROR("Error connecting to Rx trace source of SatNetDevice"
1494 << " at node ID " << (*it)->GetId() << " device #"
1495 << (*itDev)->GetIfIndex());
1496 }
1497
1498 } // end of `for (NetDeviceContainer::Iterator itDev = devs)`
1499
1500 } // end of `for (NodeContainer::Iterator it = gws)`
1501
1502} // end of `void DoInstallProbes ();`
1503
1504// RETURN USER LINK DEVICE-LEVEL ///////////////////////////////////////////////////
1505
1506NS_OBJECT_ENSURE_REGISTERED(SatStatsRtnUserDevThroughputHelper);
1507
1509 Ptr<const SatHelper> satHelper)
1510 : SatStatsThroughputHelper(satHelper)
1511{
1512 NS_LOG_FUNCTION(this << satHelper);
1513}
1514
1519
1520TypeId // static
1522{
1523 static TypeId tid =
1524 TypeId("ns3::SatStatsRtnUserDevThroughputHelper").SetParent<SatStatsThroughputHelper>();
1525 return tid;
1526}
1527
1528void
1530{
1531 NS_LOG_FUNCTION(this);
1532
1533 NodeContainer sats = Singleton<SatTopology>::Get()->GetOrbiterNodes();
1534 Callback<void, Ptr<const Packet>, const Address&> callback =
1536
1537 for (NodeContainer::Iterator it = sats.Begin(); it != sats.End(); ++it)
1538 {
1539 Ptr<NetDevice> dev = GetSatSatOrbiterNetDevice(*it);
1540 Ptr<SatOrbiterNetDevice> satOrbiterDev = dev->GetObject<SatOrbiterNetDevice>();
1541 NS_ASSERT(satOrbiterDev != nullptr);
1542 satOrbiterDev->SetAttribute("EnableStatisticsTags", BooleanValue(true));
1543
1544 // Connect the object to the probe.
1545 if (satOrbiterDev->TraceConnectWithoutContext("RxUser", callback))
1546 {
1547 NS_LOG_INFO(this << " successfully connected with node ID " << (*it)->GetId()
1548 << " device #" << satOrbiterDev->GetIfIndex());
1549 }
1550 else
1551 {
1552 NS_FATAL_ERROR("Error connecting to Rx trace source of SatMac"
1553 << " at node ID " << (*it)->GetId() << " device #"
1554 << satOrbiterDev->GetIfIndex());
1555 }
1556 } // end of `for (it = sats.Begin(); it != sats.End (); ++it)`
1557
1558 NodeContainer uts = Singleton<SatTopology>::Get()->GetUtNodes();
1559 for (NodeContainer::Iterator it = uts.Begin(); it != uts.End(); ++it)
1560 {
1561 // Create a map of UT addresses and identifiers.
1563
1564 // Enable statistics-related tags and trace sources on the device.
1565 Ptr<NetDevice> dev = GetUtSatNetDevice(*it);
1566 Ptr<SatNetDevice> satDev = dev->GetObject<SatNetDevice>();
1567 NS_ASSERT(satDev != nullptr);
1568 satDev->SetAttribute("EnableStatisticsTags", BooleanValue(true));
1569 }
1570
1571 // Connect to trace sources at GW nodes.
1572
1573 NodeContainer gws = Singleton<SatTopology>::Get()->GetGwNodes();
1574
1575 for (NodeContainer::Iterator it = gws.Begin(); it != gws.End(); ++it)
1576 {
1577 NetDeviceContainer devs = GetGwSatNetDevice(*it);
1578
1579 for (NetDeviceContainer::Iterator itDev = devs.Begin(); itDev != devs.End(); ++itDev)
1580 {
1581 Ptr<SatNetDevice> satDev = (*itDev)->GetObject<SatNetDevice>();
1582 NS_ASSERT(satDev != nullptr);
1583
1584 satDev->SetAttribute("EnableStatisticsTags", BooleanValue(true));
1585 } // end of `for (NetDeviceContainer::Iterator itDev = devs)`
1586
1587 } // end of `for (NodeContainer::Iterator it = gws)`
1588
1589} // end of `void DoInstallProbes ();`
1590
1591// RETURN FEEDER LINK MAC-LEVEL //////////////////////////////////////////////////////
1592
1593NS_OBJECT_ENSURE_REGISTERED(SatStatsRtnFeederMacThroughputHelper);
1594
1596 Ptr<const SatHelper> satHelper)
1597 : SatStatsThroughputHelper(satHelper)
1598{
1599 NS_LOG_FUNCTION(this << satHelper);
1600}
1601
1606
1607TypeId // static
1609{
1610 static TypeId tid =
1611 TypeId("ns3::SatStatsRtnFeederMacThroughputHelper").SetParent<SatStatsThroughputHelper>();
1612 return tid;
1613}
1614
1615void
1617{
1618 NS_LOG_FUNCTION(this);
1619
1620 NodeContainer sats = Singleton<SatTopology>::Get()->GetOrbiterNodes();
1621
1622 for (NodeContainer::Iterator it = sats.Begin(); it != sats.End(); ++it)
1623 {
1624 Ptr<SatMac> satMac;
1625 Ptr<NetDevice> dev = GetSatSatOrbiterNetDevice(*it);
1626 Ptr<SatOrbiterNetDevice> satOrbiterDev = dev->GetObject<SatOrbiterNetDevice>();
1627 NS_ASSERT(satOrbiterDev != nullptr);
1628 satOrbiterDev->SetAttribute("EnableStatisticsTags", BooleanValue(true));
1629 std::map<uint32_t, Ptr<SatMac>> satOrbiterFeederMacs = satOrbiterDev->GetAllFeederMac();
1630 for (std::map<uint32_t, Ptr<SatMac>>::iterator it2 = satOrbiterFeederMacs.begin();
1631 it2 != satOrbiterFeederMacs.end();
1632 ++it2)
1633 {
1634 satMac = it2->second;
1635 NS_ASSERT(satMac != nullptr);
1636 satMac->SetAttribute("EnableStatisticsTags", BooleanValue(true));
1637 }
1638 std::map<uint32_t, Ptr<SatMac>> satOrbiterUserMacs = satOrbiterDev->GetUserMac();
1639 for (std::map<uint32_t, Ptr<SatMac>>::iterator it2 = satOrbiterUserMacs.begin();
1640 it2 != satOrbiterUserMacs.end();
1641 ++it2)
1642 {
1643 satMac = it2->second;
1644 NS_ASSERT(satMac != nullptr);
1645 satMac->SetAttribute("EnableStatisticsTags", BooleanValue(true));
1646 }
1647 } // end of `for (it = sats.Begin(); it != sats.End (); ++it)`
1648
1649 NodeContainer uts = Singleton<SatTopology>::Get()->GetUtNodes();
1650 for (NodeContainer::Iterator it = uts.Begin(); it != uts.End(); ++it)
1651 {
1652 // Create a map of UT addresses and identifiers.
1654
1655 // Enable statistics-related tags and trace sources on the device.
1656 Ptr<NetDevice> dev = GetUtSatNetDevice(*it);
1657 Ptr<SatNetDevice> satDev = dev->GetObject<SatNetDevice>();
1658 NS_ASSERT(satDev != nullptr);
1659 Ptr<SatMac> satMac = satDev->GetMac();
1660 NS_ASSERT(satMac != nullptr);
1661 satDev->SetAttribute("EnableStatisticsTags", BooleanValue(true));
1662 satMac->SetAttribute("EnableStatisticsTags", BooleanValue(true));
1663 }
1664
1665 // Connect to trace sources at GW nodes.
1666
1667 NodeContainer gws = Singleton<SatTopology>::Get()->GetGwNodes();
1668 Callback<void, Ptr<const Packet>, const Address&> callback =
1670
1671 for (NodeContainer::Iterator it = gws.Begin(); it != gws.End(); ++it)
1672 {
1673 NetDeviceContainer devs = GetGwSatNetDevice(*it);
1674
1675 for (NetDeviceContainer::Iterator itDev = devs.Begin(); itDev != devs.End(); ++itDev)
1676 {
1677 Ptr<SatNetDevice> satDev = (*itDev)->GetObject<SatNetDevice>();
1678 NS_ASSERT(satDev != nullptr);
1679 Ptr<SatMac> satMac = satDev->GetMac();
1680 NS_ASSERT(satMac != nullptr);
1681
1682 // Connect the object to the probe.
1683 if (satMac->TraceConnectWithoutContext("Rx", callback))
1684 {
1685 NS_LOG_INFO(this << " successfully connected with node ID " << (*it)->GetId()
1686 << " device #" << satDev->GetIfIndex());
1687
1688 // Enable statistics-related tags and trace sources on the device.
1689 satDev->SetAttribute("EnableStatisticsTags", BooleanValue(true));
1690 satMac->SetAttribute("EnableStatisticsTags", BooleanValue(true));
1691 }
1692 else
1693 {
1694 NS_FATAL_ERROR("Error connecting to Rx trace source of SatMac"
1695 << " at node ID " << (*it)->GetId() << " device #"
1696 << satDev->GetIfIndex());
1697 }
1698
1699 } // end of `for (NetDeviceContainer::Iterator itDev = devs)`
1700
1701 } // end of `for (NodeContainer::Iterator it = gws)`
1702
1703} // end of `void DoInstallProbes ();`
1704
1705// RETURN USER LINK MAC-LEVEL //////////////////////////////////////////////////////
1706
1707NS_OBJECT_ENSURE_REGISTERED(SatStatsRtnUserMacThroughputHelper);
1708
1710 Ptr<const SatHelper> satHelper)
1711 : SatStatsThroughputHelper(satHelper)
1712{
1713 NS_LOG_FUNCTION(this << satHelper);
1714}
1715
1720
1721TypeId // static
1723{
1724 static TypeId tid =
1725 TypeId("ns3::SatStatsRtnUserMacThroughputHelper").SetParent<SatStatsThroughputHelper>();
1726 return tid;
1727}
1728
1729void
1731{
1732 NS_LOG_FUNCTION(this);
1733
1734 NodeContainer sats = Singleton<SatTopology>::Get()->GetOrbiterNodes();
1735 Callback<void, Ptr<const Packet>, const Address&> callback =
1737
1738 for (NodeContainer::Iterator it = sats.Begin(); it != sats.End(); ++it)
1739 {
1740 Ptr<NetDevice> dev = GetSatSatOrbiterNetDevice(*it);
1741 Ptr<SatOrbiterNetDevice> satOrbiterDev = dev->GetObject<SatOrbiterNetDevice>();
1742 NS_ASSERT(satOrbiterDev != nullptr);
1743 satOrbiterDev->SetAttribute("EnableStatisticsTags", BooleanValue(true));
1744 std::map<uint32_t, Ptr<SatMac>> satOrbiterFeederMacs = satOrbiterDev->GetAllFeederMac();
1745 Ptr<SatMac> satMac;
1746 for (std::map<uint32_t, Ptr<SatMac>>::iterator it2 = satOrbiterFeederMacs.begin();
1747 it2 != satOrbiterFeederMacs.end();
1748 ++it2)
1749 {
1750 satMac = it2->second;
1751 NS_ASSERT(satMac != nullptr);
1752 satMac->SetAttribute("EnableStatisticsTags", BooleanValue(true));
1753 }
1754 std::map<uint32_t, Ptr<SatMac>> satOrbiterUserMacs = satOrbiterDev->GetUserMac();
1755 for (std::map<uint32_t, Ptr<SatMac>>::iterator it2 = satOrbiterUserMacs.begin();
1756 it2 != satOrbiterUserMacs.end();
1757 ++it2)
1758 {
1759 satMac = it2->second;
1760 NS_ASSERT(satMac != nullptr);
1761 satMac->SetAttribute("EnableStatisticsTags", BooleanValue(true));
1762
1763 // Connect the object to the probe.
1764 if (satMac->TraceConnectWithoutContext("Rx", callback))
1765 {
1766 NS_LOG_INFO(this << " successfully connected with node ID " << (*it)->GetId()
1767 << " device #" << satOrbiterDev->GetIfIndex());
1768 }
1769 else
1770 {
1771 NS_FATAL_ERROR("Error connecting to Rx trace source of SatMac"
1772 << " at node ID " << (*it)->GetId() << " device #"
1773 << satOrbiterDev->GetIfIndex());
1774 }
1775 }
1776 } // end of `for (it = sats.Begin(); it != sats.End (); ++it)`
1777
1778 NodeContainer uts = Singleton<SatTopology>::Get()->GetUtNodes();
1779 for (NodeContainer::Iterator it = uts.Begin(); it != uts.End(); ++it)
1780 {
1781 // Create a map of UT addresses and identifiers.
1783
1784 // Enable statistics-related tags and trace sources on the device.
1785 Ptr<NetDevice> dev = GetUtSatNetDevice(*it);
1786 Ptr<SatNetDevice> satDev = dev->GetObject<SatNetDevice>();
1787 NS_ASSERT(satDev != nullptr);
1788 Ptr<SatMac> satMac = satDev->GetMac();
1789 NS_ASSERT(satMac != nullptr);
1790 satDev->SetAttribute("EnableStatisticsTags", BooleanValue(true));
1791 satMac->SetAttribute("EnableStatisticsTags", BooleanValue(true));
1792 }
1793
1794 // Connect to trace sources at GW nodes.
1795
1796 NodeContainer gws = Singleton<SatTopology>::Get()->GetGwNodes();
1797
1798 for (NodeContainer::Iterator it = gws.Begin(); it != gws.End(); ++it)
1799 {
1800 NetDeviceContainer devs = GetGwSatNetDevice(*it);
1801
1802 for (NetDeviceContainer::Iterator itDev = devs.Begin(); itDev != devs.End(); ++itDev)
1803 {
1804 Ptr<SatNetDevice> satDev = (*itDev)->GetObject<SatNetDevice>();
1805 NS_ASSERT(satDev != nullptr);
1806 Ptr<SatMac> satMac = satDev->GetMac();
1807 NS_ASSERT(satMac != nullptr);
1808
1809 satDev->SetAttribute("EnableStatisticsTags", BooleanValue(true));
1810 satMac->SetAttribute("EnableStatisticsTags", BooleanValue(true));
1811 } // end of `for (NetDeviceContainer::Iterator itDev = devs)`
1812
1813 } // end of `for (NodeContainer::Iterator it = gws)`
1814
1815} // end of `void DoInstallProbes ();`
1816
1817// RETURN FEEDER LINK PHY-LEVEL //////////////////////////////////////////////////////
1818
1819NS_OBJECT_ENSURE_REGISTERED(SatStatsRtnFeederPhyThroughputHelper);
1820
1822 Ptr<const SatHelper> satHelper)
1823 : SatStatsThroughputHelper(satHelper)
1824{
1825 NS_LOG_FUNCTION(this << satHelper);
1826}
1827
1832
1833TypeId // static
1835{
1836 static TypeId tid =
1837 TypeId("ns3::SatStatsRtnFeederPhyThroughputHelper").SetParent<SatStatsThroughputHelper>();
1838 return tid;
1839}
1840
1841void
1843{
1844 NS_LOG_FUNCTION(this);
1845
1846 NodeContainer sats = Singleton<SatTopology>::Get()->GetOrbiterNodes();
1847
1848 for (NodeContainer::Iterator it = sats.Begin(); it != sats.End(); ++it)
1849 {
1850 Ptr<SatPhy> satPhy;
1851 Ptr<NetDevice> dev = GetSatSatOrbiterNetDevice(*it);
1852 Ptr<SatOrbiterNetDevice> satOrbiterDev = dev->GetObject<SatOrbiterNetDevice>();
1853 NS_ASSERT(satOrbiterDev != nullptr);
1854 satOrbiterDev->SetAttribute("EnableStatisticsTags", BooleanValue(true));
1855 std::map<uint32_t, Ptr<SatPhy>> satOrbiterFeederPhys = satOrbiterDev->GetFeederPhy();
1856 for (std::map<uint32_t, Ptr<SatPhy>>::iterator it2 = satOrbiterFeederPhys.begin();
1857 it2 != satOrbiterFeederPhys.end();
1858 ++it2)
1859 {
1860 satPhy = it2->second;
1861 NS_ASSERT(satPhy != nullptr);
1862 satPhy->SetAttribute("EnableStatisticsTags", BooleanValue(true));
1863 }
1864 std::map<uint32_t, Ptr<SatPhy>> satOrbiterUserPhys = satOrbiterDev->GetUserPhy();
1865 for (std::map<uint32_t, Ptr<SatPhy>>::iterator it2 = satOrbiterUserPhys.begin();
1866 it2 != satOrbiterUserPhys.end();
1867 ++it2)
1868 {
1869 satPhy = it2->second;
1870 NS_ASSERT(satPhy != nullptr);
1871 satPhy->SetAttribute("EnableStatisticsTags", BooleanValue(true));
1872 }
1873 } // end of `for (it = sats.Begin(); it != sats.End (); ++it)`
1874
1875 NodeContainer uts = Singleton<SatTopology>::Get()->GetUtNodes();
1876 for (NodeContainer::Iterator it = uts.Begin(); it != uts.End(); ++it)
1877 {
1878 // Create a map of UT addresses and identifiers.
1880
1881 // Enable statistics-related tags and trace sources on the device.
1882 Ptr<NetDevice> dev = GetUtSatNetDevice(*it);
1883 Ptr<SatNetDevice> satDev = dev->GetObject<SatNetDevice>();
1884 NS_ASSERT(satDev != nullptr);
1885 Ptr<SatPhy> satPhy = satDev->GetPhy();
1886 NS_ASSERT(satPhy != nullptr);
1887 satDev->SetAttribute("EnableStatisticsTags", BooleanValue(true));
1888 satPhy->SetAttribute("EnableStatisticsTags", BooleanValue(true));
1889 }
1890
1891 // Connect to trace sources at GW nodes.
1892
1893 NodeContainer gws = Singleton<SatTopology>::Get()->GetGwNodes();
1894 Callback<void, Ptr<const Packet>, const Address&> callback =
1896
1897 for (NodeContainer::Iterator it = gws.Begin(); it != gws.End(); ++it)
1898 {
1899 NetDeviceContainer devs = GetGwSatNetDevice(*it);
1900
1901 for (NetDeviceContainer::Iterator itDev = devs.Begin(); itDev != devs.End(); ++itDev)
1902 {
1903 Ptr<SatNetDevice> satDev = (*itDev)->GetObject<SatNetDevice>();
1904 NS_ASSERT(satDev != nullptr);
1905 Ptr<SatPhy> satPhy = satDev->GetPhy();
1906 NS_ASSERT(satPhy != nullptr);
1907
1908 // Connect the object to the probe.
1909 if (satPhy->TraceConnectWithoutContext("Rx", callback))
1910 {
1911 NS_LOG_INFO(this << " successfully connected with node ID " << (*it)->GetId()
1912 << " device #" << satDev->GetIfIndex());
1913
1914 // Enable statistics-related tags and trace sources on the device.
1915 satDev->SetAttribute("EnableStatisticsTags", BooleanValue(true));
1916 satPhy->SetAttribute("EnableStatisticsTags", BooleanValue(true));
1917 }
1918 else
1919 {
1920 NS_FATAL_ERROR("Error connecting to Rx trace source of SatPhy"
1921 << " at node ID " << (*it)->GetId() << " device #"
1922 << satDev->GetIfIndex());
1923 }
1924
1925 } // end of `for (NetDeviceContainer::Iterator itDev = devs)`
1926
1927 } // end of `for (NodeContainer::Iterator it = gws)`
1928
1929} // end of `void DoInstallProbes ();`
1930
1931// RETURN USER LINK PHY-LEVEL //////////////////////////////////////////////////////
1932
1933NS_OBJECT_ENSURE_REGISTERED(SatStatsRtnUserPhyThroughputHelper);
1934
1936 Ptr<const SatHelper> satHelper)
1937 : SatStatsThroughputHelper(satHelper)
1938{
1939 NS_LOG_FUNCTION(this << satHelper);
1940}
1941
1946
1947TypeId // static
1949{
1950 static TypeId tid =
1951 TypeId("ns3::SatStatsRtnUserPhyThroughputHelper").SetParent<SatStatsThroughputHelper>();
1952 return tid;
1953}
1954
1955void
1957{
1958 NS_LOG_FUNCTION(this);
1959
1960 NodeContainer sats = Singleton<SatTopology>::Get()->GetOrbiterNodes();
1961 Callback<void, Ptr<const Packet>, const Address&> callback =
1963
1964 for (NodeContainer::Iterator it = sats.Begin(); it != sats.End(); ++it)
1965 {
1966 Ptr<NetDevice> dev = GetSatSatOrbiterNetDevice(*it);
1967 Ptr<SatOrbiterNetDevice> satOrbiterDev = dev->GetObject<SatOrbiterNetDevice>();
1968 NS_ASSERT(satOrbiterDev != nullptr);
1969 satOrbiterDev->SetAttribute("EnableStatisticsTags", BooleanValue(true));
1970 std::map<uint32_t, Ptr<SatPhy>> satOrbiterFeederPhys = satOrbiterDev->GetFeederPhy();
1971 Ptr<SatPhy> satPhy;
1972 for (std::map<uint32_t, Ptr<SatPhy>>::iterator it2 = satOrbiterFeederPhys.begin();
1973 it2 != satOrbiterFeederPhys.end();
1974 ++it2)
1975 {
1976 satPhy = it2->second;
1977 NS_ASSERT(satPhy != nullptr);
1978 satPhy->SetAttribute("EnableStatisticsTags", BooleanValue(true));
1979 }
1980 std::map<uint32_t, Ptr<SatPhy>> satOrbiterUserPhys = satOrbiterDev->GetUserPhy();
1981 for (std::map<uint32_t, Ptr<SatPhy>>::iterator it2 = satOrbiterUserPhys.begin();
1982 it2 != satOrbiterUserPhys.end();
1983 ++it2)
1984 {
1985 satPhy = it2->second;
1986 NS_ASSERT(satPhy != nullptr);
1987 satPhy->SetAttribute("EnableStatisticsTags", BooleanValue(true));
1988
1989 // Connect the object to the probe.
1990 if (satPhy->TraceConnectWithoutContext("Rx", callback))
1991 {
1992 NS_LOG_INFO(this << " successfully connected with node ID " << (*it)->GetId()
1993 << " device #" << satOrbiterDev->GetIfIndex());
1994 }
1995 else
1996 {
1997 NS_FATAL_ERROR("Error connecting to Rx trace source of SatPhy"
1998 << " at node ID " << (*it)->GetId() << " device #"
1999 << satOrbiterDev->GetIfIndex());
2000 }
2001 }
2002 } // end of `for (it = sats.Begin(); it != sats.End (); ++it)`
2003
2004 NodeContainer uts = Singleton<SatTopology>::Get()->GetUtNodes();
2005 for (NodeContainer::Iterator it = uts.Begin(); it != uts.End(); ++it)
2006 {
2007 // Create a map of UT addresses and identifiers.
2009
2010 // Enable statistics-related tags and trace sources on the device.
2011 Ptr<NetDevice> dev = GetUtSatNetDevice(*it);
2012 Ptr<SatNetDevice> satDev = dev->GetObject<SatNetDevice>();
2013 NS_ASSERT(satDev != nullptr);
2014 Ptr<SatPhy> satPhy = satDev->GetPhy();
2015 NS_ASSERT(satPhy != nullptr);
2016 satDev->SetAttribute("EnableStatisticsTags", BooleanValue(true));
2017 satPhy->SetAttribute("EnableStatisticsTags", BooleanValue(true));
2018 }
2019
2020 // Connect to trace sources at GW nodes.
2021
2022 NodeContainer gws = Singleton<SatTopology>::Get()->GetGwNodes();
2023
2024 for (NodeContainer::Iterator it = gws.Begin(); it != gws.End(); ++it)
2025 {
2026 NetDeviceContainer devs = GetGwSatNetDevice(*it);
2027
2028 for (NetDeviceContainer::Iterator itDev = devs.Begin(); itDev != devs.End(); ++itDev)
2029 {
2030 Ptr<SatNetDevice> satDev = (*itDev)->GetObject<SatNetDevice>();
2031 NS_ASSERT(satDev != nullptr);
2032 Ptr<SatPhy> satPhy = satDev->GetPhy();
2033 NS_ASSERT(satPhy != nullptr);
2034
2035 satDev->SetAttribute("EnableStatisticsTags", BooleanValue(true));
2036 satPhy->SetAttribute("EnableStatisticsTags", BooleanValue(true));
2037 } // end of `for (NetDeviceContainer::Iterator itDev = devs)`
2038
2039 } // end of `for (NodeContainer::Iterator it = gws)`
2040
2041} // end of `void DoInstallProbes ();`
2042
2043} // end of namespace ns3
SatNetDevice to be utilized in the UT and GW nodes.
SatOrbiterNetDevice to be utilized in geostationary satellite.
Produce forward link application-level throughput statistics from a satellite module simulation.
std::map< Ptr< Probe >, std::pair< Ptr< Node >, uint32_t > > m_probes
Maintains a list of probes created by this helper.
SatStatsFwdAppThroughputHelper(Ptr< const SatHelper > satHelper)
static TypeId GetTypeId()
inherited from ObjectBase base class
virtual void UpdateIdentifierOnProbes()
Change identifier used on probes, when handovers occur.
Produce forward feeder link device-level throughput statistics from a satellite module simulation.
static TypeId GetTypeId()
inherited from ObjectBase base class
SatStatsFwdFeederDevThroughputHelper(Ptr< const SatHelper > satHelper)
Produce forward feeder link MAC-level throughput statistics from a satellite module simulation.
SatStatsFwdFeederMacThroughputHelper(Ptr< const SatHelper > satHelper)
static TypeId GetTypeId()
inherited from ObjectBase base class
Produce forward feeder link PHY-level throughput statistics from a satellite module simulation.
SatStatsFwdFeederPhyThroughputHelper(Ptr< const SatHelper > satHelper)
static TypeId GetTypeId()
inherited from ObjectBase base class
Produce forward user link device-level throughput statistics from a satellite module simulation.
SatStatsFwdUserDevThroughputHelper(Ptr< const SatHelper > satHelper)
std::map< Ptr< Probe >, std::pair< Ptr< Node >, uint32_t > > m_probes
Maintains a list of probes created by this helper.
virtual void UpdateIdentifierOnProbes()
Change identifier used on probes, when handovers occur.
static TypeId GetTypeId()
inherited from ObjectBase base class
Produce forward user link MAC-level throughput statistics from a satellite module simulation.
std::map< Ptr< Probe >, std::pair< Ptr< Node >, uint32_t > > m_probes
Maintains a list of probes created by this helper.
virtual void UpdateIdentifierOnProbes()
Change identifier used on probes, when handovers occur.
SatStatsFwdUserMacThroughputHelper(Ptr< const SatHelper > satHelper)
static TypeId GetTypeId()
inherited from ObjectBase base class
Produce forward user link PHY-level throughput statistics from a satellite module simulation.
virtual void UpdateIdentifierOnProbes()
Change identifier used on probes, when handovers occur.
SatStatsFwdUserPhyThroughputHelper(Ptr< const SatHelper > satHelper)
static TypeId GetTypeId()
inherited from ObjectBase base class
std::map< Ptr< Probe >, std::pair< Ptr< Node >, uint32_t > > m_probes
Maintains a list of probes created by this helper.
static Ptr< NetDevice > GetSatSatOrbiterNetDevice(Ptr< Node > satNode)
uint32_t GetIdentifierForUtUser(Ptr< Node > utUserNode) const
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
uint32_t GetIdentifierForUt(Ptr< Node > utNode) const
std::map< const Address, uint32_t > m_identifierMap
Map of address and the identifier associated with it.
uint32_t GetUtUserId(Ptr< Node > utUserNode) const
std::string GetName() const
virtual std::string GetTimeHeading(std::string dataLabel) const
virtual std::string GetDistributionHeading(std::string dataLabel) const
Produce return link application-level throughput statistics from a satellite module simulation.
void Ipv4Callback(Ptr< const Packet > packet, const Address &from)
Receive inputs from trace sources and determine the right collector to forward the inputs to.
SatStatsRtnAppThroughputHelper(Ptr< const SatHelper > satHelper)
static TypeId GetTypeId()
inherited from ObjectBase base class
void SaveIpv4AddressAndIdentifier(Ptr< Node > utUserNode)
Save the IPv4 address and the proper identifier from the given UT user node.
Produce return feeder link device-level throughput statistics from a satellite module simulation.
SatStatsRtnFeederDevThroughputHelper(Ptr< const SatHelper > satHelper)
static TypeId GetTypeId()
inherited from ObjectBase base class
Produce return feeder link MAC-level throughput statistics from a satellite module simulation.
SatStatsRtnFeederMacThroughputHelper(Ptr< const SatHelper > satHelper)
static TypeId GetTypeId()
inherited from ObjectBase base class
Produce return feeder link PHY-level throughput statistics from a satellite module simulation.
static TypeId GetTypeId()
inherited from ObjectBase base class
SatStatsRtnFeederPhyThroughputHelper(Ptr< const SatHelper > satHelper)
Produce return user link device-level throughput statistics from a satellite module simulation.
static TypeId GetTypeId()
inherited from ObjectBase base class
SatStatsRtnUserDevThroughputHelper(Ptr< const SatHelper > satHelper)
Produce return user link MAC-level throughput statistics from a satellite module simulation.
SatStatsRtnUserMacThroughputHelper(Ptr< const SatHelper > satHelper)
static TypeId GetTypeId()
inherited from ObjectBase base class
Produce return user link PHY-level throughput statistics from a satellite module simulation.
static TypeId GetTypeId()
inherited from ObjectBase base class
SatStatsRtnUserPhyThroughputHelper(Ptr< const SatHelper > satHelper)
CollectorMap m_conversionCollectors
Maintains a list of first-level collectors created by this helper.
void InstallProbes()
Set up several probes or other means of listeners and connect them to the first-level collectors.
Ptr< DistributionCollector > m_averagingCollector
The final collector utilized in averaged output (histogram, PDF, and CDF).
void RxCallback(Ptr< const Packet > packet, const Address &from)
Receive inputs from trace sources and determine the right collector to forward the inputs to.
Ptr< DataCollectionObject > m_aggregator
The aggregator created by this helper.
static TypeId GetTypeId()
inherited from ObjectBase base class
virtual void DoInstallProbes()=0
CollectorMap m_terminalCollectors
Maintains a list of second-level collectors created by this helper.
SatStatsThroughputHelper(Ptr< const SatHelper > satHelper)
void DoInstall()
Install the probes, collectors, and aggregators necessary to produce the statistics output.
SatArqSequenceNumber is handling the sequence numbers for the ARQ process.