diff --git a/examples/mtp/tcp-pacing-mtp.cc b/examples/mtp/tcp-pacing-mtp.cc index a14db3807..670f20b35 100644 --- a/examples/mtp/tcp-pacing-mtp.cc +++ b/examples/mtp/tcp-pacing-mtp.cc @@ -163,7 +163,7 @@ main(int argc, char* argv[]) Time simulationEndTime = Seconds(5); DataRate bottleneckBandwidth("10Mbps"); // value of x as shown in the above network topology Time bottleneckDelay = MilliSeconds(40); - DataRate regLinkBandwidth = DataRate(4 * bottleneckBandwidth.GetBitRate()); + DataRate regLinkBandwidth(4 * bottleneckBandwidth.GetBitRate()); Time regLinkDelay = MilliSeconds(5); DataRate maxPacingRate("4Gbps"); @@ -326,9 +326,7 @@ main(int argc, char* argv[]) monitor->CheckForLostPackets(); Ptr classifier = DynamicCast(flowmon.GetClassifier()); FlowMonitor::FlowStatsContainer stats = monitor->GetFlowStats(); - for (std::map::const_iterator i = stats.begin(); - i != stats.end(); - ++i) + for (auto i = stats.begin(); i != stats.end(); ++i) { Ipv4FlowClassifier::FiveTuple t = classifier->FindFlow(i->first); diff --git a/examples/mtp/tcp-validation-mtp.cc b/examples/mtp/tcp-validation-mtp.cc index 5bbb09df9..2007a1b4b 100644 --- a/examples/mtp/tcp-validation-mtp.cc +++ b/examples/mtp/tcp-validation-mtp.cc @@ -163,12 +163,12 @@ NS_LOG_COMPONENT_DEFINE("TcpValidation"); // These variables are declared outside of main() so that they can // be used in trace sinks. -std::atomic g_firstBytesReceived (0); //!< First received packet size. -std::atomic g_secondBytesReceived (0); //!< Second received packet size. -std::atomic g_marksObserved (0); //!< Number of marked packets observed. -std::atomic g_dropsObserved (0); //!< Number of dropped packets observed. -std::string g_validate = ""; //!< Empty string disables validation. -bool g_validationFailed = false; //!< True if validation failed. +std::atomic g_firstBytesReceived(0); //!< First received packet size. +std::atomic g_secondBytesReceived(0); //!< Second received packet size. +std::atomic g_marksObserved(0); //!< Number of marked packets observed. +std::atomic g_dropsObserved(0); //!< Number of dropped packets observed. +std::string g_validate = ""; //!< Empty string disables validation. +bool g_validationFailed = false; //!< True if validation failed. /** * Trace first congestion window. @@ -748,7 +748,7 @@ main(int argc, char* argv[]) firstTcpTypeId = TcpDctcp::GetTypeId(); Config::SetDefault("ns3::CoDelQueueDisc::CeThreshold", TimeValue(ceThreshold)); Config::SetDefault("ns3::FqCoDelQueueDisc::CeThreshold", TimeValue(ceThreshold)); - if (queueUseEcn == false) + if (!queueUseEcn) { std::cout << "Warning: using DCTCP with queue ECN disabled" << std::endl; } @@ -935,7 +935,7 @@ main(int argc, char* argv[]) proto->SetAttribute("SocketType", TypeIdValue(secondTcpTypeId)); } - // InternetStackHelper will install a base TrafficControLayer on the node, + // InternetStackHelper will install a base TrafficControlLayer on the node, // but the Ipv4AddressHelper below will install the default FqCoDelQueueDisc // on all single device nodes. The below code overrides the configuration // that is normally done by the Ipv4AddressHelper::Install() method by diff --git a/src/mpi/examples/fat-tree-hybrid.cc b/src/mpi/examples/fat-tree-hybrid.cc index 9ee650267..d5b335afe 100644 --- a/src/mpi/examples/fat-tree-hybrid.cc +++ b/src/mpi/examples/fat-tree-hybrid.cc @@ -52,15 +52,16 @@ class Distribution { public: // load a distribution from a CDF file - Distribution(string filename = "src/mtp/examples/web-search.txt") + Distribution(const string filename) { ifstream fin; fin.open(filename); while (!fin.eof()) { - double x, cdf; + double x; + double cdf; fin >> x >> cdf; - m_cdf.push_back(std::make_pair(x, cdf)); + m_cdf.emplace_back(x, cdf); } fin.close(); @@ -68,7 +69,7 @@ class Distribution } // expectation value of the distribution - double Expectation() + double Expectation() const { double ex = 0; for (uint32_t i = 1; i < m_cdf.size(); i++) @@ -106,22 +107,20 @@ class Distribution class TrafficGenerator { public: - TrafficGenerator(string cdfFile, - uint32_t hostTotal, - double dataRate, - double incastRatio, - vector victims) + TrafficGenerator(const string cdfFile, + const uint32_t hostTotal, + const double dataRate, + const double incastRatio, + const vector victims) + : m_currentTime(0), + m_incastRatio(incastRatio), + m_hostTotal(hostTotal), + m_victims(victims), + m_flowCount(0), + m_flowSizeTotal(0), + m_distribution(cdfFile) { - m_distribution = Distribution(cdfFile); - - m_currentTime = 0; m_averageInterval = m_distribution.Expectation() * 8 / dataRate; - m_incastRatio = incastRatio; - m_hostTotal = hostTotal; - m_victims = victims; - - m_flowCount = 0; - m_flowSizeTotal = 0; m_uniformRand = CreateObject(); m_expRand = CreateObject(); } @@ -129,7 +128,8 @@ class TrafficGenerator // get one flow with incremental time and random src, dst and size tuple GetFlow() { - uint32_t src, dst; + uint32_t src; + uint32_t dst; if (m_uniformRand->GetValue(0, 1) < m_incastRatio) { dst = m_victims[m_uniformRand->GetInteger(0, m_victims.size() - 1)]; @@ -151,22 +151,22 @@ class TrafficGenerator return make_tuple(m_currentTime, src, dst, flowSize); } - double GetActualDataRate() + double GetActualDataRate() const { return m_flowSizeTotal / m_currentTime * 8; } - double GetAvgFlowSize() + double GetAvgFlowSize() const { return m_distribution.Expectation(); } - double GetActualAvgFlowSize() + double GetActualAvgFlowSize() const { return m_flowSizeTotal / (double)m_flowCount; } - uint32_t GetFlowCount() + uint32_t GetFlowCount() const { return m_flowCount; } @@ -463,10 +463,17 @@ StartSimulation() uint64_t eventCount = Simulator::GetEventCount(); if (conf::flowmon) { - uint64_t dropped = 0, totalTx = 0, totalRx = 0, totalTxBytes = 0, flowCount = 0, - finishedFlowCount = 0; + uint64_t dropped = 0; + uint64_t totalTx = 0; + uint64_t totalRx = 0; + uint64_t totalTxBytes = 0; + uint64_t flowCount = 0; + uint64_t finishedFlowCount = 0; double totalThroughput = 0; - Time totalFct(0), totalFinishedFct(0), totalDelay(0); + Time totalFct(0); + Time totalFinishedFct(0); + Time totalDelay(0); + flowMonitor->CheckForLostPackets(); for (auto& p : flowMonitor->GetFlowStats()) { @@ -490,6 +497,7 @@ StartSimulation() flowCount++; } } + double avgFct = (double)totalFct.GetMicroSeconds() / flowCount; double avgFinishedFct = (double)totalFinishedFct.GetMicroSeconds() / finishedFlowCount; double avgDelay = (double)totalDelay.GetMicroSeconds() / totalRx; @@ -542,7 +550,10 @@ main(int argc, char* argv[]) uint32_t nAgg = conf::k / 2; // number of aggregation switch in a pod uint32_t nEdge = conf::k / 2; // number of edge switch in a pod uint32_t nHost = conf::k / 2; // number of hosts under a switch - NodeContainer core[nGroup], agg[nPod], edge[nPod], host[nPod][nEdge]; + NodeContainer core[nGroup]; + NodeContainer agg[nPod]; + NodeContainer edge[nPod]; + NodeContainer host[nPod][nEdge]; // create nodes for (uint32_t i = 0; i < nGroup; i++) diff --git a/src/mpi/examples/fat-tree-mpi.cc b/src/mpi/examples/fat-tree-mpi.cc index ebbb29b57..a3443e1b3 100644 --- a/src/mpi/examples/fat-tree-mpi.cc +++ b/src/mpi/examples/fat-tree-mpi.cc @@ -51,15 +51,16 @@ class Distribution { public: // load a distribution from a CDF file - Distribution(string filename = "src/mtp/examples/web-search.txt") + Distribution(const string filename) { ifstream fin; fin.open(filename); while (!fin.eof()) { - double x, cdf; + double x; + double cdf; fin >> x >> cdf; - m_cdf.push_back(std::make_pair(x, cdf)); + m_cdf.emplace_back(x, cdf); } fin.close(); @@ -67,7 +68,7 @@ class Distribution } // expectation value of the distribution - double Expectation() + double Expectation() const { double ex = 0; for (uint32_t i = 1; i < m_cdf.size(); i++) @@ -105,22 +106,20 @@ class Distribution class TrafficGenerator { public: - TrafficGenerator(string cdfFile, - uint32_t hostTotal, - double dataRate, - double incastRatio, - vector victims) + TrafficGenerator(const string cdfFile, + const uint32_t hostTotal, + const double dataRate, + const double incastRatio, + const vector victims) + : m_currentTime(0), + m_incastRatio(incastRatio), + m_hostTotal(hostTotal), + m_victims(victims), + m_flowCount(0), + m_flowSizeTotal(0), + m_distribution(cdfFile) { - m_distribution = Distribution(cdfFile); - - m_currentTime = 0; m_averageInterval = m_distribution.Expectation() * 8 / dataRate; - m_incastRatio = incastRatio; - m_hostTotal = hostTotal; - m_victims = victims; - - m_flowCount = 0; - m_flowSizeTotal = 0; m_uniformRand = CreateObject(); m_expRand = CreateObject(); } @@ -128,7 +127,8 @@ class TrafficGenerator // get one flow with incremental time and random src, dst and size tuple GetFlow() { - uint32_t src, dst; + uint32_t src; + uint32_t dst; if (m_uniformRand->GetValue(0, 1) < m_incastRatio) { dst = m_victims[m_uniformRand->GetInteger(0, m_victims.size() - 1)]; @@ -150,22 +150,22 @@ class TrafficGenerator return make_tuple(m_currentTime, src, dst, flowSize); } - double GetActualDataRate() + double GetActualDataRate() const { return m_flowSizeTotal / m_currentTime * 8; } - double GetAvgFlowSize() + double GetAvgFlowSize() const { return m_distribution.Expectation(); } - double GetActualAvgFlowSize() + double GetActualAvgFlowSize() const { return m_flowSizeTotal / (double)m_flowCount; } - uint32_t GetFlowCount() + uint32_t GetFlowCount() const { return m_flowCount; } @@ -467,10 +467,17 @@ StartSimulation() uint64_t eventCount = Simulator::GetEventCount(); if (conf::flowmon) { - uint64_t dropped = 0, totalTx = 0, totalRx = 0, totalTxBytes = 0, flowCount = 0, - finishedFlowCount = 0; + uint64_t dropped = 0; + uint64_t totalTx = 0; + uint64_t totalRx = 0; + uint64_t totalTxBytes = 0; + uint64_t flowCount = 0; + uint64_t finishedFlowCount = 0; double totalThroughput = 0; - Time totalFct(0), totalFinishedFct(0), totalDelay(0); + Time totalFct(0); + Time totalFinishedFct(0); + Time totalDelay(0); + flowMonitor->CheckForLostPackets(); for (auto& p : flowMonitor->GetFlowStats()) { @@ -494,6 +501,7 @@ StartSimulation() flowCount++; } } + double avgFct = (double)totalFct.GetMicroSeconds() / flowCount; double avgFinishedFct = (double)totalFinishedFct.GetMicroSeconds() / finishedFlowCount; double avgDelay = (double)totalDelay.GetMicroSeconds() / totalRx; @@ -546,7 +554,10 @@ main(int argc, char* argv[]) uint32_t nAgg = conf::k / 2; // number of aggregation switch in a pod uint32_t nEdge = conf::k / 2; // number of edge switch in a pod uint32_t nHost = conf::k / 2; // number of hosts under a switch - NodeContainer core[nGroup], agg[nPod], edge[nPod], host[nPod][nEdge]; + NodeContainer core[nGroup]; + NodeContainer agg[nPod]; + NodeContainer edge[nPod]; + NodeContainer host[nPod][nEdge]; // create nodes for (uint32_t i = 0; i < nGroup; i++) diff --git a/src/mpi/model/granted-time-window-mpi-interface.cc b/src/mpi/model/granted-time-window-mpi-interface.cc index 26e6bcb7c..c4f617aaa 100644 --- a/src/mpi/model/granted-time-window-mpi-interface.cc +++ b/src/mpi/model/granted-time-window-mpi-interface.cc @@ -225,7 +225,8 @@ GrantedTimeWindowMpiInterface::SendPacket(Ptr p, #ifdef NS3_MTP while (g_sending.exchange(true, std::memory_order_acquire)) - ; + { + }; #endif SentBuffer sendBuf; diff --git a/src/mpi/model/hybrid-simulator-impl.cc b/src/mpi/model/hybrid-simulator-impl.cc index 39719a198..f2c4ddf33 100644 --- a/src/mpi/model/hybrid-simulator-impl.cc +++ b/src/mpi/model/hybrid-simulator-impl.cc @@ -178,8 +178,7 @@ HybridSimulatorImpl::Remove(const EventId& id) if (id.GetUid() == EventId::DESTROY) { // destroy events. - for (std::list::iterator i = m_destroyEvents.begin(); i != m_destroyEvents.end(); - i++) + for (auto i = m_destroyEvents.begin(); i != m_destroyEvents.end(); i++) { if (*i == id) { @@ -209,13 +208,11 @@ HybridSimulatorImpl::IsExpired(const EventId& id) const if (id.GetUid() == EventId::DESTROY) { // destroy events. - if (id.PeekEventImpl() == 0 || id.PeekEventImpl()->IsCancelled()) + if (id.PeekEventImpl() == nullptr || id.PeekEventImpl()->IsCancelled()) { return true; } - for (std::list::const_iterator i = m_destroyEvents.begin(); - i != m_destroyEvents.end(); - i++) + for (auto i = m_destroyEvents.begin(); i != m_destroyEvents.end(); i++) { if (*i == id) { @@ -374,7 +371,7 @@ HybridSimulatorImpl::Partition() if (m_minLookahead == TimeStep(0)) { std::vector