build: switch to C++17
Change-Id: Id6217b5c993f3e4726e89773128b565e5f136bb6
diff --git a/tools/chunks/catchunks/consumer.cpp b/tools/chunks/catchunks/consumer.cpp
index ac83227..a1c2edf 100644
--- a/tools/chunks/catchunks/consumer.cpp
+++ b/tools/chunks/catchunks/consumer.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2016-2021, Regents of the University of California,
+ * Copyright (c) 2016-2022, Regents of the University of California,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University.
*
@@ -27,8 +27,7 @@
#include "consumer.hpp"
-namespace ndn {
-namespace chunks {
+namespace ndn::chunks {
Consumer::Consumer(security::Validator& validator, std::ostream& os)
: m_validator(validator)
@@ -86,5 +85,4 @@
}
}
-} // namespace chunks
-} // namespace ndn
+} // namespace ndn::chunks
diff --git a/tools/chunks/catchunks/consumer.hpp b/tools/chunks/catchunks/consumer.hpp
index a2151a9..8423ace 100644
--- a/tools/chunks/catchunks/consumer.hpp
+++ b/tools/chunks/catchunks/consumer.hpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2016-2021, Regents of the University of California,
+ * Copyright (c) 2016-2022, Regents of the University of California,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University.
*
@@ -36,8 +36,7 @@
#include <map>
-namespace ndn {
-namespace chunks {
+namespace ndn::chunks {
/**
* @brief Segmented version consumer
@@ -100,7 +99,6 @@
std::map<uint64_t, shared_ptr<const Data>> m_bufferedData;
};
-} // namespace chunks
-} // namespace ndn
+} // namespace ndn::chunks
#endif // NDN_TOOLS_CHUNKS_CATCHUNKS_CONSUMER_HPP
diff --git a/tools/chunks/catchunks/data-fetcher.cpp b/tools/chunks/catchunks/data-fetcher.cpp
index baed34f..2e5fc9e 100644
--- a/tools/chunks/catchunks/data-fetcher.cpp
+++ b/tools/chunks/catchunks/data-fetcher.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2016-2021, Regents of the University of California,
+ * Copyright (c) 2016-2022, Regents of the University of California,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University.
*
@@ -28,11 +28,7 @@
#include <cmath>
-namespace ndn {
-namespace chunks {
-
-const int DataFetcher::MAX_RETRIES_INFINITE = -1;
-const time::milliseconds DataFetcher::MAX_CONGESTION_BACKOFF_TIME = time::seconds(10);
+namespace ndn::chunks {
shared_ptr<DataFetcher>
DataFetcher::fetch(Face& face, const Interest& interest, int maxNackRetries, int maxTimeoutRetries,
@@ -60,12 +56,7 @@
, m_onTimeout(std::move(onTimeout))
, m_maxNackRetries(maxNackRetries)
, m_maxTimeoutRetries(maxTimeoutRetries)
- , m_nNacks(0)
- , m_nTimeouts(0)
- , m_nCongestionRetries(0)
, m_isVerbose(isVerbose)
- , m_isStopped(false)
- , m_hasError(false)
{
BOOST_ASSERT(m_onData != nullptr);
}
@@ -177,5 +168,4 @@
}
}
-} // namespace chunks
-} // namespace ndn
+} // namespace ndn::chunks
diff --git a/tools/chunks/catchunks/data-fetcher.hpp b/tools/chunks/catchunks/data-fetcher.hpp
index 53e32c0..c51d577 100644
--- a/tools/chunks/catchunks/data-fetcher.hpp
+++ b/tools/chunks/catchunks/data-fetcher.hpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2016-2019, Regents of the University of California,
+ * Copyright (c) 2016-2022, Regents of the University of California,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University.
*
@@ -29,11 +29,10 @@
#include "core/common.hpp"
-namespace ndn {
-namespace chunks {
+namespace ndn::chunks {
/**
- * @brief fetch data for a given interest and handle timeout or nack error with retries
+ * @brief Fetch data for a given interest and handle timeout or nack error with retries.
*
* To instantiate a DataFetcher you need to use the static method fetch, this will also express the
* interest. After a timeout or nack is received, the same interest with a different nonce will be
@@ -53,12 +52,12 @@
* @brief means that there is no maximum number of retries,
* i.e. fetching must be retried indefinitely
*/
- static const int MAX_RETRIES_INFINITE;
+ static constexpr int MAX_RETRIES_INFINITE = -1;
/**
* @brief ceiling value for backoff time used in congestion handling
*/
- static const time::milliseconds MAX_CONGESTION_BACKOFF_TIME;
+ static constexpr time::milliseconds MAX_CONGESTION_BACKOFF_TIME = 10_s;
using FailureCallback = std::function<void(const Interest& interest, const std::string& reason)>;
@@ -117,16 +116,15 @@
int m_maxNackRetries;
int m_maxTimeoutRetries;
- int m_nNacks;
- int m_nTimeouts;
- uint32_t m_nCongestionRetries;
+ int m_nNacks = 0;
+ int m_nTimeouts = 0;
+ uint32_t m_nCongestionRetries = 0;
- bool m_isVerbose;
- bool m_isStopped;
- bool m_hasError;
+ bool m_isVerbose = false;
+ bool m_isStopped = false;
+ bool m_hasError = false;
};
-} // namespace chunks
-} // namespace ndn
+} // namespace ndn::chunks
#endif // NDN_TOOLS_CHUNKS_CATCHUNKS_DATA_FETCHER_HPP
diff --git a/tools/chunks/catchunks/discover-version.cpp b/tools/chunks/catchunks/discover-version.cpp
index e35fc21..5eae250 100644
--- a/tools/chunks/catchunks/discover-version.cpp
+++ b/tools/chunks/catchunks/discover-version.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2016-2021, Regents of the University of California,
+ * Copyright (c) 2016-2022, Regents of the University of California,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University.
*
@@ -31,8 +31,7 @@
#include <ndn-cxx/metadata-object.hpp>
-namespace ndn {
-namespace chunks {
+namespace ndn::chunks {
DiscoverVersion::DiscoverVersion(Face& face, const Name& prefix, const Options& options)
: m_face(face)
@@ -93,5 +92,4 @@
onDiscoverySuccess(mobject.getVersionedName());
}
-} // namespace chunks
-} // namespace ndn
+} // namespace ndn::chunks
diff --git a/tools/chunks/catchunks/discover-version.hpp b/tools/chunks/catchunks/discover-version.hpp
index 62a5e42..6a05727 100644
--- a/tools/chunks/catchunks/discover-version.hpp
+++ b/tools/chunks/catchunks/discover-version.hpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2016-2021, Regents of the University of California,
+ * Copyright (c) 2016-2022, Regents of the University of California,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University.
*
@@ -33,8 +33,7 @@
#include <ndn-cxx/util/signal.hpp>
-namespace ndn {
-namespace chunks {
+namespace ndn::chunks {
class DataFetcher;
@@ -73,7 +72,6 @@
shared_ptr<DataFetcher> m_fetcher;
};
-} // namespace chunks
-} // namespace ndn
+} // namespace ndn::chunks
#endif // NDN_TOOLS_CHUNKS_CATCHUNKS_DISCOVER_VERSION_HPP
diff --git a/tools/chunks/catchunks/main.cpp b/tools/chunks/catchunks/main.cpp
index 59ea8d8..e89d904 100644
--- a/tools/chunks/catchunks/main.cpp
+++ b/tools/chunks/catchunks/main.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2016-2021, Regents of the University of California,
+ * Copyright (c) 2016-2022, Regents of the University of California,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University.
*
@@ -45,8 +45,7 @@
#include <boost/program_options/parsers.hpp>
#include <boost/program_options/variables_map.hpp>
-namespace ndn {
-namespace chunks {
+namespace ndn::chunks {
namespace po = boost::program_options;
@@ -309,8 +308,7 @@
return 0;
}
-} // namespace chunks
-} // namespace ndn
+} // namespace ndn::chunks
int
main(int argc, char* argv[])
diff --git a/tools/chunks/catchunks/options.hpp b/tools/chunks/catchunks/options.hpp
index fbca964..c93e9c2 100644
--- a/tools/chunks/catchunks/options.hpp
+++ b/tools/chunks/catchunks/options.hpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2016-2019, Regents of the University of California,
+ * Copyright (c) 2016-2022, Regents of the University of California,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University.
*
@@ -29,8 +29,7 @@
#include "core/common.hpp"
-namespace ndn {
-namespace chunks {
+namespace ndn::chunks {
struct Options : noncopyable
{
@@ -62,7 +61,6 @@
bool enableFastConv = false; ///< use cubic fast convergence
};
-} // namespace chunks
-} // namespace ndn
+} // namespace ndn::chunks
#endif // NDN_TOOLS_CHUNKS_CATCHUNKS_OPTIONS_HPP
diff --git a/tools/chunks/catchunks/pipeline-interests-adaptive.cpp b/tools/chunks/catchunks/pipeline-interests-adaptive.cpp
index 595dcdc..3b3e0cd 100644
--- a/tools/chunks/catchunks/pipeline-interests-adaptive.cpp
+++ b/tools/chunks/catchunks/pipeline-interests-adaptive.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2016-2021, Regents of the University of California,
+ * Copyright (c) 2016-2022, Regents of the University of California,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University.
*
@@ -32,8 +32,7 @@
#include <cmath>
#include <iomanip>
-namespace ndn {
-namespace chunks {
+namespace ndn::chunks {
constexpr double PipelineInterestsAdaptive::MIN_SSTHRESH;
@@ -45,19 +44,6 @@
, m_ssthresh(m_options.initSsthresh)
, m_rttEstimator(rttEstimator)
, m_scheduler(m_face.getIoService())
- , m_highData(0)
- , m_highInterest(0)
- , m_recPoint(0)
- , m_nInFlight(0)
- , m_nLossDecr(0)
- , m_nMarkDecr(0)
- , m_nTimeouts(0)
- , m_nSkippedRetx(0)
- , m_nRetransmitted(0)
- , m_nCongMarks(0)
- , m_nSent(0)
- , m_hasFailure(false)
- , m_failedSegNo(0)
{
}
@@ -139,7 +125,7 @@
if (isRetransmission) {
// keep track of retx count for this segment
auto ret = m_retxCount.emplace(segNo, 1);
- if (ret.second == false) { // not the first retransmission
+ if (!ret.second) { // not the first retransmission
m_retxCount[segNo] += 1;
if (m_options.maxRetriesOnTimeoutOrNack != DataFetcher::MAX_RETRIES_INFINITE &&
m_retxCount[segNo] > m_options.maxRetriesOnTimeoutOrNack) {
@@ -157,7 +143,6 @@
auto interest = Interest()
.setName(Name(m_prefix).appendSegment(segNo))
- .setCanBePrefix(false)
.setMustBeFresh(m_options.mustBeFresh)
.setInterestLifetime(m_options.interestLifetime);
@@ -471,5 +456,4 @@
return os;
}
-} // namespace chunks
-} // namespace ndn
+} // namespace ndn::chunks
diff --git a/tools/chunks/catchunks/pipeline-interests-adaptive.hpp b/tools/chunks/catchunks/pipeline-interests-adaptive.hpp
index 596c70e..15e4dcf 100644
--- a/tools/chunks/catchunks/pipeline-interests-adaptive.hpp
+++ b/tools/chunks/catchunks/pipeline-interests-adaptive.hpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2016-2021, Regents of the University of California,
+ * Copyright (c) 2016-2022, Regents of the University of California,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University.
*
@@ -37,8 +37,7 @@
#include <queue>
#include <unordered_map>
-namespace ndn {
-namespace chunks {
+namespace ndn::chunks {
using util::RttEstimatorWithStats;
@@ -199,20 +198,20 @@
Scheduler m_scheduler;
scheduler::ScopedEventId m_checkRtoEvent;
- uint64_t m_highData; ///< the highest segment number of the Data packet the consumer has received so far
- uint64_t m_highInterest; ///< the highest segment number of the Interests the consumer has sent so far
- uint64_t m_recPoint; ///< the value of m_highInterest when a packet loss event occurred,
- ///< it remains fixed until the next packet loss event happens
+ uint64_t m_highData = 0; ///< the highest segment number of the Data packet the consumer has received so far
+ uint64_t m_highInterest = 0; ///< the highest segment number of the Interests the consumer has sent so far
+ uint64_t m_recPoint = 0; ///< the value of m_highInterest when a packet loss event occurred,
+ ///< it remains fixed until the next packet loss event happens
- int64_t m_nInFlight; ///< # of segments in flight
- int64_t m_nLossDecr; ///< # of window decreases caused by packet loss
- int64_t m_nMarkDecr; ///< # of window decreases caused by congestion marks
- int64_t m_nTimeouts; ///< # of timed out segments
- int64_t m_nSkippedRetx; ///< # of segments queued for retransmission but received before the
- ///< retransmission occurred
- int64_t m_nRetransmitted; ///< # of retransmitted segments
- int64_t m_nCongMarks; ///< # of data packets with congestion mark
- int64_t m_nSent; ///< # of interest packets sent out (including retransmissions)
+ int64_t m_nInFlight = 0; ///< # of segments in flight
+ int64_t m_nLossDecr = 0; ///< # of window decreases caused by packet loss
+ int64_t m_nMarkDecr = 0; ///< # of window decreases caused by congestion marks
+ int64_t m_nTimeouts = 0; ///< # of timed out segments
+ int64_t m_nSkippedRetx = 0; ///< # of segments queued for retransmission but received before the
+ ///< retransmission occurred
+ int64_t m_nRetransmitted = 0; ///< # of retransmitted segments
+ int64_t m_nCongMarks = 0; ///< # of data packets with congestion mark
+ int64_t m_nSent = 0; ///< # of interest packets sent out (including retransmissions)
std::unordered_map<uint64_t, SegmentInfo> m_segmentInfo; ///< keeps all the internal information
///< on sent but not acked segments
@@ -221,12 +220,11 @@
///< timeout/nack retries, the pipeline will be aborted
std::queue<uint64_t> m_retxQueue;
- bool m_hasFailure;
- uint64_t m_failedSegNo;
+ bool m_hasFailure = false;
+ uint64_t m_failedSegNo = 0;
std::string m_failureReason;
};
-} // namespace chunks
-} // namespace ndn
+} // namespace ndn::chunks
#endif // NDN_TOOLS_CHUNKS_CATCHUNKS_PIPELINE_INTERESTS_ADAPTIVE_HPP
diff --git a/tools/chunks/catchunks/pipeline-interests-aimd.cpp b/tools/chunks/catchunks/pipeline-interests-aimd.cpp
index 667bd9e..4d84fdd 100644
--- a/tools/chunks/catchunks/pipeline-interests-aimd.cpp
+++ b/tools/chunks/catchunks/pipeline-interests-aimd.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2016-2019, Regents of the University of California,
+ * Copyright (c) 2016-2022, Regents of the University of California,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University.
*
@@ -30,8 +30,7 @@
#include <cmath>
-namespace ndn {
-namespace chunks {
+namespace ndn::chunks {
PipelineInterestsAimd::PipelineInterestsAimd(Face& face, RttEstimatorWithStats& rttEstimator,
const Options& opts)
@@ -65,5 +64,4 @@
emitSignal(afterCwndChange, time::steady_clock::now() - getStartTime(), m_cwnd);
}
-} // namespace chunks
-} // namespace ndn
+} // namespace ndn::chunks
diff --git a/tools/chunks/catchunks/pipeline-interests-aimd.hpp b/tools/chunks/catchunks/pipeline-interests-aimd.hpp
index f76163e..1792f95 100644
--- a/tools/chunks/catchunks/pipeline-interests-aimd.hpp
+++ b/tools/chunks/catchunks/pipeline-interests-aimd.hpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2016-2019, Regents of the University of California,
+ * Copyright (c) 2016-2022, Regents of the University of California,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University.
*
@@ -31,8 +31,7 @@
#include "pipeline-interests-adaptive.hpp"
-namespace ndn {
-namespace chunks {
+namespace ndn::chunks {
/**
* @brief Implements AIMD window increase and decrease.
@@ -50,7 +49,6 @@
decreaseWindow() final;
};
-} // namespace chunks
-} // namespace ndn
+} // namespace ndn::chunks
#endif // NDN_TOOLS_CHUNKS_CATCHUNKS_PIPELINE_INTERESTS_AIMD_HPP
diff --git a/tools/chunks/catchunks/pipeline-interests-cubic.cpp b/tools/chunks/catchunks/pipeline-interests-cubic.cpp
index 74aab0c..5eaf411 100644
--- a/tools/chunks/catchunks/pipeline-interests-cubic.cpp
+++ b/tools/chunks/catchunks/pipeline-interests-cubic.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2016-2019, Regents of the University of California,
+ * Copyright (c) 2016-2022, Regents of the University of California,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University.
*
@@ -27,8 +27,7 @@
#include <cmath>
-namespace ndn {
-namespace chunks {
+namespace ndn::chunks {
constexpr double CUBIC_C = 0.4;
@@ -111,5 +110,4 @@
emitSignal(afterCwndChange, time::steady_clock::now() - getStartTime(), m_cwnd);
}
-} // namespace chunks
-} // namespace ndn
+} // namespace ndn::chunks
diff --git a/tools/chunks/catchunks/pipeline-interests-cubic.hpp b/tools/chunks/catchunks/pipeline-interests-cubic.hpp
index daa59eb..87b4824 100644
--- a/tools/chunks/catchunks/pipeline-interests-cubic.hpp
+++ b/tools/chunks/catchunks/pipeline-interests-cubic.hpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2016-2021, Regents of the University of California,
+ * Copyright (c) 2016-2022, Regents of the University of California,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University.
*
@@ -28,8 +28,7 @@
#include "pipeline-interests-adaptive.hpp"
-namespace ndn {
-namespace chunks {
+namespace ndn::chunks {
/**
* @brief Implements Cubic window increase and decrease.
@@ -55,7 +54,6 @@
time::steady_clock::time_point m_lastDecrease; ///< time of last window decrease
};
-} // namespace chunks
-} // namespace ndn
+} // namespace ndn::chunks
#endif // NDN_TOOLS_CHUNKS_CATCHUNKS_PIPELINE_INTERESTS_CUBIC_HPP
diff --git a/tools/chunks/catchunks/pipeline-interests-fixed.cpp b/tools/chunks/catchunks/pipeline-interests-fixed.cpp
index 7fab8e3..a80ca5e 100644
--- a/tools/chunks/catchunks/pipeline-interests-fixed.cpp
+++ b/tools/chunks/catchunks/pipeline-interests-fixed.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2016-2021, Regents of the University of California,
+ * Copyright (c) 2016-2022, Regents of the University of California,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University.
*
@@ -30,8 +30,7 @@
#include "pipeline-interests-fixed.hpp"
#include "data-fetcher.hpp"
-namespace ndn {
-namespace chunks {
+namespace ndn::chunks {
PipelineInterestsFixed::PipelineInterestsFixed(Face& face, const Options& opts)
: PipelineInterests(face, opts)
@@ -83,7 +82,6 @@
auto interest = Interest()
.setName(Name(m_prefix).appendSegment(nextSegmentNo))
- .setCanBePrefix(false)
.setMustBeFresh(m_options.mustBeFresh)
.setInterestLifetime(m_options.interestLifetime);
@@ -194,5 +192,4 @@
}
}
-} // namespace chunks
-} // namespace ndn
+} // namespace ndn::chunks
diff --git a/tools/chunks/catchunks/pipeline-interests-fixed.hpp b/tools/chunks/catchunks/pipeline-interests-fixed.hpp
index b21575e..a317ad2 100644
--- a/tools/chunks/catchunks/pipeline-interests-fixed.hpp
+++ b/tools/chunks/catchunks/pipeline-interests-fixed.hpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2016-2019, Regents of the University of California,
+ * Copyright (c) 2016-2022, Regents of the University of California,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University.
*
@@ -32,8 +32,7 @@
#include "pipeline-interests.hpp"
-namespace ndn {
-namespace chunks {
+namespace ndn::chunks {
class DataFetcher;
@@ -91,7 +90,6 @@
bool m_hasFailure = false;
};
-} // namespace chunks
-} // namespace ndn
+} // namespace ndn::chunks
#endif // NDN_TOOLS_CHUNKS_CATCHUNKS_PIPELINE_INTERESTS_FIXED_HPP
diff --git a/tools/chunks/catchunks/pipeline-interests.cpp b/tools/chunks/catchunks/pipeline-interests.cpp
index 9f2e3b5..218df28 100644
--- a/tools/chunks/catchunks/pipeline-interests.cpp
+++ b/tools/chunks/catchunks/pipeline-interests.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2016-2021, Regents of the University of California,
+ * Copyright (c) 2016-2022, Regents of the University of California,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University.
*
@@ -33,18 +33,11 @@
#include <boost/asio/io_service.hpp>
-namespace ndn {
-namespace chunks {
+namespace ndn::chunks {
PipelineInterests::PipelineInterests(Face& face, const Options& opts)
: m_options(opts)
, m_face(face)
- , m_hasFinalBlockId(false)
- , m_lastSegmentNo(0)
- , m_nReceived(0)
- , m_receivedSize(0)
- , m_nextSegmentNo(0)
- , m_isStopping(false)
{
}
@@ -160,5 +153,4 @@
return "";
}
-} // namespace chunks
-} // namespace ndn
+} // namespace ndn::chunks
diff --git a/tools/chunks/catchunks/pipeline-interests.hpp b/tools/chunks/catchunks/pipeline-interests.hpp
index 9fc3389..ea52d2f 100644
--- a/tools/chunks/catchunks/pipeline-interests.hpp
+++ b/tools/chunks/catchunks/pipeline-interests.hpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2016-2021, Regents of the University of California,
+ * Copyright (c) 2016-2022, Regents of the University of California,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University.
*
@@ -33,8 +33,7 @@
#include "options.hpp"
-namespace ndn {
-namespace chunks {
+namespace ndn::chunks {
/**
* @brief Service for retrieving Data via an Interest pipeline
@@ -46,7 +45,7 @@
* No guarantees are made as to the order in which segments are fetched or callbacks are invoked,
* i.e. out-of-order delivery is possible.
*/
-class PipelineInterests
+class PipelineInterests : noncopyable
{
public:
/**
@@ -96,7 +95,7 @@
* @brief check if the transfer is complete
* @return true if all segments have been received, false otherwise
*/
- bool
+ [[nodiscard]] bool
allSegmentsReceived() const;
/**
@@ -157,17 +156,17 @@
Name m_prefix;
PUBLIC_WITH_TESTS_ELSE_PROTECTED:
- bool m_hasFinalBlockId; ///< true if the last segment number is known
- uint64_t m_lastSegmentNo; ///< valid only if m_hasFinalBlockId == true
- int64_t m_nReceived; ///< number of segments received
- size_t m_receivedSize; ///< size of received data in bytes
+ bool m_hasFinalBlockId = false; ///< true if the last segment number is known
+ uint64_t m_lastSegmentNo = 0; ///< valid only if m_hasFinalBlockId == true
+ int64_t m_nReceived = 0; ///< number of segments received
+ size_t m_receivedSize = 0; ///< size of received data in bytes
private:
DataCallback m_onData;
FailureCallback m_onFailure;
- uint64_t m_nextSegmentNo;
+ uint64_t m_nextSegmentNo = 0;
time::steady_clock::time_point m_startTime;
- bool m_isStopping;
+ bool m_isStopping = false;
};
template<typename Packet>
@@ -177,7 +176,6 @@
return packet.getName().at(-1).toSegment();
}
-} // namespace chunks
-} // namespace ndn
+} // namespace ndn::chunks
#endif // NDN_TOOLS_CHUNKS_CATCHUNKS_PIPELINE_INTERESTS_HPP
diff --git a/tools/chunks/catchunks/statistics-collector.cpp b/tools/chunks/catchunks/statistics-collector.cpp
index 91af79d..2e303c9 100644
--- a/tools/chunks/catchunks/statistics-collector.cpp
+++ b/tools/chunks/catchunks/statistics-collector.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2016-2019, Regents of the University of California,
+ * Copyright (c) 2016-2022, Regents of the University of California,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University.
*
@@ -24,8 +24,7 @@
#include "statistics-collector.hpp"
-namespace ndn {
-namespace chunks {
+namespace ndn::chunks {
StatisticsCollector::StatisticsCollector(PipelineInterestsAdaptive& pipeline,
std::ostream& osCwnd, std::ostream& osRtt)
@@ -48,5 +47,4 @@
});
}
-} // namespace chunks
-} // namespace ndn
+} // namespace ndn::chunks
diff --git a/tools/chunks/catchunks/statistics-collector.hpp b/tools/chunks/catchunks/statistics-collector.hpp
index bc57f00..95abbae 100644
--- a/tools/chunks/catchunks/statistics-collector.hpp
+++ b/tools/chunks/catchunks/statistics-collector.hpp
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2016-2019, Regents of the University of California,
+ * Copyright (c) 2016-2022, Regents of the University of California,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University.
*
@@ -27,8 +27,7 @@
#include "pipeline-interests-adaptive.hpp"
-namespace ndn {
-namespace chunks {
+namespace ndn::chunks {
/**
* @brief Statistics collector for Adaptive pipelines
@@ -44,7 +43,6 @@
std::ostream& m_osRtt;
};
-} // namespace chunks
-} // namespace ndn
+} // namespace ndn::chunks
#endif // NDN_TOOLS_CHUNKS_CATCHUNKS_STATISTICS_COLLECTOR_HPP
diff --git a/tools/chunks/putchunks/main.cpp b/tools/chunks/putchunks/main.cpp
index de338f3..8969e06 100644
--- a/tools/chunks/putchunks/main.cpp
+++ b/tools/chunks/putchunks/main.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2016-2021, Regents of the University of California,
+ * Copyright (c) 2016-2022, Regents of the University of California,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University.
*
@@ -34,13 +34,12 @@
#include <boost/program_options/parsers.hpp>
#include <boost/program_options/variables_map.hpp>
-namespace ndn {
-namespace chunks {
+namespace ndn::chunks {
namespace po = boost::program_options;
static void
-usage(std::ostream& os, const std::string& programName, const po::options_description& desc)
+usage(std::ostream& os, std::string_view programName, const po::options_description& desc)
{
os << "Usage: " << programName << " [options] ndn:/name\n"
<< "\n"
@@ -163,8 +162,7 @@
return 0;
}
-} // namespace chunks
-} // namespace ndn
+} // namespace ndn::chunks
int
main(int argc, char* argv[])
diff --git a/tools/chunks/putchunks/producer.cpp b/tools/chunks/putchunks/producer.cpp
index c353817..24565c0 100644
--- a/tools/chunks/putchunks/producer.cpp
+++ b/tools/chunks/putchunks/producer.cpp
@@ -32,8 +32,7 @@
#include <ndn-cxx/metadata-object.hpp>
-namespace ndn {
-namespace chunks {
+namespace ndn::chunks {
Producer::Producer(const Name& prefix, Face& face, KeyChain& keyChain, std::istream& is,
const Options& opts)
@@ -185,5 +184,4 @@
std::cerr << "Created " << m_store.size() << " chunks for prefix " << m_prefix << "\n";
}
-} // namespace chunks
-} // namespace ndn
+} // namespace ndn::chunks
diff --git a/tools/chunks/putchunks/producer.hpp b/tools/chunks/putchunks/producer.hpp
index aad6245..7000bd7 100644
--- a/tools/chunks/putchunks/producer.hpp
+++ b/tools/chunks/putchunks/producer.hpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2016-2021, Regents of the University of California,
+ * Copyright (c) 2016-2022, Regents of the University of California,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University.
*
@@ -32,8 +32,7 @@
#include "core/common.hpp"
-namespace ndn {
-namespace chunks {
+namespace ndn::chunks {
/**
* @brief Segmented & versioned data publisher
@@ -107,7 +106,6 @@
const Options m_options;
};
-} // namespace chunks
-} // namespace ndn
+} // namespace ndn::chunks
#endif // NDN_TOOLS_CHUNKS_PUTCHUNKS_PRODUCER_HPP
diff --git a/tools/dissect/dissector.cpp b/tools/dissect/dissector.cpp
index dfc5c98..c612352 100644
--- a/tools/dissect/dissector.cpp
+++ b/tools/dissect/dissector.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2013-2021, Regents of the University of California.
+ * Copyright (c) 2013-2022, Regents of the University of California.
*
* This file is part of ndn-tools (Named Data Networking Essential Tools).
* See AUTHORS.md for complete list of ndn-tools authors and contributors.
@@ -29,8 +29,7 @@
#include <ndn-cxx/encoding/tlv.hpp>
#include <ndn-cxx/name-component.hpp>
-namespace ndn {
-namespace dissect {
+namespace ndn::dissect {
Dissector::Dissector(std::istream& input, std::ostream& output, const Options& options)
: m_options(options)
@@ -74,7 +73,7 @@
}
}
-static const std::map<uint32_t, const char*> TLV_DICT = {
+static const std::map<uint32_t, std::string_view> TLV_DICT = {
{tlv::Interest , "Interest"},
{tlv::Data , "Data"},
{tlv::Name , "Name"},
@@ -185,5 +184,4 @@
m_branches.pop_back();
}
-} // namespace dissect
-} // namespace ndn
+} // namespace ndn::dissect
diff --git a/tools/dissect/dissector.hpp b/tools/dissect/dissector.hpp
index e408efe..6ab7087 100644
--- a/tools/dissect/dissector.hpp
+++ b/tools/dissect/dissector.hpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2014-2021, Regents of the University of California.
+ * Copyright (c) 2014-2022, Regents of the University of California.
*
* This file is part of ndn-tools (Named Data Networking Essential Tools).
* See AUTHORS.md for complete list of ndn-tools authors and contributors.
@@ -24,8 +24,7 @@
#include <ndn-cxx/encoding/block.hpp>
-namespace ndn {
-namespace dissect {
+namespace ndn::dissect {
struct Options
{
@@ -59,7 +58,6 @@
std::vector<bool> m_branches;
};
-} // namespace dissect
-} // namespace ndn
+} // namespace ndn::dissect
#endif // NDN_TOOLS_DISSECT_DISSECTOR_HPP
diff --git a/tools/dissect/main.cpp b/tools/dissect/main.cpp
index bcb2339..1cb6546 100644
--- a/tools/dissect/main.cpp
+++ b/tools/dissect/main.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2014-2021, Regents of the University of California.
+ * Copyright (c) 2014-2022, Regents of the University of California.
*
* This file is part of ndn-tools (Named Data Networking Essential Tools).
* See AUTHORS.md for complete list of ndn-tools authors and contributors.
@@ -26,13 +26,12 @@
#include <fstream>
-namespace ndn {
-namespace dissect {
+namespace ndn::dissect {
namespace po = boost::program_options;
static void
-usage(std::ostream& os, const std::string& programName, const po::options_description& options)
+usage(std::ostream& os, std::string_view programName, const po::options_description& options)
{
os << "Usage: " << programName << " [options] [input-file]\n"
<< "\n"
@@ -99,8 +98,7 @@
return 0;
}
-} // namespace dissect
-} // namespace ndn
+} // namespace ndn::dissect
int
main(int argc, char* argv[])
diff --git a/tools/dump/main.cpp b/tools/dump/main.cpp
index 49ea5b0..033ffc4 100644
--- a/tools/dump/main.cpp
+++ b/tools/dump/main.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2011-2021, Regents of the University of California.
+ * Copyright (c) 2011-2022, Regents of the University of California.
*
* This file is part of ndn-tools (Named Data Networking Essential Tools).
* See AUTHORS.md for complete list of ndn-tools authors and contributors.
@@ -28,15 +28,14 @@
#include <sstream>
-namespace ndn {
-namespace dump {
+namespace ndn::dump {
namespace po = boost::program_options;
static void
-usage(std::ostream& os, const std::string& appName, const po::options_description& options)
+usage(std::ostream& os, std::string_view progName, const po::options_description& options)
{
- os << "Usage: " << appName << " [options] [pcap-filter]\n"
+ os << "Usage: " << progName << " [options] [pcap-filter]\n"
<< "\n"
<< "Default pcap-filter:\n"
<< " '" << NdnDump::getDefaultPcapFilter() << "'\n"
@@ -142,8 +141,7 @@
return 0;
}
-} // namespace dump
-} // namespace ndn
+} // namespace ndn::dump
int
main(int argc, char* argv[])
diff --git a/tools/dump/ndndump.cpp b/tools/dump/ndndump.cpp
index cb1583f..4b28c63 100644
--- a/tools/dump/ndndump.cpp
+++ b/tools/dump/ndndump.cpp
@@ -39,8 +39,7 @@
#include <boost/endian/conversion.hpp>
-namespace ndn {
-namespace dump {
+namespace ndn::dump {
namespace endian = boost::endian;
@@ -517,9 +516,7 @@
}
out.addDelimiter();
- bool isOk = false;
- Block block;
- std::tie(isOk, block) = Block::fromBuffer({pkt, len});
+ auto [isOk, block] = Block::fromBuffer({pkt, len});
if (!isOk) {
// if packet is incomplete, we will not be able to process it
out << "NDN truncated packet, length " << len;
@@ -539,15 +536,12 @@
return true;
}
- Buffer::const_iterator begin, end;
- if (lpPacket.has<lp::FragmentField>()) {
- std::tie(begin, end) = lpPacket.get<lp::FragmentField>();
- }
- else {
+ if (!lpPacket.has<lp::FragmentField>()) {
out << " idle";
return true;
}
+ auto [begin, end] = lpPacket.get<lp::FragmentField>();
std::tie(isOk, netPacket) = Block::fromBuffer({begin, end});
if (!isOk) {
// if network packet is fragmented, we will not be able to process it
@@ -610,5 +604,4 @@
return std::regex_match(name.toUri(), *nameFilter);
}
-} // namespace dump
-} // namespace ndn
+} // namespace ndn::dump
diff --git a/tools/dump/ndndump.hpp b/tools/dump/ndndump.hpp
index 47a455a..9d786e7 100644
--- a/tools/dump/ndndump.hpp
+++ b/tools/dump/ndndump.hpp
@@ -37,8 +37,7 @@
#define UH_LEN len
#endif
-namespace ndn {
-namespace dump {
+namespace ndn::dump {
class OutputFormatter;
@@ -59,7 +58,7 @@
void
printPacket(const pcap_pkthdr* pkthdr, const uint8_t* payload) const;
- static constexpr const char*
+ static constexpr std::string_view
getDefaultPcapFilter() noexcept
{
return "(ether proto 0x8624) or (tcp port 6363) or (udp port 6363) or (udp port 56363)";
@@ -99,13 +98,13 @@
bool
printNdn(OutputFormatter& out, const uint8_t* pkt, size_t len) const;
- bool
+ [[nodiscard]] bool
matchesFilter(const Name& name) const;
public: // options
std::string interface;
std::string inputFile;
- std::string pcapFilter = getDefaultPcapFilter();
+ std::string pcapFilter{getDefaultPcapFilter()};
optional<std::regex> nameFilter;
bool wantPromisc = true;
bool wantTimestamp = true;
@@ -118,7 +117,6 @@
int m_dataLinkType = -1;
};
-} // namespace dump
-} // namespace ndn
+} // namespace ndn::dump
#endif // NDN_TOOLS_DUMP_NDNDUMP_HPP
diff --git a/tools/peek/ndnpeek/main.cpp b/tools/peek/ndnpeek/main.cpp
index 22523b7..0bfb677 100644
--- a/tools/peek/ndnpeek/main.cpp
+++ b/tools/peek/ndnpeek/main.cpp
@@ -41,13 +41,12 @@
#include <cstring>
#include <fstream>
-namespace ndn {
-namespace peek {
+namespace ndn::peek {
namespace po = boost::program_options;
static void
-usage(std::ostream& os, const std::string& program, const po::options_description& options)
+usage(std::ostream& os, std::string_view program, const po::options_description& options)
{
os << "Usage: " << program << " [options] /name\n"
<< "\n"
@@ -203,8 +202,7 @@
}
}
-} // namespace peek
-} // namespace ndn
+} // namespace ndn::peek
int
main(int argc, char* argv[])
diff --git a/tools/peek/ndnpeek/ndnpeek.cpp b/tools/peek/ndnpeek/ndnpeek.cpp
index 01fd6de..d58b92e 100644
--- a/tools/peek/ndnpeek/ndnpeek.cpp
+++ b/tools/peek/ndnpeek/ndnpeek.cpp
@@ -29,8 +29,7 @@
#include "ndnpeek.hpp"
-namespace ndn {
-namespace peek {
+namespace ndn::peek {
NdnPeek::NdnPeek(Face& face, const PeekOptions& options)
: m_options(options)
@@ -132,5 +131,4 @@
}
}
-} // namespace peek
-} // namespace ndn
+} // namespace ndn::peek
diff --git a/tools/peek/ndnpeek/ndnpeek.hpp b/tools/peek/ndnpeek/ndnpeek.hpp
index ce37712..eba1b1f 100644
--- a/tools/peek/ndnpeek/ndnpeek.hpp
+++ b/tools/peek/ndnpeek/ndnpeek.hpp
@@ -35,8 +35,7 @@
#include <ndn-cxx/link.hpp>
#include <ndn-cxx/util/scheduler.hpp>
-namespace ndn {
-namespace peek {
+namespace ndn::peek {
/**
* @brief options for NdnPeek
@@ -58,7 +57,7 @@
optional<time::milliseconds> timeout;
};
-class NdnPeek : boost::noncopyable
+class NdnPeek : noncopyable
{
public:
NdnPeek(Face& face, const PeekOptions& options);
@@ -119,7 +118,6 @@
Result m_result = Result::UNKNOWN;
};
-} // namespace peek
-} // namespace ndn
+} // namespace ndn::peek
#endif // NDN_TOOLS_NDNPEEK_NDNPEEK_HPP
diff --git a/tools/peek/ndnpoke/main.cpp b/tools/peek/ndnpoke/main.cpp
index f2a6830..a3e5ec2 100644
--- a/tools/peek/ndnpoke/main.cpp
+++ b/tools/peek/ndnpoke/main.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2014-2021, Regents of the University of California,
+ * Copyright (c) 2014-2022, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
@@ -33,13 +33,12 @@
#include <boost/program_options/parsers.hpp>
#include <boost/program_options/variables_map.hpp>
-namespace ndn {
-namespace peek {
+namespace ndn::peek {
namespace po = boost::program_options;
static void
-usage(std::ostream& os, const std::string& program, const po::options_description& options)
+usage(std::ostream& os, std::string_view program, const po::options_description& options)
{
os << "Usage: " << program << " [options] /name\n"
<< "\n"
@@ -167,8 +166,7 @@
}
}
-} // namespace peek
-} // namespace ndn
+} // namespace ndn::peek
int
main(int argc, char* argv[])
diff --git a/tools/peek/ndnpoke/ndnpoke.cpp b/tools/peek/ndnpoke/ndnpoke.cpp
index d31a939..27feb17 100644
--- a/tools/peek/ndnpoke/ndnpoke.cpp
+++ b/tools/peek/ndnpoke/ndnpoke.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2014-2019, Regents of the University of California,
+ * Copyright (c) 2014-2022, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
@@ -30,8 +30,7 @@
#include <ndn-cxx/encoding/buffer-stream.hpp>
-namespace ndn {
-namespace peek {
+namespace ndn::peek {
NdnPoke::NdnPoke(Face& face, KeyChain& keyChain, std::istream& input, const PokeOptions& options)
: m_options(options)
@@ -123,11 +122,10 @@
}
void
-NdnPoke::onRegFailure(const std::string& reason)
+NdnPoke::onRegFailure(std::string_view reason)
{
m_result = Result::PREFIX_REG_FAIL;
std::cerr << "Prefix registration failure (" << reason << ")" << std::endl;
}
-} // namespace peek
-} // namespace ndn
+} // namespace ndn::peek
diff --git a/tools/peek/ndnpoke/ndnpoke.hpp b/tools/peek/ndnpoke/ndnpoke.hpp
index 5ffd8cf..16a3795 100644
--- a/tools/peek/ndnpoke/ndnpoke.hpp
+++ b/tools/peek/ndnpoke/ndnpoke.hpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2014-2019, Regents of the University of California,
+ * Copyright (c) 2014-2022, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
@@ -33,8 +33,7 @@
#include <ndn-cxx/util/scheduler.hpp>
-namespace ndn {
-namespace peek {
+namespace ndn::peek {
/**
* \brief options for NdnPoke
@@ -53,7 +52,7 @@
optional<time::milliseconds> timeout;
};
-class NdnPoke : boost::noncopyable
+class NdnPoke : noncopyable
{
public:
NdnPoke(Face& face, KeyChain& keyChain, std::istream& input, const PokeOptions& options);
@@ -93,7 +92,7 @@
onRegSuccess();
void
- onRegFailure(const std::string& reason);
+ onRegFailure(std::string_view reason);
private:
const PokeOptions m_options;
@@ -106,7 +105,6 @@
Result m_result = Result::UNKNOWN;
};
-} // namespace peek
-} // namespace ndn
+} // namespace ndn::peek
#endif // NDN_TOOLS_NDNPOKE_NDNPOKE_HPP
diff --git a/tools/ping/client/main.cpp b/tools/ping/client/main.cpp
index f49c972..a37a461 100644
--- a/tools/ping/client/main.cpp
+++ b/tools/ping/client/main.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2014-2021, Arizona Board of Regents.
+ * Copyright (c) 2014-2022, Arizona Board of Regents.
*
* This file is part of ndn-tools (Named Data Networking Essential Tools).
* See AUTHORS.md for complete list of ndn-tools authors and contributors.
@@ -32,9 +32,7 @@
#include <boost/program_options/parsers.hpp>
#include <boost/program_options/variables_map.hpp>
-namespace ndn {
-namespace ping {
-namespace client {
+namespace ndn::ping::client {
class Runner : noncopyable
{
@@ -115,25 +113,7 @@
boost::asio::signal_set m_signalSetQuit;
};
-static time::milliseconds
-getMinimumPingInterval()
-{
- return time::milliseconds(1);
-}
-
-static time::milliseconds
-getDefaultPingInterval()
-{
- return time::milliseconds(1000);
-}
-
-static time::milliseconds
-getDefaultPingTimeoutThreshold()
-{
- return time::milliseconds(4000);
-}
-
-static void
+[[noreturn]] static void
usage(const boost::program_options::options_description& options)
{
std::cout << "Usage: ndnping [options] ndn:/name/prefix\n"
@@ -151,8 +131,8 @@
Options options;
options.shouldAllowStaleData = false;
options.nPings = -1;
- options.interval = time::milliseconds(getDefaultPingInterval());
- options.timeout = time::milliseconds(getDefaultPingTimeoutThreshold());
+ options.interval = 1_s;
+ options.timeout = 4_s;
options.startSeq = 0;
options.shouldGenerateRandomSeq = true;
options.shouldPrintTimestamp = false;
@@ -165,9 +145,9 @@
visibleOptDesc.add_options()
("help,h", "print this message and exit")
("version,V", "display version and exit")
- ("interval,i", po::value<time::milliseconds::rep>()->default_value(getDefaultPingInterval().count()),
+ ("interval,i", po::value<time::milliseconds::rep>()->default_value(options.interval.count()),
"ping interval, in milliseconds")
- ("timeout,o", po::value<time::milliseconds::rep>()->default_value(getDefaultPingTimeoutThreshold().count()),
+ ("timeout,o", po::value<time::milliseconds::rep>()->default_value(options.timeout.count()),
"ping timeout, in milliseconds")
("count,c", po::value<int>(&options.nPings), "number of pings to send (default = no limit)")
("start,n", po::value<uint64_t>(&options.startSeq),
@@ -212,9 +192,8 @@
}
options.interval = time::milliseconds(optVm["interval"].as<time::milliseconds::rep>());
- if (options.interval < getMinimumPingInterval()) {
- std::cerr << "ERROR: Specified ping interval is less than the minimum "
- << getMinimumPingInterval() << "\n";
+ if (options.interval < 1_ms) {
+ std::cerr << "ERROR: Specified ping interval is less than the minimum (1 ms)\n";
usage(visibleOptDesc);
}
@@ -258,9 +237,7 @@
return Runner(options).run();
}
-} // namespace client
-} // namespace ping
-} // namespace ndn
+} // namespace ndn::ping::client
int
main(int argc, char* argv[])
diff --git a/tools/ping/client/ping.cpp b/tools/ping/client/ping.cpp
index c52ed10..5ce8765 100644
--- a/tools/ping/client/ping.cpp
+++ b/tools/ping/client/ping.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2014-2021, Arizona Board of Regents.
+ * Copyright (c) 2014-2022, Arizona Board of Regents.
*
* This file is part of ndn-tools (Named Data Networking Essential Tools).
* See AUTHORS.md for complete list of ndn-tools authors and contributors.
@@ -25,15 +25,11 @@
#include <ndn-cxx/util/random.hpp>
-namespace ndn {
-namespace ping {
-namespace client {
+namespace ndn::ping::client {
Ping::Ping(Face& face, const Options& options)
: m_options(options)
- , m_nSent(0)
, m_nextSeq(options.startSeq)
- , m_nOutstanding(0)
, m_face(face)
, m_scheduler(m_face.getIoService())
{
@@ -60,7 +56,6 @@
BOOST_ASSERT((m_options.nPings < 0) || (m_nSent < m_options.nPings));
Interest interest(makePingName(m_nextSeq));
- interest.setCanBePrefix(false);
interest.setMustBeFresh(!m_options.shouldAllowStaleData);
interest.setInterestLifetime(m_options.timeout);
@@ -126,6 +121,4 @@
return name;
}
-} // namespace client
-} // namespace ping
-} // namespace ndn
+} // namespace ndn::ping::client
diff --git a/tools/ping/client/ping.hpp b/tools/ping/client/ping.hpp
index a44ca0c..f78d761 100644
--- a/tools/ping/client/ping.hpp
+++ b/tools/ping/client/ping.hpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2015-2021, Arizona Board of Regents.
+ * Copyright (c) 2015-2022, Arizona Board of Regents.
*
* This file is part of ndn-tools (Named Data Networking Essential Tools).
* See AUTHORS.md for complete list of ndn-tools authors and contributors.
@@ -28,14 +28,12 @@
#include <ndn-cxx/util/signal.hpp>
-namespace ndn {
-namespace ping {
-namespace client {
+namespace ndn::ping::client {
-typedef time::duration<double, time::milliseconds::period> Rtt;
+using Rtt = time::duration<double, time::milliseconds::period>;
/**
- * @brief options for ndnping client
+ * @brief %Options for ndnping client.
*/
struct Options
{
@@ -144,16 +142,14 @@
private:
const Options& m_options;
- int m_nSent;
+ int m_nSent = 0;
uint64_t m_nextSeq;
- int m_nOutstanding;
+ int m_nOutstanding = 0;
Face& m_face;
Scheduler m_scheduler;
scheduler::ScopedEventId m_nextPingEvent;
};
-} // namespace client
-} // namespace ping
-} // namespace ndn
+} // namespace ndn::ping::client
#endif // NDN_TOOLS_PING_CLIENT_PING_HPP
diff --git a/tools/ping/client/statistics-collector.cpp b/tools/ping/client/statistics-collector.cpp
index 6c29405..0b6b39f 100644
--- a/tools/ping/client/statistics-collector.cpp
+++ b/tools/ping/client/statistics-collector.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2015-2021, Arizona Board of Regents.
+ * Copyright (c) 2015-2022, Arizona Board of Regents.
*
* This file is part of ndn-tools (Named Data Networking Essential Tools).
* See AUTHORS.md for complete list of ndn-tools authors and contributors.
@@ -23,21 +23,11 @@
#include "statistics-collector.hpp"
-namespace ndn {
-namespace ping {
-namespace client {
+namespace ndn::ping::client {
StatisticsCollector::StatisticsCollector(Ping& ping, const Options& options)
: m_ping(ping)
, m_options(options)
- , m_nSent(0)
- , m_nReceived(0)
- , m_nNacked(0)
- , m_pingStartTime(time::steady_clock::now())
- , m_minRtt(std::numeric_limits<double>::max())
- , m_maxRtt(0.0)
- , m_sumRtt(0.0)
- , m_sumRttSquared(0.0)
{
m_ping.afterData.connect([this] (auto&&, Rtt rtt) { recordData(rtt); });
m_ping.afterNack.connect([this] (auto&&...) { recordNack(); });
@@ -153,6 +143,4 @@
return os;
}
-} // namespace client
-} // namespace ping
-} // namespace ndn
+} // namespace ndn::ping::client
diff --git a/tools/ping/client/statistics-collector.hpp b/tools/ping/client/statistics-collector.hpp
index 9622717..1810208 100644
--- a/tools/ping/client/statistics-collector.hpp
+++ b/tools/ping/client/statistics-collector.hpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2015-2021, Arizona Board of Regents.
+ * Copyright (c) 2015-2022, Arizona Board of Regents.
*
* This file is part of ndn-tools (Named Data Networking Essential Tools).
* See AUTHORS.md for complete list of ndn-tools authors and contributors.
@@ -28,9 +28,7 @@
#include "ping.hpp"
-namespace ndn {
-namespace ping {
-namespace client {
+namespace ndn::ping::client {
/**
* @brief statistics data
@@ -52,6 +50,9 @@
std::ostream&
printSummary(std::ostream& os) const;
+
+ friend std::ostream&
+ operator<<(std::ostream& os, const Statistics& statistics);
};
/**
@@ -69,7 +70,7 @@
/**
* @brief Compute and return ping statistics as structure
*/
- Statistics
+ [[nodiscard]] Statistics
computeStatistics() const;
PUBLIC_WITH_TESTS_ELSE_PRIVATE:
@@ -94,21 +95,16 @@
private:
Ping& m_ping;
const Options& m_options;
- int m_nSent;
- int m_nReceived;
- int m_nNacked;
- time::steady_clock::time_point m_pingStartTime;
- double m_minRtt;
- double m_maxRtt;
- double m_sumRtt;
- double m_sumRttSquared;
+ time::steady_clock::time_point m_pingStartTime = time::steady_clock::now();
+ int m_nSent = 0;
+ int m_nReceived = 0;
+ int m_nNacked = 0;
+ double m_minRtt = std::numeric_limits<double>::max();
+ double m_maxRtt = 0.0;
+ double m_sumRtt = 0.0;
+ double m_sumRttSquared = 0.0;
};
-std::ostream&
-operator<<(std::ostream& os, const Statistics& statistics);
-
-} // namespace client
-} // namespace ping
-} // namespace ndn
+} // namespace ndn::ping::client
#endif // NDN_TOOLS_PING_CLIENT_STATISTICS_COLLECTOR_HPP
diff --git a/tools/ping/client/tracer.cpp b/tools/ping/client/tracer.cpp
index 7db5085..7c16a4c 100644
--- a/tools/ping/client/tracer.cpp
+++ b/tools/ping/client/tracer.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2015-2021, Arizona Board of Regents.
+ * Copyright (c) 2015-2022, Arizona Board of Regents.
*
* This file is part of ndn-tools (Named Data Networking Essential Tools).
* See AUTHORS.md for complete list of ndn-tools authors and contributors.
@@ -22,9 +22,7 @@
#include "tracer.hpp"
-namespace ndn {
-namespace ping {
-namespace client {
+namespace ndn::ping::client {
Tracer::Tracer(Ping& ping, const Options& options)
: m_options(options)
@@ -72,6 +70,4 @@
std::cerr << "ERROR: " << msg << "\n";
}
-} // namespace client
-} // namespace ping
-} // namespace ndn
+} // namespace ndn::ping::client
diff --git a/tools/ping/client/tracer.hpp b/tools/ping/client/tracer.hpp
index b6b4812..c2d375e 100644
--- a/tools/ping/client/tracer.hpp
+++ b/tools/ping/client/tracer.hpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2015-2021, Arizona Board of Regents.
+ * Copyright (c) 2015-2022, Arizona Board of Regents.
*
* This file is part of ndn-tools (Named Data Networking Essential Tools).
* See AUTHORS.md for complete list of ndn-tools authors and contributors.
@@ -27,9 +27,7 @@
#include "ping.hpp"
-namespace ndn {
-namespace ping {
-namespace client {
+namespace ndn::ping::client {
/**
* @brief prints ping responses and timeouts
@@ -80,8 +78,6 @@
const Options& m_options;
};
-} // namespace client
-} // namespace ping
-} // namespace ndn
+} // namespace ndn::ping::client
#endif // NDN_TOOLS_PING_CLIENT_TRACER_HPP
diff --git a/tools/ping/server/main.cpp b/tools/ping/server/main.cpp
index e81125c..bf050da 100644
--- a/tools/ping/server/main.cpp
+++ b/tools/ping/server/main.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2015-2021, Arizona Board of Regents.
+ * Copyright (c) 2015-2022, Arizona Board of Regents.
*
* This file is part of ndn-tools (Named Data Networking Essential Tools).
* See AUTHORS.md for complete list of ndn-tools authors and contributors.
@@ -31,9 +31,7 @@
#include <boost/program_options/parsers.hpp>
#include <boost/program_options/variables_map.hpp>
-namespace ndn {
-namespace ping {
-namespace server {
+namespace ndn::ping::server {
namespace po = boost::program_options;
@@ -90,7 +88,7 @@
};
static void
-usage(std::ostream& os, const std::string& programName, const po::options_description& options)
+usage(std::ostream& os, std::string_view programName, const po::options_description& options)
{
os << "Usage: " << programName << " [options] <prefix>\n"
<< "\n"
@@ -187,9 +185,7 @@
return Runner(options).run();
}
-} // namespace server
-} // namespace ping
-} // namespace ndn
+} // namespace ndn::ping::server
int
main(int argc, char* argv[])
diff --git a/tools/ping/server/ping-server.cpp b/tools/ping/server/ping-server.cpp
index 5ceeb76..69093d3 100644
--- a/tools/ping/server/ping-server.cpp
+++ b/tools/ping/server/ping-server.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2015-2021, Arizona Board of Regents.
+ * Copyright (c) 2015-2022, Arizona Board of Regents.
*
* This file is part of ndn-tools (Named Data Networking Essential Tools).
* See AUTHORS.md for complete list of ndn-tools authors and contributors.
@@ -24,15 +24,12 @@
#include <ndn-cxx/security/signing-helpers.hpp>
-namespace ndn {
-namespace ping {
-namespace server {
+namespace ndn::ping::server {
PingServer::PingServer(Face& face, KeyChain& keyChain, const Options& options)
: m_options(options)
, m_face(face)
, m_keyChain(keyChain)
- , m_nPings(0)
{
auto b = make_shared<Buffer>();
b->assign(m_options.payloadSize, 'a');
@@ -78,6 +75,4 @@
}
}
-} // namespace server
-} // namespace ping
-} // namespace ndn
+} // namespace ndn::ping::server
diff --git a/tools/ping/server/ping-server.hpp b/tools/ping/server/ping-server.hpp
index f13769c..e9127c0 100644
--- a/tools/ping/server/ping-server.hpp
+++ b/tools/ping/server/ping-server.hpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2015-2021, Arizona Board of Regents.
+ * Copyright (c) 2015-2022, Arizona Board of Regents.
*
* This file is part of ndn-tools (Named Data Networking Essential Tools).
* See AUTHORS.md for complete list of ndn-tools authors and contributors.
@@ -27,9 +27,7 @@
#include <ndn-cxx/util/signal.hpp>
-namespace ndn {
-namespace ping {
-namespace server {
+namespace ndn::ping::server {
/**
* @brief Options for PingServer
@@ -105,13 +103,11 @@
const Options& m_options;
Face& m_face;
KeyChain& m_keyChain;
- size_t m_nPings;
+ size_t m_nPings = 0;
Block m_payload;
RegisteredPrefixHandle m_registeredPrefix;
};
-} // namespace server
-} // namespace ping
-} // namespace ndn
+} // namespace ndn::ping::server
#endif // NDN_TOOLS_PING_SERVER_PING_SERVER_HPP
diff --git a/tools/ping/server/tracer.cpp b/tools/ping/server/tracer.cpp
index c6b30b9..0a9df40 100644
--- a/tools/ping/server/tracer.cpp
+++ b/tools/ping/server/tracer.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2015-2021, Arizona Board of Regents.
+ * Copyright (c) 2015-2022, Arizona Board of Regents.
*
* This file is part of ndn-tools (Named Data Networking Essential Tools).
* See AUTHORS.md for complete list of ndn-tools authors and contributors.
@@ -21,9 +21,7 @@
#include "tracer.hpp"
-namespace ndn {
-namespace ping {
-namespace server {
+namespace ndn::ping::server {
Tracer::Tracer(PingServer& pingServer, const Options& options)
: m_options(options)
@@ -38,6 +36,4 @@
}
}
-} // namespace server
-} // namespace ping
-} // namespace ndn
+} // namespace ndn::ping::server
diff --git a/tools/ping/server/tracer.hpp b/tools/ping/server/tracer.hpp
index a84b72e..e8aac85 100644
--- a/tools/ping/server/tracer.hpp
+++ b/tools/ping/server/tracer.hpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2015-2021, Arizona Board of Regents.
+ * Copyright (c) 2015-2022, Arizona Board of Regents.
*
* This file is part of ndn-tools (Named Data Networking Essential Tools).
* See AUTHORS.md for complete list of ndn-tools authors and contributors.
@@ -26,9 +26,7 @@
#include "ping-server.hpp"
-namespace ndn {
-namespace ping {
-namespace server {
+namespace ndn::ping::server {
/**
* @brief Logs ping responses
@@ -42,8 +40,6 @@
const Options& m_options;
};
-} // namespace server
-} // namespace ping
-} // namespace ndn
+} // namespace ndn::ping::server
#endif // NDN_TOOLS_PING_SERVER_TRACER_HPP