diff options
author | Angelo Mantellini <manangel@cisco.com> | 2019-03-20 11:03:25 +0100 |
---|---|---|
committer | Angelo Mantellini <manangel@cisco.com> | 2019-03-20 14:49:36 +0100 |
commit | d0111c2f8b5b73739f7193a79415e1d0bc8ee8c8 (patch) | |
tree | 6422f7126c5200e384b7cc34a15dc79a8a54d3bb | |
parent | d9b0f33a36f0f3f345d1059a82d725002780ca96 (diff) |
[HICN-128] README utils and renaming of executables
Change-Id: I5e3cd78306d9f4a25197b54ca5b2779e600891c8
Signed-off-by: Angelo Mantellini <manangel@cisco.com>
-rw-r--r-- | CMakeLists.txt | 4 | ||||
-rw-r--r-- | apps/README.md | 23 | ||||
-rw-r--r-- | apps/src/higet/higet.cc | 14 | ||||
-rw-r--r-- | apps/src/http-server/http-server.cc | 18 | ||||
-rw-r--r-- | hicn-light/CMakeLists.txt | 4 | ||||
-rw-r--r-- | hicn-light/README.md | 61 | ||||
-rw-r--r-- | hicn-light/src/command_line/daemon/hicnLightDaemon_main.c | 4 | ||||
-rw-r--r-- | utils/CMakeLists.txt | 41 | ||||
-rw-r--r-- | utils/README.md | 137 | ||||
-rw-r--r-- | utils/src/hiperf.cc | 413 | ||||
-rw-r--r-- | utils/src/ping_client.cc | 198 | ||||
-rw-r--r-- | utils/src/ping_server.cc | 161 |
12 files changed, 608 insertions, 470 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 999b54ef9..a2cd8edd7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -61,8 +61,8 @@ endforeach() ## Static targets set(LIBHICN hicn) set(LIBHICN_LIGHT hicn-light) -set(HICN_LIGHT_CONTROL hicnLightControl) -set(HICN_LIGHT_DAEMON hicnLightDaemon) +set(HICN_LIGHT_CONTROL hicn-light-control) +set(HICN_LIGHT_DAEMON hicn-light-daemon) set(HICN_PLUGIN hicn-plugin) set(LIBTRANSPORT hicntransport) set(HICN_UTILS hicn-utils) diff --git a/apps/README.md b/apps/README.md index 10a93f948..1311006f6 100644 --- a/apps/README.md +++ b/apps/README.md @@ -30,6 +30,7 @@ Basic dependencies: - pthreads - Libevent - Libparc +- Libcurl ## Executables ## @@ -41,14 +42,10 @@ The command `higet` runs the higet application. higet can be executed with the following options: ``` -higet [OPTION]... [URL]... - +higet [option]... [url]... Options: - -O filename write documents to FILE - -S print server response -Example: - higet -O - http://origin/index.html - +-O <output_path> = write documents to <output_file> +-S = print server response ``` ### hicn-http-server ### @@ -60,12 +57,12 @@ The command can be executed in the following way: hicn-http-server [OPTIONS] Options: - -p path path to root foot folder - -f confFile configuration file - -o tcpPort tcp listener port - -l webserverPrefix webserver prefix - -x tcpProxyPrefix tcp proxy prefix - -z hicnProxyPrefix hicn proxy prefix +-p <root_folder_path> = path to root folder +-f <coniguration_path> = configuration file path +-o <tcp_port> = tcp listener port +-l <webserver_prefix> = webserver prefix +-x <tcp_proxy_prefix> = tcp proxy prefix +-z <hicn_proxy_prefix> = hicn proxy prefix ``` ## License ## diff --git a/apps/src/higet/higet.cc b/apps/src/higet/higet.cc index 58b582a9d..1d1379887 100644 --- a/apps/src/higet/higet.cc +++ b/apps/src/higet/higet.cc @@ -87,14 +87,12 @@ void processResponse(Configuration &conf, } void usage(char *program_name) { - std::cerr << "USAGE:" << std::endl; - std::cerr << "\t" << program_name << " [OPTION]... [URL]..." << std::endl; - std::cerr << "OPTIONS:" << std::endl; - std::cerr << "\t" - << "-O filename write documents to FILE" << std::endl; - std::cerr << "\t" - << "-S print server response" << std::endl; - std::cerr << "EXAMPLE:" << std::endl; + std::cerr << "usage:" << std::endl; + std::cerr << program_name << " [option]... [url]..." << std::endl; + std::cerr << program_name << "options:" << std::endl; + std::cerr << "-O <output_path> = write documents to <output_file>" << std::endl; + std::cerr << "-S = print server response" << std::endl; + std::cerr << "example:" << std::endl; std::cerr << "\t" << program_name << " -O - http://origin/index.html" << std::endl; exit(EXIT_FAILURE); diff --git a/apps/src/http-server/http-server.cc b/apps/src/http-server/http-server.cc index f65734bae..ec6aa19a1 100644 --- a/apps/src/http-server/http-server.cc +++ b/apps/src/http-server/http-server.cc @@ -166,13 +166,19 @@ void afterSignal(HttpServer *webServer, const std::error_code &errorCode) { } void usage(const char *programName) { - cerr << programName - << " [-p PATH_TO_ROOT_FOOT_FOLDER] [-f CONFIGURATION_FILE] [-o " - "TCP_LISTEN_PORT] [-l WEBSERVER_PREFIX] [-x TCP_PROXY_ADDRESS] [-z " - "ICN_PROXY_PREFIX]\n" - << "Web server able to publish content and generate http responses over " - "TCP/ICN\n" + cerr << "usage: " << programName << " [options]" << endl; + cerr << programName << " options:" << endl; + cerr << "-p <root_folder_path> = path to root folder" << endl; + cerr << "-f <coniguration_path> = configuration file path" << endl; + cerr << "-o <tcp_port> = tcp listener port" << endl; + cerr << "-l <webserver_prefix> = webserver prefix" << endl; + cerr << "-x <tcp_proxy_prefix> = tcp proxy prefix" << endl; + cerr << "-z <hicn_proxy_prefix> = hicn proxy prefix" << endl; + cerr << endl; + cerr << "Web server able to publish content and generate http responses over " + "TCP/ICN" << endl; + cerr << endl; exit(1); } diff --git a/hicn-light/CMakeLists.txt b/hicn-light/CMakeLists.txt index eb6a50121..4bebb76d7 100644 --- a/hicn-light/CMakeLists.txt +++ b/hicn-light/CMakeLists.txt @@ -56,8 +56,8 @@ if(CMAKE_SOURCE_DIR STREQUAL PROJECT_SOURCE_DIR) find_package_wrapper(Libhicn REQUIRED) find_package_wrapper(Libparc REQUIRED) set(LIBHICN_LIGHT hicn-light) - set(HICN_LIGHT_CONTROL hicnLightControl) - set(HICN_LIGHT_DAEMON hicnLightDaemon) + set(HICN_LIGHT_CONTROL hicn-light-control) + set(HICN_LIGHT_DAEMON hicn-light-daemon) else() set(HICN_LIBRARIES ${LIBHICN_SHARED}) set(DEPENDENCIES diff --git a/hicn-light/README.md b/hicn-light/README.md index ba7ed77b3..974cad1fe 100644 --- a/hicn-light/README.md +++ b/hicn-light/README.md @@ -33,67 +33,66 @@ Basic dependencies: ## hicn-light Executables ## -hicn-light is a set of binary executables that are used to run a forwarder instance. +hicn-light is a set of binary executables that are used to run a forwarder instance. The forwarder can be run and configured using the commands -- `hicnLightDaemon` -- `hicnLightControl` +- `hicn-light-daemon` +- `hicn-light-control` Use the `-h` option to display the help messages ### hicn-light Daemon ### -The command `hicnLightDaemon` runs the hicn-light forwarder. The forwarder can be executed +The command `hicn-light-daemon` runs the hicn-light forwarder. The forwarder can be executed with the following options: ``` -hicnLightDaemon [--port port] [--daemon] [--capacity objectStoreSize] [--log facility=level] +hicn-light-daemon [--port port] [--daemon] [--capacity objectStoreSize] [--log facility=level] [--log-file filename] [--config file] Options: - ---port = tcp port for local in-bound connections ---daemon = start as daemon process ---capacity = maximum number of content objects to cache. To disable the cache - objectStoreSize must be 0. - Default vaule for objectStoreSize is 100000 ---log = sets a facility to a given log level. You can have multiple of these. - facilities: all, config, core, io, message, processor - levels: debug, info, notice, warning, error, critical, alert, off - example: hicnLightDaemon --log io=debug --log core=off ---log-file = file to write log messages to (required in daemon mode) ---config = configuration filename -``` - -The configuration file contains configuration lines as per hicnLightControl (see below for all +--port <tcp_port> = tcp port for local in-bound connections +--daemon = start as daemon process +--capacity <capacity> = maximum number of content objects to cache. To disable the cache + objectStoreSize must be 0. + Default vaule for objectStoreSize is 100000 +--log <log_granularity> = sets a facility to a given log level. You can have multiple of these. + facilities: all, config, core, io, message, processor + levels: debug, info, notice, warning, error, critical, alert, off + example: hicn-light-daemon --log io=debug --log core=off +--log-file <output_logfile> = file to write log messages to (required in daemon mode) +--config <config_path> = configuration filename +``` + +The configuration file contains configuration lines as per hicn-light-control (see below for all the available commands). If logging level or content store capacity is set in the configuration file, it overrides the command_line. When a configuration file is specified, no default listeners are setup. Only 'add listener' lines in the configuration file matter. -If no configuration file is specified, hicnLightDaemon will listen on TCP and UDP ports specified +If no configuration file is specified, hicn-light-daemon will listen on TCP and UDP ports specified by the --port flag (or default port). It will listen on both IPv4 and IPv6 if available. The default port for hicn-light is 9695. Commands are expected on port 2001. -### hicn-light Control ### +### hicn-light-control ### -`hicnLightControl` can be used to send command to the hicn-light forwarder and configure it. +`hicn-light-control` can be used to send command to the hicn-light forwarder and configure it. The command can be executed in the following way: ``` -hicnLightControl [commands] +hicn-light-control [commands] Options: - -h = This help screen - commands = configuration line to send to hicn-light (use 'help' for list) + -h = This help screen + commands = configuration line to send to hicn-light (use 'help' for list) ``` -#### Available Commands in hicn-light Control #### +#### Available Commands in hicn-light-control #### -This is the full list of available commands in `hicnLightControl`. This commands can be used -from the command line running `hicnLightControl` as explained before, or listing them in a +This is the full list of available commands in `hicn-light-control`. This commands can be used +from the command line running `hicn-light-control` as explained before, or listing them in a configuration file. -Information about the commands are also available in the `hicnLightControl` help message. +Information about the commands are also available in the `hicn-light-control` help message. `add listener`: creates a TCP or UDP listener with the specified options on the local forwarder. For local connections (application to hicn-light) we expect a TCP listener. The default port for @@ -267,7 +266,7 @@ mapme retx <milliseconds> ### hicn-light Configuration File Example ### This is an example of a simple configuration file for hicn-light. It can be loaded by running -the command `hicnLightDaemon --config configFile.cfg`, assuming the file name is configFile.cfg +the command `hicn-light-daemon --config configFile.cfg`, assuming the file name is configFile.cfg ``` #create a local listener on port 9199. This will be used by the applications to talk diff --git a/hicn-light/src/command_line/daemon/hicnLightDaemon_main.c b/hicn-light/src/command_line/daemon/hicnLightDaemon_main.c index 39e57ad9e..14192618b 100644 --- a/hicn-light/src/command_line/daemon/hicnLightDaemon_main.c +++ b/hicn-light/src/command_line/daemon/hicnLightDaemon_main.c @@ -86,11 +86,11 @@ static void _displayForwarderLogo(void) { static void _usage(int exitCode) { #ifndef _WIN32 printf( - "Usage: daemon [--port port] [--capacity objectStoreSize] " + "Usage: hicn-light-daemon [--port port] [--capacity objectStoreSize] " "[--log facility=level] [--log-file filename] [--config file]\n"); #else printf( - "Usage: daemon [--port port] [--daemon] [--capacity objectStoreSize] " + "Usage: hicn-light-daemon.exe [--port port] [--daemon] [--capacity objectStoreSize] " "[--log facility=level] [--log-file filename] [--config file]\n"); #endif printf("\n"); diff --git a/utils/CMakeLists.txt b/utils/CMakeLists.txt index f7ea729a8..9d3a77863 100644 --- a/utils/CMakeLists.txt +++ b/utils/CMakeLists.txt @@ -36,25 +36,30 @@ include(Packaging) set (COMPILER_DEFINITIONS "") -list(APPEND UTILS_SRC - src/hiperf.cc - src/ping_client.cc - src/ping_server.cc -) - if (WIN32) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd4200 /wd4996") endif () -foreach(util ${UTILS_SRC}) - get_filename_component(_util_name ${util} NAME) - string(REGEX REPLACE ".cc" "" util_name ${_util_name}) - - build_executable(${util_name} - SOURCES ${util} - LINK_LIBRARIES ${LIBTRANSPORT_LIBRARIES} ${WSOCK32_LIBRARY} ${WS2_32_LIBRARY} - DEPENDS ${LIBTRANSPORT} - COMPONENT ${HICN_UTILS} - DEFINITIONS ${COMPILER_DEFINITIONS} - ) -endforeach() +build_executable(hiperf + SOURCES src/hiperf.cc + LINK_LIBRARIES ${LIBTRANSPORT_LIBRARIES} ${WSOCK32_LIBRARY} ${WS2_32_LIBRARY} + DEPENDS ${LIBTRANSPORT} + COMPONENT ${HICN_UTILS} + DEFINITIONS ${COMPILER_DEFINITIONS} +) + +build_executable(hicn-ping-server + SOURCES src/ping_server.cc + LINK_LIBRARIES ${LIBTRANSPORT_LIBRARIES} ${WSOCK32_LIBRARY} ${WS2_32_LIBRARY} + DEPENDS ${LIBTRANSPORT} + COMPONENT ${HICN_UTILS} + DEFINITIONS ${COMPILER_DEFINITIONS} +) + +build_executable(hicn-ping-client + SOURCES src/ping_client.cc + LINK_LIBRARIES ${LIBTRANSPORT_LIBRARIES} ${WSOCK32_LIBRARY} ${WS2_32_LIBRARY} + DEPENDS ${LIBTRANSPORT} + COMPONENT ${HICN_UTILS} + DEFINITIONS ${COMPILER_DEFINITIONS} +) diff --git a/utils/README.md b/utils/README.md new file mode 100644 index 000000000..73525c6c2 --- /dev/null +++ b/utils/README.md @@ -0,0 +1,137 @@ +Utility applications +================== + +## Introduction ## + +hicn-ping-server, hicn-ping-client and hiperf are three utility applications that use hicn stack. + +## Using hICN Utils applications ## + +### Platforms ### + +The hICN application Examples have been tested in: + +- Ubuntu 16.04 (x86_64) +- Debian Testing +- MacOSX 10.12 + +Other platforms and architectures may work. + +### Dependencies ### + +Build dependencies: + +- c++14 ( clang++ / g++ ) +- CMake 3.4 + +Basic dependencies: + +- OpenSSL +- pthreads +- Libevent +- Libparc + +## Executables ## + +The utility applications are a set of binary executables that are used to run a clinet/server ping applications (hicn-ping-server and hicn-ping-client) and a hicn implementation of hicn (hiperf). + +### hicn-ping-server ### + +The command `hicn-ping-server` runs the server side ping application. hicn-ping-server can be executed +with the following options: + +``` +usage: hicn-ping-server [options] + +Options: +-s <content_size> = object content size (default 1350B) +-n <hicn_name> = hicn name (default b001::/64) +-f = set tcp flags according to the flag received (default false) +-l <lifetime> = data lifetime +-r = always reply with a reset flag (default false) +-t <ttl> = set ttl (default 64) +-V = verbose, prints statistics about the messagges sent and received (default false) +-D = dump, dumps sent and received packets (default false) +-q = quite, not prints (default false) +-d = daemon mode +-H = help +``` + +### hicn-ping-client ### + +The command `hicn-ping-client` runs the client side ping application. hicn-ping-client can be executed +with the following options: + +``` +usage: hicn-ping-client [options] + +Options: +-i <ping_interval> = ping interval in microseconds (default 1000000ms) +-m <max_pings> = maximum number of pings to send (default 10) +-s <source_port> = source port (default 9695) +-d <destination_port> = destination port (default 8080) +-t <ttl> = set packet ttl (default 64) +-O = open tcp connection (three way handshake) (default false) +-S = send always syn messages (default false) +-A = send always ack messages (default false) +-n <hicn_name> = hicn name (default b001::1) +-l <lifetime> = interest lifetime in milliseconds (default 500ms) +-V = verbose, prints statistics about the messagges sent and received (default false) +-D = dump, dumps sent and received packets (default false) +-q = quiet, not prints (default false) +-H = help +``` + +### hiperf ### + +The command `hiperf` is a tool for performing network throughput measurements with hicn. It can be executed as server or client using the following options: + +``` +usage: hiperf [-S|-C] [options] [prefix|name] + +Options: +-D = run as a daemon +-R = run RTC protocol (client or server) +-f <ouptup_log_file> = output log file path + +Server specific: +-A <download_size> = size of the content to publish. This is not the size of the packet (see -s for it) +-s <payload_size> = size of the payload of each data packet +-r = produce real content of content_size bytes +-m = produce transport manifest +-l = start producing content upon the reception of the first interest +-k <keystore_path> = path of p12 file containing the crypto material used for signing the packets +-y <hash_algorithm> = use the selected hash algorithm for calculating manifest digests +-p <password> = password for p12 keystore +-x = produce a content of <download_size>, then after downloading it produce a new content of + <download_size> without resetting the suffix to 0 +-B <bitrate> = bitrate for RTC producer, to be used with the -R option + +Client specific: +-b <beta_parameter> = RAAQM beta parameter +-d <drop_factor_parameter> = RAAQM drop factor parameter +-M = store the content downloaded (default false) +-W <window_size> = use a fixed congestion window for retrieving the data +-c <certificate_path> = path of the producer certificate to be used for verifying the origin of the packets received +-i <stats_interval> = show the statistics every <stats_interval> milliseconds +-v = Enable verification of received data +``` + +## License ## + +This software is distributed under the following license: + +``` +Copyright (c) 2017-2019 Cisco and/or its affiliates. +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at: + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +``` diff --git a/utils/src/hiperf.cc b/utils/src/hiperf.cc index 6f605aab9..34cb79b3f 100644 --- a/utils/src/hiperf.cc +++ b/utils/src/hiperf.cc @@ -46,17 +46,11 @@ using Identity = utils::Identity; struct ClientConfiguration { ClientConfiguration() - : name("b001::abcd", 0), - verify(false), - beta(-1.f), - drop_factor(-1.f), - window(-1), - virtual_download(true), + : name("b001::abcd", 0), verify(false), beta(-1.f), drop_factor(-1.f), + window(-1), virtual_download(true), producer_certificate("/tmp/rsa_certificate.pem"), receive_buffer(std::make_shared<std::vector<uint8_t>>()), - download_size(0), - report_interval_milliseconds_(1000), - rtc_(false) {} + download_size(0), report_interval_milliseconds_(1000), rtc_(false) {} Name name; bool verify; @@ -73,7 +67,7 @@ struct ClientConfiguration { }; class Rate { - public: +public: Rate() : rate_kbps_(0) {} Rate(const std::string &rate) { @@ -103,27 +97,19 @@ class Rate { packet_size * long(std::round(1000.0 * 8.0 / rate_kbps_))); } - private: +private: float rate_kbps_; }; struct ServerConfiguration { ServerConfiguration() - : name("b001::abcd/64"), - virtual_producer(true), - manifest(false), - live_production(false), - sign(false), - content_lifetime(600000000_U32), - content_object_size(1440), - download_size(20 * 1024 * 1024), + : name("b001::abcd/64"), virtual_producer(true), manifest(false), + live_production(false), sign(false), content_lifetime(600000000_U32), + content_object_size(1440), download_size(20 * 1024 * 1024), hash_algorithm(HashAlgorithm::SHA_256), keystore_name("/tmp/rsa_crypto_material.p12"), - keystore_password("cisco"), - multiphase_produce_(false), - rtc_(false), - production_rate_(std::string("2048kbps")), - payload_size_(1400) {} + keystore_password("cisco"), multiphase_produce_(false), rtc_(false), + production_rate_(std::string("2048kbps")), payload_size_(1400) {} Prefix name; bool virtual_producer; @@ -146,12 +132,10 @@ class HIperfClient { typedef std::chrono::time_point<std::chrono::steady_clock> Time; typedef std::chrono::microseconds TimeDuration; - public: +public: HIperfClient(const ClientConfiguration &conf) - : configuration_(conf), - total_duration_milliseconds_(0), - old_bytes_value_(0), - signals_(io_service_, SIGINT) {} + : configuration_(conf), total_duration_milliseconds_(0), + old_bytes_value_(0), signals_(io_service_, SIGINT) {} void processPayload(ConsumerSocket &c, std::size_t bytes_transferred, const std::error_code &ec) { @@ -362,7 +346,7 @@ class HIperfClient { return ERROR_SUCCESS; } - private: +private: ClientConfiguration configuration_; Time t_stats_; Time t_download_; @@ -376,10 +360,9 @@ class HIperfClient { class HIperfServer { const std::size_t log2_content_object_buffer_size = 8; - public: +public: HIperfServer(ServerConfiguration &conf) - : configuration_(conf), - signals_(io_service_, SIGINT), + : configuration_(conf), signals_(io_service_, SIGINT), rtc_timer_(io_service_), content_objects_((std::uint16_t)(1 << log2_content_object_buffer_size)), content_objects_index_(0), @@ -431,9 +414,10 @@ class HIperfServer { << std::endl; } - std::shared_ptr<utils::Identity> setProducerIdentity( - std::string &keystore_name, std::string &keystore_password, - HashAlgorithm &hash_algorithm) { + std::shared_ptr<utils::Identity> + setProducerIdentity(std::string &keystore_name, + std::string &keystore_password, + HashAlgorithm &hash_algorithm) { if (access(keystore_name.c_str(), F_OK) != -1) { return std::make_shared<utils::Identity>(keystore_name, keystore_password, hash_algorithm); @@ -566,7 +550,7 @@ class HIperfServer { return ERROR_SUCCESS; } - private: +private: ServerConfiguration configuration_; asio::io_service io_service_; asio::signal_set signals_; @@ -585,72 +569,69 @@ void usage() { std::cerr << "usage: hiperf [-S|-C] [options] [prefix|name]" << std::endl; std::cerr << "Server or Client:" << std::endl; #ifndef _WIN32 - std::cerr << "-D\t\t\t\t\t" - << "Run as a daemon" << std::endl; - std::cerr << "-R\t\t\t\t\t" - << "Run RTC protocol (client or server)" << std::endl; - std::cerr << "-f\t<filename>\t\t\t" - << "Log file" << std::endl; + std::cerr << "-D = run as a daemon" << std::endl; + #endif + std::cerr + << "-R = run RTC protocol (client or server)" + << std::endl; + std::cerr << "-f <ouptup_log_file> = output log file path" + << std::endl; std::cerr << std::endl; std::cerr << "Server specific:" << std::endl; - std::cerr << "-A\t<download_size>\t\t\tSize of the content to publish. This " - "is not the size of the packet (see -s for it)." + std::cerr << "-A <download_size> = size of the content to publish" + "This is not the size of the packet (see -s for it)" << std::endl; - std::cerr << "-s\t<packet_size>\t\t\tSize of the payload of each data packet." + std::cerr + << "-s <payload_size> = size of the payload of each data packet" + << std::endl; + std::cerr << "-r = produce real content of " + "content_size bytes" << std::endl; - std::cerr << "-r\t\t\t\t\t" - << "Produce real content of content_size bytes" << std::endl; - std::cerr << "-m\t\t\t\t\t" - << "Produce transport manifest" << std::endl; - std::cerr << "-l\t\t\t\t\t" - << "Start producing content upon the reception of the " - "first interest" + std::cerr << "-m = produce transport manifest" << std::endl; - std::cerr << "-k\t<keystore_path>\t\t\t" - << "Path of p12 file containing the " + std::cerr << "-l = start producing content upon the " + "reception of the first interest" + << std::endl; + std::cerr << "-k <keystore_path> = path of p12 file containing the " "crypto material used for signing the packets" << std::endl; - std::cerr << "-y\t<hash_algorithm>\t\t" - << "Use the selected hash algorithm for " - "calculating manifest digests" + std::cerr << "-y <hash_algorithm> = use the selected hash algorithm " + "for calculating manifest digests" << std::endl; - std::cerr << "-p\t<password>\t\t\t" - << "Password for p12 keystore" << std::endl; - std::cerr << "-x\t\t\t\t\t" - << "Produce a content of <download_size>, then after downloading " - "it produce a new content of" - << std::endl - << "\t\t\t\t\t<download_size> without resetting " - "the suffix to 0." + std::cerr << "-p <password> = password for p12 keystore" << std::endl; - std::cerr << "-B\t<bitrate>\t\t\t" - << "Bitrate for RTC producer, to be used with the -R option." + std::cerr + << "-x = produce a content of <download_size>, " + "then after downloading it produce a new content of" + << std::endl; + std::cerr << " <download_size> without " + "resetting the suffix to 0" + << std::endl; + std::cerr << "-B <bitrate> = bitrate for RTC " + "producer, to be used with the -R option" << std::endl; std::cerr << std::endl; std::cerr << "Client specific:" << std::endl; - std::cerr << "-b\t<beta_parameter>\t\t" - << "RAAQM beta parameter" << std::endl; - std::cerr << "-d\t<drop_factor_parameter>\t\t" - << "RAAQM drop factor " - "parameter" + std::cerr << "-b <beta_parameter> = RAAQM beta parameter" + << std::endl; + std::cerr << "-d <drop_factor_parameter> = RAAQM drop factor parameter" << std::endl; - std::cerr << "-M\t<Download for real>\t\t" - << "Store the content downloaded." << std::endl; - std::cerr << "-W\t<window_size>\t\t\t" - << "Use a fixed congestion window " - "for retrieving the data." + std::cerr << "-M = store the content downloaded" + "(default false)" << std::endl; - std::cerr << "-c\t<certificate_path>\t\t" - << "Path of the producer certificate " - "to be used for verifying the " - "origin of the packets received" + std::cerr << "-W <window_size> = use a fixed congestion window" + "for retrieving the data" << std::endl; - std::cerr << "-i\t<stats_interval>\t\t" - << "Show the statistics every <stats_interval> milliseconds." + std::cerr << "-c <certificate_path> = path of the producer certificate" + "to be used for verifying the origin of the packets received" << std::endl; - std::cout << "-v\t\t\t\t\t" - << "Enable verification of received data" << std::endl; + std::cerr << "-i <stats_interval> = show the statistics every " + "<stats_interval> milliseconds" + << std::endl; + std::cout + << "-v = Enable verification of received data" + << std::endl; } int main(int argc, char *argv[]) { @@ -679,143 +660,143 @@ int main(int argc, char *argv[]) { while ((opt = getopt(argc, argv, "DSCf:b:d:W:RMc:vA:s:rmlk:y:p:hi:xB:")) != -1) { switch (opt) { - // Common - case 'D': { - daemon = true; - break; - } + // Common + case 'D': { + daemon = true; + break; + } #else while ((opt = getopt(argc, argv, "SCf:b:d:W:RMc:vA:s:rmlk:y:p:hi:xB:")) != -1) { switch (opt) { #endif - case 'f': { - log_file = optarg; - break; - } - case 'R': { - client_configuration.rtc_ = true; - server_configuration.rtc_ = true; - break; - } + case 'f': { + log_file = optarg; + break; + } + case 'R': { + client_configuration.rtc_ = true; + server_configuration.rtc_ = true; + break; + } - // Server or Client - case 'S': { - role -= 1; - break; - } - case 'C': { - role += 1; - break; - } + // Server or Client + case 'S': { + role -= 1; + break; + } + case 'C': { + role += 1; + break; + } - // Client specifc - case 'b': { - client_configuration.beta = std::stod(optarg); - options = 1; - break; - } - case 'd': { - client_configuration.drop_factor = std::stod(optarg); - options = 1; - break; - } - case 'W': { - client_configuration.window = std::stod(optarg); - options = 1; - break; - } - case 'M': { - client_configuration.virtual_download = false; - options = 1; - break; - } - case 'c': { - client_configuration.producer_certificate = std::string(optarg); - options = 1; - break; - } - case 'v': { - client_configuration.verify = true; - options = 1; - break; - } - case 'i': { - client_configuration.report_interval_milliseconds_ = std::stoul(optarg); - options = 1; - break; - } + // Client specifc + case 'b': { + client_configuration.beta = std::stod(optarg); + options = 1; + break; + } + case 'd': { + client_configuration.drop_factor = std::stod(optarg); + options = 1; + break; + } + case 'W': { + client_configuration.window = std::stod(optarg); + options = 1; + break; + } + case 'M': { + client_configuration.virtual_download = false; + options = 1; + break; + } + case 'c': { + client_configuration.producer_certificate = std::string(optarg); + options = 1; + break; + } + case 'v': { + client_configuration.verify = true; + options = 1; + break; + } + case 'i': { + client_configuration.report_interval_milliseconds_ = std::stoul(optarg); + options = 1; + break; + } - // Server specific - case 'A': { - server_configuration.download_size = std::stoul(optarg); - options = -1; - break; - } - case 's': { - server_configuration.payload_size_ = std::stoul(optarg); - options = -1; - break; - } - case 'r': { - server_configuration.virtual_producer = false; - options = -1; - break; - } - case 'm': { - server_configuration.manifest = true; - options = -1; - break; - } - case 'l': { - server_configuration.live_production = true; - options = -1; - break; - } - case 'k': { - server_configuration.keystore_name = std::string(optarg); - server_configuration.sign = true; - options = -1; - break; - } - case 'y': { - if (strncasecmp(optarg, "sha256", 6) == 0) { - server_configuration.hash_algorithm = HashAlgorithm::SHA_256; - } else if (strncasecmp(optarg, "sha512", 6) == 0) { - server_configuration.hash_algorithm = HashAlgorithm::SHA_512; - } else if (strncasecmp(optarg, "crc32", 5) == 0) { - server_configuration.hash_algorithm = HashAlgorithm::CRC32C; - } else { - std::cerr << "Ignored unknown hash algorithm. Using SHA 256." - << std::endl; - } - options = -1; - break; - } - case 'p': { - server_configuration.keystore_password = std::string(optarg); - options = -1; - break; - } - case 'x': { - server_configuration.multiphase_produce_ = true; - options = -1; - break; - } - case 'B': { - auto str = std::string(optarg); - std::transform(str.begin(), str.end(), str.begin(), ::tolower); - std::cout << "---------------------------------------------------------" - "---------------------->" - << str << std::endl; - server_configuration.production_rate_ = str; - options = -1; - break; + // Server specific + case 'A': { + server_configuration.download_size = std::stoul(optarg); + options = -1; + break; + } + case 's': { + server_configuration.payload_size_ = std::stoul(optarg); + options = -1; + break; + } + case 'r': { + server_configuration.virtual_producer = false; + options = -1; + break; + } + case 'm': { + server_configuration.manifest = true; + options = -1; + break; + } + case 'l': { + server_configuration.live_production = true; + options = -1; + break; + } + case 'k': { + server_configuration.keystore_name = std::string(optarg); + server_configuration.sign = true; + options = -1; + break; + } + case 'y': { + if (strncasecmp(optarg, "sha256", 6) == 0) { + server_configuration.hash_algorithm = HashAlgorithm::SHA_256; + } else if (strncasecmp(optarg, "sha512", 6) == 0) { + server_configuration.hash_algorithm = HashAlgorithm::SHA_512; + } else if (strncasecmp(optarg, "crc32", 5) == 0) { + server_configuration.hash_algorithm = HashAlgorithm::CRC32C; + } else { + std::cerr << "Ignored unknown hash algorithm. Using SHA 256." + << std::endl; } - case 'h': - default: - usage(); - return EXIT_FAILURE; + options = -1; + break; + } + case 'p': { + server_configuration.keystore_password = std::string(optarg); + options = -1; + break; + } + case 'x': { + server_configuration.multiphase_produce_ = true; + options = -1; + break; + } + case 'B': { + auto str = std::string(optarg); + std::transform(str.begin(), str.end(), str.begin(), ::tolower); + std::cout << "---------------------------------------------------------" + "---------------------->" + << str << std::endl; + server_configuration.production_rate_ = str; + options = -1; + break; + } + case 'h': + default: + usage(); + return EXIT_FAILURE; } } @@ -894,9 +875,9 @@ int main(int argc, char *argv[]) { return 0; } -} // end namespace interface +} // end namespace interface -} // end namespace transport +} // end namespace transport int main(int argc, char *argv[]) { return transport::interface::main(argc, argv); diff --git a/utils/src/ping_client.cc b/utils/src/ping_client.cc index 72a310c2d..d72177830 100644 --- a/utils/src/ping_client.cc +++ b/utils/src/ping_client.cc @@ -38,7 +38,7 @@ typedef std::map<uint64_t, uint64_t> SendTimeMap; typedef utils::Verifier Verifier; class Configuration { - public: +public: uint64_t interestLifetime_; uint64_t pingInterval_; uint64_t maxPing_; @@ -59,11 +59,11 @@ class Configuration { uint8_t ttl_; Configuration() { - interestLifetime_ = 500; // ms - pingInterval_ = 1000000; // us - maxPing_ = 10; // number of interests + interestLifetime_ = 500; // ms + pingInterval_ = 1000000; // us + maxPing_ = 10; // number of interests first_suffix_ = 0; - name_ = "b001::1"; // string + name_ = "b001::1"; // string srcPort_ = 9695; dstPort_ = 8080; verbose_ = false; @@ -80,7 +80,7 @@ class Configuration { }; class Client : interface::BasePortal::ConsumerCallback { - public: +public: Client(Configuration *c) : portal_(), signals_(portal_.getIoService(), SIGINT) { // Let the main thread to catch SIGINT @@ -169,7 +169,8 @@ class Client : interface::BasePortal::ConsumerCallback { std::cout << "-------------------------" << std::endl; } - if (!config_->quiet_) std::cout << std::endl; + if (!config_->quiet_) + std::cout << std::endl; if (!config_->always_syn_) { if (object->testSyn() && object->testAck() && state_ == SYN_STATE) { @@ -200,7 +201,8 @@ class Client : interface::BasePortal::ConsumerCallback { std::cout << "-------------------------" << std::endl; } - if (!config_->quiet_) std::cout << std::endl; + if (!config_->quiet_) + std::cout << std::endl; timedout_++; processed_++; @@ -255,7 +257,8 @@ class Client : interface::BasePortal::ConsumerCallback { std::cout << "-------------------------" << std::endl; } - if (!config_->quiet_) std::cout << std::endl; + if (!config_->quiet_) + std::cout << std::endl; send_timestamps_[sequence_number_] = std::chrono::duration_cast<std::chrono::microseconds>( @@ -292,7 +295,7 @@ class Client : interface::BasePortal::ConsumerCallback { timedout_ = 0; } - private: +private: SendTimeMap send_timestamps_; interface::BasePortal portal_; asio::signal_set signals_; @@ -310,38 +313,45 @@ class Client : interface::BasePortal::ConsumerCallback { }; void help() { - std::cout << "usage: hicn-consumer-ping [options]" << std::endl; - std::cout << "PING options" << std::endl; - std::cout - << "-i <val> ping interval in microseconds (default 1000000ms)" - << std::endl; - std::cout << "-m <val> maximum number of pings to send (default 10)" + std::cout << "usage: hicn-ping-client [options]" << std::endl; + std::cout << "PING client options:" << std::endl; + std::cout << "-i <ping_interval> = ping interval in microseconds " + "(default 1000000ms)" << std::endl; - std::cout << "-s <val> sorce port (default 9695)" << std::endl; - std::cout << "-d <val> destination port (default 8080)" << std::endl; - std::cout << "-t <val> set packet ttl (default 64)" << std::endl; - std::cout << "-O open tcp connection (three way handshake) " - "(default false)" + std::cout << "-m <max_pings> = maximum number of pings to send " + "(default 10)" + << std::endl; + std::cout << "-s <source_port> = source port (default 9695)" + << std::endl; + std::cout << "-d <destination_port> = destination port (default 8080)" + << std::endl; + std::cout << "-t <ttl> = set packet ttl (default 64)" + << std::endl; + std::cout << "-O = open tcp connection (three way " + "handshake) (default false)" << std::endl; - std::cout << "-S send always syn messages (default false)" + std::cout << "-S = send always syn messages " + "(default false)" << std::endl; - std::cout << "-A send always ack messages (default false)" + std::cout << "-A = send always ack messages " + "(default false)" << std::endl; std::cout << "HICN options" << std::endl; - std::cout << "-n <val> hicn name (default b001::1)" << std::endl; - std::cout - << "-l <val> interest lifetime in milliseconds (default 500ms)" - << std::endl; + std::cout << "-n <hicn_name> = hicn name (default b001::1)" + << std::endl; + std::cout << "-l <lifetime> = interest lifetime in " + "milliseconds (default 500ms)" + << std::endl; std::cout << "OUTPUT options" << std::endl; - std::cout << "-V verbose, prints statistics about the " - "messagges sent and received (default false)" + std::cout << "-V = verbose, prints statistics about " + "the messagges sent and received (default false)" << std::endl; - std::cout << "-D dump, dumps sent and received packets " - "(default false)" + std::cout << "-D = dump, dumps sent and received " + "packets (default false)" << std::endl; - std::cout << "-q quiet, not prints (default false)" + std::cout << "-q = quiet, not prints (default false)" << std::endl; - std::cout << "-H prints this message" << std::endl; + std::cout << "-H = prints this message" << std::endl; } int main(int argc, char *argv[]) { @@ -356,64 +366,64 @@ int main(int argc, char *argv[]) { while ((opt = getopt(argc, argv, "j::t:i:m:s:d:n:l:f:c:SAOqVDH")) != -1) { switch (opt) { - case 't': - c->ttl_ = (uint8_t)std::stoi(optarg); - break; - case 'i': - c->pingInterval_ = std::stoi(optarg); - break; - case 'm': - c->maxPing_ = std::stoi(optarg); - break; - case 'f': - c->first_suffix_ = std::stoul(optarg); - break; - case 's': - c->srcPort_ = std::stoi(optarg); - break; - case 'd': - c->dstPort_ = std::stoi(optarg); - break; - case 'n': - c->name_ = optarg; - break; - case 'l': - c->interestLifetime_ = std::stoi(optarg); - break; - case 'V': - c->verbose_ = true; - ; - break; - case 'D': - c->dump_ = true; - break; - case 'O': - c->always_syn_ = false; - c->always_ack_ = false; - c->open_ = true; - break; - case 'S': - c->always_syn_ = true; - c->always_ack_ = false; - c->open_ = false; - break; - case 'A': - c->always_syn_ = false; - c->always_ack_ = true; - c->open_ = false; - break; - case 'q': - c->quiet_ = true; - c->verbose_ = false; - c->dump_ = false; - break; - case 'c': - c->certificate_ = std::string(optarg); - break; - case 'H': - default: - help(); - exit(EXIT_FAILURE); + case 't': + c->ttl_ = (uint8_t)std::stoi(optarg); + break; + case 'i': + c->pingInterval_ = std::stoi(optarg); + break; + case 'm': + c->maxPing_ = std::stoi(optarg); + break; + case 'f': + c->first_suffix_ = std::stoul(optarg); + break; + case 's': + c->srcPort_ = std::stoi(optarg); + break; + case 'd': + c->dstPort_ = std::stoi(optarg); + break; + case 'n': + c->name_ = optarg; + break; + case 'l': + c->interestLifetime_ = std::stoi(optarg); + break; + case 'V': + c->verbose_ = true; + ; + break; + case 'D': + c->dump_ = true; + break; + case 'O': + c->always_syn_ = false; + c->always_ack_ = false; + c->open_ = true; + break; + case 'S': + c->always_syn_ = true; + c->always_ack_ = false; + c->open_ = false; + break; + case 'A': + c->always_syn_ = false; + c->always_ack_ = true; + c->open_ = false; + break; + case 'q': + c->quiet_ = true; + c->verbose_ = false; + c->dump_ = false; + break; + case 'c': + c->certificate_ = std::string(optarg); + break; + case 'H': + default: + help(); + exit(EXIT_FAILURE); } } @@ -434,11 +444,11 @@ int main(int argc, char *argv[]) { return 0; } -} // namespace ping +} // namespace ping -} // namespace core +} // namespace core -} // namespace transport +} // namespace transport int main(int argc, char *argv[]) { return transport::core::ping::main(argc, argv); diff --git a/utils/src/ping_server.cc b/utils/src/ping_server.cc index 5482c2b1c..d6614303a 100644 --- a/utils/src/ping_server.cc +++ b/utils/src/ping_server.cc @@ -43,22 +43,16 @@ utils::Identity setProducerIdentity(std::string keystore_name, class CallbackContainer { const std::size_t log2_content_object_buffer_size = 12; - public: +public: CallbackContainer(const Name &prefix, uint32_t object_size, bool verbose, bool dump, bool quite, bool flags, bool reset, uint8_t ttl, utils::Identity *identity, bool sign, uint32_t lifetime) : buffer_(object_size, 'X'), content_objects_((std::uint32_t)(1 << log2_content_object_buffer_size)), mask_((std::uint16_t)(1 << log2_content_object_buffer_size) - 1), - content_objects_index_(0), - verbose_(verbose), - dump_(dump), - quite_(quite), - flags_(flags), - reset_(reset), - ttl_(ttl), - identity_(identity), - sign_(sign) { + content_objects_index_(0), verbose_(verbose), dump_(dump), + quite_(quite), flags_(flags), reset_(reset), ttl_(ttl), + identity_(identity), sign_(sign) { core::Packet::Format format; if (prefix.getAddressFamily() == AF_INET) { @@ -80,7 +74,8 @@ class CallbackContainer { } } - void processInterest(ProducerSocket &p, const Interest &interest, uint32_t lifetime) { + void processInterest(ProducerSocket &p, const Interest &interest, + uint32_t lifetime) { if (verbose_) { std::cout << "<<< received interest " << interest.getName() << " src port: " << interest.getSrcPort() @@ -119,7 +114,7 @@ class CallbackContainer { content_object->setAck(); } else if (interest.testAck()) { content_object->setAck(); - } // here I may need to handle the FIN flag; + } // here I may need to handle the FIN flag; } else if (reset_) { content_object->setRst(); } @@ -141,7 +136,8 @@ class CallbackContainer { std::cout << "-----------------------" << std::endl; } - if (!quite_) std::cout << std::endl; + if (!quite_) + std::cout << std::endl; if (sign_) { identity_->getSigner().sign(*content_object); @@ -151,7 +147,7 @@ class CallbackContainer { } } - private: +private: std::string buffer_; std::vector<std::shared_ptr<ContentObject>> content_objects_; std::uint16_t mask_; @@ -167,28 +163,35 @@ class CallbackContainer { }; void help() { - std::cout << "usage: hicn-preoducer-ping [options]" << std::endl; - std::cout << "PING options" << std::endl; - std::cout << "-s <val> object content size (default 1350B)" << std::endl; - std::cout << "-n <val> hicn name (default b001::/64)" << std::endl; - std::cout << "-f set tcp flags according to the flag received " + std::cout << "usage: hicn-ping-server [options]" << std::endl; + std::cout << "PING server options" << std::endl; + std::cout + << "-s <content_size> = object content size (default 1350B)" + << std::endl; + std::cout << "-n <hicn_name> = hicn name (default b001::/64)" + << std::endl; + std::cout << "-f = set tcp flags according to the " + "flag received (default false)" + << std::endl; + std::cout << "-l <lifetime> = data lifetime" << std::endl; + std::cout << "-r = always reply with a reset flag " "(default false)" << std::endl; - std::cout << "-l data lifetime" << std::endl; - std::cout << "-r always reply with a reset flag (default false)" + std::cout << "-t <ttl> = set ttl (default 64)" << std::endl; - std::cout << "-t set ttl (default 64)" << std::endl; std::cout << "OUTPUT options" << std::endl; - std::cout << "-V verbose, prints statistics about the messagges sent " - "and received (default false)" + std::cout << "-V = verbose, prints statistics about " + "the messagges sent and received (default false)" + << std::endl; + std::cout << "-D = dump, dumps sent and received " + "packets (default false)" << std::endl; - std::cout << "-D dump, dumps sent and received packets (default false)" + std::cout << "-q = quite, not prints (default false)" << std::endl; - std::cout << "-q quite, not prints (default false)" << std::endl; #ifndef _WIN32 - std::cout << "-d daemon mode" << std::endl; + std::cout << "-d = daemon mode" << std::endl; #endif - std::cout << "-H prints this message" << std::endl; + std::cout << "-H = prints help options" << std::endl; } int main(int argc, char **argv) { @@ -219,51 +222,51 @@ int main(int argc, char **argv) { while ((opt = getopt(argc, argv, "s:n:t:l:qfrVDHk:p:")) != -1) { #endif switch (opt) { - case 's': - object_size = std::stoi(optarg); - break; - case 'n': - name_prefix = optarg; - break; - case 't': - ttl = (uint8_t)std::stoi(optarg); - break; - case 'l': - data_lifetime = std::stoi(optarg); - break; - case 'V': - verbose = true; - break; - case 'D': - dump = true; - break; - case 'q': - verbose = false; - dump = false; - quite = true; - break; + case 's': + object_size = std::stoi(optarg); + break; + case 'n': + name_prefix = optarg; + break; + case 't': + ttl = (uint8_t)std::stoi(optarg); + break; + case 'l': + data_lifetime = std::stoi(optarg); + break; + case 'V': + verbose = true; + break; + case 'D': + dump = true; + break; + case 'q': + verbose = false; + dump = false; + quite = true; + break; #ifndef _WIN32 - case 'd': - daemon = true; - break; + case 'd': + daemon = true; + break; #endif - case 'f': - flags = true; - break; - case 'r': - reset = true; - break; - case 'k': - keystore_path = optarg; - sign = true; - break; - case 'p': - keystore_password = optarg; - break; - case 'H': - default: - help(); - exit(EXIT_FAILURE); + case 'f': + flags = true; + break; + case 'r': + reset = true; + break; + case 'k': + keystore_path = optarg; + sign = true; + break; + case 'p': + keystore_password = optarg; + break; + case 'H': + default: + help(); + exit(EXIT_FAILURE); } } @@ -279,7 +282,8 @@ int main(int argc, char **argv) { std::string ip_address = tokenizer.nextToken(); Name n(ip_address); - if (object_size > 1350) object_size = 1350; + if (object_size > 1350) + object_size = 1350; CallbackContainer *stubs; utils::Identity identity = setProducerIdentity( @@ -298,10 +302,11 @@ int main(int argc, char **argv) { p.registerPrefix(producer_namespace); p.setSocketOption(GeneralTransportOptions::OUTPUT_BUFFER_SIZE, 0U); - p.setSocketOption(ProducerCallbacksOptions::CACHE_MISS, - (ProducerInterestCallback)bind( - &CallbackContainer::processInterest, stubs, - std::placeholders::_1, std::placeholders::_2, data_lifetime)); + p.setSocketOption( + ProducerCallbacksOptions::CACHE_MISS, + (ProducerInterestCallback)bind(&CallbackContainer::processInterest, stubs, + std::placeholders::_1, + std::placeholders::_2, data_lifetime)); p.connect(); @@ -322,9 +327,9 @@ int main(int argc, char **argv) { return 0; } -} // namespace interface +} // namespace interface -} // end namespace transport +} // end namespace transport int main(int argc, char **argv) { return transport::interface::main(argc, argv); |