pingserver: add --quiet option
Change-Id: I7e61383e587044fd65a50e4dee58a020d3b292ad
Refs: #4673
diff --git a/tests/ping/server/ping-server.t.cpp b/tests/ping/server/ping-server.t.cpp
index 497d4d6..84e967f 100644
--- a/tests/ping/server/ping-server.t.cpp
+++ b/tests/ping/server/ping-server.t.cpp
@@ -48,12 +48,12 @@
makePingInterest(int seq) const
{
Name name(pingOptions.prefix);
- name.append("ping");
- name.append(std::to_string(seq));
- Interest interest(name);
- interest.setMustBeFresh(true);
- interest.setInterestLifetime(time::milliseconds(2000));
- return interest;
+ name.append("ping")
+ .append(to_string(seq));
+
+ return Interest(name)
+ .setMustBeFresh(true)
+ .setInterestLifetime(2_s);
}
private:
@@ -61,11 +61,12 @@
makeOptions()
{
Options opt;
- opt.prefix = "ndn:/test-prefix";
- opt.freshnessPeriod = time::milliseconds(5000);
+ opt.prefix = "/test-prefix";
+ opt.freshnessPeriod = 5_s;
opt.nMaxPings = 2;
- opt.wantTimestamp = false;
opt.payloadSize = 0;
+ opt.wantTimestamp = false;
+ opt.wantQuiet = true;
return opt;
}
diff --git a/tools/ping/server/ndn-ping-server.cpp b/tools/ping/server/ndn-ping-server.cpp
index a51519c..28c6871 100644
--- a/tools/ping/server/ndn-ping-server.cpp
+++ b/tools/ping/server/ndn-ping-server.cpp
@@ -111,7 +111,10 @@
"maximum number of pings to be satisfied (0=infinite)")
("size,s", po::value(&payloadSize)->default_value(payloadSize),
"size of response payload")
- ("timestamp,t", po::bool_switch(&options.wantTimestamp), "log timestamp with responses")
+ ("timestamp,t", po::bool_switch(&options.wantTimestamp),
+ "prepend a timestamp to each log message")
+ ("quiet,q", po::bool_switch(&options.wantQuiet),
+ "do not print a log message each time a ping packet is received")
("version,V", "print program version and exit")
;
diff --git a/tools/ping/server/ping-server.hpp b/tools/ping/server/ping-server.hpp
index 2d81e5f..3a43a6d 100644
--- a/tools/ping/server/ping-server.hpp
+++ b/tools/ping/server/ping-server.hpp
@@ -39,6 +39,7 @@
size_t nMaxPings = 0; //!< max number of pings to satisfy (0 == no limit)
size_t payloadSize = 0; //!< response payload size (0 == no payload)
bool wantTimestamp = false; //!< print timestamp when response sent
+ bool wantQuiet = false; //!< suppress printing per-packet log message
};
/**
diff --git a/tools/ping/server/tracer.cpp b/tools/ping/server/tracer.cpp
index 5f5150a..51b191c 100644
--- a/tools/ping/server/tracer.cpp
+++ b/tools/ping/server/tracer.cpp
@@ -28,7 +28,9 @@
Tracer::Tracer(PingServer& pingServer, const Options& options)
: m_options(options)
{
- pingServer.afterReceive.connect([this] (const Name& name) { onReceive(name); });
+ if (!m_options.wantQuiet) {
+ pingServer.afterReceive.connect([this] (const Name& name) { onReceive(name); });
+ }
}
void