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(
"SatStatsDelayHelper");
 
   65 NS_OBJECT_ENSURE_REGISTERED(SatStatsDelayHelper);
 
   69       m_averagingMode(false)
 
   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" 
  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 delay of " << delay.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, delay.GetSeconds());
 
  602         Ptr<UnitConversionCollector> c = collector->GetObject<UnitConversionCollector>();
 
  603         NS_ASSERT(c != 
nullptr);
 
  604         c->TraceSinkDouble(0.0, delay.GetSeconds());
 
  616             Ptr<ScalarCollector> c = collector->GetObject<ScalarCollector>();
 
  617             NS_ASSERT(c != 
nullptr);
 
  618             c->TraceSinkDouble(0.0, delay.GetSeconds());
 
  622             Ptr<DistributionCollector> c = collector->GetObject<DistributionCollector>();
 
  623             NS_ASSERT(c != 
nullptr);
 
  624             c->TraceSinkDouble(0.0, delay.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::SatStatsFwdAppDelayHelper").SetParent<
SatStatsDelayHelper>();
 
  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(
"RxDelay") != 
nullptr)
 
  682                 NS_LOG_INFO(
this << 
" attempt to connect using RxDelay");
 
  685                 std::ostringstream probeName;
 
  686                 probeName << utUserId << 
"-" << i;
 
  687                 Ptr<ApplicationDelayProbe> probe = CreateObject<ApplicationDelayProbe>();
 
  688                 probe->SetName(probeName.str());
 
  691                 if (probe->ConnectByObject(
"RxDelay", 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 delay statistics" 
  743                                  << 
" from this application");
 
  755                                       Ptr<const Packet> packet,
 
  758     NS_LOG_FUNCTION(helper << identifier << packet << packet->GetSize() << from);
 
  787     TrafficTimeTag timeTag;
 
  788     if (packet->PeekPacketTag(timeTag))
 
  790         NS_LOG_DEBUG(
"Contains a TrafficTimeTag tag");
 
  791         const Time delay = Simulator::Now() - timeTag.GetSenderTimestamp();
 
  792         helper->PassSampleToCollector(delay, identifier);
 
  796         NS_LOG_WARN(
"Discarding a packet of " << packet->GetSize() << 
" from statistics collection" 
  797                                               << 
" because it does not contain any TrafficTimeTag");
 
  804     NS_LOG_FUNCTION(
this);
 
  806     std::map<Ptr<Probe>, std::pair<Ptr<Node>, uint32_t>>::iterator it;
 
  810         Ptr<Probe> probe = it->first;
 
  811         Ptr<Node> node = it->second.first;
 
  812         uint32_t identifier = it->second.second;
 
  816             NS_FATAL_ERROR(
"Error disconnecting trace file on handover");
 
  823             NS_FATAL_ERROR(
"Error connecting trace file on handover");
 
  826         it->second.second = identifier;
 
  837     NS_LOG_FUNCTION(
this << satHelper);
 
  842     NS_LOG_FUNCTION(
this);
 
  848     static TypeId tid = TypeId(
"ns3::SatStatsFwdDevDelayHelper").SetParent<
SatStatsDelayHelper>();
 
  855     NS_LOG_FUNCTION(
this);
 
  856     NodeContainer uts = Singleton<SatTopology>::Get()->GetUtNodes();
 
  858     for (NodeContainer::Iterator it = uts.Begin(); it != uts.End(); ++it)
 
  860         const int32_t utId = 
GetUtId(*it);
 
  861         NS_ASSERT_MSG(utId > 0, 
"Node " << (*it)->GetId() << 
" is not a valid UT");
 
  865         std::ostringstream probeName;
 
  867         Ptr<ApplicationDelayProbe> probe = CreateObject<ApplicationDelayProbe>();
 
  868         probe->SetName(probeName.str());
 
  876                 std::make_pair(probe->GetObject<Probe>(), std::make_pair(*it, identifier)));
 
  879             dev->SetAttribute(
"EnableStatisticsTags", BooleanValue(
true));
 
  883             NS_FATAL_ERROR(
"Error connecting to RxDelay trace source of SatNetDevice" 
  884                            << 
" at node ID " << (*it)->GetId() << 
" device #2");
 
  890     NodeContainer gws = Singleton<SatTopology>::Get()->GetGwNodes();
 
  891     for (NodeContainer::Iterator it = gws.Begin(); it != gws.End(); ++it)
 
  895         for (NetDeviceContainer::Iterator itDev = devs.Begin(); itDev != devs.End(); ++itDev)
 
  897             NS_ASSERT((*itDev)->GetObject<
SatNetDevice>() != 
nullptr);
 
  898             (*itDev)->SetAttribute(
"EnableStatisticsTags", BooleanValue(
true));
 
  907     NS_LOG_FUNCTION(
this);
 
  909     std::map<Ptr<Probe>, std::pair<Ptr<Node>, uint32_t>>::iterator it;
 
  913         Ptr<Probe> probe = it->first;
 
  914         Ptr<Node> node = it->second.first;
 
  915         uint32_t identifier = it->second.second;
 
  919             NS_FATAL_ERROR(
"Error disconnecting trace file on handover");
 
  926             NS_FATAL_ERROR(
"Error connecting trace file on handover");
 
  929         it->second.second = identifier;
 
  940     NS_LOG_FUNCTION(
this << satHelper);
 
  945     NS_LOG_FUNCTION(
this);
 
  951     static TypeId tid = TypeId(
"ns3::SatStatsFwdMacDelayHelper").SetParent<
SatStatsDelayHelper>();
 
  958     NS_LOG_FUNCTION(
this);
 
  959     NodeContainer uts = Singleton<SatTopology>::Get()->GetUtNodes();
 
  961     for (NodeContainer::Iterator it = uts.Begin(); it != uts.End(); ++it)
 
  963         const int32_t utId = 
GetUtId(*it);
 
  964         NS_ASSERT_MSG(utId > 0, 
"Node " << (*it)->GetId() << 
" is not a valid UT");
 
  968         std::ostringstream probeName;
 
  970         Ptr<ApplicationDelayProbe> probe = CreateObject<ApplicationDelayProbe>();
 
  971         probe->SetName(probeName.str());
 
  974         Ptr<SatNetDevice> satDev = dev->GetObject<
SatNetDevice>();
 
  975         NS_ASSERT(satDev != 
nullptr);
 
  976         Ptr<SatMac> satMac = satDev->GetMac();
 
  977         NS_ASSERT(satMac != 
nullptr);
 
  983                 std::make_pair(probe->GetObject<Probe>(), std::make_pair(*it, identifier)));
 
  986             satDev->SetAttribute(
"EnableStatisticsTags", BooleanValue(
true));
 
  987             satMac->SetAttribute(
"EnableStatisticsTags", BooleanValue(
true));
 
  991             NS_FATAL_ERROR(
"Error connecting to RxDelay trace source of satMac" 
  992                            << 
" at node ID " << (*it)->GetId() << 
" device #2");
 
  998     NodeContainer gws = Singleton<SatTopology>::Get()->GetGwNodes();
 
  999     for (NodeContainer::Iterator it = gws.Begin(); it != gws.End(); ++it)
 
 1003         for (NetDeviceContainer::Iterator itDev = devs.Begin(); itDev != devs.End(); ++itDev)
 
 1005             Ptr<SatNetDevice> satDev = (*itDev)->GetObject<
SatNetDevice>();
 
 1006             NS_ASSERT(satDev != 
nullptr);
 
 1007             Ptr<SatMac> satMac = satDev->GetMac();
 
 1008             NS_ASSERT(satMac != 
nullptr);
 
 1010             satDev->SetAttribute(
"EnableStatisticsTags", BooleanValue(
true));
 
 1011             satMac->SetAttribute(
"EnableStatisticsTags", BooleanValue(
true));
 
 1020     NS_LOG_FUNCTION(
this);
 
 1022     std::map<Ptr<Probe>, std::pair<Ptr<Node>, uint32_t>>::iterator it;
 
 1026         Ptr<Probe> probe = it->first;
 
 1027         Ptr<Node> node = it->second.first;
 
 1028         uint32_t identifier = it->second.second;
 
 1032             NS_FATAL_ERROR(
"Error disconnecting trace file on handover");
 
 1039             NS_FATAL_ERROR(
"Error connecting trace file on handover");
 
 1042         it->second.second = identifier;
 
 1053     NS_LOG_FUNCTION(
this << satHelper);
 
 1058     NS_LOG_FUNCTION(
this);
 
 1064     static TypeId tid = TypeId(
"ns3::SatStatsFwdPhyDelayHelper").SetParent<
SatStatsDelayHelper>();
 
 1071     NS_LOG_FUNCTION(
this);
 
 1073     NodeContainer sats = Singleton<SatTopology>::Get()->GetOrbiterNodes();
 
 1075     for (NodeContainer::Iterator it = sats.Begin(); it != sats.End(); ++it)
 
 1079         NS_ASSERT(satOrbiterDev != 
nullptr);
 
 1080         std::map<uint32_t, Ptr<SatPhy>> satOrbiterFeederPhys = satOrbiterDev->GetFeederPhy();
 
 1082         for (std::map<uint32_t, Ptr<SatPhy>>::iterator it2 = satOrbiterFeederPhys.begin();
 
 1083              it2 != satOrbiterFeederPhys.end();
 
 1086             satPhy = it2->second;
 
 1087             NS_ASSERT(satPhy != 
nullptr);
 
 1088             satPhy->SetAttribute(
"EnableStatisticsTags", BooleanValue(
true));
 
 1090         std::map<uint32_t, Ptr<SatPhy>> satOrbiterUserPhys = satOrbiterDev->GetUserPhy();
 
 1091         for (std::map<uint32_t, Ptr<SatPhy>>::iterator it2 = satOrbiterUserPhys.begin();
 
 1092              it2 != satOrbiterUserPhys.end();
 
 1095             satPhy = it2->second;
 
 1096             NS_ASSERT(satPhy != 
nullptr);
 
 1097             satPhy->SetAttribute(
"EnableStatisticsTags", BooleanValue(
true));
 
 1101     NodeContainer uts = Singleton<SatTopology>::Get()->GetUtNodes();
 
 1103     for (NodeContainer::Iterator it = uts.Begin(); it != uts.End(); ++it)
 
 1105         const int32_t utId = 
GetUtId(*it);
 
 1106         NS_ASSERT_MSG(utId > 0, 
"Node " << (*it)->GetId() << 
" is not a valid UT");
 
 1110         std::ostringstream probeName;
 
 1112         Ptr<ApplicationDelayProbe> probe = CreateObject<ApplicationDelayProbe>();
 
 1113         probe->SetName(probeName.str());
 
 1116         Ptr<SatNetDevice> satDev = dev->GetObject<
SatNetDevice>();
 
 1117         NS_ASSERT(satDev != 
nullptr);
 
 1118         Ptr<SatPhy> satPhy = satDev->GetPhy();
 
 1119         NS_ASSERT(satPhy != 
nullptr);
 
 1125                 std::make_pair(probe->GetObject<Probe>(), std::make_pair(*it, identifier)));
 
 1128             satDev->SetAttribute(
"EnableStatisticsTags", BooleanValue(
true));
 
 1129             satPhy->SetAttribute(
"EnableStatisticsTags", BooleanValue(
true));
 
 1133             NS_FATAL_ERROR(
"Error connecting to RxDelay trace source of SatPhy" 
 1134                            << 
" at node ID " << (*it)->GetId() << 
" device #2");
 
 1140     NodeContainer gws = Singleton<SatTopology>::Get()->GetGwNodes();
 
 1141     for (NodeContainer::Iterator it = gws.Begin(); it != gws.End(); ++it)
 
 1145         for (NetDeviceContainer::Iterator itDev = devs.Begin(); itDev != devs.End(); ++itDev)
 
 1147             Ptr<SatNetDevice> satDev = (*itDev)->GetObject<
SatNetDevice>();
 
 1148             NS_ASSERT(satDev != 
nullptr);
 
 1149             Ptr<SatPhy> satPhy = satDev->GetPhy();
 
 1150             NS_ASSERT(satPhy != 
nullptr);
 
 1152             satDev->SetAttribute(
"EnableStatisticsTags", BooleanValue(
true));
 
 1153             satPhy->SetAttribute(
"EnableStatisticsTags", BooleanValue(
true));
 
 1162     NS_LOG_FUNCTION(
this);
 
 1164     std::map<Ptr<Probe>, std::pair<Ptr<Node>, uint32_t>>::iterator it;
 
 1168         Ptr<Probe> probe = it->first;
 
 1169         Ptr<Node> node = it->second.first;
 
 1170         uint32_t identifier = it->second.second;
 
 1174             NS_FATAL_ERROR(
"Error disconnecting trace file on handover");
 
 1181             NS_FATAL_ERROR(
"Error connecting trace file on handover");
 
 1184         it->second.second = identifier;
 
 1195     NS_LOG_FUNCTION(
this << satHelper);
 
 1200     NS_LOG_FUNCTION(
this);
 
 1206     static TypeId tid = TypeId(
"ns3::SatStatsRtnAppDelayHelper").SetParent<
SatStatsDelayHelper>();
 
 1213     NS_LOG_FUNCTION(
this);
 
 1215     NodeContainer utUsers = Singleton<SatTopology>::Get()->GetUtUserNodes();
 
 1216     for (NodeContainer::Iterator it = utUsers.Begin(); it != utUsers.End(); ++it)
 
 1225         for (uint32_t i = 0; i < (*it)->GetNApplications(); i++)
 
 1227             Ptr<Application> app = (*it)->GetApplication(i);
 
 1229             if (!app->SetAttributeFailSafe(
"EnableStatisticsTags", BooleanValue(
true)))
 
 1231                 NS_LOG_WARN(
this << 
" node ID " << (*it)->GetId() << 
" application #" << i
 
 1232                                  << 
" might not produce the required tags" 
 1233                                  << 
" in the transmitted packets," 
 1234                                  << 
" thus preventing delay statistics" 
 1235                                  << 
" from this sender application");
 
 1244     NodeContainer gwUsers = Singleton<SatTopology>::Get()->GetGwUserNodes();
 
 1245     Callback<void, const Time&, const Address&> rxDelayCallback =
 
 1247     Callback<void, Ptr<const Packet>, 
const Address&> rxCallback =
 
 1250     for (NodeContainer::Iterator it = gwUsers.Begin(); it != gwUsers.End(); ++it)
 
 1252         for (uint32_t i = 0; i < (*it)->GetNApplications(); i++)
 
 1254             Ptr<Application> app = (*it)->GetApplication(i);
 
 1255             bool isConnected = 
false;
 
 1261             if (app->GetInstanceTypeId().LookupTraceSourceByName(
"RxDelay") != 
nullptr)
 
 1263                 isConnected = app->TraceConnectWithoutContext(
"RxDelay", rxDelayCallback);
 
 1265             else if (app->GetInstanceTypeId().LookupTraceSourceByName(
"Rx") != 
nullptr)
 
 1267                 isConnected = app->TraceConnectWithoutContext(
"Rx", rxCallback);
 
 1272                 NS_LOG_INFO(
this << 
" successfully connected" 
 1273                                  << 
" with node ID " << (*it)->GetId() << 
" application #" << i);
 
 1282                 NS_LOG_WARN(
this << 
" unable to connect" 
 1283                                  << 
" with node ID " << (*it)->GetId() << 
" application #" << i);
 
 1324     TrafficTimeTag timeTag;
 
 1325     if (packet->PeekPacketTag(timeTag))
 
 1327         NS_LOG_DEBUG(
this << 
" contains a TrafficTimeTag tag");
 
 1328         Ipv4Callback(Simulator::Now() - timeTag.GetSenderTimestamp(), from);
 
 1332         NS_LOG_WARN(
this << 
" discarding a packet of " << packet->GetSize()
 
 1333                          << 
" from statistics collection" 
 1334                          << 
" because it does not contain any TrafficTimeTag");
 
 1344     if (InetSocketAddress::IsMatchingType(from))
 
 1347         const Address ipv4Addr = InetSocketAddress::ConvertFrom(from).GetIpv4();
 
 1348         std::map<const Address, uint32_t>::const_iterator it1 = 
m_identifierMap.find(ipv4Addr);
 
 1352             NS_LOG_WARN(
this << 
" discarding a packet delay of " << delay.GetSeconds()
 
 1353                              << 
" from statistics collection because of" 
 1354                              << 
" unknown sender IPV4 address " << ipv4Addr);
 
 1363         NS_LOG_WARN(
this << 
" discarding a packet delay of " << delay.GetSeconds()
 
 1364                          << 
" from statistics collection" 
 1365                          << 
" because it comes from sender " << from
 
 1366                          << 
" without valid InetSocketAddress");
 
 1373     NS_LOG_FUNCTION(
this << utUserNode->GetId());
 
 1375     Ptr<Ipv4> ipv4 = utUserNode->GetObject<Ipv4>();
 
 1377     if (ipv4 == 
nullptr)
 
 1379         NS_LOG_INFO(
this << 
" Node " << utUserNode->GetId() << 
" does not support IPv4 protocol");
 
 1381     else if (ipv4->GetNInterfaces() >= 2)
 
 1389         for (uint32_t i = 0; i < ipv4->GetNAddresses(1); i++)
 
 1391             const Address addr = ipv4->GetAddress(1, i).GetLocal();
 
 1393             NS_LOG_INFO(
this << 
" associated address " << addr << 
" with identifier " 
 1399         NS_LOG_WARN(
this << 
" Node " << utUserNode->GetId() << 
" is not a valid UT user");
 
 1410     NS_LOG_FUNCTION(
this << satHelper);
 
 1415     NS_LOG_FUNCTION(
this);
 
 1421     static TypeId tid = TypeId(
"ns3::SatStatsRtnDevDelayHelper").SetParent<
SatStatsDelayHelper>();
 
 1428     NS_LOG_FUNCTION(
this);
 
 1430     NodeContainer uts = Singleton<SatTopology>::Get()->GetUtNodes();
 
 1431     for (NodeContainer::Iterator it = uts.Begin(); it != uts.End(); ++it)
 
 1438         dev->SetAttribute(
"EnableStatisticsTags", BooleanValue(
true));
 
 1443     NodeContainer gws = Singleton<SatTopology>::Get()->GetGwNodes();
 
 1444     Callback<void, const Time&, const Address&> callback =
 
 1447     for (NodeContainer::Iterator it = gws.Begin(); it != gws.End(); ++it)
 
 1451         for (NetDeviceContainer::Iterator itDev = devs.Begin(); itDev != devs.End(); ++itDev)
 
 1453             NS_ASSERT((*itDev)->GetObject<
SatNetDevice>() != 
nullptr);
 
 1455             if ((*itDev)->TraceConnectWithoutContext(
"RxDelay", callback))
 
 1457                 NS_LOG_INFO(
this << 
" successfully connected with node ID " << (*it)->GetId()
 
 1458                                  << 
" device #" << (*itDev)->GetIfIndex());
 
 1461                 (*itDev)->SetAttribute(
"EnableStatisticsTags", BooleanValue(
true));
 
 1465                 NS_FATAL_ERROR(
"Error connecting to RxDelay trace source of SatNetDevice" 
 1466                                << 
" at node ID " << (*it)->GetId() << 
" device #" 
 1467                                << (*itDev)->GetIfIndex());
 
 1483     NS_LOG_FUNCTION(
this << satHelper);
 
 1488     NS_LOG_FUNCTION(
this);
 
 1494     static TypeId tid = TypeId(
"ns3::SatStatsRtnMacDelayHelper").SetParent<
SatStatsDelayHelper>();
 
 1501     NS_LOG_FUNCTION(
this);
 
 1503     NodeContainer uts = Singleton<SatTopology>::Get()->GetUtNodes();
 
 1504     for (NodeContainer::Iterator it = uts.Begin(); it != uts.End(); ++it)
 
 1511         Ptr<SatNetDevice> satDev = dev->GetObject<
SatNetDevice>();
 
 1512         NS_ASSERT(satDev != 
nullptr);
 
 1513         Ptr<SatMac> satMac = satDev->GetMac();
 
 1514         NS_ASSERT(satMac != 
nullptr);
 
 1515         satDev->SetAttribute(
"EnableStatisticsTags", BooleanValue(
true));
 
 1516         satMac->SetAttribute(
"EnableStatisticsTags", BooleanValue(
true));
 
 1521     NodeContainer gws = Singleton<SatTopology>::Get()->GetGwNodes();
 
 1522     Callback<void, const Time&, const Address&> callback =
 
 1525     for (NodeContainer::Iterator it = gws.Begin(); it != gws.End(); ++it)
 
 1529         for (NetDeviceContainer::Iterator itDev = devs.Begin(); itDev != devs.End(); ++itDev)
 
 1531             Ptr<SatNetDevice> satDev = (*itDev)->GetObject<
SatNetDevice>();
 
 1532             NS_ASSERT(satDev != 
nullptr);
 
 1533             Ptr<SatMac> satMac = satDev->GetMac();
 
 1534             NS_ASSERT(satMac != 
nullptr);
 
 1537             if (satMac->TraceConnectWithoutContext(
"RxDelay", callback))
 
 1539                 NS_LOG_INFO(
this << 
" successfully connected with node ID " << (*it)->GetId()
 
 1540                                  << 
" device #" << satDev->GetIfIndex());
 
 1543                 satDev->SetAttribute(
"EnableStatisticsTags", BooleanValue(
true));
 
 1544                 satMac->SetAttribute(
"EnableStatisticsTags", BooleanValue(
true));
 
 1548                 NS_FATAL_ERROR(
"Error connecting to RxDelay trace source of SatNetDevice" 
 1549                                << 
" at node ID " << (*it)->GetId() << 
" device #" 
 1550                                << satDev->GetIfIndex());
 
 1566     NS_LOG_FUNCTION(
this << satHelper);
 
 1571     NS_LOG_FUNCTION(
this);
 
 1577     static TypeId tid = TypeId(
"ns3::SatStatsRtnPhyDelayHelper").SetParent<
SatStatsDelayHelper>();
 
 1584     NS_LOG_FUNCTION(
this);
 
 1586     NodeContainer sats = Singleton<SatTopology>::Get()->GetOrbiterNodes();
 
 1588     for (NodeContainer::Iterator it = sats.Begin(); it != sats.End(); ++it)
 
 1593         NS_ASSERT(satOrbiterDev != 
nullptr);
 
 1594         std::map<uint32_t, Ptr<SatPhy>> satOrbiterFeederPhys = satOrbiterDev->GetFeederPhy();
 
 1595         for (std::map<uint32_t, Ptr<SatPhy>>::iterator it2 = satOrbiterFeederPhys.begin();
 
 1596              it2 != satOrbiterFeederPhys.end();
 
 1599             satPhy = it2->second;
 
 1600             NS_ASSERT(satPhy != 
nullptr);
 
 1601             satPhy->SetAttribute(
"EnableStatisticsTags", BooleanValue(
true));
 
 1603         std::map<uint32_t, Ptr<SatPhy>> satOrbiterUserPhys = satOrbiterDev->GetUserPhy();
 
 1604         for (std::map<uint32_t, Ptr<SatPhy>>::iterator it2 = satOrbiterUserPhys.begin();
 
 1605              it2 != satOrbiterUserPhys.end();
 
 1608             satPhy = it2->second;
 
 1609             NS_ASSERT(satPhy != 
nullptr);
 
 1610             satPhy->SetAttribute(
"EnableStatisticsTags", BooleanValue(
true));
 
 1614     NodeContainer uts = Singleton<SatTopology>::Get()->GetUtNodes();
 
 1615     for (NodeContainer::Iterator it = uts.Begin(); it != uts.End(); ++it)
 
 1622         Ptr<SatNetDevice> satDev = dev->GetObject<
SatNetDevice>();
 
 1623         NS_ASSERT(satDev != 
nullptr);
 
 1624         Ptr<SatPhy> satPhy = satDev->GetPhy();
 
 1625         NS_ASSERT(satPhy != 
nullptr);
 
 1626         satDev->SetAttribute(
"EnableStatisticsTags", BooleanValue(
true));
 
 1627         satPhy->SetAttribute(
"EnableStatisticsTags", BooleanValue(
true));
 
 1632     NodeContainer gws = Singleton<SatTopology>::Get()->GetGwNodes();
 
 1633     Callback<void, const Time&, const Address&> callback =
 
 1636     for (NodeContainer::Iterator it = gws.Begin(); it != gws.End(); ++it)
 
 1640         for (NetDeviceContainer::Iterator itDev = devs.Begin(); itDev != devs.End(); ++itDev)
 
 1642             Ptr<SatNetDevice> satDev = (*itDev)->GetObject<
SatNetDevice>();
 
 1643             NS_ASSERT(satDev != 
nullptr);
 
 1644             Ptr<SatPhy> satPhy = satDev->GetPhy();
 
 1645             NS_ASSERT(satPhy != 
nullptr);
 
 1648             if (satPhy->TraceConnectWithoutContext(
"RxDelay", callback))
 
 1650                 NS_LOG_INFO(
this << 
" successfully connected with node ID " << (*it)->GetId()
 
 1651                                  << 
" device #" << satDev->GetIfIndex());
 
 1654                 satDev->SetAttribute(
"EnableStatisticsTags", BooleanValue(
true));
 
 1655                 satPhy->SetAttribute(
"EnableStatisticsTags", BooleanValue(
true));
 
 1659                 NS_FATAL_ERROR(
"Error connecting to RxDelay trace source of SatNetDevice" 
 1660                                << 
" at node ID " << (*it)->GetId() << 
" device #" 
 1661                                << 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)
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
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.