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(
"SatStatsJitterHelper");
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" <<
" 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 jitter of " << jitter.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, jitter.GetSeconds());
601 Ptr<UnitConversionCollector> c = collector->GetObject<UnitConversionCollector>();
602 NS_ASSERT(c !=
nullptr);
603 c->TraceSinkDouble(0.0, jitter.GetSeconds());
615 Ptr<ScalarCollector> c = collector->GetObject<ScalarCollector>();
616 NS_ASSERT(c !=
nullptr);
617 c->TraceSinkDouble(0.0, jitter.GetSeconds());
621 Ptr<DistributionCollector> c = collector->GetObject<DistributionCollector>();
622 NS_ASSERT(c !=
nullptr);
623 c->TraceSinkDouble(0.0, jitter.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::SatStatsFwdAppJitterHelper").SetParent<
SatStatsJitterHelper>();
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(
"RxJitter") !=
nullptr)
681 NS_LOG_INFO(
this <<
" attempt to connect using RxJitter");
684 std::ostringstream probeName;
685 probeName << utUserId <<
"-" << i;
686 Ptr<ApplicationDelayProbe> probe = CreateObject<ApplicationDelayProbe>();
687 probe->SetName(probeName.str());
690 if (probe->ConnectByObject(
"RxJitter", 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 jitter statistics"
742 <<
" from this application");
754 NS_LOG_FUNCTION(
this);
756 std::map<Ptr<Probe>, std::pair<Ptr<Node>, uint32_t>>::iterator it;
760 Ptr<Probe> probe = it->first;
761 Ptr<Node> node = it->second.first;
762 uint32_t identifier = it->second.second;
766 NS_FATAL_ERROR(
"Error disconnecting trace file on handover");
773 NS_FATAL_ERROR(
"Error connecting trace file on handover");
776 it->second.second = identifier;
783 NS_LOG_FUNCTION(identifier);
785 Time delay = Seconds(0);
798 Ptr<const Packet> packet,
801 NS_LOG_FUNCTION(helper << identifier << packet << packet->GetSize() << from);
803 TrafficTimeTag timeTag;
804 if (packet->PeekPacketTag(timeTag))
806 NS_LOG_DEBUG(
"Contains a TrafficTimeTag tag");
807 const Time delay = Simulator::Now() - timeTag.GetSenderTimestamp();
808 Time previousDelay = helper->GetAndUpdatePreviousDelay(identifier, delay);
809 if (previousDelay.IsZero() ==
false)
811 Time jitter = Abs(delay - previousDelay);
812 helper->PassSampleToCollector(jitter, identifier);
817 NS_LOG_WARN(
"Discarding a packet of " << packet->GetSize() <<
" from statistics collection"
818 <<
" because it does not contain any TrafficTimeTag");
829 NS_LOG_FUNCTION(
this << satHelper);
834 NS_LOG_FUNCTION(
this);
840 static TypeId tid = TypeId(
"ns3::SatStatsFwdDevJitterHelper").SetParent<
SatStatsJitterHelper>();
847 NS_LOG_FUNCTION(
this);
848 NodeContainer uts = Singleton<SatTopology>::Get()->GetUtNodes();
850 for (NodeContainer::Iterator it = uts.Begin(); it != uts.End(); ++it)
852 const int32_t utId =
GetUtId(*it);
853 NS_ASSERT_MSG(utId > 0,
"Node " << (*it)->GetId() <<
" is not a valid UT");
857 std::ostringstream probeName;
859 Ptr<ApplicationDelayProbe> probe = CreateObject<ApplicationDelayProbe>();
860 probe->SetName(probeName.str());
868 std::make_pair(probe->GetObject<Probe>(), std::make_pair(*it, identifier)));
871 dev->SetAttribute(
"EnableStatisticsTags", BooleanValue(
true));
875 NS_FATAL_ERROR(
"Error connecting to RxJitter trace source of SatNetDevice"
876 <<
" at node ID " << (*it)->GetId() <<
" device #2");
882 NodeContainer gws = Singleton<SatTopology>::Get()->GetGwNodes();
883 for (NodeContainer::Iterator it = gws.Begin(); it != gws.End(); ++it)
887 for (NetDeviceContainer::Iterator itDev = devs.Begin(); itDev != devs.End(); ++itDev)
889 NS_ASSERT((*itDev)->GetObject<
SatNetDevice>() !=
nullptr);
890 (*itDev)->SetAttribute(
"EnableStatisticsTags", BooleanValue(
true));
899 NS_LOG_FUNCTION(
this);
901 std::map<Ptr<Probe>, std::pair<Ptr<Node>, uint32_t>>::iterator it;
905 Ptr<Probe> probe = it->first;
906 Ptr<Node> node = it->second.first;
907 uint32_t identifier = it->second.second;
911 NS_FATAL_ERROR(
"Error disconnecting trace file on handover");
918 NS_FATAL_ERROR(
"Error connecting trace file on handover");
921 it->second.second = identifier;
932 NS_LOG_FUNCTION(
this << satHelper);
937 NS_LOG_FUNCTION(
this);
943 static TypeId tid = TypeId(
"ns3::SatStatsFwdMacJitterHelper").SetParent<
SatStatsJitterHelper>();
950 NS_LOG_FUNCTION(
this);
951 NodeContainer uts = Singleton<SatTopology>::Get()->GetUtNodes();
953 for (NodeContainer::Iterator it = uts.Begin(); it != uts.End(); ++it)
955 const int32_t utId =
GetUtId(*it);
956 NS_ASSERT_MSG(utId > 0,
"Node " << (*it)->GetId() <<
" is not a valid UT");
960 std::ostringstream probeName;
962 Ptr<ApplicationDelayProbe> probe = CreateObject<ApplicationDelayProbe>();
963 probe->SetName(probeName.str());
966 Ptr<SatNetDevice> satDev = dev->GetObject<
SatNetDevice>();
967 NS_ASSERT(satDev !=
nullptr);
968 Ptr<SatMac> satMac = satDev->GetMac();
969 NS_ASSERT(satMac !=
nullptr);
972 if (probe->ConnectByObject(
"RxJitter", satMac) &&
976 std::make_pair(probe->GetObject<Probe>(), std::make_pair(*it, identifier)));
979 satDev->SetAttribute(
"EnableStatisticsTags", BooleanValue(
true));
980 satMac->SetAttribute(
"EnableStatisticsTags", BooleanValue(
true));
984 NS_FATAL_ERROR(
"Error connecting to RxJitter trace source of satMac"
985 <<
" at node ID " << (*it)->GetId() <<
" device #2");
991 NodeContainer gws = Singleton<SatTopology>::Get()->GetGwNodes();
992 for (NodeContainer::Iterator it = gws.Begin(); it != gws.End(); ++it)
996 for (NetDeviceContainer::Iterator itDev = devs.Begin(); itDev != devs.End(); ++itDev)
998 Ptr<SatNetDevice> satDev = (*itDev)->GetObject<
SatNetDevice>();
999 NS_ASSERT(satDev !=
nullptr);
1000 Ptr<SatMac> satMac = satDev->GetMac();
1001 NS_ASSERT(satMac !=
nullptr);
1003 satDev->SetAttribute(
"EnableStatisticsTags", BooleanValue(
true));
1004 satMac->SetAttribute(
"EnableStatisticsTags", BooleanValue(
true));
1013 NS_LOG_FUNCTION(
this);
1015 std::map<Ptr<Probe>, std::pair<Ptr<Node>, uint32_t>>::iterator it;
1019 Ptr<Probe> probe = it->first;
1020 Ptr<Node> node = it->second.first;
1021 uint32_t identifier = it->second.second;
1025 NS_FATAL_ERROR(
"Error disconnecting trace file on handover");
1032 NS_FATAL_ERROR(
"Error connecting trace file on handover");
1035 it->second.second = identifier;
1046 NS_LOG_FUNCTION(
this << satHelper);
1051 NS_LOG_FUNCTION(
this);
1057 static TypeId tid = TypeId(
"ns3::SatStatsFwdPhyJitterHelper").SetParent<
SatStatsJitterHelper>();
1064 NS_LOG_FUNCTION(
this);
1066 NodeContainer sats = Singleton<SatTopology>::Get()->GetOrbiterNodes();
1068 for (NodeContainer::Iterator it = sats.Begin(); it != sats.End(); ++it)
1072 NS_ASSERT(satOrbiterDev !=
nullptr);
1073 std::map<uint32_t, Ptr<SatPhy>> satOrbiterFeederPhys = satOrbiterDev->GetFeederPhy();
1075 for (std::map<uint32_t, Ptr<SatPhy>>::iterator it2 = satOrbiterFeederPhys.begin();
1076 it2 != satOrbiterFeederPhys.end();
1079 satPhy = it2->second;
1080 satPhy->SetAttribute(
"EnableStatisticsTags", BooleanValue(
true));
1082 std::map<uint32_t, Ptr<SatPhy>> satOrbiterUserPhys = satOrbiterDev->GetUserPhy();
1083 for (std::map<uint32_t, Ptr<SatPhy>>::iterator it2 = satOrbiterUserPhys.begin();
1084 it2 != satOrbiterUserPhys.end();
1087 satPhy = it2->second;
1088 satPhy->SetAttribute(
"EnableStatisticsTags", BooleanValue(
true));
1092 NodeContainer uts = Singleton<SatTopology>::Get()->GetUtNodes();
1094 for (NodeContainer::Iterator it = uts.Begin(); it != uts.End(); ++it)
1096 const int32_t utId =
GetUtId(*it);
1097 NS_ASSERT_MSG(utId > 0,
"Node " << (*it)->GetId() <<
" is not a valid UT");
1101 std::ostringstream probeName;
1103 Ptr<ApplicationDelayProbe> probe = CreateObject<ApplicationDelayProbe>();
1104 probe->SetName(probeName.str());
1107 Ptr<SatNetDevice> satDev = dev->GetObject<
SatNetDevice>();
1108 NS_ASSERT(satDev !=
nullptr);
1109 Ptr<SatPhy> satPhy = satDev->GetPhy();
1110 NS_ASSERT(satPhy !=
nullptr);
1113 if (probe->ConnectByObject(
"RxJitter", satPhy) &&
1117 std::make_pair(probe->GetObject<Probe>(), std::make_pair(*it, identifier)));
1120 satDev->SetAttribute(
"EnableStatisticsTags", BooleanValue(
true));
1121 satPhy->SetAttribute(
"EnableStatisticsTags", BooleanValue(
true));
1125 NS_FATAL_ERROR(
"Error connecting to RxJitter trace source of SatPhy"
1126 <<
" at node ID " << (*it)->GetId() <<
" device #2");
1132 NodeContainer gws = Singleton<SatTopology>::Get()->GetGwNodes();
1133 for (NodeContainer::Iterator it = gws.Begin(); it != gws.End(); ++it)
1137 for (NetDeviceContainer::Iterator itDev = devs.Begin(); itDev != devs.End(); ++itDev)
1139 Ptr<SatNetDevice> satDev = (*itDev)->GetObject<
SatNetDevice>();
1140 NS_ASSERT(satDev !=
nullptr);
1141 Ptr<SatPhy> satPhy = satDev->GetPhy();
1142 NS_ASSERT(satPhy !=
nullptr);
1144 satDev->SetAttribute(
"EnableStatisticsTags", BooleanValue(
true));
1145 satPhy->SetAttribute(
"EnableStatisticsTags", BooleanValue(
true));
1154 NS_LOG_FUNCTION(
this);
1156 std::map<Ptr<Probe>, std::pair<Ptr<Node>, uint32_t>>::iterator it;
1160 Ptr<Probe> probe = it->first;
1161 Ptr<Node> node = it->second.first;
1162 uint32_t identifier = it->second.second;
1166 NS_FATAL_ERROR(
"Error disconnecting trace file on handover");
1173 NS_FATAL_ERROR(
"Error connecting trace file on handover");
1176 it->second.second = identifier;
1187 NS_LOG_FUNCTION(
this << satHelper);
1192 NS_LOG_FUNCTION(
this);
1198 static TypeId tid = TypeId(
"ns3::SatStatsRtnAppJitterHelper").SetParent<
SatStatsJitterHelper>();
1205 NS_LOG_FUNCTION(
this);
1207 NodeContainer utUsers = Singleton<SatTopology>::Get()->GetUtUserNodes();
1208 for (NodeContainer::Iterator it = utUsers.Begin(); it != utUsers.End(); ++it)
1217 for (uint32_t i = 0; i < (*it)->GetNApplications(); i++)
1219 Ptr<Application> app = (*it)->GetApplication(i);
1221 if (!app->SetAttributeFailSafe(
"EnableStatisticsTags", BooleanValue(
true)))
1223 NS_LOG_WARN(
this <<
" node ID " << (*it)->GetId() <<
" application #" << i
1224 <<
" might not produce the required tags"
1225 <<
" in the transmitted packets,"
1226 <<
" thus preventing jitter statistics"
1227 <<
" from this sender application");
1236 NodeContainer gwUsers = Singleton<SatTopology>::Get()->GetGwUserNodes();
1237 Callback<void, const Time&, const Address&> rxJitterCallback =
1239 Callback<void, Ptr<const Packet>,
const Address&> rxCallback =
1242 for (NodeContainer::Iterator it = gwUsers.Begin(); it != gwUsers.End(); ++it)
1244 for (uint32_t i = 0; i < (*it)->GetNApplications(); i++)
1246 Ptr<Application> app = (*it)->GetApplication(i);
1247 bool isConnected =
false;
1253 if (app->GetInstanceTypeId().LookupTraceSourceByName(
"RxJitter") !=
nullptr)
1255 isConnected = app->TraceConnectWithoutContext(
"RxJitter", rxJitterCallback);
1257 else if (app->GetInstanceTypeId().LookupTraceSourceByName(
"Rx") !=
nullptr)
1259 isConnected = app->TraceConnectWithoutContext(
"Rx", rxCallback);
1264 NS_LOG_INFO(
this <<
" successfully connected" <<
" with node ID " << (*it)->GetId()
1265 <<
" application #" << i);
1274 NS_LOG_WARN(
this <<
" unable to connect" <<
" with node ID " << (*it)->GetId()
1275 <<
" application #" << i);
1287 TrafficTimeTag timeTag;
1288 if (packet->PeekPacketTag(timeTag))
1290 NS_LOG_DEBUG(
this <<
" contains a TrafficTimeTag tag");
1291 const Time delay = Simulator::Now() - timeTag.GetSenderTimestamp();
1292 const Address identifier = InetSocketAddress::ConvertFrom(from).GetIpv4();
1296 Time previousDelay = it->second;
1297 Time jitter = Abs(delay - previousDelay);
1304 NS_LOG_WARN(
this <<
" discarding a packet of " << packet->GetSize()
1305 <<
" from statistics collection"
1306 <<
" because it does not contain any TrafficTimeTag");
1315 if (InetSocketAddress::IsMatchingType(from))
1318 const Address ipv4Addr = InetSocketAddress::ConvertFrom(from).GetIpv4();
1319 std::map<const Address, uint32_t>::const_iterator it1 =
m_identifierMap.find(ipv4Addr);
1323 NS_LOG_WARN(
this <<
" discarding a packet jitter of " << jitter.GetSeconds()
1324 <<
" from statistics collection because of"
1325 <<
" unknown sender IPV4 address " << ipv4Addr);
1334 NS_LOG_WARN(
this <<
" discarding a packet jitter of " << jitter.GetSeconds()
1335 <<
" from statistics collection" <<
" because it comes from sender "
1336 << from <<
" without valid InetSocketAddress");
1343 NS_LOG_FUNCTION(
this << utUserNode->GetId());
1345 Ptr<Ipv4> ipv4 = utUserNode->GetObject<Ipv4>();
1347 if (ipv4 ==
nullptr)
1349 NS_LOG_INFO(
this <<
" Node " << utUserNode->GetId() <<
" does not support IPv4 protocol");
1351 else if (ipv4->GetNInterfaces() >= 2)
1359 for (uint32_t i = 0; i < ipv4->GetNAddresses(1); i++)
1361 const Address addr = ipv4->GetAddress(1, i).GetLocal();
1363 NS_LOG_INFO(
this <<
" associated address " << addr <<
" with identifier "
1369 NS_LOG_WARN(
this <<
" Node " << utUserNode->GetId() <<
" is not a valid UT user");
1380 NS_LOG_FUNCTION(
this << satHelper);
1385 NS_LOG_FUNCTION(
this);
1391 static TypeId tid = TypeId(
"ns3::SatStatsRtnDevJitterHelper").SetParent<
SatStatsJitterHelper>();
1398 NS_LOG_FUNCTION(
this);
1400 NodeContainer uts = Singleton<SatTopology>::Get()->GetUtNodes();
1401 for (NodeContainer::Iterator it = uts.Begin(); it != uts.End(); ++it)
1408 dev->SetAttribute(
"EnableStatisticsTags", BooleanValue(
true));
1413 NodeContainer gws = Singleton<SatTopology>::Get()->GetGwNodes();
1414 Callback<void, const Time&, const Address&> callback =
1417 for (NodeContainer::Iterator it = gws.Begin(); it != gws.End(); ++it)
1421 for (NetDeviceContainer::Iterator itDev = devs.Begin(); itDev != devs.End(); ++itDev)
1423 NS_ASSERT((*itDev)->GetObject<
SatNetDevice>() !=
nullptr);
1425 if ((*itDev)->TraceConnectWithoutContext(
"RxJitter", callback))
1427 NS_LOG_INFO(
this <<
" successfully connected with node ID " << (*it)->GetId()
1428 <<
" device #" << (*itDev)->GetIfIndex());
1431 (*itDev)->SetAttribute(
"EnableStatisticsTags", BooleanValue(
true));
1435 NS_FATAL_ERROR(
"Error connecting to RxJitter trace source of SatNetDevice"
1436 <<
" at node ID " << (*it)->GetId() <<
" device #"
1437 << (*itDev)->GetIfIndex());
1453 NS_LOG_FUNCTION(
this << satHelper);
1458 NS_LOG_FUNCTION(
this);
1464 static TypeId tid = TypeId(
"ns3::SatStatsRtnMacJitterHelper").SetParent<
SatStatsJitterHelper>();
1471 NS_LOG_FUNCTION(
this);
1473 NodeContainer uts = Singleton<SatTopology>::Get()->GetUtNodes();
1474 for (NodeContainer::Iterator it = uts.Begin(); it != uts.End(); ++it)
1481 Ptr<SatNetDevice> satDev = dev->GetObject<
SatNetDevice>();
1482 NS_ASSERT(satDev !=
nullptr);
1483 Ptr<SatMac> satMac = satDev->GetMac();
1484 NS_ASSERT(satMac !=
nullptr);
1485 satDev->SetAttribute(
"EnableStatisticsTags", BooleanValue(
true));
1486 satMac->SetAttribute(
"EnableStatisticsTags", BooleanValue(
true));
1491 NodeContainer gws = Singleton<SatTopology>::Get()->GetGwNodes();
1492 Callback<void, const Time&, const Address&> callback =
1495 for (NodeContainer::Iterator it = gws.Begin(); it != gws.End(); ++it)
1499 for (NetDeviceContainer::Iterator itDev = devs.Begin(); itDev != devs.End(); ++itDev)
1501 Ptr<SatNetDevice> satDev = (*itDev)->GetObject<
SatNetDevice>();
1502 NS_ASSERT(satDev !=
nullptr);
1503 Ptr<SatMac> satMac = satDev->GetMac();
1504 NS_ASSERT(satMac !=
nullptr);
1507 if (satMac->TraceConnectWithoutContext(
"RxJitter", callback))
1509 NS_LOG_INFO(
this <<
" successfully connected with node ID " << (*it)->GetId()
1510 <<
" device #" << satDev->GetIfIndex());
1513 satDev->SetAttribute(
"EnableStatisticsTags", BooleanValue(
true));
1514 satMac->SetAttribute(
"EnableStatisticsTags", BooleanValue(
true));
1518 NS_FATAL_ERROR(
"Error connecting to RxJitter trace source of SatNetDevice"
1519 <<
" at node ID " << (*it)->GetId() <<
" device #"
1520 << satDev->GetIfIndex());
1536 NS_LOG_FUNCTION(
this << satHelper);
1541 NS_LOG_FUNCTION(
this);
1547 static TypeId tid = TypeId(
"ns3::SatStatsRtnPhyJitterHelper").SetParent<
SatStatsJitterHelper>();
1554 NS_LOG_FUNCTION(
this);
1556 NodeContainer sats = Singleton<SatTopology>::Get()->GetOrbiterNodes();
1558 for (NodeContainer::Iterator it = sats.Begin(); it != sats.End(); ++it)
1562 NS_ASSERT(satOrbiterDev !=
nullptr);
1563 std::map<uint32_t, Ptr<SatPhy>> satOrbiterFeederPhys = satOrbiterDev->GetFeederPhy();
1565 for (std::map<uint32_t, Ptr<SatPhy>>::iterator it2 = satOrbiterFeederPhys.begin();
1566 it2 != satOrbiterFeederPhys.end();
1569 satPhy = it2->second;
1570 satPhy->SetAttribute(
"EnableStatisticsTags", BooleanValue(
true));
1572 std::map<uint32_t, Ptr<SatPhy>> satOrbiterUserPhys = satOrbiterDev->GetUserPhy();
1573 for (std::map<uint32_t, Ptr<SatPhy>>::iterator it2 = satOrbiterUserPhys.begin();
1574 it2 != satOrbiterUserPhys.end();
1577 satPhy = it2->second;
1578 satPhy->SetAttribute(
"EnableStatisticsTags", BooleanValue(
true));
1582 NodeContainer uts = Singleton<SatTopology>::Get()->GetUtNodes();
1583 for (NodeContainer::Iterator it = uts.Begin(); it != uts.End(); ++it)
1590 Ptr<SatNetDevice> satDev = dev->GetObject<
SatNetDevice>();
1591 NS_ASSERT(satDev !=
nullptr);
1592 Ptr<SatPhy> satPhy = satDev->GetPhy();
1593 NS_ASSERT(satPhy !=
nullptr);
1594 satDev->SetAttribute(
"EnableStatisticsTags", BooleanValue(
true));
1595 satPhy->SetAttribute(
"EnableStatisticsTags", BooleanValue(
true));
1600 NodeContainer gws = Singleton<SatTopology>::Get()->GetGwNodes();
1601 Callback<void, const Time&, const Address&> callback =
1604 for (NodeContainer::Iterator it = gws.Begin(); it != gws.End(); ++it)
1608 for (NetDeviceContainer::Iterator itDev = devs.Begin(); itDev != devs.End(); ++itDev)
1610 Ptr<SatNetDevice> satDev = (*itDev)->GetObject<
SatNetDevice>();
1611 NS_ASSERT(satDev !=
nullptr);
1612 Ptr<SatPhy> satPhy = satDev->GetPhy();
1613 NS_ASSERT(satPhy !=
nullptr);
1616 if (satPhy->TraceConnectWithoutContext(
"RxJitter", callback))
1618 NS_LOG_INFO(
this <<
" successfully connected with node ID " << (*it)->GetId()
1619 <<
" device #" << satDev->GetIfIndex());
1622 satDev->SetAttribute(
"EnableStatisticsTags", BooleanValue(
true));
1623 satPhy->SetAttribute(
"EnableStatisticsTags", BooleanValue(
true));
1627 NS_FATAL_ERROR(
"Error connecting to RxJitter trace source of SatNetDevice"
1628 <<
" at node ID " << (*it)->GetId() <<
" device #"
1629 << 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.
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
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.