chunks+peek+ping: use correct underlying type for time::milliseconds

Change-Id: I3f46f846401eccc0c11d3abcd1a5ebff89056f7d
This commit is contained in:
Davide Pesavento committed 2019-07-26 19:06:36 -04:00
1 parent 6a1396e2e0
commit 0da1f44c79
8 files changed
+56 -73

No files matched your search

+8 -8
View File
@@ -58,7 +58,7 @@ main(int argc, char* argv[])
ignoreCongMarks(false), enableFastConv(false);
int initCwnd(1), initSsthresh(std::numeric_limits<int>::max()), k(8);
double aiStep(1.0), rtoAlpha(0.125), rtoBeta(0.25), aimdBeta(0.5), cubicBeta(0.7);
int64_t minRto(200), maxRto(60000);
time::milliseconds::rep minRto(200), maxRto(60000);
std::string cwndPath, rttPath;
namespace po = boost::program_options;
@@ -68,7 +68,7 @@ main(int argc, char* argv[])
("pipeline-type,p", po::value<std::string>(&pipelineType)->default_value(pipelineType),
"type of Interest pipeline to use; valid values are: 'fixed', 'aimd', 'cubic'")
("fresh,f", po::bool_switch(&options.mustBeFresh), "only return fresh content")
("lifetime,l", po::value<int64_t>()->default_value(options.interestLifetime.count()),
("lifetime,l", po::value<time::milliseconds::rep>()->default_value(options.interestLifetime.count()),
"lifetime of expressed Interests, in milliseconds")
("retries,r", po::value<int>(&options.maxRetriesOnTimeoutOrNack)->default_value(options.maxRetriesOnTimeoutOrNack),
"maximum number of retries in case of Nack or timeout (-1 = no limit)")
@@ -107,10 +107,10 @@ main(int argc, char* argv[])
"beta value for RTO calculation")
("rto-k", po::value<int>(&k)->default_value(k),
"k value for RTO calculation")
("min-rto", po::value<int64_t>(&minRto)->default_value(minRto),
"minimum RTO value in milliseconds")
("max-rto", po::value<int64_t>(&maxRto)->default_value(maxRto),
"maximum RTO value in milliseconds")
("min-rto", po::value<time::milliseconds::rep>(&minRto)->default_value(minRto),
"minimum RTO value, in milliseconds")
("max-rto", po::value<time::milliseconds::rep>(&maxRto)->default_value(maxRto),
"maximum RTO value, in milliseconds")
("log-cwnd", po::value<std::string>(&cwndPath), "log file for congestion window stats")
("log-rtt", po::value<std::string>(&rttPath), "log file for round-trip time stats")
;
@@ -179,11 +179,11 @@ main(int argc, char* argv[])
return 2;
}
if (vm["lifetime"].as<int64_t>() < 0) {
options.interestLifetime = time::milliseconds(vm["lifetime"].as<time::milliseconds::rep>());
if (options.interestLifetime < 0_ms) {
std::cerr << "ERROR: lifetime cannot be negative" << std::endl;
return 2;
}
options.interestLifetime = time::milliseconds(vm["lifetime"].as<int64_t>());
if (options.isQuiet && options.isVerbose) {
std::cerr << "ERROR: cannot be quiet and verbose at the same time" << std::endl;
+1 -1
View File
@@ -35,7 +35,7 @@ namespace chunks {
struct Options
{
time::milliseconds interestLifetime = ndn::DEFAULT_INTEREST_LIFETIME;
time::milliseconds interestLifetime = DEFAULT_INTEREST_LIFETIME;
int maxRetriesOnTimeoutOrNack = 15;
bool mustBeFresh = false;
bool isQuiet = false;
+1 -1
View File
@@ -109,7 +109,7 @@ main(int argc, char* argv[])
}
opts.freshnessPeriod = time::milliseconds(vm["freshness"].as<time::milliseconds::rep>());
if (opts.freshnessPeriod < time::milliseconds::zero()) {
if (opts.freshnessPeriod < 0_ms) {
std::cerr << "ERROR: FreshnessPeriod cannot be negative" << std::endl;
return 2;
}
+11 -15
View File
@@ -54,8 +54,9 @@ main(int argc, char* argv[])
po::options_description genericOptDesc("Generic options");
genericOptDesc.add_options()
("help,h", "print help and exit")
("payload,p", po::bool_switch(&options.wantPayloadOnly), "print payload only, instead of full packet")
("timeout,w", po::value<int>(), "set timeout (in milliseconds)")
("payload,p", po::bool_switch(&options.wantPayloadOnly),
"print payload only, instead of full packet")
("timeout,w", po::value<time::milliseconds::rep>(), "execution timeout, in milliseconds")
("verbose,v", po::bool_switch(&options.isVerbose), "turn on verbose output")
("version,V", "print version and exit")
;
@@ -65,7 +66,8 @@ main(int argc, char* argv[])
("prefix,P", po::bool_switch(&options.canBePrefix), "set CanBePrefix")
("fresh,f", po::bool_switch(&options.mustBeFresh), "set MustBeFresh")
("link-file", po::value<std::string>(), "set ForwardingHint from a file")
("lifetime,l", po::value<int>(), "set InterestLifetime (in milliseconds)")
("lifetime,l", po::value<time::milliseconds::rep>()->default_value(options.interestLifetime.count()),
"set InterestLifetime, in milliseconds")
;
po::options_description visibleOptDesc;
@@ -115,21 +117,15 @@ main(int argc, char* argv[])
return 2;
}
if (vm.count("lifetime") > 0) {
if (vm["lifetime"].as<int>() >= 0) {
options.interestLifetime = time::milliseconds(vm["lifetime"].as<int>());
}
else {
std::cerr << "ERROR: lifetime cannot be negative" << std::endl;
return 2;
}
options.interestLifetime = time::milliseconds(vm["lifetime"].as<time::milliseconds::rep>());
if (options.interestLifetime < 0_ms) {
std::cerr << "ERROR: lifetime cannot be negative" << std::endl;
return 2;
}
if (vm.count("timeout") > 0) {
if (vm["timeout"].as<int>() >= 0) {
options.timeout = time::milliseconds(vm["timeout"].as<int>());
}
else {
options.timeout = time::milliseconds(vm["timeout"].as<time::milliseconds::rep>());
if (*options.timeout < 0_ms) {
std::cerr << "ERROR: timeout cannot be negative" << std::endl;
return 2;
}
+1 -3
View File
@@ -62,12 +62,10 @@ NdnPeek::createInterest() const
Interest interest(m_options.name);
interest.setCanBePrefix(m_options.canBePrefix);
interest.setMustBeFresh(m_options.mustBeFresh);
interest.setInterestLifetime(m_options.interestLifetime);
if (m_options.link) {
interest.setForwardingHint(m_options.link->getDelegationList());
}
if (m_options.interestLifetime) {
interest.setInterestLifetime(*m_options.interestLifetime);
}
if (m_options.isVerbose) {
std::cerr << "INTEREST: " << interest << std::endl;
+2 -2
View File
@@ -47,9 +47,9 @@ struct PeekOptions
bool canBePrefix = false;
bool mustBeFresh = false;
shared_ptr<Link> link;
optional<time::milliseconds> interestLifetime;
time::milliseconds interestLifetime = DEFAULT_INTEREST_LIFETIME;
// output behavior options
// program behavior options
bool isVerbose = false;
bool wantPayloadOnly = false;
optional<time::milliseconds> timeout;
+8 -12
View File
@@ -55,7 +55,7 @@ main(int argc, char* argv[])
("help,h", "print help and exit")
("unsolicited,u", po::bool_switch(&options.wantUnsolicited),
"send the Data packet without waiting for an incoming Interest")
("timeout,w", po::value<time::milliseconds::rep>(), "set timeout (in milliseconds)")
("timeout,w", po::value<time::milliseconds::rep>(), "execution timeout, in milliseconds")
("verbose,v", po::bool_switch(&options.isVerbose), "turn on verbose output")
("version,V", "print version and exit")
;
@@ -65,7 +65,7 @@ main(int argc, char* argv[])
("final,F", po::bool_switch(&options.wantFinalBlockId),
"set FinalBlockId to the last component of the Data name")
("freshness,x", po::value<time::milliseconds::rep>()->default_value(options.freshnessPeriod.count()),
"set FreshnessPeriod (in milliseconds)")
"set FreshnessPeriod, in milliseconds")
("identity,i", po::value<std::string>(), "use the specified identity for signing")
("digest,D", po::bool_switch(&wantDigestSha256),
"use DigestSha256 signing method instead of SignatureSha256WithRsa")
@@ -134,13 +134,10 @@ main(int argc, char* argv[])
return 2;
}
if (vm.count("freshness") > 0) {
auto freshness = vm["freshness"].as<time::milliseconds::rep>();
if (freshness < 0) {
std::cerr << "ERROR: freshness cannot be negative" << std::endl;
return 2;
}
options.freshnessPeriod = time::milliseconds(freshness);
options.freshnessPeriod = time::milliseconds(vm["freshness"].as<time::milliseconds::rep>());
if (options.freshnessPeriod < 0_ms) {
std::cerr << "ERROR: freshness cannot be negative" << std::endl;
return 2;
}
if (vm.count("identity") > 0) {
@@ -166,12 +163,11 @@ main(int argc, char* argv[])
std::cerr << "ERROR: conflicting '--unsolicited' and '--timeout' options specified" << std::endl;
return 2;
}
auto timeout = vm["timeout"].as<time::milliseconds::rep>();
if (timeout < 0) {
options.timeout = time::milliseconds(vm["timeout"].as<time::milliseconds::rep>());
if (*options.timeout < 0_ms) {
std::cerr << "ERROR: timeout cannot be negative" << std::endl;
return 2;
}
options.timeout = time::milliseconds(timeout);
}
try {
+24 -31
View File
@@ -160,37 +160,35 @@ main(int argc, char* argv[])
namespace po = boost::program_options;
po::options_description visibleOptDesc("Allowed options");
po::options_description visibleOptDesc("Options");
visibleOptDesc.add_options()
("help,h", "print this message and exit")
("version,V", "display version and exit")
("interval,i", po::value<int>(),
("set ping interval in milliseconds (default " +
std::to_string(getDefaultPingInterval().count()) + " ms - minimum " +
std::to_string(getMinimumPingInterval().count()) + " ms)").c_str())
("timeout,o", po::value<int>(),
("set ping timeout in milliseconds (default " +
std::to_string(getDefaultPingTimeoutThreshold().count()) + " ms)").c_str())
("count,c", po::value<int>(&options.nPings), "set total number of pings")
("start,n", po::value<uint64_t>(&options.startSeq),
"set the starting seq number, the number is incremented by 1 after each Interest")
("help,h", "print this message and exit")
("version,V", "display version and exit")
("interval,i", po::value<time::milliseconds::rep>()->default_value(getDefaultPingInterval().count()),
"ping interval, in milliseconds")
("timeout,o", po::value<time::milliseconds::rep>()->default_value(getDefaultPingTimeoutThreshold().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),
"set the starting sequence number, the number is incremented by 1 after each Interest")
("identifier,p", po::value<std::string>(&identifier),
"add identifier to the Interest names before the numbers to avoid conflict")
("cache,a", "allows routers to return stale Data from cache")
"add identifier to the Interest names before the sequence numbers to avoid conflicts")
("cache,a", "allow routers to return stale Data from cache")
("timestamp,t", "print timestamp with messages")
;
po::options_description hiddenOptDesc("Hidden options");
po::options_description hiddenOptDesc;
hiddenOptDesc.add_options()
("prefix", po::value<std::string>(), "prefix to send pings to")
;
po::options_description optDesc("Allowed options");
po::options_description optDesc;
optDesc.add(visibleOptDesc).add(hiddenOptDesc);
try {
po::positional_options_description optPos;
optPos.add("prefix", -1);
po::positional_options_description optPos;
optPos.add("prefix", -1);
try {
po::variables_map optVm;
po::store(po::command_line_parser(argc, argv).options(optDesc).positional(optPos).run(), optVm);
po::notify(optVm);
@@ -212,19 +210,14 @@ main(int argc, char* argv[])
usage(visibleOptDesc);
}
if (optVm.count("interval") > 0) {
options.interval = time::milliseconds(optVm["interval"].as<int>());
if (options.interval.count() < getMinimumPingInterval().count()) {
std::cerr << "ERROR: Specified ping interval is less than the minimum " <<
getMinimumPingInterval() << std::endl;
usage(visibleOptDesc);
}
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() << std::endl;
usage(visibleOptDesc);
}
if (optVm.count("timeout") > 0) {
options.timeout = time::milliseconds(optVm["timeout"].as<int>());
}
options.timeout = time::milliseconds(optVm["timeout"].as<time::milliseconds::rep>());
if (optVm.count("count") > 0) {
if (options.nPings <= 0) {