build: switch to C++17

Change-Id: Id6217b5c993f3e4726e89773128b565e5f136bb6
This commit is contained in:
Davide Pesavento committed 2022-02-20 15:35:23 -05:00
1 parent ebea9094a3
commit b3570c614a
75 files changed
+336 -617

No files matched your search

+1 -1
View File
@@ -135,7 +135,7 @@ class GccBasicFlags(CompilerFlags):
"""
def getGeneralFlags(self, conf):
flags = super(GccBasicFlags, self).getGeneralFlags(conf)
flags['CXXFLAGS'] += ['-std=c++14']
flags['CXXFLAGS'] += ['-std=c++17']
if Utils.unversioned_sys_platform() == 'linux':
flags['LINKFLAGS'] += ['-fuse-ld=gold']
elif Utils.unversioned_sys_platform() == 'freebsd':
+1 -1
View File
@@ -2,7 +2,7 @@
[![CI](https://github.com/named-data/ndn-tools/actions/workflows/ci.yml/badge.svg)](https://github.com/named-data/ndn-tools/actions/workflows/ci.yml)
[![Docs](https://github.com/named-data/ndn-tools/actions/workflows/docs.yml/badge.svg)](https://github.com/named-data/ndn-tools/actions/workflows/docs.yml)
![Language](https://img.shields.io/badge/C%2B%2B-14-blue)
![Language](https://img.shields.io/badge/C%2B%2B-17-blue)
![Latest version](https://img.shields.io/github/v/tag/named-data/ndn-tools?label=Latest%20version)
**ndn-tools** is a collection of basic tools for [Named Data Networking](https://named-data.net/).
+2 -1
View File
@@ -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,
@@ -46,6 +46,7 @@
#include <memory>
#include <stdexcept>
#include <string>
#include <string_view>
#include <utility>
#include <vector>
+2 -4
View File
@@ -19,10 +19,8 @@
#include "core/version.hpp"
namespace ndn {
namespace tools {
namespace ndn::tools {
const char VERSION[] = "@VERSION_BUILD@";
} // namespace tools
} // namespace ndn
} // namespace ndn::tools
+2 -4
View File
@@ -22,15 +22,13 @@
#include "core/common.hpp"
namespace ndn {
namespace tools {
namespace ndn::tools {
/**
* \brief The version of ndn-tools.
*/
extern const char VERSION[];
} // namespace tools
} // namespace ndn
} // namespace ndn::tools
#endif // NDN_TOOLS_CORE_VERSION_HPP
+2 -6
View File
@@ -39,9 +39,7 @@
#include <boost/test/output_test_stream.hpp>
#endif
namespace ndn {
namespace chunks {
namespace tests {
namespace ndn::chunks::tests {
using namespace ndn::tests;
using boost::test_tools::output_test_stream;
@@ -175,6 +173,4 @@ BOOST_FIXTURE_TEST_CASE(RunBasic, IoFixture)
BOOST_AUTO_TEST_SUITE_END() // TestConsumer
BOOST_AUTO_TEST_SUITE_END() // Chunks
} // namespace tests
} // namespace chunks
} // namespace ndn
} // namespace ndn::chunks::tests
+3 -7
View File
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
* Copyright (c) 2016-2020, 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,9 +32,7 @@
#include <ndn-cxx/metadata-object.hpp>
#include <ndn-cxx/util/dummy-client-face.hpp>
namespace ndn {
namespace chunks {
namespace tests {
namespace ndn::chunks::tests {
using namespace ndn::tests;
@@ -215,6 +213,4 @@ BOOST_AUTO_TEST_CASE(SuccessAfterNackAndTimeout)
BOOST_AUTO_TEST_SUITE_END() // TestDiscoverVersion
BOOST_AUTO_TEST_SUITE_END() // Chunks
} // namespace tests
} // namespace chunks
} // namespace ndn
} // namespace ndn::chunks::tests
+5 -10
View File
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
* Copyright (c) 2016-2020, 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,17 +29,14 @@
#include "pipeline-interests-fixture.hpp"
namespace ndn {
namespace chunks {
namespace tests {
namespace ndn::chunks::tests {
using namespace ndn::tests;
class PipelineInterestAimdFixture : public PipelineInterestsFixture
{
public:
protected:
PipelineInterestAimdFixture()
: rttEstimator(makeRttEstimatorOptions())
{
opt.isQuiet = true;
createPipeline();
@@ -70,7 +67,7 @@ private:
protected:
Options opt;
RttEstimatorWithStats rttEstimator;
RttEstimatorWithStats rttEstimator{makeRttEstimatorOptions()};
PipelineInterestsAdaptive* pipeline;
static constexpr double MARGIN = 0.001;
};
@@ -596,6 +593,4 @@ BOOST_AUTO_TEST_CASE(StopsWhenFileSizeLessThanChunkSize)
BOOST_AUTO_TEST_SUITE_END() // TestPipelineInterestsAimd
BOOST_AUTO_TEST_SUITE_END() // Chunks
} // namespace tests
} // namespace chunks
} // namespace ndn
} // namespace ndn::chunks::tests
+5 -10
View File
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
* Copyright (c) 2016-2020, 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,17 +29,14 @@
#include "pipeline-interests-fixture.hpp"
namespace ndn {
namespace chunks {
namespace tests {
namespace ndn::chunks::tests {
using namespace ndn::tests;
class PipelineInterestCubicFixture : public PipelineInterestsFixture
{
public:
protected:
PipelineInterestCubicFixture()
: rttEstimator(makeRttEstimatorOptions())
{
opt.isQuiet = true;
createPipeline();
@@ -70,7 +67,7 @@ private:
protected:
Options opt;
RttEstimatorWithStats rttEstimator;
RttEstimatorWithStats rttEstimator{makeRttEstimatorOptions()};
PipelineInterestsCubic* pipeline;
static constexpr double MARGIN = 0.001;
};
@@ -562,6 +559,4 @@ BOOST_AUTO_TEST_CASE(StopsWhenFileSizeLessThanChunkSize)
BOOST_AUTO_TEST_SUITE_END() // TestPipelineInterestsCubic
BOOST_AUTO_TEST_SUITE_END() // Chunks
} // namespace tests
} // namespace chunks
} // namespace ndn
} // namespace ndn::chunks::tests
+3 -7
View File
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
* Copyright (c) 2016-2020, 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,9 +29,7 @@
#include "pipeline-interests-fixture.hpp"
namespace ndn {
namespace chunks {
namespace tests {
namespace ndn::chunks::tests {
class PipelineInterestFixedFixture : public PipelineInterestsFixture
{
@@ -298,6 +296,4 @@ BOOST_AUTO_TEST_CASE(CongestionAllSegments)
BOOST_AUTO_TEST_SUITE_END() // TestPipelineInterests
BOOST_AUTO_TEST_SUITE_END() // Chunks
} // namespace tests
} // namespace chunks
} // namespace ndn
} // namespace ndn::chunks::tests
+3 -7
View File
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
* Copyright (c) 2016-2020, 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,9 +36,7 @@
#include <ndn-cxx/util/dummy-client-face.hpp>
namespace ndn {
namespace chunks {
namespace tests {
namespace ndn::chunks::tests {
using namespace ndn::tests;
@@ -88,8 +86,6 @@ private:
unique_ptr<PipelineInterests> m_pipeline;
};
} // namespace tests
} // namespace chunks
} // namespace ndn
} // namespace ndn::chunks::tests
#endif // NDN_TOOLS_TESTS_CHUNKS_PIPELINE_INTERESTS_FIXTURE_HPP
+3 -7
View File
@@ -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,9 +37,7 @@
#include <cmath>
#include <sstream>
namespace ndn {
namespace chunks {
namespace tests {
namespace ndn::chunks::tests {
using namespace ndn::tests;
@@ -222,6 +220,4 @@ BOOST_AUTO_TEST_CASE(RequestMetadata)
BOOST_AUTO_TEST_SUITE_END() // TestProducer
BOOST_AUTO_TEST_SUITE_END() // Chunks
} // namespace tests
} // namespace chunks
} // namespace ndn
} // namespace ndn::chunks::tests
+3 -5
View File
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
* Copyright (c) 2014-2020, 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,
@@ -25,8 +25,7 @@
#include "tests/clock-fixture.hpp"
namespace ndn {
namespace tests {
namespace ndn::tests {
ClockFixture::ClockFixture()
: m_steadyClock(make_shared<time::UnitTestSteadyClock>())
@@ -56,5 +55,4 @@ ClockFixture::advanceClocks(time::nanoseconds tick, time::nanoseconds total)
}
}
} // namespace tests
} // namespace ndn
} // namespace ndn::tests
+3 -5
View File
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
* Copyright (c) 2014-2020, 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,
@@ -28,8 +28,7 @@
#include <ndn-cxx/util/time-unit-test-clock.hpp>
namespace ndn {
namespace tests {
namespace ndn::tests {
/** \brief A test fixture that overrides steady clock and system clock.
*/
@@ -83,7 +82,6 @@ protected:
shared_ptr<time::UnitTestSystemClock> m_systemClock;
};
} // namespace tests
} // namespace ndn
} // namespace ndn::tests
#endif // NDN_TOOLS_TESTS_CLOCK_FIXTURE_HPP
+5 -13
View File
@@ -39,9 +39,7 @@
#include <ndn-cxx/lp/packet.hpp>
#include <ndn-cxx/net/ethernet.hpp>
namespace ndn {
namespace dump {
namespace tests {
namespace ndn::dump::tests {
namespace endian = boost::endian;
using namespace ndn::tests;
@@ -157,15 +155,11 @@ protected:
NdnDump dump;
boost::test_tools::output_test_stream output;
static const uint16_t s_ethertypeNdn;
static const uint16_t s_ethertypeIp4;
static const uint16_t s_ethertypeIp6;
static inline const uint16_t s_ethertypeNdn = endian::native_to_big(ethernet::ETHERTYPE_NDN);
static inline const uint16_t s_ethertypeIp4 = endian::native_to_big(uint16_t(ETHERTYPE_IP));
static inline const uint16_t s_ethertypeIp6 = endian::native_to_big(uint16_t(ETHERTYPE_IPV6));
};
const uint16_t NdnDumpFixture::s_ethertypeNdn = endian::native_to_big(ethernet::ETHERTYPE_NDN);
const uint16_t NdnDumpFixture::s_ethertypeIp4 = endian::native_to_big(uint16_t(ETHERTYPE_IP));
const uint16_t NdnDumpFixture::s_ethertypeIp6 = endian::native_to_big(uint16_t(ETHERTYPE_IPV6));
BOOST_AUTO_TEST_SUITE(Dump)
BOOST_FIXTURE_TEST_SUITE(TestNdnDump, NdnDumpFixture)
@@ -500,6 +494,4 @@ BOOST_AUTO_TEST_CASE(LinuxSllUdp6)
BOOST_AUTO_TEST_SUITE_END() // TestNdnDump
BOOST_AUTO_TEST_SUITE_END() // Dump
} // namespace tests
} // namespace dump
} // namespace ndn
} // namespace ndn::dump::tests
+3 -5
View File
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
* Copyright (c) 2014-2020, 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.
@@ -25,8 +25,7 @@
#include <fstream>
#include <stdlib.h>
namespace ndn {
namespace tests {
namespace ndn::tests {
class GlobalConfiguration
{
@@ -68,5 +67,4 @@ BOOST_GLOBAL_FIXTURE(GlobalConfiguration);
BOOST_GLOBAL_FIXTURE(GlobalConfiguration)
#endif
} // namespace tests
} // namespace ndn
} // namespace ndn::tests
+3 -5
View File
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
* Copyright (c) 2014-2020, 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 <boost/asio/io_service.hpp>
namespace ndn {
namespace tests {
namespace ndn::tests {
class IoFixture : public ClockFixture
{
@@ -53,7 +52,6 @@ protected:
boost::asio::io_service m_io;
};
} // namespace tests
} // namespace ndn
} // namespace ndn::tests
#endif // NDN_TOOLS_TESTS_IO_FIXTURE_HPP
+2 -4
View File
@@ -23,8 +23,7 @@
#include <boost/filesystem.hpp>
namespace ndn {
namespace tests {
namespace ndn::tests {
using namespace ndn::security;
@@ -113,5 +112,4 @@ KeyChainFixture::saveIdentityCert(const Name& identityName, const std::string& f
return saveIdentityCert(id, filename);
}
} // namespace tests
} // namespace ndn
} // namespace ndn::tests
+3 -5
View File
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
* Copyright (c) 2014-2020, 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.
@@ -23,8 +23,7 @@
#include <ndn-cxx/security/key-chain.hpp>
#include <ndn-cxx/security/signing-helpers.hpp>
namespace ndn {
namespace tests {
namespace ndn::tests {
/**
* @brief A fixture providing an in-memory KeyChain.
@@ -87,7 +86,6 @@ private:
std::vector<std::string> m_certFiles;
};
} // namespace tests
} // namespace ndn
} // namespace ndn::tests
#endif // NDN_TOOLS_TESTS_KEY_CHAIN_FIXTURE_HPP
+2 -6
View File
@@ -31,9 +31,7 @@
#include <boost/test/output_test_stream.hpp>
#endif
namespace ndn {
namespace peek {
namespace tests {
namespace ndn::peek::tests {
using namespace ndn::tests;
using boost::test_tools::output_test_stream;
@@ -324,6 +322,4 @@ BOOST_AUTO_TEST_CASE(OversizedPacket)
BOOST_AUTO_TEST_SUITE_END() // TestNdnPeek
BOOST_AUTO_TEST_SUITE_END() // Peek
} // namespace tests
} // namespace peek
} // namespace ndn
} // namespace ndn::peek::tests
+3 -7
View File
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
* Copyright (c) 2014-2020, 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,
@@ -31,9 +31,7 @@
#include <ndn-cxx/util/dummy-client-face.hpp>
namespace ndn {
namespace peek {
namespace tests {
namespace ndn::peek::tests {
using namespace ndn::tests;
@@ -256,6 +254,4 @@ BOOST_AUTO_TEST_CASE(OversizedPacket)
BOOST_AUTO_TEST_SUITE_END() // TestNdnPoke
BOOST_AUTO_TEST_SUITE_END() // Peek
} // namespace tests
} // namespace peek
} // namespace ndn
} // namespace ndn::peek::tests
+3 -9
View File
@@ -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.
@@ -24,10 +24,7 @@
#include <ndn-cxx/util/dummy-client-face.hpp>
namespace ndn {
namespace ping {
namespace client {
namespace tests {
namespace ndn::ping::client::tests {
using namespace ndn::tests;
@@ -96,7 +93,4 @@ BOOST_FIXTURE_TEST_CASE(Basic, IoFixture)
BOOST_AUTO_TEST_SUITE_END() // TestClient
BOOST_AUTO_TEST_SUITE_END() // Ping
} // namespace tests
} // namespace client
} // namespace ping
} // namespace ndn
} // namespace ndn::ping::client::tests
+11 -26
View File
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/**
* Copyright (c) 2014-2016, 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.
@@ -20,46 +20,34 @@
#include "tools/ping/client/statistics-collector.hpp"
#include "tests/test-common.hpp"
#include <ndn-cxx/util/dummy-client-face.hpp>
namespace ndn {
namespace ping {
namespace client {
namespace tests {
using namespace ndn::tests;
namespace ndn::ping::client::tests {
class StatisticsCollectorFixture
{
protected:
StatisticsCollectorFixture()
: pingOptions(makeOptions())
, pingProgram(face, pingOptions)
, sc(pingProgram, pingOptions)
{
}
private:
static Options
makeOptions()
{
Options opt;
opt.prefix = "ndn:/ping-prefix";
opt.prefix = "/ping-prefix";
opt.shouldAllowStaleData = false;
opt.shouldGenerateRandomSeq = false;
opt.shouldPrintTimestamp = false;
opt.nPings = 5;
opt.interval = time::milliseconds(100);
opt.timeout = time::milliseconds(2000);
opt.interval = 100_ms;
opt.timeout = 2_s;
opt.startSeq = 1;
return opt;
}
protected:
util::DummyClientFace face;
Options pingOptions;
Ping pingProgram;
StatisticsCollector sc;
Options pingOptions{makeOptions()};
Ping pingProgram{face, pingOptions};
StatisticsCollector sc{pingProgram, pingOptions};
};
BOOST_AUTO_TEST_SUITE(Ping)
@@ -211,7 +199,4 @@ BOOST_AUTO_TEST_CASE(NoneSent)
BOOST_AUTO_TEST_SUITE_END() // TestStatisticsCollector
BOOST_AUTO_TEST_SUITE_END() // Ping
} // namespace tests
} // namespace client
} // namespace ping
} // namespace ndn
} // namespace ndn::ping::client::tests
+32 -27
View File
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
* Copyright (c) 2015-2020, 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,53 +26,60 @@
#include <ndn-cxx/util/dummy-client-face.hpp>
namespace ndn {
namespace ping {
namespace tests {
namespace ndn::ping::tests {
using namespace ndn::tests;
class PingIntegratedFixture : public IoFixture, public KeyChainFixture
{
public:
protected:
PingIntegratedFixture()
: serverFace(m_io, m_keyChain, {false, true})
, clientFace(m_io, m_keyChain, {false, true})
, wantLoss(false)
{
serverFace.onSendInterest.connect([this] (const Interest& interest) {
m_io.post([=] { if (!wantLoss) { clientFace.receive(interest); } });
serverFace.onSendInterest.connect([this] (const auto& interest) {
receive(clientFace, interest);
});
clientFace.onSendInterest.connect([this] (const Interest& interest) {
m_io.post([=] { if (!wantLoss) { serverFace.receive(interest); } });
clientFace.onSendInterest.connect([this] (const auto& interest) {
receive(serverFace, interest);
});
serverFace.onSendData.connect([this] (const Data& data) {
m_io.post([=] { if (!wantLoss) { clientFace.receive(data); } });
serverFace.onSendData.connect([this] (const auto& data) {
receive(clientFace, data);
});
clientFace.onSendData.connect([this] (const Data& data) {
m_io.post([=] { if (!wantLoss) { serverFace.receive(data); } });
clientFace.onSendData.connect([this] (const auto& data) {
receive(serverFace, data);
});
}
void onFinish()
template<typename Packet>
void
receive(util::DummyClientFace& face, const Packet& pkt)
{
m_io.post([=, &face] {
if (!wantLoss) {
face.receive(pkt);
}
});
}
void
onFinish()
{
serverFace.shutdown();
clientFace.shutdown();
m_io.stop();
}
public:
util::DummyClientFace serverFace;
util::DummyClientFace clientFace;
protected:
util::DummyClientFace serverFace{m_io, m_keyChain, {false, true}};
util::DummyClientFace clientFace{m_io, m_keyChain, {false, true}};
std::unique_ptr<server::PingServer> server;
std::unique_ptr<client::Ping> client;
bool wantLoss;
bool wantLoss = false;
};
BOOST_AUTO_TEST_SUITE(Ping)
BOOST_AUTO_TEST_SUITE(TestIntegrated)
BOOST_FIXTURE_TEST_SUITE(TestIntegrated, PingIntegratedFixture)
BOOST_FIXTURE_TEST_CASE(Normal, PingIntegratedFixture)
BOOST_AUTO_TEST_CASE(Normal)
{
server::Options serverOpts;
serverOpts.prefix = "ndn:/test-prefix";
@@ -103,7 +110,7 @@ BOOST_FIXTURE_TEST_CASE(Normal, PingIntegratedFixture)
BOOST_CHECK_EQUAL(4, server->getNPings());
}
BOOST_FIXTURE_TEST_CASE(Timeout, PingIntegratedFixture)
BOOST_AUTO_TEST_CASE(Timeout)
{
wantLoss = true;
@@ -139,6 +146,4 @@ BOOST_FIXTURE_TEST_CASE(Timeout, PingIntegratedFixture)
BOOST_AUTO_TEST_SUITE_END() // TestIntegrated
BOOST_AUTO_TEST_SUITE_END() // Ping
} // namespace tests
} // namespace ping
} // namespace ndn
} // namespace ndn::ping::tests
+9 -23
View File
@@ -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,26 +25,13 @@
#include <ndn-cxx/util/dummy-client-face.hpp>
namespace ndn {
namespace ping {
namespace server {
namespace tests {
namespace ndn::ping::server::tests {
using namespace ndn::tests;
BOOST_AUTO_TEST_SUITE(Ping)
BOOST_AUTO_TEST_SUITE(TestServer)
class PingServerFixture : public IoFixture, public KeyChainFixture
{
protected:
PingServerFixture()
: face(m_io, m_keyChain, {false, true})
, pingOptions(makeOptions())
, pingServer(face, m_keyChain, pingOptions)
{
}
Interest
makePingInterest(int seq) const
{
@@ -53,7 +40,6 @@ protected:
.append(to_string(seq));
return Interest(name)
.setCanBePrefix(false)
.setMustBeFresh(true)
.setInterestLifetime(2_s);
}
@@ -73,11 +59,14 @@ private:
}
protected:
util::DummyClientFace face;
Options pingOptions;
PingServer pingServer;
util::DummyClientFace face{m_io, m_keyChain, {false, true}};
Options pingOptions{makeOptions()};
PingServer pingServer{face, m_keyChain, pingOptions};
};
BOOST_AUTO_TEST_SUITE(Ping)
BOOST_AUTO_TEST_SUITE(TestServer)
BOOST_FIXTURE_TEST_CASE(Receive, PingServerFixture)
{
BOOST_TEST(pingServer.getNPings() == 0);
@@ -96,7 +85,4 @@ BOOST_FIXTURE_TEST_CASE(Receive, PingServerFixture)
BOOST_AUTO_TEST_SUITE_END() // TestServer
BOOST_AUTO_TEST_SUITE_END() // Ping
} // namespace tests
} // namespace server
} // namespace ping
} // namespace ndn
} // namespace ndn::ping::server::tests
+6 -9
View File
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
* Copyright (c) 2014-2020 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.
@@ -26,15 +26,14 @@
#include "tests/io-fixture.hpp" // optional, for IoFixture
//#include "tests/key-chain-fixture.hpp" // optional, for KeyChainFixture
namespace ndn {
namespace tool_name {
namespace tests {
// Unit tests should go inside the ndn::tool_name::tests namespace.
namespace ndn::tool_name::tests {
// Common fixtures in ndn::tests can be imported if needed.
using namespace ndn::tests;
// See https://redmine.named-data.net/projects/nfd/wiki/UnitTesting for a guide on how to name a test suite.
// See https://redmine.named-data.net/projects/nfd/wiki/UnitTesting
// for a guide on how to name a test suite.
BOOST_AUTO_TEST_SUITE(TestSkeleton)
BOOST_AUTO_TEST_CASE(Test1)
@@ -55,8 +54,6 @@ BOOST_FIXTURE_TEST_CASE(Test2, IoFixture)
advanceClocks(500_ms);
}
BOOST_AUTO_TEST_SUITE_END()
BOOST_AUTO_TEST_SUITE_END() // TestSkeleton
} // namespace tests
} // namespace tool_name
} // namespace ndn
} // namespace ndn::tool_name::tests
+3 -5
View File
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
* Copyright (c) 2014-2020, 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,
@@ -25,8 +25,7 @@
#include "tests/test-common.hpp"
namespace ndn {
namespace tests {
namespace ndn::tests {
shared_ptr<Interest>
makeInterest(const Name& name, bool canBePrefix, optional<time::milliseconds> lifetime,
@@ -65,5 +64,4 @@ makeNack(Interest interest, lp::NackReason reason)
return nack;
}
} // namespace tests
} // namespace ndn
} // namespace ndn::tests
+3 -5
View File
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
* Copyright (c) 2014-2020, 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,
@@ -29,8 +29,7 @@
#include "core/common.hpp"
#include "tests/boost-test.hpp"
namespace ndn {
namespace tests {
namespace ndn::tests {
/**
* \brief Create an Interest
@@ -85,7 +84,6 @@ setNameComponent(Packet& pkt, ssize_t index, Args&& ...args)
pkt.setName(name);
}
} // namespace tests
} // namespace ndn
} // namespace ndn::tests
#endif // NDN_TOOLS_TESTS_TEST_COMMON_HPP
+3 -5
View File
@@ -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 @@ Consumer::writeInOrderData()
}
}
} // namespace chunks
} // namespace ndn
} // namespace ndn::chunks
+3 -5
View File
@@ -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 @@ PUBLIC_WITH_TESTS_ELSE_PRIVATE:
std::map<uint64_t, shared_ptr<const Data>> m_bufferedData;
};
} // namespace chunks
} // namespace ndn
} // namespace ndn::chunks
#endif // NDN_TOOLS_CHUNKS_CATCHUNKS_CONSUMER_HPP
+3 -13
View File
@@ -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 @@ DataFetcher::DataFetcher(Face& face, int maxNackRetries, int maxTimeoutRetries,
, 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 @@ DataFetcher::handleTimeout(const Interest& interest, const shared_ptr<DataFetche
}
}
} // namespace chunks
} // namespace ndn
} // namespace ndn::chunks
+12 -14
View File
@@ -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 @@ public:
* @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 @@ private:
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
+3 -5
View File
@@ -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 @@ DiscoverVersion::handleData(const Interest& interest, const Data& data)
onDiscoverySuccess(mobject.getVersionedName());
}
} // namespace chunks
} // namespace ndn
} // namespace ndn::chunks
+3 -5
View File
@@ -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 @@ private:
shared_ptr<DataFetcher> m_fetcher;
};
} // namespace chunks
} // namespace ndn
} // namespace ndn::chunks
#endif // NDN_TOOLS_CHUNKS_CATCHUNKS_DISCOVER_VERSION_HPP
+3 -5
View File
@@ -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 @@ main(int argc, char* argv[])
return 0;
}
} // namespace chunks
} // namespace ndn
} // namespace ndn::chunks
int
main(int argc, char* argv[])
+3 -5
View File
@@ -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 @@ struct Options : noncopyable
bool enableFastConv = false; ///< use cubic fast convergence
};
} // namespace chunks
} // namespace ndn
} // namespace ndn::chunks
#endif // NDN_TOOLS_CHUNKS_CATCHUNKS_OPTIONS_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 <cmath>
#include <iomanip>
namespace ndn {
namespace chunks {
namespace ndn::chunks {
constexpr double PipelineInterestsAdaptive::MIN_SSTHRESH;
@@ -45,19 +44,6 @@ PipelineInterestsAdaptive::PipelineInterestsAdaptive(Face& face,
, 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 @@ PipelineInterestsAdaptive::sendInterest(uint64_t segNo, bool isRetransmission)
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 @@ PipelineInterestsAdaptive::sendInterest(uint64_t segNo, bool isRetransmission)
auto interest = Interest()
.setName(Name(m_prefix).appendSegment(segNo))
.setCanBePrefix(false)
.setMustBeFresh(m_options.mustBeFresh)
.setInterestLifetime(m_options.interestLifetime);
@@ -471,5 +456,4 @@ operator<<(std::ostream& os, SegmentState state)
return os;
}
} // namespace chunks
} // namespace ndn
} // namespace ndn::chunks
@@ -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 @@ PUBLIC_WITH_TESTS_ELSE_PRIVATE:
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 @@ PUBLIC_WITH_TESTS_ELSE_PRIVATE:
///< 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
@@ -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 @@ PipelineInterestsAimd::decreaseWindow()
emitSignal(afterCwndChange, time::steady_clock::now() - getStartTime(), m_cwnd);
}
} // namespace chunks
} // namespace ndn
} // namespace ndn::chunks
@@ -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 @@ private:
decreaseWindow() final;
};
} // namespace chunks
} // namespace ndn
} // namespace ndn::chunks
#endif // NDN_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.
*
@@ -27,8 +27,7 @@
#include <cmath>
namespace ndn {
namespace chunks {
namespace ndn::chunks {
constexpr double CUBIC_C = 0.4;
@@ -111,5 +110,4 @@ PipelineInterestsCubic::decreaseWindow()
emitSignal(afterCwndChange, time::steady_clock::now() - getStartTime(), m_cwnd);
}
} // namespace chunks
} // namespace ndn
} // namespace ndn::chunks
@@ -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 @@ private:
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
@@ -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 @@ PipelineInterestsFixed::fetchNextSegment(std::size_t pipeNo)
auto interest = Interest()
.setName(Name(m_prefix).appendSegment(nextSegmentNo))
.setCanBePrefix(false)
.setMustBeFresh(m_options.mustBeFresh)
.setInterestLifetime(m_options.interestLifetime);
@@ -194,5 +192,4 @@ void PipelineInterestsFixed::handleFail(const std::string& reason, std::size_t p
}
}
} // namespace chunks
} // namespace ndn
} // namespace ndn::chunks
@@ -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 @@ private:
bool m_hasFailure = false;
};
} // namespace chunks
} // namespace ndn
} // namespace ndn::chunks
#endif // NDN_TOOLS_CHUNKS_CATCHUNKS_PIPELINE_INTERESTS_FIXED_HPP
+3 -11
View File
@@ -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 @@ PipelineInterests::formatThroughput(double throughput)
return "";
}
} // namespace chunks
} // namespace ndn
} // namespace ndn::chunks
+11 -13
View File
@@ -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 @@ namespace chunks {
* 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 @@ protected:
* @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 @@ protected:
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 @@ getSegmentFromPacket(const Packet& packet)
return packet.getName().at(-1).toSegment();
}
} // namespace chunks
} // namespace ndn
} // namespace ndn::chunks
#endif // NDN_TOOLS_CHUNKS_CATCHUNKS_PIPELINE_INTERESTS_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.
*
@@ -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 @@ StatisticsCollector::StatisticsCollector(PipelineInterestsAdaptive& pipeline,
});
}
} // namespace chunks
} // namespace ndn
} // namespace ndn::chunks
@@ -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 @@ private:
std::ostream& m_osRtt;
};
} // namespace chunks
} // namespace ndn
} // namespace ndn::chunks
#endif // NDN_TOOLS_CHUNKS_CATCHUNKS_STATISTICS_COLLECTOR_HPP
+4 -6
View File
@@ -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 @@ main(int argc, char* argv[])
return 0;
}
} // namespace chunks
} // namespace ndn
} // namespace ndn::chunks
int
main(int argc, char* argv[])
+2 -4
View File
@@ -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 @@ Producer::populateStore(std::istream& is)
std::cerr << "Created " << m_store.size() << " chunks for prefix " << m_prefix << "\n";
}
} // namespace chunks
} // namespace ndn
} // namespace ndn::chunks
+3 -5
View File
@@ -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 @@ private:
const Options m_options;
};
} // namespace chunks
} // namespace ndn
} // namespace ndn::chunks
#endif // NDN_TOOLS_CHUNKS_PUTCHUNKS_PRODUCER_HPP
+4 -6
View File
@@ -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 @@ Dissector::printBranches()
}
}
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 @@ Dissector::printBlock(const Block& block)
m_branches.pop_back();
}
} // namespace dissect
} // namespace ndn
} // namespace ndn::dissect
+3 -5
View File
@@ -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 @@ private:
std::vector<bool> m_branches;
};
} // namespace dissect
} // namespace ndn
} // namespace ndn::dissect
#endif // NDN_TOOLS_DISSECT_DISSECTOR_HPP
+4 -6
View File
@@ -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 @@ main(int argc, char* argv[])
return 0;
}
} // namespace dissect
} // namespace ndn
} // namespace ndn::dissect
int
main(int argc, char* argv[])
+5 -7
View File
@@ -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 @@ main(int argc, char* argv[])
return 0;
}
} // namespace dump
} // namespace ndn
} // namespace ndn::dump
int
main(int argc, char* argv[])
+5 -12
View File
@@ -39,8 +39,7 @@
#include <boost/endian/conversion.hpp>
namespace ndn {
namespace dump {
namespace ndn::dump {
namespace endian = boost::endian;
@@ -517,9 +516,7 @@ NdnDump::printNdn(OutputFormatter& out, const uint8_t* pkt, size_t len) const
}
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 @@ NdnDump::printNdn(OutputFormatter& out, const uint8_t* pkt, size_t len) const
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 @@ NdnDump::matchesFilter(const Name& name) const
return std::regex_match(name.toUri(), *nameFilter);
}
} // namespace dump
} // namespace ndn
} // namespace ndn::dump
+5 -7
View File
@@ -37,8 +37,7 @@
#define UH_LEN len
#endif
namespace ndn {
namespace dump {
namespace ndn::dump {
class OutputFormatter;
@@ -59,7 +58,7 @@ public:
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 @@ private:
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 @@ PUBLIC_WITH_TESTS_ELSE_PRIVATE:
int m_dataLinkType = -1;
};
} // namespace dump
} // namespace ndn
} // namespace ndn::dump
#endif // NDN_TOOLS_DUMP_NDNDUMP_HPP
+3 -5
View File
@@ -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 @@ main(int argc, char* argv[])
}
}
} // namespace peek
} // namespace ndn
} // namespace ndn::peek
int
main(int argc, char* argv[])
+2 -4
View File
@@ -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 @@ NdnPeek::onTimeout()
}
}
} // namespace peek
} // namespace ndn
} // namespace ndn::peek
+3 -5
View File
@@ -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 @@ struct PeekOptions
optional<time::milliseconds> timeout;
};
class NdnPeek : boost::noncopyable
class NdnPeek : noncopyable
{
public:
NdnPeek(Face& face, const PeekOptions& options);
@@ -119,7 +118,6 @@ private:
Result m_result = Result::UNKNOWN;
};
} // namespace peek
} // namespace ndn
} // namespace ndn::peek
#endif // NDN_TOOLS_NDNPEEK_NDNPEEK_HPP
+4 -6
View File
@@ -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 @@ main(int argc, char* argv[])
}
}
} // namespace peek
} // namespace ndn
} // namespace ndn::peek
int
main(int argc, char* argv[])
+4 -6
View File
@@ -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 @@ NdnPoke::onRegSuccess()
}
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
+5 -7
View File
@@ -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 @@ struct PokeOptions
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 @@ private:
onRegSuccess();
void
onRegFailure(const std::string& reason);
onRegFailure(std::string_view reason);
private:
const PokeOptions m_options;
@@ -106,7 +105,6 @@ private:
Result m_result = Result::UNKNOWN;
};
} // namespace peek
} // namespace ndn
} // namespace ndn::peek
#endif // NDN_TOOLS_NDNPOKE_NDNPOKE_HPP
+10 -33
View File
@@ -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 @@ private:
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 @@ main(int argc, char* argv[])
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 @@ main(int argc, char* argv[])
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 @@ main(int argc, char* argv[])
}
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 @@ main(int argc, char* argv[])
return Runner(options).run();
}
} // namespace client
} // namespace ping
} // namespace ndn
} // namespace ndn::ping::client
int
main(int argc, char* argv[])
+3 -10
View File
@@ -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 @@ Ping::performPing()
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 @@ Ping::makePingName(uint64_t seq) const
return name;
}
} // namespace client
} // namespace ping
} // namespace ndn
} // namespace ndn::ping::client
+7 -11
View File
@@ -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:
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
+3 -15
View File
@@ -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 @@ operator<<(std::ostream& os, const Statistics& statistics)
return os;
}
} // namespace client
} // namespace ping
} // namespace ndn
} // namespace ndn::ping::client
+15 -19
View File
@@ -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 @@ struct Statistics
std::ostream&
printSummary(std::ostream& os) const;
friend std::ostream&
operator<<(std::ostream& os, const Statistics& statistics);
};
/**
@@ -69,7 +70,7 @@ public:
/**
* @brief Compute and return ping statistics as structure
*/
Statistics
[[nodiscard]] Statistics
computeStatistics() const;
PUBLIC_WITH_TESTS_ELSE_PRIVATE:
@@ -94,21 +95,16 @@ PUBLIC_WITH_TESTS_ELSE_PRIVATE:
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
+3 -7
View File
@@ -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 @@ Tracer::onError(const std::string& msg)
std::cerr << "ERROR: " << msg << "\n";
}
} // namespace client
} // namespace ping
} // namespace ndn
} // namespace ndn::ping::client
+3 -7
View File
@@ -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 @@ private:
const Options& m_options;
};
} // namespace client
} // namespace ping
} // namespace ndn
} // namespace ndn::ping::client
#endif // NDN_TOOLS_PING_CLIENT_TRACER_HPP
+4 -8
View File
@@ -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 @@ private:
};
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 @@ main(int argc, char* argv[])
return Runner(options).run();
}
} // namespace server
} // namespace ping
} // namespace ndn
} // namespace ndn::ping::server
int
main(int argc, char* argv[])
+3 -8
View File
@@ -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 @@ PingServer::onInterest(const Interest& interest)
}
}
} // namespace server
} // namespace ping
} // namespace ndn
} // namespace ndn::ping::server
+4 -8
View File
@@ -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 @@ private:
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
+3 -7
View File
@@ -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 @@ Tracer::Tracer(PingServer& pingServer, const Options& options)
}
}
} // namespace server
} // namespace ping
} // namespace ndn
} // namespace ndn::ping::server
+3 -7
View File
@@ -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 @@ private:
const Options& m_options;
};
} // namespace server
} // namespace ping
} // namespace ndn
} // namespace ndn::ping::server
#endif // NDN_TOOLS_PING_SERVER_TRACER_HPP