pingserver: change the short form of --freshness to -f

-x is still accepted but will print a deprecation warning

Change-Id: Ibc2e9750006a450c85d19c432ec1a02416cdc174
This commit is contained in:
Davide Pesavento committed 2019-07-27 19:35:13 -04:00
1 parent 7de32c1f2d
commit 0d4b182304
3 files changed
+58 -46

No files matched your search

+31 -32
View File
@@ -1,25 +1,23 @@
ndnping
=======
Usage
-----
Synopsis
--------
::
ndnpingserver [-h] [-V] [-x freshness] [-p satisfy] [-t] [-s size] prefix
**ndnpingserver** [-h] [-f *freshness*] [-p *count*] [-s *size*] [-t] [-q] [-V] *prefix*
Description
-----------
``ndnpingserver`` listens for the specified Interest prefix and sends Data packets when an Interest
under that prefix is received. Once ``ndnpingserver`` either reaches the specified total number of
Interests to be satisfied or receives an interrupt signal, it prints the number of Data packets
sent.
:program:`ndnpingserver` listens for the specified Interest prefix and sends Data packets when
an Interest under that prefix is received. Once :program:`ndnpingserver` either reaches the
specified total number of Interests to be satisfied or receives an interrupt signal, it prints
the number of Data packets sent.
``prefix`` is interpreted as the Interest prefix to listen for. The FreshnessPeriod of Data packets
is set with the -x option (default 1000ms). The content is by default empty, but if a size is
specified with the '-s' option, it contains the specified number of the letter "a". Finally, the
Data is signed with an SHA256 digest.
*prefix* is interpreted as the Interest prefix to listen for. The FreshnessPeriod of Data packets
is set with the **-f** option (default 1 second). The content is by default empty, but if a size
is specified with the **-s** option, it contains the specified number of the letter "a". Finally,
the Data is signed with a SHA-256 digest.
Options
-------
@@ -27,27 +25,28 @@ Options
``-h``
Print help and exit.
``-f``
Set freshness period in milliseconds.
``-p``
Maximum number of pings to satisfy. A value of 0 means no limit.
``-s``
Size of the response payload.
``-t``
Print a timestamp before each log message.
``-q``
Do not print a log message each time a ping is received.
``-V``
Print version and exit.
``-x``
Set freshness period in milliseconds (minimum 1000ms).
Example
-------
``-p``
Set maximum number of pings to satisfy.
Listen on ``/edu/arizona`` and respond to at most 4 pings, printing the timestamp
on each received ping::
``-t``
Prints a timestamp with received Data and timeouts.
``-s``
Specify the size of the response payload.
Examples
--------
Listen on ``ndn:/edu/arizona`` and response to at most 4 pings, printing timestamp on each received
ping
::
ndnpingserver -p 4 -t ndn:/edu/arizona
ndnpingserver -p 4 -t /edu/arizona
+9 -9
View File
@@ -11,29 +11,29 @@ marks it as a timeout if the Data is not received within the timeout period.
## Using the Client
The client can be invoked by calling **ndnping** with a name to ping. For example, to ping
`ndn:/edu/arizona`, one would execute::
`/edu/arizona`, one would execute:
ndnping ndn:/edu/arizona
ndnping /edu/arizona
There are also a variety of options to control the behavior of the ping client. For example, to
send only four pings to `ndn:/edu/arizona`, displaying a timestamp with each received Data or
timeout, type::
send only four pings to `/edu/arizona`, displaying a timestamp with each received Data or
timeout, type:
ndnping -c 4 -t ndn:/edu/arizona
ndnping -c 4 -t /edu/arizona
A list of the available options can be found with `man ndnping`.
## Using the Server
The server can be invoked by calling **ndnpingserver** with a name to listen for pings to. For
example, to listen for pings to `ndn:/edu/arizona`, one would execute::
example, to listen for pings to `/edu/arizona`, one would execute:
ndnpingserver ndn:/edu/arizona
ndnpingserver /edu/arizona
There are also a variety of options to control the behavior of the ping server. For example, to
satisfy only 4 ping requests before exiting, execute the following::
satisfy only 4 ping requests before exiting, execute the following:
ndnpingserver -p 4 ndn:/edu/arizona
ndnpingserver -p 4 /edu/arizona
A list of the available options can be found with `man ndnpingserver`.
+18 -5
View File
@@ -105,10 +105,10 @@ main(int argc, char* argv[])
po::options_description visibleDesc("Options");
visibleDesc.add_options()
("help,h", "print this help message and exit")
("freshness,x", po::value<time::milliseconds::rep>()->default_value(options.freshnessPeriod.count()),
("freshness,f", po::value<time::milliseconds::rep>()->default_value(options.freshnessPeriod.count()),
"FreshnessPeriod of the ping response, in milliseconds")
("satisfy,p", po::value(&nMaxPings)->default_value(nMaxPings),
"maximum number of pings to be satisfied (0=infinite)")
"maximum number of pings to satisfy (0 = no limit)")
("size,s", po::value(&payloadSize)->default_value(payloadSize),
"size of response payload")
("timestamp,t", po::bool_switch(&options.wantTimestamp),
@@ -122,11 +122,16 @@ main(int argc, char* argv[])
hiddenDesc.add_options()
("prefix", po::value<std::string>(&prefix));
po::positional_options_description posDesc;
posDesc.add("prefix", -1);
po::options_description deprecatedDesc;
deprecatedDesc.add_options()
("_deprecated_freshness_,x", po::value<time::milliseconds::rep>())
;
po::options_description optDesc;
optDesc.add(visibleDesc).add(hiddenDesc);
optDesc.add(visibleDesc).add(hiddenDesc).add(deprecatedDesc);
po::positional_options_description posDesc;
posDesc.add("prefix", -1);
po::variables_map vm;
try {
@@ -144,6 +149,11 @@ main(int argc, char* argv[])
return 2;
}
if (vm.count("_deprecated_freshness_") > 0) {
std::cerr << "WARNING: short option '-x' is deprecated and will be removed in the near "
"future. Please use '-f' or the long form '--freshness'." << std::endl;
}
if (vm.count("help") > 0) {
usage(std::cout, argv[0], visibleDesc);
return 0;
@@ -162,6 +172,9 @@ main(int argc, char* argv[])
options.prefix = prefix;
options.freshnessPeriod = time::milliseconds(vm["freshness"].as<time::milliseconds::rep>());
if (vm.count("_deprecated_freshness_") > 0) {
options.freshnessPeriod = time::milliseconds(vm["_deprecated_freshness_"].as<time::milliseconds::rep>());
}
if (options.freshnessPeriod < 0_ms) {
std::cerr << "ERROR: FreshnessPeriod cannot be negative" << std::endl;
return 2;