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 
24 #include <ns3/boolean.h>
25 #include <ns3/callback.h>
26 #include <ns3/data-collection-object.h>
27 #include <ns3/enum.h>
28 #include <ns3/interval-rate-collector.h>
29 #include <ns3/log.h>
30 #include <ns3/mac48-address.h>
31 #include <ns3/magister-gnuplot-aggregator.h>
32 #include <ns3/multi-file-aggregator.h>
33 #include <ns3/node-container.h>
34 #include <ns3/object-vector.h>
35 #include <ns3/satellite-geo-net-device.h>
36 #include <ns3/satellite-helper.h>
37 #include <ns3/satellite-id-mapper.h>
38 #include <ns3/satellite-net-device.h>
39 #include <ns3/satellite-phy-rx-carrier-packet-probe.h>
40 #include <ns3/satellite-phy-rx-carrier.h>
41 #include <ns3/satellite-phy-rx.h>
42 #include <ns3/satellite-phy.h>
43 #include <ns3/scalar-collector.h>
44 #include <ns3/singleton.h>
45 #include <ns3/string.h>
46 
47 #include <sstream>
48 
49 NS_LOG_COMPONENT_DEFINE("SatStatsPacketErrorHelper");
50 
51 namespace ns3
52 {
53 
54 // BASE CLASS /////////////////////////////////////////////////////////////////
55 
56 NS_OBJECT_ENSURE_REGISTERED(SatStatsPacketErrorHelper);
57 
59  : SatStatsHelper(satHelper),
60  m_traceSourceName(""),
61  m_channelType(SatEnums::UNKNOWN_CH)
62 {
63  NS_LOG_FUNCTION(this << satHelper);
64 }
65 
67 {
68  NS_LOG_FUNCTION(this);
69 }
70 
71 TypeId // static
73 {
74  static TypeId tid = TypeId("ns3::SatStatsPacketErrorHelper").SetParent<SatStatsHelper>();
75  return tid;
76 }
77 
78 void
80 {
81  NS_LOG_FUNCTION(this << traceSourceName);
82  m_traceSourceName = traceSourceName;
83 }
84 
85 std::string
87 {
88  return m_traceSourceName;
89 }
90 
91 void
93 {
94  NS_LOG_FUNCTION(this << SatEnums::GetChannelTypeName(channelType));
95  m_channelType = channelType;
96 }
97 
100 {
101  return m_channelType;
102 }
103 
104 void
106 {
107  NS_LOG_FUNCTION(this);
108 
109  switch (GetOutputType())
110  {
112  NS_FATAL_ERROR(GetOutputTypeName(GetOutputType())
113  << " is not a valid output type for this statistics.");
114  break;
115 
117  // Setup aggregator.
118  m_aggregator = CreateAggregator("ns3::MultiFileAggregator",
119  "OutputFileName",
120  StringValue(GetOutputFileName()),
121  "MultiFileMode",
122  BooleanValue(false),
123  "EnableContextPrinting",
124  BooleanValue(true),
125  "GeneralHeading",
126  StringValue(GetIdentifierHeading("error_rate")));
127 
128  // Setup collectors.
129  m_terminalCollectors.SetType("ns3::ScalarCollector");
130  m_terminalCollectors.SetAttribute("InputDataType",
131  EnumValue(ScalarCollector::INPUT_DATA_TYPE_BOOLEAN));
132  m_terminalCollectors.SetAttribute(
133  "OutputType",
134  EnumValue(ScalarCollector::OUTPUT_TYPE_AVERAGE_PER_SAMPLE));
136  m_terminalCollectors.ConnectToAggregator("Output",
137  m_aggregator,
138  &MultiFileAggregator::Write1d);
139  break;
140  }
141 
143  // Setup aggregator.
144  m_aggregator = CreateAggregator("ns3::MultiFileAggregator",
145  "OutputFileName",
146  StringValue(GetOutputFileName()),
147  "GeneralHeading",
148  StringValue(GetTimeHeading("error_rate")));
149 
150  // Setup collectors.
151  m_terminalCollectors.SetType("ns3::IntervalRateCollector");
152  m_terminalCollectors.SetAttribute(
153  "InputDataType",
154  EnumValue(IntervalRateCollector::INPUT_DATA_TYPE_BOOLEAN));
155  m_terminalCollectors.SetAttribute(
156  "OutputType",
157  EnumValue(IntervalRateCollector::OUTPUT_TYPE_AVERAGE_PER_SAMPLE));
159  m_terminalCollectors.ConnectToAggregator("OutputWithTime",
160  m_aggregator,
161  &MultiFileAggregator::Write2d);
162  m_terminalCollectors.ConnectToAggregator("OutputString",
163  m_aggregator,
164  &MultiFileAggregator::AddContextHeading);
165  break;
166  }
167 
171  NS_FATAL_ERROR(GetOutputTypeName(GetOutputType())
172  << " is not a valid output type for this statistics.");
173  break;
174 
177  NS_FATAL_ERROR(GetOutputTypeName(GetOutputType())
178  << " is not a valid output type for this statistics.");
179  break;
180 
182  // Setup aggregator.
183  m_aggregator = CreateAggregator("ns3::MagisterGnuplotAggregator",
184  "OutputPath",
185  StringValue(GetOutputPath()),
186  "OutputFileName",
187  StringValue(GetName()));
188  Ptr<MagisterGnuplotAggregator> plotAggregator =
189  m_aggregator->GetObject<MagisterGnuplotAggregator>();
190  NS_ASSERT(plotAggregator != nullptr);
191  // plot->SetTitle ("");
192  plotAggregator->SetLegend("Time (in seconds)", "Packet error rate");
193  plotAggregator->Set2dDatasetDefaultStyle(Gnuplot2dDataset::LINES);
194 
195  // Setup collectors.
196  m_terminalCollectors.SetType("ns3::IntervalRateCollector");
197  m_terminalCollectors.SetAttribute(
198  "InputDataType",
199  EnumValue(IntervalRateCollector::INPUT_DATA_TYPE_BOOLEAN));
200  m_terminalCollectors.SetAttribute(
201  "OutputType",
202  EnumValue(IntervalRateCollector::OUTPUT_TYPE_AVERAGE_PER_SAMPLE));
204  for (CollectorMap::Iterator it = m_terminalCollectors.Begin();
205  it != m_terminalCollectors.End();
206  ++it)
207  {
208  const std::string context = it->second->GetName();
209  plotAggregator->Add2dDataset(context, context);
210  }
211  m_terminalCollectors.ConnectToAggregator("OutputWithTime",
212  m_aggregator,
213  &MagisterGnuplotAggregator::Write2d);
214  break;
215  }
216 
220  NS_FATAL_ERROR(GetOutputTypeName(GetOutputType())
221  << " is not a valid output type for this statistics.");
222  break;
223 
224  default:
225  NS_FATAL_ERROR("SatStatsPacketErrorHelper - Invalid output type");
226  break;
227  }
228 
229  switch (m_channelType)
230  {
232  // Connect to trace sources at UT nodes.
233  NodeContainer uts = GetSatHelper()->GetBeamHelper()->GetUtNodes();
234  for (NodeContainer::Iterator it = uts.Begin(); it != uts.End(); ++it)
235  {
236  InstallProbeOnUt(*it);
237  }
238 
239  break;
240  }
241 
243  // Create a map of UT addresses and identifiers.
244  NodeContainer uts = GetSatHelper()->GetBeamHelper()->GetUtNodes();
245  for (NodeContainer::Iterator it = uts.Begin(); it != uts.End(); ++it)
246  {
248  }
249 
250  // Connect to trace sources at SAT nodes.
251  NodeContainer sats = GetSatHelper()->GetBeamHelper()->GetGeoSatNodes();
252  for (NodeContainer::Iterator it = sats.Begin(); it != sats.End(); ++it)
253  {
255  }
256 
257  break;
258  }
259 
261  // Create a map of UT addresses and identifiers.
262  NodeContainer uts = GetSatHelper()->GetBeamHelper()->GetUtNodes();
263  for (NodeContainer::Iterator it = uts.Begin(); it != uts.End(); ++it)
264  {
266  }
267 
268  // Connect to trace sources at GW nodes.
269  NodeContainer gws = GetSatHelper()->GetBeamHelper()->GetGwNodes();
270  for (NodeContainer::Iterator it = gws.Begin(); it != gws.End(); ++it)
271  {
272  InstallProbeOnGw(*it);
273  }
274 
275  break;
276  }
277 
279  // Create a map of UT addresses and identifiers.
280  NodeContainer uts = GetSatHelper()->GetBeamHelper()->GetUtNodes();
281  for (NodeContainer::Iterator it = uts.Begin(); it != uts.End(); ++it)
282  {
284  }
285 
286  // Connect to trace sources at SAT nodes.
287  NodeContainer sats = GetSatHelper()->GetBeamHelper()->GetGeoSatNodes();
288  for (NodeContainer::Iterator it = sats.Begin(); it != sats.End(); ++it)
289  {
291  }
292 
293  break;
294  }
295 
296  default:
297  NS_FATAL_ERROR("SatStatsPacketErrorHelper - Invalid link");
298  break;
299  }
300 
301 } // end of `void DoInstall ();`
302 
303 void
304 SatStatsPacketErrorHelper::ErrorRxCallback(uint32_t nPackets, const Address& fromOrTo, bool isError)
305 {
306  NS_LOG_FUNCTION(this << nPackets << fromOrTo << isError);
307 
308  if (fromOrTo.IsInvalid())
309  {
310  NS_LOG_WARN(this << " discarding " << nPackets << " packets"
311  << " from statistics collection because of"
312  << " invalid sender/destination address");
313  }
314  else if (Mac48Address::ConvertFrom(fromOrTo).IsBroadcast())
315  {
316  for (std::pair<const Address, uint32_t> item : m_identifierMap)
317  {
318  // Find the first-level collector with the right identifier.
319  Ptr<DataCollectionObject> collector = m_terminalCollectors.Get(item.second);
320  NS_ASSERT_MSG(collector != nullptr,
321  "Unable to find collector with identifier " << item.second);
322 
323  switch (GetOutputType())
324  {
327  Ptr<ScalarCollector> c = collector->GetObject<ScalarCollector>();
328  NS_ASSERT(c != nullptr);
329  c->TraceSinkBoolean(false, isError);
330  break;
331  }
332 
335  Ptr<IntervalRateCollector> c = collector->GetObject<IntervalRateCollector>();
336  NS_ASSERT(c != nullptr);
337  c->TraceSinkBoolean(false, isError);
338  break;
339  }
340 
341  default:
342  NS_FATAL_ERROR(GetOutputTypeName(GetOutputType())
343  << " is not a valid output type for this statistics.");
344  break;
345 
346  } // end of `switch (GetOutputType ())`
347  } // end of for (it == m_identifierMap.begin ())
348  }
349  else
350  {
351  // Determine the identifier associated with the sender address.
352  std::map<const Address, uint32_t>::const_iterator it = m_identifierMap.find(fromOrTo);
353 
354  if (it == m_identifierMap.end())
355  {
356  NS_LOG_WARN(this << " discarding " << nPackets << " packets"
357  << " from statistics collection because of"
358  << " unknown sender/destination address " << fromOrTo);
359  }
360  else
361  {
362  // Find the first-level collector with the right identifier.
363  Ptr<DataCollectionObject> collector = m_terminalCollectors.Get(it->second);
364  NS_ASSERT_MSG(collector != nullptr,
365  "Unable to find collector with identifier " << it->second);
366 
367  switch (GetOutputType())
368  {
371  Ptr<ScalarCollector> c = collector->GetObject<ScalarCollector>();
372  NS_ASSERT(c != nullptr);
373  c->TraceSinkBoolean(false, isError);
374  break;
375  }
376 
379  Ptr<IntervalRateCollector> c = collector->GetObject<IntervalRateCollector>();
380  NS_ASSERT(c != nullptr);
381  c->TraceSinkBoolean(false, isError);
382  break;
383  }
384 
385  default:
386  NS_FATAL_ERROR(GetOutputTypeName(GetOutputType())
387  << " is not a valid output type for this statistics.");
388  break;
389 
390  } // end of `switch (GetOutputType ())`
391 
392  } // end of else of `if (it == m_identifierMap.end ())`
393 
394  } // end of else of `if (from.IsInvalid ())`
395 
396 } // end of `void ErrorRxCallback (uint32_t, const Address &, bool);`
397 
398 void
400 {
401  NS_LOG_FUNCTION(this << utNode->GetId());
402 
403  const SatIdMapper* satIdMapper = Singleton<SatIdMapper>::Get();
404  const Address addr = satIdMapper->GetUtMacWithNode(utNode);
405 
406  if (addr.IsInvalid())
407  {
408  NS_LOG_WARN(this << " Node " << utNode->GetId() << " is not a valid UT");
409  }
410  else
411  {
412  const uint32_t identifier = GetIdentifierForUt(utNode);
413  m_identifierMap[addr] = identifier;
414  NS_LOG_INFO(this << " associated address " << addr << " with identifier " << identifier);
415  }
416 }
417 
418 void
420 {
421  NS_LOG_FUNCTION(this << gwNode->GetId());
422 
423  NetDeviceContainer devs = GetGwSatNetDevice(gwNode);
424  Callback<void, uint32_t, const Address&, bool> callback =
425  MakeCallback(&SatStatsPacketErrorHelper::ErrorRxCallback, this);
426 
427  for (NetDeviceContainer::Iterator itDev = devs.Begin(); itDev != devs.End(); ++itDev)
428  {
429  Ptr<SatNetDevice> satDev = (*itDev)->GetObject<SatNetDevice>();
430  NS_ASSERT(satDev != nullptr);
431  Ptr<SatPhy> satPhy = satDev->GetPhy();
432  NS_ASSERT(satPhy != nullptr);
433  Ptr<SatPhyRx> satPhyRx = satPhy->GetPhyRx();
434  NS_ASSERT(satPhyRx != nullptr);
435  ObjectVectorValue carriers;
436  satPhyRx->GetAttribute("RxCarrierList", carriers);
437  NS_LOG_DEBUG(this << " Node ID " << gwNode->GetId() << " device #" << (*itDev)->GetIfIndex()
438  << " has " << carriers.GetN() << " RX carriers");
439 
440  for (ObjectVectorValue::Iterator itCarrier = carriers.Begin(); itCarrier != carriers.End();
441  ++itCarrier)
442  {
443  if (DynamicCast<SatPhyRxCarrier>(itCarrier->second)->GetCarrierType() !=
445  {
446  continue;
447  }
448  const bool ret =
449  itCarrier->second->TraceConnectWithoutContext(GetTraceSourceName(), callback);
450  if (ret)
451  {
452  NS_LOG_INFO(this << " successfully connected with node ID " << gwNode->GetId()
453  << " device #" << (*itDev)->GetIfIndex() << " RX carrier #"
454  << itCarrier->first);
455  }
456  else
457  {
458  NS_FATAL_ERROR("Error connecting to " << GetTraceSourceName() << " trace source"
459  << " of SatPhyRxCarrier"
460  << " at node ID " << gwNode->GetId()
461  << " device #" << (*itDev)->GetIfIndex()
462  << " RX carrier #" << itCarrier->first);
463  }
464 
465  } // end of `for (ObjectVectorValue::Iterator itCarrier = carriers)`
466 
467  } // end of `for (NetDeviceContainer::Iterator itDev = devs)`
468 
469 } // end of `void InstallProbeOnGw (Ptr<Node>)`
470 
471 void
473 {
474  NS_LOG_FUNCTION(this << satNode->GetId());
475 
476  Ptr<NetDevice> dev = GetSatSatGeoNetDevice(satNode);
477  Callback<void, uint32_t, const Address&, bool> callback =
478  MakeCallback(&SatStatsPacketErrorHelper::ErrorRxCallback, this);
479 
480  Ptr<SatPhy> satPhy;
481  Ptr<SatGeoNetDevice> satGeoDev = dev->GetObject<SatGeoNetDevice>();
482  NS_ASSERT(satGeoDev != nullptr);
483  std::map<uint32_t, Ptr<SatPhy>> satGeoFeederPhys = satGeoDev->GetFeederPhy();
484  for (std::map<uint32_t, Ptr<SatPhy>>::iterator itPhy = satGeoFeederPhys.begin();
485  itPhy != satGeoFeederPhys.end();
486  ++itPhy)
487  {
488  satPhy = itPhy->second;
489  NS_ASSERT(satPhy != nullptr);
490  Ptr<SatPhyRx> satPhyRx = satPhy->GetPhyRx();
491  NS_ASSERT(satPhyRx != nullptr);
492 
493  ObjectVectorValue carriers;
494  satPhyRx->GetAttribute("RxCarrierList", carriers);
495  NS_LOG_DEBUG(this << " Node ID " << satNode->GetId() << " device #" << dev->GetIfIndex()
496  << " has " << carriers.GetN() << " RX carriers");
497 
498  for (ObjectVectorValue::Iterator itCarrier = carriers.Begin(); itCarrier != carriers.End();
499  ++itCarrier)
500  {
501  if (DynamicCast<SatPhyRxCarrier>(itCarrier->second)->GetCarrierType() !=
503  {
504  continue;
505  }
506  const bool ret =
507  itCarrier->second->TraceConnectWithoutContext(GetTraceSourceName(), callback);
508  if (ret)
509  {
510  NS_LOG_INFO(this << " successfully connected with node ID " << satNode->GetId()
511  << " device #" << dev->GetIfIndex() << " RX carrier #"
512  << itCarrier->first);
513  }
514  else
515  {
516  NS_FATAL_ERROR("Error connecting to " << GetTraceSourceName() << " trace source"
517  << " of SatPhyRxCarrier"
518  << " at node ID " << satNode->GetId()
519  << " device #" << dev->GetIfIndex()
520  << " RX carrier #" << itCarrier->first);
521  }
522 
523  } // end of `for (ObjectVectorValue::Iterator itCarrier = carriers)`
524 
525  } // end of `for (std::map<uint32_t, Ptr<SatPhy>>::iterator itPhy = satGeoFeederPhys)`
526 
527 } // end of `void InstallProbeOnSatFeeder (Ptr<Node>)`
528 
529 void
531 {
532  NS_LOG_FUNCTION(this << satNode->GetId());
533 
534  Ptr<NetDevice> dev = GetSatSatGeoNetDevice(satNode);
535  Callback<void, uint32_t, const Address&, bool> callback =
536  MakeCallback(&SatStatsPacketErrorHelper::ErrorRxCallback, this);
537 
538  Ptr<SatPhy> satPhy;
539  Ptr<SatGeoNetDevice> satGeoDev = dev->GetObject<SatGeoNetDevice>();
540  NS_ASSERT(satGeoDev != nullptr);
541  std::map<uint32_t, Ptr<SatPhy>> satGeoUserPhys = satGeoDev->GetUserPhy();
542  for (std::map<uint32_t, Ptr<SatPhy>>::iterator itPhy = satGeoUserPhys.begin();
543  itPhy != satGeoUserPhys.end();
544  ++itPhy)
545  {
546  satPhy = itPhy->second;
547  NS_ASSERT(satPhy != nullptr);
548  Ptr<SatPhyRx> satPhyRx = satPhy->GetPhyRx();
549  NS_ASSERT(satPhyRx != nullptr);
550 
551  ObjectVectorValue carriers;
552  satPhyRx->GetAttribute("RxCarrierList", carriers);
553  NS_LOG_DEBUG(this << " Node ID " << satNode->GetId() << " device #" << dev->GetIfIndex()
554  << " has " << carriers.GetN() << " RX carriers");
555 
556  for (ObjectVectorValue::Iterator itCarrier = carriers.Begin(); itCarrier != carriers.End();
557  ++itCarrier)
558  {
559  if (DynamicCast<SatPhyRxCarrier>(itCarrier->second)->GetCarrierType() !=
561  {
562  continue;
563  }
564  const bool ret =
565  itCarrier->second->TraceConnectWithoutContext(GetTraceSourceName(), callback);
566  if (ret)
567  {
568  NS_LOG_INFO(this << " successfully connected with node ID " << satNode->GetId()
569  << " device #" << dev->GetIfIndex() << " RX carrier #"
570  << itCarrier->first);
571  }
572  else
573  {
574  NS_FATAL_ERROR("Error connecting to " << GetTraceSourceName() << " trace source"
575  << " of SatPhyRxCarrier"
576  << " at node ID " << satNode->GetId()
577  << " device #" << dev->GetIfIndex()
578  << " RX carrier #" << itCarrier->first);
579  }
580 
581  } // end of `for (ObjectVectorValue::Iterator itCarrier = carriers)`
582 
583  } // end of `for (std::map<uint32_t, Ptr<SatPhy>>::iterator itPhy = satGeoUserPhys)`
584 
585 } // end of `void InstallProbeOnSatUser (Ptr<Node>)`
586 
587 void
589 {
590  NS_LOG_FUNCTION(this << utNode->GetId());
591 
592  const int32_t utId = GetUtId(utNode);
593  NS_ASSERT_MSG(utId > 0, "Node " << utNode->GetId() << " is not a valid UT");
594  const uint32_t identifier = GetIdentifierForUt(utNode);
595 
596  // Create the probe.
597  std::ostringstream probeName;
598  probeName << utId;
599  Ptr<SatPhyRxCarrierPacketProbe> probe = CreateObject<SatPhyRxCarrierPacketProbe>();
600  probe->SetName(probeName.str());
601 
602  Ptr<NetDevice> dev = GetUtSatNetDevice(utNode);
603  Ptr<SatNetDevice> satDev = dev->GetObject<SatNetDevice>();
604  NS_ASSERT(satDev != nullptr);
605  Ptr<SatPhy> satPhy = satDev->GetPhy();
606  NS_ASSERT(satPhy != nullptr);
607  Ptr<SatPhyRx> satPhyRx = satPhy->GetPhyRx();
608  NS_ASSERT(satPhyRx != nullptr);
609  ObjectVectorValue carriers;
610  satPhyRx->GetAttribute("RxCarrierList", carriers);
611  NS_LOG_DEBUG(this << " Node ID " << utNode->GetId() << " device #" << dev->GetIfIndex()
612  << " has " << carriers.GetN() << " RX carriers");
613 
614  for (ObjectVectorValue::Iterator itCarrier = carriers.Begin(); itCarrier != carriers.End();
615  ++itCarrier)
616  {
617  if (DynamicCast<SatPhyRxCarrier>(itCarrier->second)->GetCarrierType() !=
619  {
620  continue;
621  }
622  // Connect the object to the probe.
623  if (probe->ConnectByObject(GetTraceSourceName(), itCarrier->second))
624  {
625  // Connect the probe to the right collector.
626  bool ret = false;
627  switch (GetOutputType())
628  {
631  ret = m_terminalCollectors.ConnectWithProbe(probe->GetObject<Probe>(),
632  "OutputBool",
633  identifier,
634  &ScalarCollector::TraceSinkBoolean);
635  break;
636 
639  ret =
640  m_terminalCollectors.ConnectWithProbe(probe->GetObject<Probe>(),
641  "OutputBool",
642  identifier,
643  &IntervalRateCollector::TraceSinkBoolean);
644  break;
645 
646  default:
647  NS_FATAL_ERROR(GetOutputTypeName(GetOutputType())
648  << " is not a valid output type for this statistics.");
649  break;
650 
651  } // end of `switch (GetOutputType ())`
652 
653  if (ret)
654  {
655  NS_LOG_INFO(this << " created probe " << probeName.str()
656  << ", connected to collector " << identifier);
657  m_probes.push_back(probe->GetObject<Probe>());
658  }
659  else
660  {
661  NS_LOG_WARN(this << " unable to connect probe " << probeName.str()
662  << " to collector " << identifier);
663  }
664 
665  } // end of `if (probe->ConnectByObject (GetTraceSourceName (), itCarrier->second))`
666  else
667  {
668  NS_FATAL_ERROR("Error connecting to " << GetTraceSourceName() << " trace source"
669  << " of SatPhyRxCarrier"
670  << " at node ID " << utNode->GetId()
671  << " device #" << dev->GetIfIndex()
672  << " RX carrier #" << itCarrier->first);
673  }
674 
675  } // end of `for (ObjectVectorValue::Iterator itCarrier = carriers)`
676 
677 } // end of `void InstallProbeOnUt (Ptr<Node>)`
678 
679 // FORWARD FEEDER LINK DEDICATED ACCESS //////////////////////////////////////////////
680 
681 NS_OBJECT_ENSURE_REGISTERED(SatStatsFwdFeederDaPacketErrorHelper);
682 
684  Ptr<const SatHelper> satHelper)
685  : SatStatsPacketErrorHelper(satHelper)
686 {
687  NS_LOG_FUNCTION(this << satHelper);
688  SetTraceSourceName("DaRx");
691 }
692 
694 {
695  NS_LOG_FUNCTION(this);
696 }
697 
698 TypeId // static
700 {
701  static TypeId tid =
702  TypeId("ns3::SatStatsFwdFeederDaPacketErrorHelper").SetParent<SatStatsPacketErrorHelper>();
703  return tid;
704 }
705 
706 // FORWARD USER LINK DEDICATED ACCESS //////////////////////////////////////////////
707 
708 NS_OBJECT_ENSURE_REGISTERED(SatStatsFwdUserDaPacketErrorHelper);
709 
711  Ptr<const SatHelper> satHelper)
712  : SatStatsPacketErrorHelper(satHelper)
713 {
714  NS_LOG_FUNCTION(this << satHelper);
715  SetTraceSourceName("DaRx");
718 }
719 
721 {
722  NS_LOG_FUNCTION(this);
723 }
724 
725 TypeId // static
727 {
728  static TypeId tid =
729  TypeId("ns3::SatStatsFwdUserDaPacketErrorHelper").SetParent<SatStatsPacketErrorHelper>();
730  return tid;
731 }
732 
733 // RETURN FEEDER LINK DEDICATED ACCESS ///////////////////////////////////////////////
734 
735 NS_OBJECT_ENSURE_REGISTERED(SatStatsRtnFeederDaPacketErrorHelper);
736 
738  Ptr<const SatHelper> satHelper)
739  : SatStatsPacketErrorHelper(satHelper)
740 {
741  NS_LOG_FUNCTION(this << satHelper);
742  SetTraceSourceName("DaRx");
745 }
746 
748 {
749  NS_LOG_FUNCTION(this);
750 }
751 
752 TypeId // static
754 {
755  static TypeId tid =
756  TypeId("ns3::SatStatsRtnFeederDaPacketErrorHelper").SetParent<SatStatsPacketErrorHelper>();
757  return tid;
758 }
759 
760 // RETURN USER LINK DEDICATED ACCESS ///////////////////////////////////////////////
761 
762 NS_OBJECT_ENSURE_REGISTERED(SatStatsRtnUserDaPacketErrorHelper);
763 
765  Ptr<const SatHelper> satHelper)
766  : SatStatsPacketErrorHelper(satHelper)
767 {
768  NS_LOG_FUNCTION(this << satHelper);
769  SetTraceSourceName("DaRx");
772 }
773 
775 {
776  NS_LOG_FUNCTION(this);
777 }
778 
779 TypeId // static
781 {
782  static TypeId tid =
783  TypeId("ns3::SatStatsRtnUserDaPacketErrorHelper").SetParent<SatStatsPacketErrorHelper>();
784  return tid;
785 }
786 
787 // FEEDER SLOTTED ALOHA //////////////////////////////////////////////////////////////
788 
789 NS_OBJECT_ENSURE_REGISTERED(SatStatsFeederSlottedAlohaPacketErrorHelper);
790 
792  Ptr<const SatHelper> satHelper)
793  : SatStatsPacketErrorHelper(satHelper)
794 {
795  NS_LOG_FUNCTION(this << satHelper);
796  SetTraceSourceName("SlottedAlohaRxError");
799 }
800 
802 {
803  NS_LOG_FUNCTION(this);
804 }
805 
806 TypeId // static
808 {
809  static TypeId tid = TypeId("ns3::SatStatsFeederSlottedAlohaPacketErrorHelper")
810  .SetParent<SatStatsPacketErrorHelper>();
811  return tid;
812 }
813 
814 // USER SLOTTED ALOHA //////////////////////////////////////////////////////////////
815 
816 NS_OBJECT_ENSURE_REGISTERED(SatStatsUserSlottedAlohaPacketErrorHelper);
817 
819  Ptr<const SatHelper> satHelper)
820  : SatStatsPacketErrorHelper(satHelper)
821 {
822  NS_LOG_FUNCTION(this << satHelper);
823  SetTraceSourceName("SlottedAlohaRxError");
826 }
827 
829 {
830  NS_LOG_FUNCTION(this);
831 }
832 
833 TypeId // static
835 {
836  static TypeId tid = TypeId("ns3::SatStatsUserSlottedAlohaPacketErrorHelper")
837  .SetParent<SatStatsPacketErrorHelper>();
838  return tid;
839 }
840 
841 // FEEDER CRDSA //////////////////////////////////////////////////////////////////////
842 
843 NS_OBJECT_ENSURE_REGISTERED(SatStatsFeederCrdsaPacketErrorHelper);
844 
846  Ptr<const SatHelper> satHelper)
847  : SatStatsPacketErrorHelper(satHelper)
848 {
849  NS_LOG_FUNCTION(this << satHelper);
850  SetTraceSourceName("CrdsaUniquePayloadRx");
853 }
854 
856 {
857  NS_LOG_FUNCTION(this);
858 }
859 
860 TypeId // static
862 {
863  static TypeId tid =
864  TypeId("ns3::SatStatsFeederCrdsaPacketErrorHelper").SetParent<SatStatsPacketErrorHelper>();
865  return tid;
866 }
867 
868 // USER CRDSA //////////////////////////////////////////////////////////////////////
869 
870 NS_OBJECT_ENSURE_REGISTERED(SatStatsUserCrdsaPacketErrorHelper);
871 
873  Ptr<const SatHelper> satHelper)
874  : SatStatsPacketErrorHelper(satHelper)
875 {
876  NS_LOG_FUNCTION(this << satHelper);
877  SetTraceSourceName("CrdsaUniquePayloadRx");
880 }
881 
883 {
884  NS_LOG_FUNCTION(this);
885 }
886 
887 TypeId // static
889 {
890  static TypeId tid =
891  TypeId("ns3::SatStatsUserCrdsaPacketErrorHelper").SetParent<SatStatsPacketErrorHelper>();
892  return tid;
893 }
894 
895 // FEEDER E-SSA //////////////////////////////////////////////////////////////////////
896 
897 NS_OBJECT_ENSURE_REGISTERED(SatStatsFeederEssaPacketErrorHelper);
898 
900  Ptr<const SatHelper> satHelper)
901  : SatStatsPacketErrorHelper(satHelper)
902 {
903  NS_LOG_FUNCTION(this << satHelper);
904  SetTraceSourceName("EssaRxError");
907 }
908 
910 {
911  NS_LOG_FUNCTION(this);
912 }
913 
914 TypeId // static
916 {
917  static TypeId tid =
918  TypeId("ns3::SatStatsFeederEssaPacketErrorHelper").SetParent<SatStatsPacketErrorHelper>();
919  return tid;
920 }
921 
922 // USER E-SSA //////////////////////////////////////////////////////////////////////
923 
924 NS_OBJECT_ENSURE_REGISTERED(SatStatsUserEssaPacketErrorHelper);
925 
927  : SatStatsPacketErrorHelper(satHelper)
928 {
929  NS_LOG_FUNCTION(this << satHelper);
930  SetTraceSourceName("EssaRxError");
933 }
934 
936 {
937  NS_LOG_FUNCTION(this);
938 }
939 
940 TypeId // static
942 {
943  static TypeId tid =
944  TypeId("ns3::SatStatsUserEssaPacketErrorHelper").SetParent<SatStatsPacketErrorHelper>();
945  return tid;
946 }
947 
948 } // 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)
SatGeoNetDevice to be utilized in geostationary satellite.
Class for ID-mapper.
Address GetUtMacWithNode(Ptr< Node > utNode) const
SatNetDevice to be utilized in the UT and GW nodes.
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
Parent abstract class of all satellite statistics helpers.
Ptr< const SatHelper > GetSatHelper() const
static NetDeviceContainer GetGwSatNetDevice(Ptr< Node > gwNode)
static std::string GetOutputTypeName(OutputType_t outputType)
static Ptr< NetDevice > GetSatSatGeoNetDevice(Ptr< Node > satNode)
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::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.
SatEnums::ChannelType_t GetChannelType() const
void InstallProbeOnGw(Ptr< Node > gwNode)
Set up several listeners on a GW node and connect them to the collectors.
Ptr< DataCollectionObject > m_aggregator
The aggregator created by this helper.
SatPhyRxCarrier::CarrierType GetValidCarrierType() const
Get the valid carrier type.
SatStatsPacketErrorHelper(Ptr< const SatHelper > satHelper)
void SaveAddressAndIdentifier(Ptr< Node > utNode)
Save the address and the proper identifier from the given UT node.
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)
std::map< const Address, uint32_t > m_identifierMap
Map of address and the identifier associated with it (for return link).
std::list< Ptr< Probe > > m_probes
Maintains a list of probes created by this helper (for forward link).
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.