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>
40 #include <ns3/probe.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>
60 NS_LOG_COMPONENT_DEFINE(
"SatStatsJitterHelper");
65 NS_OBJECT_ENSURE_REGISTERED(SatStatsJitterHelper);
69 m_averagingMode(false)
71 NS_LOG_FUNCTION(
this << satHelper);
76 NS_LOG_FUNCTION(
this);
83 TypeId(
"ns3::SatStatsJitterHelper")
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 jitter (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 jitter (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 jitter (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(
"SatStatsJitterHelper - Invalid output type");
426 if (from.IsInvalid())
428 NS_LOG_WARN(
this <<
" discarding a packet jitter of " << jitter.GetSeconds()
429 <<
" from statistics collection because of"
430 <<
" invalid sender address");
435 std::map<const Address, uint32_t>::const_iterator it =
m_identifierMap.find(from);
443 NS_LOG_WARN(
this <<
" discarding a packet jitter of " << jitter.GetSeconds()
444 <<
" from statistics collection because of"
445 <<
" unknown sender address " << from);
453 NS_LOG_FUNCTION(
this << probe << probe->GetName() << identifier);
463 &ScalarCollector::TraceSinkDouble);
471 &UnitConversionCollector::TraceSinkDouble);
485 &ScalarCollector::TraceSinkDouble);
492 &DistributionCollector::TraceSinkDouble);
498 <<
" is not a valid output type for this statistics.");
504 NS_LOG_INFO(
this <<
" created probe " << probe->GetName() <<
", connected to collector "
509 NS_LOG_WARN(
this <<
" unable to connect probe " << probe->GetName() <<
" to collector "
519 NS_LOG_FUNCTION(
this << probe << probe->GetName() << identifier);
529 &ScalarCollector::TraceSinkDouble);
537 &UnitConversionCollector::TraceSinkDouble);
551 &ScalarCollector::TraceSinkDouble);
558 &DistributionCollector::TraceSinkDouble);
564 <<
" is not a valid output type for this statistics.");
570 NS_LOG_INFO(
this <<
" probe " << probe->GetName() <<
", disconnected from collector "
575 NS_LOG_WARN(
this <<
" unable to disconnect probe " << probe->GetName() <<
" from collector "
588 NS_ASSERT_MSG(collector !=
nullptr,
"Unable to find collector with identifier " << identifier);
594 Ptr<ScalarCollector> c = collector->GetObject<ScalarCollector>();
595 NS_ASSERT(c !=
nullptr);
596 c->TraceSinkDouble(0.0, jitter.GetSeconds());
602 Ptr<UnitConversionCollector> c = collector->GetObject<UnitConversionCollector>();
603 NS_ASSERT(c !=
nullptr);
604 c->TraceSinkDouble(0.0, jitter.GetSeconds());
616 Ptr<ScalarCollector> c = collector->GetObject<ScalarCollector>();
617 NS_ASSERT(c !=
nullptr);
618 c->TraceSinkDouble(0.0, jitter.GetSeconds());
622 Ptr<DistributionCollector> c = collector->GetObject<DistributionCollector>();
623 NS_ASSERT(c !=
nullptr);
624 c->TraceSinkDouble(0.0, jitter.GetSeconds());
630 <<
" is not a valid output type for this statistics.");
644 NS_LOG_FUNCTION(
this << satHelper);
649 NS_LOG_FUNCTION(
this);
655 static TypeId tid = TypeId(
"ns3::SatStatsFwdAppJitterHelper").SetParent<
SatStatsJitterHelper>();
662 NS_LOG_FUNCTION(
this);
663 NodeContainer utUsers = Singleton<SatTopology>::Get()->GetUtUserNodes();
665 for (NodeContainer::Iterator it = utUsers.Begin(); it != utUsers.End(); ++it)
668 NS_ASSERT_MSG(utUserId > 0,
"Node " << (*it)->GetId() <<
" is not a valid UT user");
671 for (uint32_t i = 0; i < (*it)->GetNApplications(); i++)
673 Ptr<Application> app = (*it)->GetApplication(i);
674 bool isConnected =
false;
680 if (app->GetInstanceTypeId().LookupTraceSourceByName(
"RxJitter") !=
nullptr)
682 NS_LOG_INFO(
this <<
" attempt to connect using RxJitter");
685 std::ostringstream probeName;
686 probeName << utUserId <<
"-" << i;
687 Ptr<ApplicationDelayProbe> probe = CreateObject<ApplicationDelayProbe>();
688 probe->SetName(probeName.str());
691 if (probe->ConnectByObject(
"RxJitter", app))
695 std::make_pair(probe->GetObject<Probe>(), std::make_pair(*it, identifier)));
698 else if (app->GetInstanceTypeId().LookupTraceSourceByName(
"Rx") !=
nullptr)
700 NS_LOG_INFO(
this <<
" attempt to connect using Rx");
701 Callback<void, Ptr<const Packet>,
const Address&> rxCallback =
703 isConnected = app->TraceConnectWithoutContext(
"Rx", rxCallback);
708 NS_LOG_INFO(
this <<
" successfully connected"
709 <<
" with node ID " << (*it)->GetId() <<
" application #" << i);
718 NS_LOG_WARN(
this <<
" unable to connect"
719 <<
" with node ID " << (*it)->GetId() <<
" application #" << i);
730 NodeContainer gwUsers = Singleton<SatTopology>::Get()->GetGwUserNodes();
731 for (NodeContainer::Iterator it = gwUsers.Begin(); it != gwUsers.End(); ++it)
733 for (uint32_t i = 0; i < (*it)->GetNApplications(); i++)
735 Ptr<Application> app = (*it)->GetApplication(i);
737 if (!app->SetAttributeFailSafe(
"EnableStatisticsTags", BooleanValue(
true)))
739 NS_LOG_WARN(
this <<
" node ID " << (*it)->GetId() <<
" application #" << i
740 <<
" might not produce the required tags"
741 <<
" in the packets it transmits,"
742 <<
" thus preventing jitter statistics"
743 <<
" from this application");
755 NS_LOG_FUNCTION(
this);
757 std::map<Ptr<Probe>, std::pair<Ptr<Node>, uint32_t>>::iterator it;
761 Ptr<Probe> probe = it->first;
762 Ptr<Node> node = it->second.first;
763 uint32_t identifier = it->second.second;
767 NS_FATAL_ERROR(
"Error disconnecting trace file on handover");
774 NS_FATAL_ERROR(
"Error connecting trace file on handover");
777 it->second.second = identifier;
784 NS_LOG_FUNCTION(identifier);
786 Time delay = Seconds(0);
799 Ptr<const Packet> packet,
802 NS_LOG_FUNCTION(helper << identifier << packet << packet->GetSize() << from);
804 TrafficTimeTag timeTag;
805 if (packet->PeekPacketTag(timeTag))
807 NS_LOG_DEBUG(
"Contains a TrafficTimeTag tag");
808 const Time delay = Simulator::Now() - timeTag.GetSenderTimestamp();
809 Time previousDelay = helper->GetAndUpdatePreviousDelay(identifier, delay);
810 if (previousDelay.IsZero() ==
false)
812 Time jitter = Abs(delay - previousDelay);
813 helper->PassSampleToCollector(jitter, identifier);
818 NS_LOG_WARN(
"Discarding a packet of " << packet->GetSize() <<
" from statistics collection"
819 <<
" because it does not contain any TrafficTimeTag");
830 NS_LOG_FUNCTION(
this << satHelper);
835 NS_LOG_FUNCTION(
this);
841 static TypeId tid = TypeId(
"ns3::SatStatsFwdDevJitterHelper").SetParent<
SatStatsJitterHelper>();
848 NS_LOG_FUNCTION(
this);
849 NodeContainer uts = Singleton<SatTopology>::Get()->GetUtNodes();
851 for (NodeContainer::Iterator it = uts.Begin(); it != uts.End(); ++it)
853 const int32_t utId =
GetUtId(*it);
854 NS_ASSERT_MSG(utId > 0,
"Node " << (*it)->GetId() <<
" is not a valid UT");
858 std::ostringstream probeName;
860 Ptr<ApplicationDelayProbe> probe = CreateObject<ApplicationDelayProbe>();
861 probe->SetName(probeName.str());
869 std::make_pair(probe->GetObject<Probe>(), std::make_pair(*it, identifier)));
872 dev->SetAttribute(
"EnableStatisticsTags", BooleanValue(
true));
876 NS_FATAL_ERROR(
"Error connecting to RxJitter trace source of SatNetDevice"
877 <<
" at node ID " << (*it)->GetId() <<
" device #2");
883 NodeContainer gws = Singleton<SatTopology>::Get()->GetGwNodes();
884 for (NodeContainer::Iterator it = gws.Begin(); it != gws.End(); ++it)
888 for (NetDeviceContainer::Iterator itDev = devs.Begin(); itDev != devs.End(); ++itDev)
890 NS_ASSERT((*itDev)->GetObject<
SatNetDevice>() !=
nullptr);
891 (*itDev)->SetAttribute(
"EnableStatisticsTags", BooleanValue(
true));
900 NS_LOG_FUNCTION(
this);
902 std::map<Ptr<Probe>, std::pair<Ptr<Node>, uint32_t>>::iterator it;
906 Ptr<Probe> probe = it->first;
907 Ptr<Node> node = it->second.first;
908 uint32_t identifier = it->second.second;
912 NS_FATAL_ERROR(
"Error disconnecting trace file on handover");
919 NS_FATAL_ERROR(
"Error connecting trace file on handover");
922 it->second.second = identifier;
933 NS_LOG_FUNCTION(
this << satHelper);
938 NS_LOG_FUNCTION(
this);
944 static TypeId tid = TypeId(
"ns3::SatStatsFwdMacJitterHelper").SetParent<
SatStatsJitterHelper>();
951 NS_LOG_FUNCTION(
this);
952 NodeContainer uts = Singleton<SatTopology>::Get()->GetUtNodes();
954 for (NodeContainer::Iterator it = uts.Begin(); it != uts.End(); ++it)
956 const int32_t utId =
GetUtId(*it);
957 NS_ASSERT_MSG(utId > 0,
"Node " << (*it)->GetId() <<
" is not a valid UT");
961 std::ostringstream probeName;
963 Ptr<ApplicationDelayProbe> probe = CreateObject<ApplicationDelayProbe>();
964 probe->SetName(probeName.str());
967 Ptr<SatNetDevice> satDev = dev->GetObject<
SatNetDevice>();
968 NS_ASSERT(satDev !=
nullptr);
969 Ptr<SatMac> satMac = satDev->GetMac();
970 NS_ASSERT(satMac !=
nullptr);
973 if (probe->ConnectByObject(
"RxJitter", satMac) &&
977 std::make_pair(probe->GetObject<Probe>(), std::make_pair(*it, identifier)));
980 satDev->SetAttribute(
"EnableStatisticsTags", BooleanValue(
true));
981 satMac->SetAttribute(
"EnableStatisticsTags", BooleanValue(
true));
985 NS_FATAL_ERROR(
"Error connecting to RxJitter trace source of satMac"
986 <<
" at node ID " << (*it)->GetId() <<
" device #2");
992 NodeContainer gws = Singleton<SatTopology>::Get()->GetGwNodes();
993 for (NodeContainer::Iterator it = gws.Begin(); it != gws.End(); ++it)
997 for (NetDeviceContainer::Iterator itDev = devs.Begin(); itDev != devs.End(); ++itDev)
999 Ptr<SatNetDevice> satDev = (*itDev)->GetObject<
SatNetDevice>();
1000 NS_ASSERT(satDev !=
nullptr);
1001 Ptr<SatMac> satMac = satDev->GetMac();
1002 NS_ASSERT(satMac !=
nullptr);
1004 satDev->SetAttribute(
"EnableStatisticsTags", BooleanValue(
true));
1005 satMac->SetAttribute(
"EnableStatisticsTags", BooleanValue(
true));
1014 NS_LOG_FUNCTION(
this);
1016 std::map<Ptr<Probe>, std::pair<Ptr<Node>, uint32_t>>::iterator it;
1020 Ptr<Probe> probe = it->first;
1021 Ptr<Node> node = it->second.first;
1022 uint32_t identifier = it->second.second;
1026 NS_FATAL_ERROR(
"Error disconnecting trace file on handover");
1033 NS_FATAL_ERROR(
"Error connecting trace file on handover");
1036 it->second.second = identifier;
1047 NS_LOG_FUNCTION(
this << satHelper);
1052 NS_LOG_FUNCTION(
this);
1058 static TypeId tid = TypeId(
"ns3::SatStatsFwdPhyJitterHelper").SetParent<
SatStatsJitterHelper>();
1065 NS_LOG_FUNCTION(
this);
1067 NodeContainer sats = Singleton<SatTopology>::Get()->GetOrbiterNodes();
1069 for (NodeContainer::Iterator it = sats.Begin(); it != sats.End(); ++it)
1073 NS_ASSERT(satOrbiterDev !=
nullptr);
1074 std::map<uint32_t, Ptr<SatPhy>> satOrbiterFeederPhys = satOrbiterDev->GetFeederPhy();
1076 for (std::map<uint32_t, Ptr<SatPhy>>::iterator it2 = satOrbiterFeederPhys.begin();
1077 it2 != satOrbiterFeederPhys.end();
1080 satPhy = it2->second;
1081 satPhy->SetAttribute(
"EnableStatisticsTags", BooleanValue(
true));
1083 std::map<uint32_t, Ptr<SatPhy>> satOrbiterUserPhys = satOrbiterDev->GetUserPhy();
1084 for (std::map<uint32_t, Ptr<SatPhy>>::iterator it2 = satOrbiterUserPhys.begin();
1085 it2 != satOrbiterUserPhys.end();
1088 satPhy = it2->second;
1089 satPhy->SetAttribute(
"EnableStatisticsTags", BooleanValue(
true));
1093 NodeContainer uts = Singleton<SatTopology>::Get()->GetUtNodes();
1095 for (NodeContainer::Iterator it = uts.Begin(); it != uts.End(); ++it)
1097 const int32_t utId =
GetUtId(*it);
1098 NS_ASSERT_MSG(utId > 0,
"Node " << (*it)->GetId() <<
" is not a valid UT");
1102 std::ostringstream probeName;
1104 Ptr<ApplicationDelayProbe> probe = CreateObject<ApplicationDelayProbe>();
1105 probe->SetName(probeName.str());
1108 Ptr<SatNetDevice> satDev = dev->GetObject<
SatNetDevice>();
1109 NS_ASSERT(satDev !=
nullptr);
1110 Ptr<SatPhy> satPhy = satDev->GetPhy();
1111 NS_ASSERT(satPhy !=
nullptr);
1114 if (probe->ConnectByObject(
"RxJitter", satPhy) &&
1118 std::make_pair(probe->GetObject<Probe>(), std::make_pair(*it, identifier)));
1121 satDev->SetAttribute(
"EnableStatisticsTags", BooleanValue(
true));
1122 satPhy->SetAttribute(
"EnableStatisticsTags", BooleanValue(
true));
1126 NS_FATAL_ERROR(
"Error connecting to RxJitter trace source of SatPhy"
1127 <<
" at node ID " << (*it)->GetId() <<
" device #2");
1133 NodeContainer gws = Singleton<SatTopology>::Get()->GetGwNodes();
1134 for (NodeContainer::Iterator it = gws.Begin(); it != gws.End(); ++it)
1138 for (NetDeviceContainer::Iterator itDev = devs.Begin(); itDev != devs.End(); ++itDev)
1140 Ptr<SatNetDevice> satDev = (*itDev)->GetObject<
SatNetDevice>();
1141 NS_ASSERT(satDev !=
nullptr);
1142 Ptr<SatPhy> satPhy = satDev->GetPhy();
1143 NS_ASSERT(satPhy !=
nullptr);
1145 satDev->SetAttribute(
"EnableStatisticsTags", BooleanValue(
true));
1146 satPhy->SetAttribute(
"EnableStatisticsTags", BooleanValue(
true));
1155 NS_LOG_FUNCTION(
this);
1157 std::map<Ptr<Probe>, std::pair<Ptr<Node>, uint32_t>>::iterator it;
1161 Ptr<Probe> probe = it->first;
1162 Ptr<Node> node = it->second.first;
1163 uint32_t identifier = it->second.second;
1167 NS_FATAL_ERROR(
"Error disconnecting trace file on handover");
1174 NS_FATAL_ERROR(
"Error connecting trace file on handover");
1177 it->second.second = identifier;
1188 NS_LOG_FUNCTION(
this << satHelper);
1193 NS_LOG_FUNCTION(
this);
1199 static TypeId tid = TypeId(
"ns3::SatStatsRtnAppJitterHelper").SetParent<
SatStatsJitterHelper>();
1206 NS_LOG_FUNCTION(
this);
1208 NodeContainer utUsers = Singleton<SatTopology>::Get()->GetUtUserNodes();
1209 for (NodeContainer::Iterator it = utUsers.Begin(); it != utUsers.End(); ++it)
1218 for (uint32_t i = 0; i < (*it)->GetNApplications(); i++)
1220 Ptr<Application> app = (*it)->GetApplication(i);
1222 if (!app->SetAttributeFailSafe(
"EnableStatisticsTags", BooleanValue(
true)))
1224 NS_LOG_WARN(
this <<
" node ID " << (*it)->GetId() <<
" application #" << i
1225 <<
" might not produce the required tags"
1226 <<
" in the transmitted packets,"
1227 <<
" thus preventing jitter statistics"
1228 <<
" from this sender application");
1237 NodeContainer gwUsers = Singleton<SatTopology>::Get()->GetGwUserNodes();
1238 Callback<void, const Time&, const Address&> rxJitterCallback =
1240 Callback<void, Ptr<const Packet>,
const Address&> rxCallback =
1243 for (NodeContainer::Iterator it = gwUsers.Begin(); it != gwUsers.End(); ++it)
1245 for (uint32_t i = 0; i < (*it)->GetNApplications(); i++)
1247 Ptr<Application> app = (*it)->GetApplication(i);
1248 bool isConnected =
false;
1254 if (app->GetInstanceTypeId().LookupTraceSourceByName(
"RxJitter") !=
nullptr)
1256 isConnected = app->TraceConnectWithoutContext(
"RxJitter", rxJitterCallback);
1258 else if (app->GetInstanceTypeId().LookupTraceSourceByName(
"Rx") !=
nullptr)
1260 isConnected = app->TraceConnectWithoutContext(
"Rx", rxCallback);
1265 NS_LOG_INFO(
this <<
" successfully connected"
1266 <<
" with node ID " << (*it)->GetId() <<
" application #" << i);
1275 NS_LOG_WARN(
this <<
" unable to connect"
1276 <<
" with node ID " << (*it)->GetId() <<
" application #" << i);
1288 TrafficTimeTag timeTag;
1289 if (packet->PeekPacketTag(timeTag))
1291 NS_LOG_DEBUG(
this <<
" contains a TrafficTimeTag tag");
1292 const Time delay = Simulator::Now() - timeTag.GetSenderTimestamp();
1293 const Address identifier = InetSocketAddress::ConvertFrom(from).GetIpv4();
1297 Time previousDelay = it->second;
1298 Time jitter = Abs(delay - previousDelay);
1305 NS_LOG_WARN(
this <<
" discarding a packet of " << packet->GetSize()
1306 <<
" from statistics collection"
1307 <<
" because it does not contain any TrafficTimeTag");
1316 if (InetSocketAddress::IsMatchingType(from))
1319 const Address ipv4Addr = InetSocketAddress::ConvertFrom(from).GetIpv4();
1320 std::map<const Address, uint32_t>::const_iterator it1 =
m_identifierMap.find(ipv4Addr);
1324 NS_LOG_WARN(
this <<
" discarding a packet jitter of " << jitter.GetSeconds()
1325 <<
" from statistics collection because of"
1326 <<
" unknown sender IPV4 address " << ipv4Addr);
1335 NS_LOG_WARN(
this <<
" discarding a packet jitter of " << jitter.GetSeconds()
1336 <<
" from statistics collection"
1337 <<
" because it comes from sender " << from
1338 <<
" without valid InetSocketAddress");
1345 NS_LOG_FUNCTION(
this << utUserNode->GetId());
1347 Ptr<Ipv4> ipv4 = utUserNode->GetObject<Ipv4>();
1349 if (ipv4 ==
nullptr)
1351 NS_LOG_INFO(
this <<
" Node " << utUserNode->GetId() <<
" does not support IPv4 protocol");
1353 else if (ipv4->GetNInterfaces() >= 2)
1361 for (uint32_t i = 0; i < ipv4->GetNAddresses(1); i++)
1363 const Address addr = ipv4->GetAddress(1, i).GetLocal();
1365 NS_LOG_INFO(
this <<
" associated address " << addr <<
" with identifier "
1371 NS_LOG_WARN(
this <<
" Node " << utUserNode->GetId() <<
" is not a valid UT user");
1382 NS_LOG_FUNCTION(
this << satHelper);
1387 NS_LOG_FUNCTION(
this);
1393 static TypeId tid = TypeId(
"ns3::SatStatsRtnDevJitterHelper").SetParent<
SatStatsJitterHelper>();
1400 NS_LOG_FUNCTION(
this);
1402 NodeContainer uts = Singleton<SatTopology>::Get()->GetUtNodes();
1403 for (NodeContainer::Iterator it = uts.Begin(); it != uts.End(); ++it)
1410 dev->SetAttribute(
"EnableStatisticsTags", BooleanValue(
true));
1415 NodeContainer gws = Singleton<SatTopology>::Get()->GetGwNodes();
1416 Callback<void, const Time&, const Address&> callback =
1419 for (NodeContainer::Iterator it = gws.Begin(); it != gws.End(); ++it)
1423 for (NetDeviceContainer::Iterator itDev = devs.Begin(); itDev != devs.End(); ++itDev)
1425 NS_ASSERT((*itDev)->GetObject<
SatNetDevice>() !=
nullptr);
1427 if ((*itDev)->TraceConnectWithoutContext(
"RxJitter", callback))
1429 NS_LOG_INFO(
this <<
" successfully connected with node ID " << (*it)->GetId()
1430 <<
" device #" << (*itDev)->GetIfIndex());
1433 (*itDev)->SetAttribute(
"EnableStatisticsTags", BooleanValue(
true));
1437 NS_FATAL_ERROR(
"Error connecting to RxJitter trace source of SatNetDevice"
1438 <<
" at node ID " << (*it)->GetId() <<
" device #"
1439 << (*itDev)->GetIfIndex());
1455 NS_LOG_FUNCTION(
this << satHelper);
1460 NS_LOG_FUNCTION(
this);
1466 static TypeId tid = TypeId(
"ns3::SatStatsRtnMacJitterHelper").SetParent<
SatStatsJitterHelper>();
1473 NS_LOG_FUNCTION(
this);
1475 NodeContainer uts = Singleton<SatTopology>::Get()->GetUtNodes();
1476 for (NodeContainer::Iterator it = uts.Begin(); it != uts.End(); ++it)
1483 Ptr<SatNetDevice> satDev = dev->GetObject<
SatNetDevice>();
1484 NS_ASSERT(satDev !=
nullptr);
1485 Ptr<SatMac> satMac = satDev->GetMac();
1486 NS_ASSERT(satMac !=
nullptr);
1487 satDev->SetAttribute(
"EnableStatisticsTags", BooleanValue(
true));
1488 satMac->SetAttribute(
"EnableStatisticsTags", BooleanValue(
true));
1493 NodeContainer gws = Singleton<SatTopology>::Get()->GetGwNodes();
1494 Callback<void, const Time&, const Address&> callback =
1497 for (NodeContainer::Iterator it = gws.Begin(); it != gws.End(); ++it)
1501 for (NetDeviceContainer::Iterator itDev = devs.Begin(); itDev != devs.End(); ++itDev)
1503 Ptr<SatNetDevice> satDev = (*itDev)->GetObject<
SatNetDevice>();
1504 NS_ASSERT(satDev !=
nullptr);
1505 Ptr<SatMac> satMac = satDev->GetMac();
1506 NS_ASSERT(satMac !=
nullptr);
1509 if (satMac->TraceConnectWithoutContext(
"RxJitter", callback))
1511 NS_LOG_INFO(
this <<
" successfully connected with node ID " << (*it)->GetId()
1512 <<
" device #" << satDev->GetIfIndex());
1515 satDev->SetAttribute(
"EnableStatisticsTags", BooleanValue(
true));
1516 satMac->SetAttribute(
"EnableStatisticsTags", BooleanValue(
true));
1520 NS_FATAL_ERROR(
"Error connecting to RxJitter trace source of SatNetDevice"
1521 <<
" at node ID " << (*it)->GetId() <<
" device #"
1522 << satDev->GetIfIndex());
1538 NS_LOG_FUNCTION(
this << satHelper);
1543 NS_LOG_FUNCTION(
this);
1549 static TypeId tid = TypeId(
"ns3::SatStatsRtnPhyJitterHelper").SetParent<
SatStatsJitterHelper>();
1556 NS_LOG_FUNCTION(
this);
1558 NodeContainer sats = Singleton<SatTopology>::Get()->GetOrbiterNodes();
1560 for (NodeContainer::Iterator it = sats.Begin(); it != sats.End(); ++it)
1564 NS_ASSERT(satOrbiterDev !=
nullptr);
1565 std::map<uint32_t, Ptr<SatPhy>> satOrbiterFeederPhys = satOrbiterDev->GetFeederPhy();
1567 for (std::map<uint32_t, Ptr<SatPhy>>::iterator it2 = satOrbiterFeederPhys.begin();
1568 it2 != satOrbiterFeederPhys.end();
1571 satPhy = it2->second;
1572 satPhy->SetAttribute(
"EnableStatisticsTags", BooleanValue(
true));
1574 std::map<uint32_t, Ptr<SatPhy>> satOrbiterUserPhys = satOrbiterDev->GetUserPhy();
1575 for (std::map<uint32_t, Ptr<SatPhy>>::iterator it2 = satOrbiterUserPhys.begin();
1576 it2 != satOrbiterUserPhys.end();
1579 satPhy = it2->second;
1580 satPhy->SetAttribute(
"EnableStatisticsTags", BooleanValue(
true));
1584 NodeContainer uts = Singleton<SatTopology>::Get()->GetUtNodes();
1585 for (NodeContainer::Iterator it = uts.Begin(); it != uts.End(); ++it)
1592 Ptr<SatNetDevice> satDev = dev->GetObject<
SatNetDevice>();
1593 NS_ASSERT(satDev !=
nullptr);
1594 Ptr<SatPhy> satPhy = satDev->GetPhy();
1595 NS_ASSERT(satPhy !=
nullptr);
1596 satDev->SetAttribute(
"EnableStatisticsTags", BooleanValue(
true));
1597 satPhy->SetAttribute(
"EnableStatisticsTags", BooleanValue(
true));
1602 NodeContainer gws = Singleton<SatTopology>::Get()->GetGwNodes();
1603 Callback<void, const Time&, const Address&> callback =
1606 for (NodeContainer::Iterator it = gws.Begin(); it != gws.End(); ++it)
1610 for (NetDeviceContainer::Iterator itDev = devs.Begin(); itDev != devs.End(); ++itDev)
1612 Ptr<SatNetDevice> satDev = (*itDev)->GetObject<
SatNetDevice>();
1613 NS_ASSERT(satDev !=
nullptr);
1614 Ptr<SatPhy> satPhy = satDev->GetPhy();
1615 NS_ASSERT(satPhy !=
nullptr);
1618 if (satPhy->TraceConnectWithoutContext(
"RxJitter", callback))
1620 NS_LOG_INFO(
this <<
" successfully connected with node ID " << (*it)->GetId()
1621 <<
" device #" << satDev->GetIfIndex());
1624 satDev->SetAttribute(
"EnableStatisticsTags", BooleanValue(
true));
1625 satPhy->SetAttribute(
"EnableStatisticsTags", BooleanValue(
true));
1629 NS_FATAL_ERROR(
"Error connecting to RxJitter trace source of SatNetDevice"
1630 <<
" at node ID " << (*it)->GetId() <<
" device #"
1631 << satDev->GetIfIndex());
SatNetDevice to be utilized in the UT and GW nodes.
SatOrbiterNetDevice to be utilized in geostationary satellite.
Time GetAndUpdatePreviousDelay(uint32_t identifier, Time newDelay)
Returns the previous delay mesurment for given identifier, and update with new value measured.
std::map< uint32_t, Time > m_previousDelayMap
Stores the last delay to a UT to compute jitter.
static TypeId GetTypeId()
inherited from ObjectBase base class
virtual void UpdateIdentifierOnProbes()
Change identifier used on probes, when handovers occur.
SatStatsFwdAppJitterHelper(Ptr< const SatHelper > satHelper)
virtual ~SatStatsFwdAppJitterHelper()
Destructor for SatStatsFwdAppJitterHelper.
std::map< Ptr< Probe >, std::pair< Ptr< Node >, uint32_t > > m_probes
Maintains a list of probes created by this helper.
static void RxCallback(Ptr< SatStatsFwdAppJitterHelper > 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.
static TypeId GetTypeId()
inherited from ObjectBase base class
SatStatsFwdDevJitterHelper(Ptr< const SatHelper > satHelper)
virtual void UpdateIdentifierOnProbes()
Change identifier used on probes, when handovers occur.
virtual ~SatStatsFwdDevJitterHelper()
/ Destructor.
std::map< Ptr< Probe >, std::pair< Ptr< Node >, uint32_t > > m_probes
Maintains a list of probes created by this helper.
virtual ~SatStatsFwdMacJitterHelper()
/ Destructor.
SatStatsFwdMacJitterHelper(Ptr< const SatHelper > satHelper)
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
static TypeId GetTypeId()
inherited from ObjectBase base class
SatStatsFwdPhyJitterHelper(Ptr< const SatHelper > satHelper)
virtual ~SatStatsFwdPhyJitterHelper()
/ Destructor.
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.
Parent abstract class of all satellite statistics helpers.
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)
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
Base class for jitter statistics helpers.
bool m_averagingMode
AveragingMode attribute.
bool DisconnectProbeFromCollector(Ptr< Probe > probe, uint32_t identifier)
Disconnect the probe from the right collector.
static TypeId GetTypeId()
inherited from ObjectBase base class
SatStatsJitterHelper(Ptr< const SatHelper > satHelper)
void RxJitterCallback(const Time &jitter, const Address &from)
Receive inputs from trace sources and determine the right collector to forward the inputs to.
void PassSampleToCollector(const Time &jitter, uint32_t identifier)
Find a collector with the right identifier and pass a sample data to it.
bool ConnectProbeToCollector(Ptr< Probe > probe, uint32_t identifier)
Connect the probe to the right collector.
Ptr< DataCollectionObject > m_aggregator
The aggregator created by this helper.
virtual void DoInstallProbes()=0
void SetAveragingMode(bool averagingMode)
CollectorMap m_terminalCollectors
Maintains a list of collectors created by this helper.
virtual ~SatStatsJitterHelper()
/ Destructor.
bool GetAveragingMode() const
void DoInstall()
Install the probes, collectors, and aggregators necessary to produce the statistics output.
void InstallProbes()
Set up several probes or other means of listeners and connect them to the collectors.
Ptr< DistributionCollector > m_averagingCollector
The final collector utilized in averaged output (histogram, PDF, and CDF).
void SaveIpv4AddressAndIdentifier(Ptr< Node > utUserNode)
static TypeId GetTypeId()
inherited from ObjectBase base class
std::map< const Address, Time > m_previousDelayMap
Stores the last delay to a UT to compute jitter.
virtual ~SatStatsRtnAppJitterHelper()
/ Destructor.
void RxCallback(Ptr< const Packet > packet, const Address &from)
Receive inputs from trace sources and determine the right collector to forward the inputs to.
SatStatsRtnAppJitterHelper(Ptr< const SatHelper > satHelper)
void Ipv4Callback(const Time &jitter, const Address &from)
Receive inputs from trace sources and determine the right collector to forward the inputs to.
SatStatsRtnDevJitterHelper(Ptr< const SatHelper > satHelper)
virtual ~SatStatsRtnDevJitterHelper()
/ Destructor.
static TypeId GetTypeId()
inherited from ObjectBase base class
virtual ~SatStatsRtnMacJitterHelper()
/ Destructor.
SatStatsRtnMacJitterHelper(Ptr< const SatHelper > satHelper)
static TypeId GetTypeId()
inherited from ObjectBase base class
virtual ~SatStatsRtnPhyJitterHelper()
/ Destructor.
SatStatsRtnPhyJitterHelper(Ptr< const SatHelper > satHelper)
static TypeId GetTypeId()
inherited from ObjectBase base class
SatArqSequenceNumber is handling the sequence numbers for the ARQ process.