24#include "ns3/application-delay-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"
31#include "ns3/inet-socket-address.h"
34#include "ns3/mac48-address.h"
35#include "ns3/magister-gnuplot-aggregator.h"
36#include "ns3/multi-file-aggregator.h"
37#include "ns3/net-device.h"
38#include "ns3/node-container.h"
39#include "ns3/nstime.h"
41#include "ns3/satellite-helper.h"
42#include "ns3/satellite-id-mapper.h"
43#include "ns3/satellite-mac.h"
44#include "ns3/satellite-net-device.h"
45#include "ns3/satellite-orbiter-net-device.h"
46#include "ns3/satellite-phy.h"
47#include "ns3/satellite-time-tag.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/traffic-time-tag.h"
53#include "ns3/unit-conversion-collector.h"
60NS_LOG_COMPONENT_DEFINE(
"SatStatsDelayHelper");
71 NS_LOG_FUNCTION(
this << satHelper);
76 NS_LOG_FUNCTION(
this);
83 TypeId(
"ns3::SatStatsDelayHelper")
85 .AddAttribute(
"AveragingMode",
86 "If true, all samples will be averaged before passed to aggregator. "
87 "Only affects histogram, PDF, and CDF output types.",
91 MakeBooleanChecker());
98 NS_LOG_FUNCTION(
this << averagingMode);
111 NS_LOG_FUNCTION(
this);
117 <<
" is not a valid output type for this statistics.");
127 "EnableContextPrinting",
135 EnumValue(ScalarCollector::INPUT_DATA_TYPE_DOUBLE));
138 EnumValue(ScalarCollector::OUTPUT_TYPE_AVERAGE_PER_SAMPLE));
142 &MultiFileAggregator::Write1d);
157 EnumValue(UnitConversionCollector::TRANSPARENT));
161 &MultiFileAggregator::Write2d);
176 "EnableContextPrinting",
180 Ptr<MultiFileAggregator> fileAggregator =
182 NS_ASSERT(fileAggregator !=
nullptr);
186 DistributionCollector::OutputType_t outputType =
187 DistributionCollector::OUTPUT_TYPE_HISTOGRAM;
190 outputType = DistributionCollector::OUTPUT_TYPE_PROBABILITY;
194 outputType = DistributionCollector::OUTPUT_TYPE_CUMULATIVE;
201 MakeCallback(&MultiFileAggregator::Write2d, fileAggregator));
205 MakeCallback(&MultiFileAggregator::AddContextHeading, fileAggregator));
209 MakeCallback(&MultiFileAggregator::EnableContextWarning, fileAggregator));
214 EnumValue(ScalarCollector::INPUT_DATA_TYPE_DOUBLE));
217 EnumValue(ScalarCollector::OUTPUT_TYPE_AVERAGE_PER_SAMPLE));
219 Callback<void, double> callback =
225 it->second->TraceConnectWithoutContext(
"Output", callback);
239 DistributionCollector::OutputType_t outputType =
240 DistributionCollector::OUTPUT_TYPE_HISTOGRAM;
243 outputType = DistributionCollector::OUTPUT_TYPE_PROBABILITY;
247 outputType = DistributionCollector::OUTPUT_TYPE_CUMULATIVE;
253 &MultiFileAggregator::Write2d);
256 &MultiFileAggregator::AddContextHeading);
259 &MultiFileAggregator::EnableContextWarning);
268 <<
" is not a valid output type for this statistics.");
278 Ptr<MagisterGnuplotAggregator> plotAggregator =
280 NS_ASSERT(plotAggregator !=
nullptr);
282 plotAggregator->SetLegend(
"Time (in seconds)",
"Packet delay (in seconds)");
283 plotAggregator->Set2dDatasetDefaultStyle(Gnuplot2dDataset::LINES);
288 EnumValue(UnitConversionCollector::TRANSPARENT));
294 const std::string context = it->second->GetName();
295 plotAggregator->Add2dDataset(context, context);
299 &MagisterGnuplotAggregator::Write2d);
314 Ptr<MagisterGnuplotAggregator> plotAggregator =
316 NS_ASSERT(plotAggregator !=
nullptr);
318 plotAggregator->SetLegend(
"Packet delay (in seconds)",
"Frequency");
319 plotAggregator->Set2dDatasetDefaultStyle(Gnuplot2dDataset::LINES);
325 DistributionCollector::OutputType_t outputType =
326 DistributionCollector::OUTPUT_TYPE_HISTOGRAM;
329 outputType = DistributionCollector::OUTPUT_TYPE_PROBABILITY;
333 outputType = DistributionCollector::OUTPUT_TYPE_CUMULATIVE;
340 MakeCallback(&MagisterGnuplotAggregator::Write2d, plotAggregator));
346 EnumValue(ScalarCollector::INPUT_DATA_TYPE_DOUBLE));
349 EnumValue(ScalarCollector::OUTPUT_TYPE_AVERAGE_PER_SAMPLE));
351 Callback<void, double> callback =
357 it->second->TraceConnectWithoutContext(
"Output", callback);
368 Ptr<MagisterGnuplotAggregator> plotAggregator =
370 NS_ASSERT(plotAggregator !=
nullptr);
372 plotAggregator->SetLegend(
"Packet delay (in seconds)",
"Frequency");
373 plotAggregator->Set2dDatasetDefaultStyle(Gnuplot2dDataset::LINES);
377 DistributionCollector::OutputType_t outputType =
378 DistributionCollector::OUTPUT_TYPE_HISTOGRAM;
381 outputType = DistributionCollector::OUTPUT_TYPE_PROBABILITY;
385 outputType = DistributionCollector::OUTPUT_TYPE_CUMULATIVE;
393 const std::string context = it->second->GetName();
394 plotAggregator->Add2dDataset(context, context);
398 &MagisterGnuplotAggregator::Write2d);
405 NS_FATAL_ERROR(
"SatStatsDelayHelper - Invalid output type");
426 if (from.IsInvalid())
428 NS_LOG_WARN(
this <<
" discarding a packet delay of " << delay.GetSeconds()
429 <<
" from statistics collection because of" <<
" invalid sender address");
434 std::map<const Address, uint32_t>::const_iterator it =
m_identifierMap.find(from);
442 NS_LOG_WARN(
this <<
" discarding a packet delay of " << delay.GetSeconds()
443 <<
" from statistics collection because of"
444 <<
" unknown sender address " << from);
452 NS_LOG_FUNCTION(
this << probe << probe->GetName() << identifier);
462 &ScalarCollector::TraceSinkDouble);
470 &UnitConversionCollector::TraceSinkDouble);
484 &ScalarCollector::TraceSinkDouble);
491 &DistributionCollector::TraceSinkDouble);
497 <<
" is not a valid output type for this statistics.");
503 NS_LOG_INFO(
this <<
" created probe " << probe->GetName() <<
", connected to collector "
508 NS_LOG_WARN(
this <<
" unable to connect probe " << probe->GetName() <<
" to collector "
518 NS_LOG_FUNCTION(
this << probe << probe->GetName() << identifier);
528 &ScalarCollector::TraceSinkDouble);
536 &UnitConversionCollector::TraceSinkDouble);
550 &ScalarCollector::TraceSinkDouble);
557 &DistributionCollector::TraceSinkDouble);
563 <<
" is not a valid output type for this statistics.");
569 NS_LOG_INFO(
this <<
" probe " << probe->GetName() <<
", disconnected from collector "
574 NS_LOG_WARN(
this <<
" unable to disconnect probe " << probe->GetName() <<
" from collector "
587 NS_ASSERT_MSG(collector !=
nullptr,
"Unable to find collector with identifier " << identifier);
593 Ptr<ScalarCollector> c = collector->GetObject<ScalarCollector>();
594 NS_ASSERT(c !=
nullptr);
595 c->TraceSinkDouble(0.0, delay.GetSeconds());
601 Ptr<UnitConversionCollector> c = collector->GetObject<UnitConversionCollector>();
602 NS_ASSERT(c !=
nullptr);
603 c->TraceSinkDouble(0.0, delay.GetSeconds());
615 Ptr<ScalarCollector> c = collector->GetObject<ScalarCollector>();
616 NS_ASSERT(c !=
nullptr);
617 c->TraceSinkDouble(0.0, delay.GetSeconds());
621 Ptr<DistributionCollector> c = collector->GetObject<DistributionCollector>();
622 NS_ASSERT(c !=
nullptr);
623 c->TraceSinkDouble(0.0, delay.GetSeconds());
629 <<
" is not a valid output type for this statistics.");
643 NS_LOG_FUNCTION(
this << satHelper);
648 NS_LOG_FUNCTION(
this);
654 static TypeId tid = TypeId(
"ns3::SatStatsFwdAppDelayHelper").SetParent<
SatStatsDelayHelper>();
661 NS_LOG_FUNCTION(
this);
662 NodeContainer utUsers = Singleton<SatTopology>::Get()->GetUtUserNodes();
664 for (NodeContainer::Iterator it = utUsers.Begin(); it != utUsers.End(); ++it)
667 NS_ASSERT_MSG(utUserId > 0,
"Node " << (*it)->GetId() <<
" is not a valid UT user");
670 for (uint32_t i = 0; i < (*it)->GetNApplications(); i++)
672 Ptr<Application> app = (*it)->GetApplication(i);
673 bool isConnected =
false;
679 if (app->GetInstanceTypeId().LookupTraceSourceByName(
"RxDelay") !=
nullptr)
681 NS_LOG_INFO(
this <<
" attempt to connect using RxDelay");
684 std::ostringstream probeName;
685 probeName << utUserId <<
"-" << i;
686 Ptr<ApplicationDelayProbe> probe = CreateObject<ApplicationDelayProbe>();
687 probe->SetName(probeName.str());
690 if (probe->ConnectByObject(
"RxDelay", app))
694 std::make_pair(probe->GetObject<Probe>(), std::make_pair(*it, identifier)));
697 else if (app->GetInstanceTypeId().LookupTraceSourceByName(
"Rx") !=
nullptr)
699 NS_LOG_INFO(
this <<
" attempt to connect using Rx");
700 Callback<void, Ptr<const Packet>,
const Address&> rxCallback =
702 isConnected = app->TraceConnectWithoutContext(
"Rx", rxCallback);
707 NS_LOG_INFO(
this <<
" successfully connected" <<
" with node ID " << (*it)->GetId()
708 <<
" application #" << i);
717 NS_LOG_WARN(
this <<
" unable to connect" <<
" with node ID " << (*it)->GetId()
718 <<
" application #" << i);
729 NodeContainer gwUsers = Singleton<SatTopology>::Get()->GetGwUserNodes();
730 for (NodeContainer::Iterator it = gwUsers.Begin(); it != gwUsers.End(); ++it)
732 for (uint32_t i = 0; i < (*it)->GetNApplications(); i++)
734 Ptr<Application> app = (*it)->GetApplication(i);
736 if (!app->SetAttributeFailSafe(
"EnableStatisticsTags", BooleanValue(
true)))
738 NS_LOG_WARN(
this <<
" node ID " << (*it)->GetId() <<
" application #" << i
739 <<
" might not produce the required tags"
740 <<
" in the packets it transmits,"
741 <<
" thus preventing delay statistics"
742 <<
" from this application");
754 Ptr<const Packet> packet,
757 NS_LOG_FUNCTION(helper << identifier << packet << packet->GetSize() << from);
786 TrafficTimeTag timeTag;
787 if (packet->PeekPacketTag(timeTag))
789 NS_LOG_DEBUG(
"Contains a TrafficTimeTag tag");
790 const Time delay = Simulator::Now() - timeTag.GetSenderTimestamp();
791 helper->PassSampleToCollector(delay, identifier);
795 NS_LOG_WARN(
"Discarding a packet of " << packet->GetSize() <<
" from statistics collection"
796 <<
" because it does not contain any TrafficTimeTag");
803 NS_LOG_FUNCTION(
this);
805 std::map<Ptr<Probe>, std::pair<Ptr<Node>, uint32_t>>::iterator it;
809 Ptr<Probe> probe = it->first;
810 Ptr<Node> node = it->second.first;
811 uint32_t identifier = it->second.second;
815 NS_FATAL_ERROR(
"Error disconnecting trace file on handover");
822 NS_FATAL_ERROR(
"Error connecting trace file on handover");
825 it->second.second = identifier;
836 NS_LOG_FUNCTION(
this << satHelper);
841 NS_LOG_FUNCTION(
this);
847 static TypeId tid = TypeId(
"ns3::SatStatsFwdDevDelayHelper").SetParent<
SatStatsDelayHelper>();
854 NS_LOG_FUNCTION(
this);
855 NodeContainer uts = Singleton<SatTopology>::Get()->GetUtNodes();
857 for (NodeContainer::Iterator it = uts.Begin(); it != uts.End(); ++it)
859 const int32_t utId =
GetUtId(*it);
860 NS_ASSERT_MSG(utId > 0,
"Node " << (*it)->GetId() <<
" is not a valid UT");
864 std::ostringstream probeName;
866 Ptr<ApplicationDelayProbe> probe = CreateObject<ApplicationDelayProbe>();
867 probe->SetName(probeName.str());
875 std::make_pair(probe->GetObject<Probe>(), std::make_pair(*it, identifier)));
878 dev->SetAttribute(
"EnableStatisticsTags", BooleanValue(
true));
882 NS_FATAL_ERROR(
"Error connecting to RxDelay trace source of SatNetDevice"
883 <<
" at node ID " << (*it)->GetId() <<
" device #2");
889 NodeContainer gws = Singleton<SatTopology>::Get()->GetGwNodes();
890 for (NodeContainer::Iterator it = gws.Begin(); it != gws.End(); ++it)
894 for (NetDeviceContainer::Iterator itDev = devs.Begin(); itDev != devs.End(); ++itDev)
896 NS_ASSERT((*itDev)->GetObject<
SatNetDevice>() !=
nullptr);
897 (*itDev)->SetAttribute(
"EnableStatisticsTags", BooleanValue(
true));
906 NS_LOG_FUNCTION(
this);
908 std::map<Ptr<Probe>, std::pair<Ptr<Node>, uint32_t>>::iterator it;
912 Ptr<Probe> probe = it->first;
913 Ptr<Node> node = it->second.first;
914 uint32_t identifier = it->second.second;
918 NS_FATAL_ERROR(
"Error disconnecting trace file on handover");
925 NS_FATAL_ERROR(
"Error connecting trace file on handover");
928 it->second.second = identifier;
939 NS_LOG_FUNCTION(
this << satHelper);
944 NS_LOG_FUNCTION(
this);
950 static TypeId tid = TypeId(
"ns3::SatStatsFwdMacDelayHelper").SetParent<
SatStatsDelayHelper>();
957 NS_LOG_FUNCTION(
this);
958 NodeContainer uts = Singleton<SatTopology>::Get()->GetUtNodes();
960 for (NodeContainer::Iterator it = uts.Begin(); it != uts.End(); ++it)
962 const int32_t utId =
GetUtId(*it);
963 NS_ASSERT_MSG(utId > 0,
"Node " << (*it)->GetId() <<
" is not a valid UT");
967 std::ostringstream probeName;
969 Ptr<ApplicationDelayProbe> probe = CreateObject<ApplicationDelayProbe>();
970 probe->SetName(probeName.str());
973 Ptr<SatNetDevice> satDev = dev->GetObject<
SatNetDevice>();
974 NS_ASSERT(satDev !=
nullptr);
975 Ptr<SatMac> satMac = satDev->GetMac();
976 NS_ASSERT(satMac !=
nullptr);
982 std::make_pair(probe->GetObject<Probe>(), std::make_pair(*it, identifier)));
985 satDev->SetAttribute(
"EnableStatisticsTags", BooleanValue(
true));
986 satMac->SetAttribute(
"EnableStatisticsTags", BooleanValue(
true));
990 NS_FATAL_ERROR(
"Error connecting to RxDelay trace source of satMac"
991 <<
" at node ID " << (*it)->GetId() <<
" device #2");
997 NodeContainer gws = Singleton<SatTopology>::Get()->GetGwNodes();
998 for (NodeContainer::Iterator it = gws.Begin(); it != gws.End(); ++it)
1002 for (NetDeviceContainer::Iterator itDev = devs.Begin(); itDev != devs.End(); ++itDev)
1004 Ptr<SatNetDevice> satDev = (*itDev)->GetObject<
SatNetDevice>();
1005 NS_ASSERT(satDev !=
nullptr);
1006 Ptr<SatMac> satMac = satDev->GetMac();
1007 NS_ASSERT(satMac !=
nullptr);
1009 satDev->SetAttribute(
"EnableStatisticsTags", BooleanValue(
true));
1010 satMac->SetAttribute(
"EnableStatisticsTags", BooleanValue(
true));
1019 NS_LOG_FUNCTION(
this);
1021 std::map<Ptr<Probe>, std::pair<Ptr<Node>, uint32_t>>::iterator it;
1025 Ptr<Probe> probe = it->first;
1026 Ptr<Node> node = it->second.first;
1027 uint32_t identifier = it->second.second;
1031 NS_FATAL_ERROR(
"Error disconnecting trace file on handover");
1038 NS_FATAL_ERROR(
"Error connecting trace file on handover");
1041 it->second.second = identifier;
1052 NS_LOG_FUNCTION(
this << satHelper);
1057 NS_LOG_FUNCTION(
this);
1063 static TypeId tid = TypeId(
"ns3::SatStatsFwdPhyDelayHelper").SetParent<
SatStatsDelayHelper>();
1070 NS_LOG_FUNCTION(
this);
1072 NodeContainer sats = Singleton<SatTopology>::Get()->GetOrbiterNodes();
1074 for (NodeContainer::Iterator it = sats.Begin(); it != sats.End(); ++it)
1078 NS_ASSERT(satOrbiterDev !=
nullptr);
1079 std::map<uint32_t, Ptr<SatPhy>> satOrbiterFeederPhys = satOrbiterDev->GetFeederPhy();
1081 for (std::map<uint32_t, Ptr<SatPhy>>::iterator it2 = satOrbiterFeederPhys.begin();
1082 it2 != satOrbiterFeederPhys.end();
1085 satPhy = it2->second;
1086 NS_ASSERT(satPhy !=
nullptr);
1087 satPhy->SetAttribute(
"EnableStatisticsTags", BooleanValue(
true));
1089 std::map<uint32_t, Ptr<SatPhy>> satOrbiterUserPhys = satOrbiterDev->GetUserPhy();
1090 for (std::map<uint32_t, Ptr<SatPhy>>::iterator it2 = satOrbiterUserPhys.begin();
1091 it2 != satOrbiterUserPhys.end();
1094 satPhy = it2->second;
1095 NS_ASSERT(satPhy !=
nullptr);
1096 satPhy->SetAttribute(
"EnableStatisticsTags", BooleanValue(
true));
1100 NodeContainer uts = Singleton<SatTopology>::Get()->GetUtNodes();
1102 for (NodeContainer::Iterator it = uts.Begin(); it != uts.End(); ++it)
1104 const int32_t utId =
GetUtId(*it);
1105 NS_ASSERT_MSG(utId > 0,
"Node " << (*it)->GetId() <<
" is not a valid UT");
1109 std::ostringstream probeName;
1111 Ptr<ApplicationDelayProbe> probe = CreateObject<ApplicationDelayProbe>();
1112 probe->SetName(probeName.str());
1115 Ptr<SatNetDevice> satDev = dev->GetObject<
SatNetDevice>();
1116 NS_ASSERT(satDev !=
nullptr);
1117 Ptr<SatPhy> satPhy = satDev->GetPhy();
1118 NS_ASSERT(satPhy !=
nullptr);
1124 std::make_pair(probe->GetObject<Probe>(), std::make_pair(*it, identifier)));
1127 satDev->SetAttribute(
"EnableStatisticsTags", BooleanValue(
true));
1128 satPhy->SetAttribute(
"EnableStatisticsTags", BooleanValue(
true));
1132 NS_FATAL_ERROR(
"Error connecting to RxDelay trace source of SatPhy"
1133 <<
" at node ID " << (*it)->GetId() <<
" device #2");
1139 NodeContainer gws = Singleton<SatTopology>::Get()->GetGwNodes();
1140 for (NodeContainer::Iterator it = gws.Begin(); it != gws.End(); ++it)
1144 for (NetDeviceContainer::Iterator itDev = devs.Begin(); itDev != devs.End(); ++itDev)
1146 Ptr<SatNetDevice> satDev = (*itDev)->GetObject<
SatNetDevice>();
1147 NS_ASSERT(satDev !=
nullptr);
1148 Ptr<SatPhy> satPhy = satDev->GetPhy();
1149 NS_ASSERT(satPhy !=
nullptr);
1151 satDev->SetAttribute(
"EnableStatisticsTags", BooleanValue(
true));
1152 satPhy->SetAttribute(
"EnableStatisticsTags", BooleanValue(
true));
1161 NS_LOG_FUNCTION(
this);
1163 std::map<Ptr<Probe>, std::pair<Ptr<Node>, uint32_t>>::iterator it;
1167 Ptr<Probe> probe = it->first;
1168 Ptr<Node> node = it->second.first;
1169 uint32_t identifier = it->second.second;
1173 NS_FATAL_ERROR(
"Error disconnecting trace file on handover");
1180 NS_FATAL_ERROR(
"Error connecting trace file on handover");
1183 it->second.second = identifier;
1194 NS_LOG_FUNCTION(
this << satHelper);
1199 NS_LOG_FUNCTION(
this);
1205 static TypeId tid = TypeId(
"ns3::SatStatsRtnAppDelayHelper").SetParent<
SatStatsDelayHelper>();
1212 NS_LOG_FUNCTION(
this);
1214 NodeContainer utUsers = Singleton<SatTopology>::Get()->GetUtUserNodes();
1215 for (NodeContainer::Iterator it = utUsers.Begin(); it != utUsers.End(); ++it)
1224 for (uint32_t i = 0; i < (*it)->GetNApplications(); i++)
1226 Ptr<Application> app = (*it)->GetApplication(i);
1228 if (!app->SetAttributeFailSafe(
"EnableStatisticsTags", BooleanValue(
true)))
1231 this <<
" node ID " << (*it)->GetId() <<
" application #" << i
1232 <<
" might not produce the required tags" <<
" in the transmitted packets,"
1233 <<
" thus preventing delay statistics" <<
" from this sender application");
1242 NodeContainer gwUsers = Singleton<SatTopology>::Get()->GetGwUserNodes();
1243 Callback<void, const Time&, const Address&> rxDelayCallback =
1245 Callback<void, Ptr<const Packet>,
const Address&> rxCallback =
1248 for (NodeContainer::Iterator it = gwUsers.Begin(); it != gwUsers.End(); ++it)
1250 for (uint32_t i = 0; i < (*it)->GetNApplications(); i++)
1252 Ptr<Application> app = (*it)->GetApplication(i);
1253 bool isConnected =
false;
1259 if (app->GetInstanceTypeId().LookupTraceSourceByName(
"RxDelay") !=
nullptr)
1261 isConnected = app->TraceConnectWithoutContext(
"RxDelay", rxDelayCallback);
1263 else if (app->GetInstanceTypeId().LookupTraceSourceByName(
"Rx") !=
nullptr)
1265 isConnected = app->TraceConnectWithoutContext(
"Rx", rxCallback);
1270 NS_LOG_INFO(
this <<
" successfully connected" <<
" with node ID " << (*it)->GetId()
1271 <<
" application #" << i);
1280 NS_LOG_WARN(
this <<
" unable to connect" <<
" with node ID " << (*it)->GetId()
1281 <<
" application #" << i);
1322 TrafficTimeTag timeTag;
1323 if (packet->PeekPacketTag(timeTag))
1325 NS_LOG_DEBUG(
this <<
" contains a TrafficTimeTag tag");
1326 Ipv4Callback(Simulator::Now() - timeTag.GetSenderTimestamp(), from);
1330 NS_LOG_WARN(
this <<
" discarding a packet of " << packet->GetSize()
1331 <<
" from statistics collection"
1332 <<
" because it does not contain any TrafficTimeTag");
1342 if (InetSocketAddress::IsMatchingType(from))
1345 const Address ipv4Addr = InetSocketAddress::ConvertFrom(from).GetIpv4();
1346 std::map<const Address, uint32_t>::const_iterator it1 =
m_identifierMap.find(ipv4Addr);
1350 NS_LOG_WARN(
this <<
" discarding a packet delay of " << delay.GetSeconds()
1351 <<
" from statistics collection because of"
1352 <<
" unknown sender IPV4 address " << ipv4Addr);
1361 NS_LOG_WARN(
this <<
" discarding a packet delay of " << delay.GetSeconds()
1362 <<
" from statistics collection" <<
" because it comes from sender "
1363 << from <<
" without valid InetSocketAddress");
1370 NS_LOG_FUNCTION(
this << utUserNode->GetId());
1372 Ptr<Ipv4> ipv4 = utUserNode->GetObject<Ipv4>();
1374 if (ipv4 ==
nullptr)
1376 NS_LOG_INFO(
this <<
" Node " << utUserNode->GetId() <<
" does not support IPv4 protocol");
1378 else if (ipv4->GetNInterfaces() >= 2)
1386 for (uint32_t i = 0; i < ipv4->GetNAddresses(1); i++)
1388 const Address addr = ipv4->GetAddress(1, i).GetLocal();
1390 NS_LOG_INFO(
this <<
" associated address " << addr <<
" with identifier "
1396 NS_LOG_WARN(
this <<
" Node " << utUserNode->GetId() <<
" is not a valid UT user");
1407 NS_LOG_FUNCTION(
this << satHelper);
1412 NS_LOG_FUNCTION(
this);
1418 static TypeId tid = TypeId(
"ns3::SatStatsRtnDevDelayHelper").SetParent<
SatStatsDelayHelper>();
1425 NS_LOG_FUNCTION(
this);
1427 NodeContainer uts = Singleton<SatTopology>::Get()->GetUtNodes();
1428 for (NodeContainer::Iterator it = uts.Begin(); it != uts.End(); ++it)
1435 dev->SetAttribute(
"EnableStatisticsTags", BooleanValue(
true));
1440 NodeContainer gws = Singleton<SatTopology>::Get()->GetGwNodes();
1441 Callback<void, const Time&, const Address&> callback =
1444 for (NodeContainer::Iterator it = gws.Begin(); it != gws.End(); ++it)
1448 for (NetDeviceContainer::Iterator itDev = devs.Begin(); itDev != devs.End(); ++itDev)
1450 NS_ASSERT((*itDev)->GetObject<
SatNetDevice>() !=
nullptr);
1452 if ((*itDev)->TraceConnectWithoutContext(
"RxDelay", callback))
1454 NS_LOG_INFO(
this <<
" successfully connected with node ID " << (*it)->GetId()
1455 <<
" device #" << (*itDev)->GetIfIndex());
1458 (*itDev)->SetAttribute(
"EnableStatisticsTags", BooleanValue(
true));
1462 NS_FATAL_ERROR(
"Error connecting to RxDelay trace source of SatNetDevice"
1463 <<
" at node ID " << (*it)->GetId() <<
" device #"
1464 << (*itDev)->GetIfIndex());
1480 NS_LOG_FUNCTION(
this << satHelper);
1485 NS_LOG_FUNCTION(
this);
1491 static TypeId tid = TypeId(
"ns3::SatStatsRtnMacDelayHelper").SetParent<
SatStatsDelayHelper>();
1498 NS_LOG_FUNCTION(
this);
1500 NodeContainer uts = Singleton<SatTopology>::Get()->GetUtNodes();
1501 for (NodeContainer::Iterator it = uts.Begin(); it != uts.End(); ++it)
1508 Ptr<SatNetDevice> satDev = dev->GetObject<
SatNetDevice>();
1509 NS_ASSERT(satDev !=
nullptr);
1510 Ptr<SatMac> satMac = satDev->GetMac();
1511 NS_ASSERT(satMac !=
nullptr);
1512 satDev->SetAttribute(
"EnableStatisticsTags", BooleanValue(
true));
1513 satMac->SetAttribute(
"EnableStatisticsTags", BooleanValue(
true));
1518 NodeContainer gws = Singleton<SatTopology>::Get()->GetGwNodes();
1519 Callback<void, const Time&, const Address&> callback =
1522 for (NodeContainer::Iterator it = gws.Begin(); it != gws.End(); ++it)
1526 for (NetDeviceContainer::Iterator itDev = devs.Begin(); itDev != devs.End(); ++itDev)
1528 Ptr<SatNetDevice> satDev = (*itDev)->GetObject<
SatNetDevice>();
1529 NS_ASSERT(satDev !=
nullptr);
1530 Ptr<SatMac> satMac = satDev->GetMac();
1531 NS_ASSERT(satMac !=
nullptr);
1534 if (satMac->TraceConnectWithoutContext(
"RxDelay", callback))
1536 NS_LOG_INFO(
this <<
" successfully connected with node ID " << (*it)->GetId()
1537 <<
" device #" << satDev->GetIfIndex());
1540 satDev->SetAttribute(
"EnableStatisticsTags", BooleanValue(
true));
1541 satMac->SetAttribute(
"EnableStatisticsTags", BooleanValue(
true));
1545 NS_FATAL_ERROR(
"Error connecting to RxDelay trace source of SatNetDevice"
1546 <<
" at node ID " << (*it)->GetId() <<
" device #"
1547 << satDev->GetIfIndex());
1563 NS_LOG_FUNCTION(
this << satHelper);
1568 NS_LOG_FUNCTION(
this);
1574 static TypeId tid = TypeId(
"ns3::SatStatsRtnPhyDelayHelper").SetParent<
SatStatsDelayHelper>();
1581 NS_LOG_FUNCTION(
this);
1583 NodeContainer sats = Singleton<SatTopology>::Get()->GetOrbiterNodes();
1585 for (NodeContainer::Iterator it = sats.Begin(); it != sats.End(); ++it)
1590 NS_ASSERT(satOrbiterDev !=
nullptr);
1591 std::map<uint32_t, Ptr<SatPhy>> satOrbiterFeederPhys = satOrbiterDev->GetFeederPhy();
1592 for (std::map<uint32_t, Ptr<SatPhy>>::iterator it2 = satOrbiterFeederPhys.begin();
1593 it2 != satOrbiterFeederPhys.end();
1596 satPhy = it2->second;
1597 NS_ASSERT(satPhy !=
nullptr);
1598 satPhy->SetAttribute(
"EnableStatisticsTags", BooleanValue(
true));
1600 std::map<uint32_t, Ptr<SatPhy>> satOrbiterUserPhys = satOrbiterDev->GetUserPhy();
1601 for (std::map<uint32_t, Ptr<SatPhy>>::iterator it2 = satOrbiterUserPhys.begin();
1602 it2 != satOrbiterUserPhys.end();
1605 satPhy = it2->second;
1606 NS_ASSERT(satPhy !=
nullptr);
1607 satPhy->SetAttribute(
"EnableStatisticsTags", BooleanValue(
true));
1611 NodeContainer uts = Singleton<SatTopology>::Get()->GetUtNodes();
1612 for (NodeContainer::Iterator it = uts.Begin(); it != uts.End(); ++it)
1619 Ptr<SatNetDevice> satDev = dev->GetObject<
SatNetDevice>();
1620 NS_ASSERT(satDev !=
nullptr);
1621 Ptr<SatPhy> satPhy = satDev->GetPhy();
1622 NS_ASSERT(satPhy !=
nullptr);
1623 satDev->SetAttribute(
"EnableStatisticsTags", BooleanValue(
true));
1624 satPhy->SetAttribute(
"EnableStatisticsTags", BooleanValue(
true));
1629 NodeContainer gws = Singleton<SatTopology>::Get()->GetGwNodes();
1630 Callback<void, const Time&, const Address&> callback =
1633 for (NodeContainer::Iterator it = gws.Begin(); it != gws.End(); ++it)
1637 for (NetDeviceContainer::Iterator itDev = devs.Begin(); itDev != devs.End(); ++itDev)
1639 Ptr<SatNetDevice> satDev = (*itDev)->GetObject<
SatNetDevice>();
1640 NS_ASSERT(satDev !=
nullptr);
1641 Ptr<SatPhy> satPhy = satDev->GetPhy();
1642 NS_ASSERT(satPhy !=
nullptr);
1645 if (satPhy->TraceConnectWithoutContext(
"RxDelay", callback))
1647 NS_LOG_INFO(
this <<
" successfully connected with node ID " << (*it)->GetId()
1648 <<
" device #" << satDev->GetIfIndex());
1651 satDev->SetAttribute(
"EnableStatisticsTags", BooleanValue(
true));
1652 satPhy->SetAttribute(
"EnableStatisticsTags", BooleanValue(
true));
1656 NS_FATAL_ERROR(
"Error connecting to RxDelay trace source of SatNetDevice"
1657 <<
" at node ID " << (*it)->GetId() <<
" device #"
1658 << satDev->GetIfIndex());
SatNetDevice to be utilized in the UT and GW nodes.
SatOrbiterNetDevice to be utilized in geostationary satellite.
Base class for delay statistics helpers.
CollectorMap m_terminalCollectors
Maintains a list of collectors created by this helper.
void InstallProbes()
Set up several probes or other means of listeners and connect them to the collectors.
void SetAveragingMode(bool averagingMode)
void DoInstall()
Install the probes, collectors, and aggregators necessary to produce the statistics output.
void RxDelayCallback(const Time &delay, const Address &from)
Receive inputs from trace sources and determine the right collector to forward the inputs to.
virtual void DoInstallProbes()=0
void PassSampleToCollector(const Time &delay, uint32_t identifier)
Find a collector with the right identifier and pass a sample data to it.
Ptr< DataCollectionObject > m_aggregator
The aggregator created by this helper.
static TypeId GetTypeId()
inherited from ObjectBase base class
bool m_averagingMode
AveragingMode attribute.
Ptr< DistributionCollector > m_averagingCollector
The final collector utilized in averaged output (histogram, PDF, and CDF).
bool DisconnectProbeFromCollector(Ptr< Probe > probe, uint32_t identifier)
Disconnect the probe from the right collector.
SatStatsDelayHelper(Ptr< const SatHelper > satHelper)
virtual ~SatStatsDelayHelper()
/ Destructor.
bool GetAveragingMode() const
bool ConnectProbeToCollector(Ptr< Probe > probe, uint32_t identifier)
Connect the probe to the right collector.
Produce forward link application-level delay statistics from a satellite module simulation.
static TypeId GetTypeId()
inherited from ObjectBase base class
virtual void UpdateIdentifierOnProbes()
Change identifier used on probes, when handovers occur.
static void RxCallback(Ptr< SatStatsFwdAppDelayHelper > helper, uint32_t identifier, Ptr< const Packet > packet, const Address &from)
Receive inputs from trace sources and determine the right collector to forward the inputs to.
SatStatsFwdAppDelayHelper(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 ~SatStatsFwdAppDelayHelper()
Destructor for SatStatsFwdAppDelayHelper.
Produce forward link device-level delay statistics from a satellite module simulation.
SatStatsFwdDevDelayHelper(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
virtual ~SatStatsFwdDevDelayHelper()
/ Destructor.
Produce forward link MAC-level delay 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.
SatStatsFwdMacDelayHelper(Ptr< const SatHelper > satHelper)
static TypeId GetTypeId()
inherited from ObjectBase base class
virtual void UpdateIdentifierOnProbes()
Change identifier used on probes, when handovers occur.
virtual ~SatStatsFwdMacDelayHelper()
/ Destructor.
Produce forward link PHY-level delay statistics from a satellite module simulation.
virtual void UpdateIdentifierOnProbes()
Change identifier used on probes, when handovers occur.
std::map< Ptr< Probe >, std::pair< Ptr< Node >, uint32_t > > m_probes
Maintains a list of probes created by this helper.
static TypeId GetTypeId()
inherited from ObjectBase base class
virtual ~SatStatsFwdPhyDelayHelper()
/ Destructor.
SatStatsFwdPhyDelayHelper(Ptr< const SatHelper > satHelper)
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 delay statistics from a satellite module simulation.
static TypeId GetTypeId()
inherited from ObjectBase base class
virtual ~SatStatsRtnAppDelayHelper()
/ Destructor.
void Ipv4Callback(const Time &delay, const Address &from)
Receive inputs from trace sources and determine the right collector to forward the inputs to.
void RxCallback(Ptr< const Packet > packet, const Address &from)
Receive inputs from trace sources and determine the right collector to forward the inputs to.
SatStatsRtnAppDelayHelper(Ptr< const SatHelper > satHelper)
void SaveIpv4AddressAndIdentifier(Ptr< Node > utUserNode)
Save the IPv4 address and the proper identifier from the given UT user node.
Produce return link device-level delay statistics from a satellite module simulation.
SatStatsRtnDevDelayHelper(Ptr< const SatHelper > satHelper)
static TypeId GetTypeId()
inherited from ObjectBase base class
virtual ~SatStatsRtnDevDelayHelper()
/ Destructor.
Produce return link MAC-level delay statistics from a satellite module simulation.
SatStatsRtnMacDelayHelper(Ptr< const SatHelper > satHelper)
static TypeId GetTypeId()
inherited from ObjectBase base class
virtual ~SatStatsRtnMacDelayHelper()
/ Destructor.
Produce return link PHY-level delay statistics from a satellite module simulation.
static TypeId GetTypeId()
inherited from ObjectBase base class
SatStatsRtnPhyDelayHelper(Ptr< const SatHelper > satHelper)
virtual ~SatStatsRtnPhyDelayHelper()
/ Destructor.
SatArqSequenceNumber is handling the sequence numbers for the ARQ process.