Loading...
Searching...
No Matches
satellite-stats-packet-error-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
25
26#include "ns3/boolean.h"
27#include "ns3/callback.h"
28#include "ns3/data-collection-object.h"
29#include "ns3/enum.h"
30#include "ns3/interval-rate-collector.h"
31#include "ns3/log.h"
32#include "ns3/mac48-address.h"
33#include "ns3/magister-gnuplot-aggregator.h"
34#include "ns3/multi-file-aggregator.h"
35#include "ns3/node-container.h"
36#include "ns3/object-vector.h"
37#include "ns3/satellite-helper.h"
38#include "ns3/satellite-id-mapper.h"
39#include "ns3/satellite-net-device.h"
40#include "ns3/satellite-orbiter-net-device.h"
41#include "ns3/satellite-phy-rx-carrier.h"
42#include "ns3/satellite-phy-rx.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
49#include <map>
50#include <sstream>
51#include <string>
52#include <utility>
53
54NS_LOG_COMPONENT_DEFINE("SatStatsPacketErrorHelper");
55
56namespace ns3
57{
58
59// BASE CLASS /////////////////////////////////////////////////////////////////
60
61NS_OBJECT_ENSURE_REGISTERED(SatStatsPacketErrorHelper);
62
64 : SatStatsHelper(satHelper),
66 m_channelType(SatEnums::UNKNOWN_CH)
67{
68 NS_LOG_FUNCTION(this << satHelper);
69}
70
75
76TypeId // static
78{
79 static TypeId tid = TypeId("ns3::SatStatsPacketErrorHelper").SetParent<SatStatsHelper>();
80 return tid;
81}
82
83void
85{
86 NS_LOG_FUNCTION(this << traceSourceName);
87 m_traceSourceName = traceSourceName;
88}
89
90std::string
95
96void
98{
99 NS_LOG_FUNCTION(this << SatEnums::GetChannelTypeName(channelType));
100 m_channelType = channelType;
101}
102
108
109void
111{
112 NS_LOG_FUNCTION(this);
113
114 switch (GetOutputType())
115 {
117 NS_FATAL_ERROR(GetOutputTypeName(GetOutputType())
118 << " is not a valid output type for this statistics.");
119 break;
120
122 // Setup aggregator.
123 m_aggregator = CreateAggregator("ns3::MultiFileAggregator",
124 "OutputFileName",
125 StringValue(GetOutputFileName()),
126 "MultiFileMode",
127 BooleanValue(false),
128 "EnableContextPrinting",
129 BooleanValue(true),
130 "GeneralHeading",
131 StringValue(GetIdentifierHeading("error_rate")));
132
133 // Setup collectors.
134 m_terminalCollectors.SetType("ns3::ScalarCollector");
135 m_terminalCollectors.SetAttribute("InputDataType",
136 EnumValue(ScalarCollector::INPUT_DATA_TYPE_BOOLEAN));
137 m_terminalCollectors.SetAttribute(
138 "OutputType",
139 EnumValue(ScalarCollector::OUTPUT_TYPE_AVERAGE_PER_SAMPLE));
141 m_terminalCollectors.ConnectToAggregator("Output",
143 &MultiFileAggregator::Write1d);
144 break;
145 }
146
148 // Setup aggregator.
149 m_aggregator = CreateAggregator("ns3::MultiFileAggregator",
150 "OutputFileName",
151 StringValue(GetOutputFileName()),
152 "GeneralHeading",
153 StringValue(GetTimeHeading("error_rate")));
154
155 // Setup collectors.
156 m_terminalCollectors.SetType("ns3::IntervalRateCollector");
157 m_terminalCollectors.SetAttribute(
158 "InputDataType",
159 EnumValue(IntervalRateCollector::INPUT_DATA_TYPE_BOOLEAN));
160 m_terminalCollectors.SetAttribute(
161 "OutputType",
162 EnumValue(IntervalRateCollector::OUTPUT_TYPE_AVERAGE_PER_SAMPLE));
164 m_terminalCollectors.ConnectToAggregator("OutputWithTime",
166 &MultiFileAggregator::Write2d);
167 m_terminalCollectors.ConnectToAggregator("OutputString",
169 &MultiFileAggregator::AddContextHeading);
170 break;
171 }
172
176 NS_FATAL_ERROR(GetOutputTypeName(GetOutputType())
177 << " is not a valid output type for this statistics.");
178 break;
179
182 NS_FATAL_ERROR(GetOutputTypeName(GetOutputType())
183 << " is not a valid output type for this statistics.");
184 break;
185
187 // Setup aggregator.
188 m_aggregator = CreateAggregator("ns3::MagisterGnuplotAggregator",
189 "OutputPath",
190 StringValue(GetOutputPath()),
191 "OutputFileName",
192 StringValue(GetName()));
193 Ptr<MagisterGnuplotAggregator> plotAggregator =
194 m_aggregator->GetObject<MagisterGnuplotAggregator>();
195 NS_ASSERT(plotAggregator != nullptr);
196 // plot->SetTitle ("");
197 plotAggregator->SetLegend("Time (in seconds)", "Packet error rate");
198 plotAggregator->Set2dDatasetDefaultStyle(Gnuplot2dDataset::LINES);
199
200 // Setup collectors.
201 m_terminalCollectors.SetType("ns3::IntervalRateCollector");
202 m_terminalCollectors.SetAttribute(
203 "InputDataType",
204 EnumValue(IntervalRateCollector::INPUT_DATA_TYPE_BOOLEAN));
205 m_terminalCollectors.SetAttribute(
206 "OutputType",
207 EnumValue(IntervalRateCollector::OUTPUT_TYPE_AVERAGE_PER_SAMPLE));
209 for (CollectorMap::Iterator it = m_terminalCollectors.Begin();
210 it != m_terminalCollectors.End();
211 ++it)
212 {
213 const std::string context = it->second->GetName();
214 plotAggregator->Add2dDataset(context, context);
215 }
216 m_terminalCollectors.ConnectToAggregator("OutputWithTime",
218 &MagisterGnuplotAggregator::Write2d);
219 break;
220 }
221
225 NS_FATAL_ERROR(GetOutputTypeName(GetOutputType())
226 << " is not a valid output type for this statistics.");
227 break;
228
229 default:
230 NS_FATAL_ERROR("SatStatsPacketErrorHelper - Invalid output type");
231 break;
232 }
233
234 switch (m_channelType)
235 {
237 // Connect to trace sources at UT nodes.
238 NodeContainer uts = Singleton<SatTopology>::Get()->GetUtNodes();
239 for (NodeContainer::Iterator it = uts.Begin(); it != uts.End(); ++it)
240 {
241 InstallProbeOnUt(*it);
242 }
243
244 break;
245 }
246
248 // Create a map of UT addresses and identifiers.
249 NodeContainer uts = Singleton<SatTopology>::Get()->GetUtNodes();
250 for (NodeContainer::Iterator it = uts.Begin(); it != uts.End(); ++it)
251 {
253 }
254
255 // Connect to trace sources at SAT nodes.
256 NodeContainer sats = Singleton<SatTopology>::Get()->GetOrbiterNodes();
257 for (NodeContainer::Iterator it = sats.Begin(); it != sats.End(); ++it)
258 {
260 }
261
262 break;
263 }
264
266 // Create a map of UT addresses and identifiers.
267 NodeContainer uts = Singleton<SatTopology>::Get()->GetUtNodes();
268 for (NodeContainer::Iterator it = uts.Begin(); it != uts.End(); ++it)
269 {
271 }
272
273 // Connect to trace sources at GW nodes.
274 NodeContainer gws = Singleton<SatTopology>::Get()->GetGwNodes();
275 for (NodeContainer::Iterator it = gws.Begin(); it != gws.End(); ++it)
276 {
277 InstallProbeOnGw(*it);
278 }
279
280 break;
281 }
282
284 // Create a map of UT addresses and identifiers.
285 NodeContainer uts = Singleton<SatTopology>::Get()->GetUtNodes();
286 for (NodeContainer::Iterator it = uts.Begin(); it != uts.End(); ++it)
287 {
289 }
290
291 // Connect to trace sources at SAT nodes.
292 NodeContainer sats = Singleton<SatTopology>::Get()->GetOrbiterNodes();
293 for (NodeContainer::Iterator it = sats.Begin(); it != sats.End(); ++it)
294 {
296 }
297
298 break;
299 }
300
301 default:
302 NS_FATAL_ERROR("SatStatsPacketErrorHelper - Invalid link");
303 break;
304 }
305
306} // end of `void DoInstall ();`
307
308void
309SatStatsPacketErrorHelper::ErrorRxCallback(uint32_t nPackets, const Address& fromOrTo, bool isError)
310{
311 NS_LOG_FUNCTION(this << nPackets << fromOrTo << isError);
312
313 if (fromOrTo.IsInvalid())
314 {
315 NS_LOG_WARN(this << " discarding " << nPackets << " packets"
316 << " from statistics collection because of"
317 << " invalid sender/destination address");
318 }
319 else if (Mac48Address::ConvertFrom(fromOrTo).IsBroadcast())
320 {
321 for (std::pair<const Address, uint32_t> item : m_identifierMap)
322 {
323 // Find the first-level collector with the right identifier.
324 Ptr<DataCollectionObject> collector = m_terminalCollectors.Get(item.second);
325 NS_ASSERT_MSG(collector != nullptr,
326 "Unable to find collector with identifier " << item.second);
327
328 switch (GetOutputType())
329 {
332 Ptr<ScalarCollector> c = collector->GetObject<ScalarCollector>();
333 NS_ASSERT(c != nullptr);
334 c->TraceSinkBoolean(false, isError);
335 break;
336 }
337
340 Ptr<IntervalRateCollector> c = collector->GetObject<IntervalRateCollector>();
341 NS_ASSERT(c != nullptr);
342 c->TraceSinkBoolean(false, isError);
343 break;
344 }
345
346 default:
347 NS_FATAL_ERROR(GetOutputTypeName(GetOutputType())
348 << " is not a valid output type for this statistics.");
349 break;
350
351 } // end of `switch (GetOutputType ())`
352 } // end of for (it == m_identifierMap.begin ())
353 }
354 else
355 {
356 // Determine the identifier associated with the sender address.
357 std::map<const Address, uint32_t>::const_iterator it = m_identifierMap.find(fromOrTo);
358
359 if (it == m_identifierMap.end())
360 {
361 NS_LOG_WARN(this << " discarding " << nPackets << " packets"
362 << " from statistics collection because of"
363 << " unknown sender/destination address " << fromOrTo);
364 }
365 else
366 {
367 // Find the first-level collector with the right identifier.
368 Ptr<DataCollectionObject> collector = m_terminalCollectors.Get(it->second);
369 NS_ASSERT_MSG(collector != nullptr,
370 "Unable to find collector with identifier " << it->second);
371
372 switch (GetOutputType())
373 {
376 Ptr<ScalarCollector> c = collector->GetObject<ScalarCollector>();
377 NS_ASSERT(c != nullptr);
378 c->TraceSinkBoolean(false, isError);
379 break;
380 }
381
384 Ptr<IntervalRateCollector> c = collector->GetObject<IntervalRateCollector>();
385 NS_ASSERT(c != nullptr);
386 c->TraceSinkBoolean(false, isError);
387 break;
388 }
389
390 default:
391 NS_FATAL_ERROR(GetOutputTypeName(GetOutputType())
392 << " is not a valid output type for this statistics.");
393 break;
394
395 } // end of `switch (GetOutputType ())`
396
397 } // end of else of `if (it == m_identifierMap.end ())`
398
399 } // end of else of `if (from.IsInvalid ())`
400
401} // end of `void ErrorRxCallback (uint32_t, const Address &, bool);`
402
403bool
404SatStatsPacketErrorHelper::ConnectProbeToCollector(Ptr<Probe> probe, uint32_t identifier)
405{
406 NS_LOG_FUNCTION(this << probe << probe->GetName() << identifier);
407
408 // Connect the probe to the right collector.
409 bool ret = false;
410 switch (GetOutputType())
411 {
414 ret = m_terminalCollectors.ConnectWithProbe(probe->GetObject<Probe>(),
415 "OutputBool",
416 identifier,
417 &ScalarCollector::TraceSinkBoolean);
418 break;
419
422 ret = m_terminalCollectors.ConnectWithProbe(probe->GetObject<Probe>(),
423 "OutputBool",
424 identifier,
425 &IntervalRateCollector::TraceSinkBoolean);
426 break;
427
428 default:
429 NS_FATAL_ERROR(GetOutputTypeName(GetOutputType())
430 << " is not a valid output type for this statistics.");
431 break;
432
433 } // end of `switch (GetOutputType ())`
434
435 if (ret)
436 {
437 NS_LOG_INFO(this << " created probe " << probe->GetName() << ", connected to collector "
438 << identifier);
439 }
440 else
441 {
442 NS_LOG_WARN(this << " unable to connect probe " << probe->GetName() << " to collector "
443 << identifier);
444 }
445
446 return ret;
447}
448
449bool
451{
452 NS_LOG_FUNCTION(this << probe << probe->GetName() << identifier);
453
454 // Connect the probe to the right collector.
455 bool ret = false;
456 switch (GetOutputType())
457 {
460 ret = m_terminalCollectors.DisconnectWithProbe(probe->GetObject<Probe>(),
461 "OutputBool",
462 identifier,
463 &ScalarCollector::TraceSinkBoolean);
464 break;
465
468 ret = m_terminalCollectors.DisconnectWithProbe(probe->GetObject<Probe>(),
469 "OutputBool",
470 identifier,
471 &IntervalRateCollector::TraceSinkBoolean);
472 break;
473
474 default:
475 NS_FATAL_ERROR(GetOutputTypeName(GetOutputType())
476 << " is not a valid output type for this statistics.");
477 break;
478
479 } // end of `switch (GetOutputType ())`
480
481 if (ret)
482 {
483 NS_LOG_INFO(this << " probe " << probe->GetName() << ", disconnected from collector "
484 << identifier);
485 }
486 else
487 {
488 NS_LOG_WARN(this << " unable to disconnect probe " << probe->GetName() << " from collector "
489 << identifier);
490 }
491
492 return ret;
493}
494
495void
497{
498 NS_LOG_FUNCTION(this);
499
500 std::map<Ptr<Probe>, std::pair<Ptr<Node>, uint32_t>>::iterator it;
501
502 for (it = m_probes.begin(); it != m_probes.end(); it++)
503 {
504 Ptr<Probe> probe = it->first;
505 Ptr<Node> node = it->second.first;
506 uint32_t identifier = it->second.second;
507
508 if (!DisconnectProbeFromCollector(probe, identifier))
509 {
510 NS_FATAL_ERROR("Error disconnecting trace file on handover");
511 }
512
513 identifier = GetIdentifierForUtUser(node);
514
515 if (!ConnectProbeToCollector(probe, identifier))
516 {
517 NS_FATAL_ERROR("Error connecting trace file on handover");
518 }
519
520 it->second.second = identifier;
521 }
522} // end of `void UpdateIdentifierOnProbes ();`
523
524void
526{
527 NS_LOG_FUNCTION(this << gwNode->GetId());
528
529 NetDeviceContainer devs = GetGwSatNetDevice(gwNode);
530 Callback<void, uint32_t, const Address&, bool> callback =
532
533 for (NetDeviceContainer::Iterator itDev = devs.Begin(); itDev != devs.End(); ++itDev)
534 {
535 Ptr<SatNetDevice> satDev = (*itDev)->GetObject<SatNetDevice>();
536 NS_ASSERT(satDev != nullptr);
537 Ptr<SatPhy> satPhy = satDev->GetPhy();
538 NS_ASSERT(satPhy != nullptr);
539 Ptr<SatPhyRx> satPhyRx = satPhy->GetPhyRx();
540 NS_ASSERT(satPhyRx != nullptr);
541 ObjectVectorValue carriers;
542 satPhyRx->GetAttribute("RxCarrierList", carriers);
543 NS_LOG_DEBUG(this << " Node ID " << gwNode->GetId() << " device #" << (*itDev)->GetIfIndex()
544 << " has " << carriers.GetN() << " RX carriers");
545
546 for (ObjectVectorValue::Iterator itCarrier = carriers.Begin(); itCarrier != carriers.End();
547 ++itCarrier)
548 {
549 if (DynamicCast<SatPhyRxCarrier>(itCarrier->second)->GetCarrierType() !=
551 {
552 continue;
553 }
554 const bool ret =
555 itCarrier->second->TraceConnectWithoutContext(GetTraceSourceName(), callback);
556 if (ret)
557 {
558 NS_LOG_INFO(this << " successfully connected with node ID " << gwNode->GetId()
559 << " device #" << (*itDev)->GetIfIndex() << " RX carrier #"
560 << itCarrier->first);
561 }
562 else
563 {
564 NS_FATAL_ERROR("Error connecting to "
565 << GetTraceSourceName() << " trace source" << " of SatPhyRxCarrier"
566 << " at node ID " << gwNode->GetId() << " device #"
567 << (*itDev)->GetIfIndex() << " RX carrier #" << itCarrier->first);
568 }
569
570 } // end of `for (ObjectVectorValue::Iterator itCarrier = carriers)`
571
572 } // end of `for (NetDeviceContainer::Iterator itDev = devs)`
573
574} // end of `void InstallProbeOnGw (Ptr<Node>)`
575
576void
578{
579 NS_LOG_FUNCTION(this << satNode->GetId());
580
581 Ptr<NetDevice> dev = GetSatSatOrbiterNetDevice(satNode);
582 Callback<void, uint32_t, const Address&, bool> callback =
584
585 Ptr<SatPhy> satPhy;
586 Ptr<SatOrbiterNetDevice> satOrbiterDev = dev->GetObject<SatOrbiterNetDevice>();
587 NS_ASSERT(satOrbiterDev != nullptr);
588 std::map<uint32_t, Ptr<SatPhy>> satOrbiterFeederPhys = satOrbiterDev->GetFeederPhy();
589 for (std::map<uint32_t, Ptr<SatPhy>>::iterator itPhy = satOrbiterFeederPhys.begin();
590 itPhy != satOrbiterFeederPhys.end();
591 ++itPhy)
592 {
593 satPhy = itPhy->second;
594 NS_ASSERT(satPhy != nullptr);
595 Ptr<SatPhyRx> satPhyRx = satPhy->GetPhyRx();
596 NS_ASSERT(satPhyRx != nullptr);
597
598 ObjectVectorValue carriers;
599 satPhyRx->GetAttribute("RxCarrierList", carriers);
600 NS_LOG_DEBUG(this << " Node ID " << satNode->GetId() << " device #" << dev->GetIfIndex()
601 << " has " << carriers.GetN() << " RX carriers");
602
603 for (ObjectVectorValue::Iterator itCarrier = carriers.Begin(); itCarrier != carriers.End();
604 ++itCarrier)
605 {
606 if (DynamicCast<SatPhyRxCarrier>(itCarrier->second)->GetCarrierType() !=
608 {
609 continue;
610 }
611 const bool ret =
612 itCarrier->second->TraceConnectWithoutContext(GetTraceSourceName(), callback);
613 if (ret)
614 {
615 NS_LOG_INFO(this << " successfully connected with node ID " << satNode->GetId()
616 << " device #" << dev->GetIfIndex() << " RX carrier #"
617 << itCarrier->first);
618 }
619 else
620 {
621 NS_FATAL_ERROR("Error connecting to "
622 << GetTraceSourceName() << " trace source" << " of SatPhyRxCarrier"
623 << " at node ID " << satNode->GetId() << " device #"
624 << dev->GetIfIndex() << " RX carrier #" << itCarrier->first);
625 }
626
627 } // end of `for (ObjectVectorValue::Iterator itCarrier = carriers)`
628
629 } // end of `for (std::map<uint32_t, Ptr<SatPhy>>::iterator itPhy = satOrbiterFeederPhys)`
630
631} // end of `void InstallProbeOnSatFeeder (Ptr<Node>)`
632
633void
635{
636 NS_LOG_FUNCTION(this << satNode->GetId());
637
638 Ptr<NetDevice> dev = GetSatSatOrbiterNetDevice(satNode);
639 Callback<void, uint32_t, const Address&, bool> callback =
641
642 Ptr<SatPhy> satPhy;
643 Ptr<SatOrbiterNetDevice> satOrbiterDev = dev->GetObject<SatOrbiterNetDevice>();
644 NS_ASSERT(satOrbiterDev != nullptr);
645 std::map<uint32_t, Ptr<SatPhy>> satOrbiterUserPhys = satOrbiterDev->GetUserPhy();
646 for (std::map<uint32_t, Ptr<SatPhy>>::iterator itPhy = satOrbiterUserPhys.begin();
647 itPhy != satOrbiterUserPhys.end();
648 ++itPhy)
649 {
650 satPhy = itPhy->second;
651 NS_ASSERT(satPhy != nullptr);
652 Ptr<SatPhyRx> satPhyRx = satPhy->GetPhyRx();
653 NS_ASSERT(satPhyRx != nullptr);
654
655 ObjectVectorValue carriers;
656 satPhyRx->GetAttribute("RxCarrierList", carriers);
657 NS_LOG_DEBUG(this << " Node ID " << satNode->GetId() << " device #" << dev->GetIfIndex()
658 << " has " << carriers.GetN() << " RX carriers");
659
660 for (ObjectVectorValue::Iterator itCarrier = carriers.Begin(); itCarrier != carriers.End();
661 ++itCarrier)
662 {
663 if (DynamicCast<SatPhyRxCarrier>(itCarrier->second)->GetCarrierType() !=
665 {
666 continue;
667 }
668 const bool ret =
669 itCarrier->second->TraceConnectWithoutContext(GetTraceSourceName(), callback);
670 if (ret)
671 {
672 NS_LOG_INFO(this << " successfully connected with node ID " << satNode->GetId()
673 << " device #" << dev->GetIfIndex() << " RX carrier #"
674 << itCarrier->first);
675 }
676 else
677 {
678 NS_FATAL_ERROR("Error connecting to "
679 << GetTraceSourceName() << " trace source" << " of SatPhyRxCarrier"
680 << " at node ID " << satNode->GetId() << " device #"
681 << dev->GetIfIndex() << " RX carrier #" << itCarrier->first);
682 }
683
684 } // end of `for (ObjectVectorValue::Iterator itCarrier = carriers)`
685
686 } // end of `for (std::map<uint32_t, Ptr<SatPhy>>::iterator itPhy = satOrbiterUserPhys)`
687
688} // end of `void InstallProbeOnSatUser (Ptr<Node>)`
689
690void
692{
693 NS_LOG_FUNCTION(this << utNode->GetId());
694
695 const int32_t utId = GetUtId(utNode);
696 NS_ASSERT_MSG(utId > 0, "Node " << utNode->GetId() << " is not a valid UT");
697 const uint32_t identifier = GetIdentifierForUt(utNode);
698
699 // Create the probe.
700 std::ostringstream probeName;
701 probeName << utId;
702 Ptr<SatPhyRxCarrierPacketProbe> probe = CreateObject<SatPhyRxCarrierPacketProbe>();
703 probe->SetName(probeName.str());
704
705 Ptr<NetDevice> dev = GetUtSatNetDevice(utNode);
706 Ptr<SatNetDevice> satDev = dev->GetObject<SatNetDevice>();
707 NS_ASSERT(satDev != nullptr);
708 Ptr<SatPhy> satPhy = satDev->GetPhy();
709 NS_ASSERT(satPhy != nullptr);
710 Ptr<SatPhyRx> satPhyRx = satPhy->GetPhyRx();
711 NS_ASSERT(satPhyRx != nullptr);
712 ObjectVectorValue carriers;
713 satPhyRx->GetAttribute("RxCarrierList", carriers);
714 NS_LOG_DEBUG(this << " Node ID " << utNode->GetId() << " device #" << dev->GetIfIndex()
715 << " has " << carriers.GetN() << " RX carriers");
716
717 for (ObjectVectorValue::Iterator itCarrier = carriers.Begin(); itCarrier != carriers.End();
718 ++itCarrier)
719 {
720 if (DynamicCast<SatPhyRxCarrier>(itCarrier->second)->GetCarrierType() !=
722 {
723 continue;
724 }
725 // Connect the object to the probe.
726 if (probe->ConnectByObject(GetTraceSourceName(), itCarrier->second) &&
727 ConnectProbeToCollector(probe, identifier))
728 {
729 m_probes.insert(
730 std::make_pair(probe->GetObject<Probe>(), std::make_pair(utNode, identifier)));
731
732 } // end of `if (probe->ConnectByObject (GetTraceSourceName (), itCarrier->second))`
733 else
734 {
735 NS_FATAL_ERROR("Error connecting to "
736 << GetTraceSourceName() << " trace source" << " of SatPhyRxCarrier"
737 << " at node ID " << utNode->GetId() << " device #" << dev->GetIfIndex()
738 << " RX carrier #" << itCarrier->first);
739 }
740
741 } // end of `for (ObjectVectorValue::Iterator itCarrier = carriers)`
742
743} // end of `void InstallProbeOnUt (Ptr<Node>)`
744
745// FORWARD FEEDER LINK DEDICATED ACCESS //////////////////////////////////////////////
746
747NS_OBJECT_ENSURE_REGISTERED(SatStatsFwdFeederDaPacketErrorHelper);
748
758
763
764TypeId // static
766{
767 static TypeId tid =
768 TypeId("ns3::SatStatsFwdFeederDaPacketErrorHelper").SetParent<SatStatsPacketErrorHelper>();
769 return tid;
770}
771
772// FORWARD USER LINK DEDICATED ACCESS //////////////////////////////////////////////
773
774NS_OBJECT_ENSURE_REGISTERED(SatStatsFwdUserDaPacketErrorHelper);
775
785
790
791TypeId // static
793{
794 static TypeId tid =
795 TypeId("ns3::SatStatsFwdUserDaPacketErrorHelper").SetParent<SatStatsPacketErrorHelper>();
796 return tid;
797}
798
799// RETURN FEEDER LINK DEDICATED ACCESS ///////////////////////////////////////////////
800
801NS_OBJECT_ENSURE_REGISTERED(SatStatsRtnFeederDaPacketErrorHelper);
802
812
817
818TypeId // static
820{
821 static TypeId tid =
822 TypeId("ns3::SatStatsRtnFeederDaPacketErrorHelper").SetParent<SatStatsPacketErrorHelper>();
823 return tid;
824}
825
826// RETURN USER LINK DEDICATED ACCESS ///////////////////////////////////////////////
827
828NS_OBJECT_ENSURE_REGISTERED(SatStatsRtnUserDaPacketErrorHelper);
829
839
844
845TypeId // static
847{
848 static TypeId tid =
849 TypeId("ns3::SatStatsRtnUserDaPacketErrorHelper").SetParent<SatStatsPacketErrorHelper>();
850 return tid;
851}
852
853// FEEDER SLOTTED ALOHA //////////////////////////////////////////////////////////////
854
855NS_OBJECT_ENSURE_REGISTERED(SatStatsFeederSlottedAlohaPacketErrorHelper);
856
866
871
872TypeId // static
874{
875 static TypeId tid = TypeId("ns3::SatStatsFeederSlottedAlohaPacketErrorHelper")
876 .SetParent<SatStatsPacketErrorHelper>();
877 return tid;
878}
879
880// USER SLOTTED ALOHA //////////////////////////////////////////////////////////////
881
882NS_OBJECT_ENSURE_REGISTERED(SatStatsUserSlottedAlohaPacketErrorHelper);
883
885 Ptr<const SatHelper> satHelper)
886 : SatStatsPacketErrorHelper(satHelper)
887{
888 NS_LOG_FUNCTION(this << satHelper);
889 SetTraceSourceName("SlottedAlohaRxError");
892}
893
898
899TypeId // static
901{
902 static TypeId tid = TypeId("ns3::SatStatsUserSlottedAlohaPacketErrorHelper")
903 .SetParent<SatStatsPacketErrorHelper>();
904 return tid;
905}
906
907// FEEDER CRDSA //////////////////////////////////////////////////////////////////////
908
909NS_OBJECT_ENSURE_REGISTERED(SatStatsFeederCrdsaPacketErrorHelper);
910
912 Ptr<const SatHelper> satHelper)
913 : SatStatsPacketErrorHelper(satHelper)
914{
915 NS_LOG_FUNCTION(this << satHelper);
916 SetTraceSourceName("CrdsaUniquePayloadRx");
919}
920
925
926TypeId // static
928{
929 static TypeId tid =
930 TypeId("ns3::SatStatsFeederCrdsaPacketErrorHelper").SetParent<SatStatsPacketErrorHelper>();
931 return tid;
932}
933
934// USER CRDSA //////////////////////////////////////////////////////////////////////
935
936NS_OBJECT_ENSURE_REGISTERED(SatStatsUserCrdsaPacketErrorHelper);
937
939 Ptr<const SatHelper> satHelper)
940 : SatStatsPacketErrorHelper(satHelper)
941{
942 NS_LOG_FUNCTION(this << satHelper);
943 SetTraceSourceName("CrdsaUniquePayloadRx");
946}
947
952
953TypeId // static
955{
956 static TypeId tid =
957 TypeId("ns3::SatStatsUserCrdsaPacketErrorHelper").SetParent<SatStatsPacketErrorHelper>();
958 return tid;
959}
960
961// FEEDER E-SSA //////////////////////////////////////////////////////////////////////
962
963NS_OBJECT_ENSURE_REGISTERED(SatStatsFeederEssaPacketErrorHelper);
964
966 Ptr<const SatHelper> satHelper)
967 : SatStatsPacketErrorHelper(satHelper)
968{
969 NS_LOG_FUNCTION(this << satHelper);
970 SetTraceSourceName("EssaRxError");
973}
974
979
980TypeId // static
982{
983 static TypeId tid =
984 TypeId("ns3::SatStatsFeederEssaPacketErrorHelper").SetParent<SatStatsPacketErrorHelper>();
985 return tid;
986}
987
988// USER E-SSA //////////////////////////////////////////////////////////////////////
989
990NS_OBJECT_ENSURE_REGISTERED(SatStatsUserEssaPacketErrorHelper);
991
993 : SatStatsPacketErrorHelper(satHelper)
994{
995 NS_LOG_FUNCTION(this << satHelper);
996 SetTraceSourceName("EssaRxError");
999}
1000
1005
1006TypeId // static
1008{
1009 static TypeId tid =
1010 TypeId("ns3::SatStatsUserEssaPacketErrorHelper").SetParent<SatStatsPacketErrorHelper>();
1011 return tid;
1012}
1013
1014} // end of namespace ns3
SatEnums class is for simplifying the use of enumerators in the satellite module.
ChannelType_t
Types of channel.
static std::string GetChannelTypeName(ChannelType_t channelType)
SatNetDevice to be utilized in the UT and GW nodes.
SatOrbiterNetDevice to be utilized in geostationary satellite.
Produce packet error statistics of Random Access CRDSA on feeder link from a satellite module simulat...
SatStatsFeederCrdsaPacketErrorHelper(Ptr< const SatHelper > satHelper)
static TypeId GetTypeId()
inherited from ObjectBase base class
Produce packet error statistics of Random Access E-SSA on feeder link from a satellite module simulat...
static TypeId GetTypeId()
inherited from ObjectBase base class
SatStatsFeederEssaPacketErrorHelper(Ptr< const SatHelper > satHelper)
Produce packet error statistics of Random Access Slotted ALOHA on feeder link from a satellite module...
static TypeId GetTypeId()
inherited from ObjectBase base class
Produce packet error statistics of Dedicated Access in forward feeder link from a satellite module si...
SatStatsFwdFeederDaPacketErrorHelper(Ptr< const SatHelper > satHelper)
static TypeId GetTypeId()
inherited from ObjectBase base class
Produce packet error statistics of Dedicated Access in forward user link from a satellite module simu...
SatStatsFwdUserDaPacketErrorHelper(Ptr< const SatHelper > satHelper)
static TypeId GetTypeId()
inherited from ObjectBase base class
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.
std::string GetName() const
virtual std::string GetTimeHeading(std::string dataLabel) const
Base class for packet error statistics helpers.
static TypeId GetTypeId()
inherited from ObjectBase base class
void DoInstall()
Install the probes, collectors, and aggregators necessary to produce the statistics output.
std::string m_traceSourceName
Name of trace source of PHY RX carrier to listen to.
virtual void UpdateIdentifierOnProbes()
Change identifier used on probes, when handovers occur.
void InstallProbeOnGw(Ptr< Node > gwNode)
Set up several listeners on a GW node and connect them to the collectors.
std::map< Ptr< Probe >, std::pair< Ptr< Node >, uint32_t > > m_probes
Maintains a list of probes created by this helper (for forward link).
Ptr< DataCollectionObject > m_aggregator
The aggregator created by this helper.
SatPhyRxCarrier::CarrierType GetValidCarrierType() const
Get the valid carrier type.
bool DisconnectProbeFromCollector(Ptr< Probe > probe, uint32_t identifier)
Disconnect the probe from the right collector.
SatStatsPacketErrorHelper(Ptr< const SatHelper > satHelper)
CollectorMap m_terminalCollectors
Maintains a list of collectors created by this helper.
void InstallProbeOnUt(Ptr< Node > utNode)
Set up several probes on a UT node and connect them to the collectors.
SatEnums::ChannelType_t m_channelType
Link where statistics are gathered from.
void InstallProbeOnSatUser(Ptr< Node > satNode)
Set up several listeners on a SAT user node and connect them to the collectors.
void SetChannelType(SatEnums::ChannelType_t channelType)
bool ConnectProbeToCollector(Ptr< Probe > probe, uint32_t identifier)
Connect the probe to the right collector.
void SetValidCarrierType(SatPhyRxCarrier::CarrierType carrierType)
Set valid carrier type for this statistics helper type.
void SetTraceSourceName(std::string traceSourceName)
void ErrorRxCallback(uint32_t nPackets, const Address &fromOrTo, bool isError)
Receive inputs from trace sources and determine the right collector to forward the inputs to.
void InstallProbeOnSatFeeder(Ptr< Node > satNode)
Set up several listeners on a SAT feeder node and connect them to the collectors.
Produce packet error statistics of Dedicated Access in return feeder link from a satellite module sim...
static TypeId GetTypeId()
inherited from ObjectBase base class
SatStatsRtnFeederDaPacketErrorHelper(Ptr< const SatHelper > satHelper)
Produce packet error statistics of Dedicated Access in return user link from a satellite module simul...
SatStatsRtnUserDaPacketErrorHelper(Ptr< const SatHelper > satHelper)
static TypeId GetTypeId()
inherited from ObjectBase base class
Produce packet error statistics of Random Access CRDSA on user link from a satellite module simulatio...
SatStatsUserCrdsaPacketErrorHelper(Ptr< const SatHelper > satHelper)
static TypeId GetTypeId()
inherited from ObjectBase base class
Produce packet error statistics of Random Access E-SSA on user link from a satellite module simulatio...
static TypeId GetTypeId()
inherited from ObjectBase base class
SatStatsUserEssaPacketErrorHelper(Ptr< const SatHelper > satHelper)
Produce packet error statistics of Random Access Slotted ALOHA on user link from a satellite module s...
static TypeId GetTypeId()
inherited from ObjectBase base class
SatArqSequenceNumber is handling the sequence numbers for the ARQ process.