aboutsummaryrefslogtreecommitdiffstats
path: root/apps/hiperf
diff options
context:
space:
mode:
Diffstat (limited to 'apps/hiperf')
-rw-r--r--apps/hiperf/CMakeLists.txt3
-rw-r--r--apps/hiperf/src/common.h14
-rw-r--r--apps/hiperf/src/main.cc329
-rw-r--r--apps/hiperf/src/server.cc24
4 files changed, 174 insertions, 196 deletions
diff --git a/apps/hiperf/CMakeLists.txt b/apps/hiperf/CMakeLists.txt
index 8a0c46ebc..5a0dc3c06 100644
--- a/apps/hiperf/CMakeLists.txt
+++ b/apps/hiperf/CMakeLists.txt
@@ -52,7 +52,8 @@ if (NOT DISABLE_EXECUTABLES)
INCLUDE_DIRS
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/src
PRIVATE ${LIBCONFIG_CPP_INCLUDE_DIRS}
- DEPENDS ${DEPENDENCIES}
+ PRIVATE ${THIRD_PARTY_INCLUDE_DIRS} ${COMMON_INCLUDE_DIRS}
+ DEPENDS ${DEPENDENCIES} ${THIRD_PARTY_DEPENDENCIES}
COMPONENT ${HICN_APPS}
LINK_FLAGS ${LINK_FLAGS}
COMPILE_OPTIONS ${COMPILER_OPTIONS}
diff --git a/apps/hiperf/src/common.h b/apps/hiperf/src/common.h
index 29cc05c71..3a17e0c40 100644
--- a/apps/hiperf/src/common.h
+++ b/apps/hiperf/src/common.h
@@ -30,6 +30,8 @@
#include <hicn/transport/utils/daemonizator.h>
#endif
+#include <hicn/apps/utils/logger.h>
+
#include <asio.hpp>
#include <cmath>
#include <fstream>
@@ -57,8 +59,6 @@ namespace hiperf {
/**
* Logger
*/
-static std::ostream &Logger() { return std::cout; }
-
template <typename D, typename ConfType, typename ParentType>
class Base : protected std::stringbuf, protected std::ostream {
protected:
@@ -103,7 +103,7 @@ class Base : protected std::stringbuf, protected std::ostream {
int sync() override {
auto string = str();
asio::post(io_service_,
- [this, string]() { Logger() << begin_ << string << end_; });
+ [this, string]() { LoggerInfo() << begin_ << string << end_; });
str("");
return 0;
@@ -140,7 +140,7 @@ static inline int ensureFlows(const Prefix &prefix, std::size_t flows) {
} else if (prefix.getAddressFamily() == AF_INET6) {
max_ip_addr_len_bits = IPV6_ADDR_LEN_BITS;
} else {
- Logger() << "Error: unknown address family." << std::endl;
+ LoggerErr() << "Error: unknown address family.";
ret = ERROR_SETUP;
goto end;
}
@@ -149,9 +149,9 @@ static inline int ensureFlows(const Prefix &prefix, std::size_t flows) {
max_n_flow = log2_n_flow < 64 ? (1 << log2_n_flow) : ~0ULL;
if (flows > max_n_flow) {
- Logger() << "Error: the provided prefix length does not allow to "
- "accomodate the provided number of flows ("
- << flows << " > " << max_n_flow << ")." << std::endl;
+ LoggerErr() << "Error: the provided prefix length does not allow to "
+ "accomodate the provided number of flows ("
+ << flows << " > " << max_n_flow << ").";
ret = ERROR_SETUP;
}
diff --git a/apps/hiperf/src/main.cc b/apps/hiperf/src/main.cc
index 74724209b..ac0f64d1d 100644
--- a/apps/hiperf/src/main.cc
+++ b/apps/hiperf/src/main.cc
@@ -14,186 +14,166 @@
*/
#include <client.h>
+#include <hicn/apps/utils/logger.h>
#include <server.h>
namespace hiperf {
void usage() {
- std::cerr << "HIPERF - Instrumentation tool for performing active network"
- "measurements with hICN"
- << std::endl;
- std::cerr << "usage: hiperf [-S|-C] [options] [prefix|name]" << std::endl;
- std::cerr << std::endl;
- std::cerr << "SERVER OR CLIENT:" << std::endl;
+ LoggerInfo() << "HIPERF - Instrumentation tool for performing active network"
+ "measurements with hICN";
+ LoggerInfo() << "usage: hiperf [-S|-C] [options] [prefix|name]";
+ LoggerInfo();
+ LoggerInfo() << "SERVER OR CLIENT:";
#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 << "-z\t<io_module>\t\t\t"
- << "IO module to use. Default: hicnlight_module" << std::endl;
- std::cerr << "-F\t<conf_file>\t\t\t"
- << "Path to optional configuration file for libtransport"
- << std::endl;
- std::cerr << "-a\t\t\t\t\t"
- << "Enables data packet aggregation. "
- << "Works only in RTC mode" << std::endl;
- std::cerr << "-X\t<param>\t\t\t\t"
- << "Set FEC params. Options are Rely_K#_N# or RS_K#_N#"
- << std::endl;
- std::cerr
+ LoggerInfo() << "-D\t\t\t\t\t"
+ << "Run as a daemon";
+ LoggerInfo() << "-R\t\t\t\t\t"
+ << "Run RTC protocol (client or server)";
+ LoggerInfo() << "-f\t<filename>\t\t\t"
+ << "Log file";
+ LoggerInfo() << "-z\t<io_module>\t\t\t"
+ << "IO module to use. Default: hicnlight_module";
+ LoggerInfo() << "-F\t<conf_file>\t\t\t"
+ << "Path to optional configuration file for libtransport";
+ LoggerInfo() << "-a\t\t\t\t\t"
+ << "Enables data packet aggregation. "
+ << "Works only in RTC mode";
+ LoggerInfo() << "-X\t<param>\t\t\t\t"
+ << "Set FEC params. Options are Rely_K#_N# or RS_K#_N#";
+ LoggerInfo()
<< "-J\t<passphrase>\t\t\t"
<< "Set the passphrase used to sign/verify aggregated interests. "
- "If set on the client, aggregated interests are enable automatically."
- << std::endl;
+ "If set on the client, aggregated interests are enable automatically.";
#endif
- std::cerr << std::endl;
- std::cerr << "SERVER SPECIFIC:" << std::endl;
- std::cerr << "-A\t<content_size>\t\t\t"
- "Sends an application data unit in bytes that is published once "
- "before exit"
- << std::endl;
- std::cerr << "-E\t<expiry_time>\t\t\t"
- "Expiration time for data packets generated by the producer "
- "socket"
- << std::endl;
- std::cerr << "-s\t<packet_size>\t\t\tData packet payload size." << std::endl;
- std::cerr << "-r\t\t\t\t\t"
- << "Produce real content of <content_size> bytes" << std::endl;
- std::cerr << "-m\t<manifest_max_capacity>\t\t"
- << "The maximum number of entries a manifest can contain. Set it "
- "to 0 to disable manifests. Default is 30, max is 255."
- << std::endl;
- std::cerr << "-l\t\t\t\t\t"
- << "Start producing content upon the reception of the "
- "first interest"
- << std::endl;
- std::cerr << "-K\t<keystore_path>\t\t\t"
- << "Path of p12 file containing the "
- "crypto material used for signing packets"
- << std::endl;
- std::cerr << "-k\t<passphrase>\t\t\t"
- << "String from which a 128-bit symmetric key will be "
- "derived for signing packets"
- << std::endl;
- std::cerr << "-p\t<password>\t\t\t"
- << "Password for p12 keystore" << std::endl;
- std::cerr << "-y\t<hash_algorithm>\t\t"
- << "Use the selected hash algorithm for "
- "computing manifest digests (default: SHA256)"
- << std::endl;
- std::cerr << "-x\t\t\t\t\t"
- << "Produces application data units of size <content_size> "
- << "without resetting the name suffix to 0." << std::endl;
- std::cerr << "-B\t<bitrate>\t\t\t"
- << "RTC producer data bitrate, to be used with the -R option."
- << std::endl;
+ LoggerInfo();
+ LoggerInfo() << "SERVER SPECIFIC:";
+ LoggerInfo()
+ << "-A\t<content_size>\t\t\t"
+ "Sends an application data unit in bytes that is published once "
+ "before exit";
+ LoggerInfo() << "-E\t<expiry_time>\t\t\t"
+ "Expiration time for data packets generated by the producer "
+ "socket";
+ LoggerInfo() << "-s\t<packet_size>\t\t\tData packet payload size.";
+ LoggerInfo() << "-r\t\t\t\t\t"
+ << "Produce real content of <content_size> bytes";
+ LoggerInfo()
+ << "-m\t<manifest_max_capacity>\t\t"
+ << "The maximum number of entries a manifest can contain. Set it "
+ "to 0 to disable manifests. Default is 30, max is 255.";
+ LoggerInfo() << "-l\t\t\t\t\t"
+ << "Start producing content upon the reception of the "
+ "first interest";
+ LoggerInfo() << "-K\t<keystore_path>\t\t\t"
+ << "Path of p12 file containing the "
+ "crypto material used for signing packets";
+ LoggerInfo() << "-k\t<passphrase>\t\t\t"
+ << "String from which a 128-bit symmetric key will be "
+ "derived for signing packets";
+ LoggerInfo() << "-p\t<password>\t\t\t"
+ << "Password for p12 keystore";
+ LoggerInfo() << "-y\t<hash_algorithm>\t\t"
+ << "Use the selected hash algorithm for "
+ "computing manifest digests (default: SHA256)";
+ LoggerInfo() << "-x\t\t\t\t\t"
+ << "Produces application data units of size <content_size> "
+ << "without resetting the name suffix to 0.";
+ LoggerInfo() << "-B\t<bitrate>\t\t\t"
+ << "RTC producer data bitrate, to be used with the -R option.";
#ifndef _WIN32
- std::cerr << "-I\t\t\t\t\t"
- "Interactive mode, start/stop real time content production "
- "by pressing return. To be used with the -R option"
- << std::endl;
- std::cerr
+ LoggerInfo() << "-I\t\t\t\t\t"
+ "Interactive mode, start/stop real time content production "
+ "by pressing return. To be used with the -R option";
+ LoggerInfo()
<< "-T\t<filename>\t\t\t"
"Trace based mode, hiperf takes as input a file with a trace. "
"Each line of the file indicates the timestamp and the size of "
"the packet to generate. To be used with the -R option. -B and -I "
- "will be ignored."
- << std::endl;
- std::cerr << "-G\t<port>\t\t\t\t"
- << "Input stream from localhost at the specified port" << std::endl;
+ "will be ignored.";
+ LoggerInfo() << "-G\t<port>\t\t\t\t"
+ << "Input stream from localhost at the specified port";
#endif
- 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::endl;
- std::cerr << "-L\t<interest lifetime>\t\t"
- << "Set interest lifetime." << std::endl;
- std::cerr << "-U\t<factor>\t\t\t"
- << "Update the relevance threshold: if an unverified packet has "
- "been received before the last U * manifest_max_capacity_ "
- "packets received (verified or not), it will be flushed out. "
- "Should be > 1, default is 100."
- << std::endl;
- std::cerr << "-u\t<factor>\t\t\t"
- << "Update the alert threshold: if the "
- "number of unverified packet is > u * manifest_max_capacity_, "
- "an alert is raised. Should be set such that U > u >= 1, "
- "default is 20. If u >= U, no alert will ever be raised."
- << std::endl;
- std::cerr << "-M\t<input_buffer_size>\t\t"
- << "Size of consumer input buffer. If 0, reassembly of packets "
- "will be disabled."
- << std::endl;
- std::cerr << "-N\t\t\t\t\t"
- << "Enable aggregated interests; the number of suffixes (including "
- "the one in the header) can be set through the env variable "
- "`MAX_AGGREGATED_INTERESTS`."
- << std::endl;
- std::cerr << "-W\t<window_size>\t\t\t"
- << "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::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::endl;
- std::cerr << "-k\t<passphrase>\t\t\t"
- << "String from which is derived the symmetric key used by the "
- "producer to sign packets and by the consumer to verify them."
- << std::endl;
- std::cerr << "-t\t\t\t\t\t"
- "Test mode, check if the client is receiving the "
- "correct data. This is an RTC specific option, to be "
- "used with the -R (default: false)"
- << std::endl;
- std::cerr << "-P\t\t\t\t\t"
- << "Number of parallel streams. For hiperf client, this is the "
- "number of consumer to create, while for hiperf server this is "
- "the number of producers to create."
- << std::endl;
- std::cerr << "-j\t<relay_name>\t\t\t"
- << "Publish received content under the name relay_name."
- "This is an RTC specific option, to be "
- "used with the -R (default: false)"
- << std::endl;
- std::cerr << "-g\t<port>\t\t\t\t"
- << "Output stream to localhost at the specified port" << std::endl;
- std::cerr << "-o\t\t\t\t\t"
- << "Content sharing mode: if set the socket work in content sharing"
- << "mode. It works only in RTC mode" << std::endl;
- std::cerr << "-e\t<strategy>\t\t\t"
- << "Enhance the network with a reliability strategy. Options"
- << std::endl;
- std::cerr << "\t\t\t\t\t\t1: unreliable " << std::endl;
- std::cerr << "\t\t\t\t\t\t2: rtx only " << std::endl;
- std::cerr << "\t\t\t\t\t\t3: fec only " << std::endl;
- std::cerr << "\t\t\t\t\t\t4: delay based " << std::endl;
- std::cerr << "\t\t\t\t\t\t5: low rate " << std::endl;
- std::cerr << "\t\t\t\t\t\t6: low rate and best path " << std::endl;
- std::cerr << "\t\t\t\t\t\t7: low rate and replication" << std::endl;
- std::cerr << "\t\t\t\t\t\t8: low rate and best path/replication "
- << std::endl;
- std::cerr << "\t\t\t\t\t\t9: only fec low residual losses " << std::endl;
- std::cerr << "\t\t\t\t\t\t10: delay and best path " << std::endl;
- std::cerr << "\t\t\t\t\t\t11: delay and replication " << std::endl;
- std::cerr << "\t\t\t\t\t\t(default: 2 = rtx only) " << std::endl;
- std::cerr << "-H\t\t\t\t\t"
- << "Disable periodic print headers in stats report." << std::endl;
- std::cerr << "-n\t<nb_iterations>\t\t\t"
- << "Print the stats report <nb_iterations> times and exit.\n"
- << "\t\t\t\t\tThis option limits the duration of the run to "
- "<nb_iterations> * <stats_interval> milliseconds."
- << std::endl;
+ LoggerInfo();
+ LoggerInfo() << "CLIENT SPECIFIC:";
+ LoggerInfo() << "-b\t<beta_parameter>\t\t"
+ << "RAAQM beta parameter";
+ LoggerInfo() << "-d\t<drop_factor_parameter>\t\t"
+ << "RAAQM drop factor "
+ "parameter";
+ LoggerInfo() << "-L\t<interest lifetime>\t\t"
+ << "Set interest lifetime.";
+ LoggerInfo() << "-U\t<factor>\t\t\t"
+ << "Update the relevance threshold: if an unverified packet has "
+ "been received before the last U * manifest_max_capacity_ "
+ "packets received (verified or not), it will be flushed out. "
+ "Should be > 1, default is 100.";
+ LoggerInfo()
+ << "-u\t<factor>\t\t\t"
+ << "Update the alert threshold: if the "
+ "number of unverified packet is > u * manifest_max_capacity_, "
+ "an alert is raised. Should be set such that U > u >= 1, "
+ "default is 20. If u >= U, no alert will ever be raised.";
+ LoggerInfo() << "-M\t<input_buffer_size>\t\t"
+ << "Size of consumer input buffer. If 0, reassembly of packets "
+ "will be disabled.";
+ LoggerInfo()
+ << "-N\t\t\t\t\t"
+ << "Enable aggregated interests; the number of suffixes (including "
+ "the one in the header) can be set through the env variable "
+ "`MAX_AGGREGATED_INTERESTS`.";
+ LoggerInfo() << "-W\t<window_size>\t\t\t"
+ << "Use a fixed congestion window "
+ "for retrieving the data.";
+ LoggerInfo() << "-i\t<stats_interval>\t\t"
+ << "Show the statistics every <stats_interval> milliseconds.";
+ LoggerInfo()
+ << "-c\t<certificate_path>\t\t"
+ << "Path of the producer certificate to be used for verifying the "
+ "origin of the packets received.";
+ LoggerInfo()
+ << "-k\t<passphrase>\t\t\t"
+ << "String from which is derived the symmetric key used by the "
+ "producer to sign packets and by the consumer to verify them.";
+ LoggerInfo() << "-t\t\t\t\t\t"
+ "Test mode, check if the client is receiving the "
+ "correct data. This is an RTC specific option, to be "
+ "used with the -R (default: false)";
+ LoggerInfo()
+ << "-P\t\t\t\t\t"
+ << "Number of parallel streams. For hiperf client, this is the "
+ "number of consumer to create, while for hiperf server this is "
+ "the number of producers to create.";
+ LoggerInfo() << "-j\t<relay_name>\t\t\t"
+ << "Publish received content under the name relay_name."
+ "This is an RTC specific option, to be "
+ "used with the -R (default: false)";
+ LoggerInfo() << "-g\t<port>\t\t\t\t"
+ << "Output stream to localhost at the specified port";
+ LoggerInfo()
+ << "-o\t\t\t\t\t"
+ << "Content sharing mode: if set the socket work in content sharing"
+ << "mode. It works only in RTC mode";
+ LoggerInfo() << "-e\t<strategy>\t\t\t"
+ << "Enhance the network with a reliability strategy. Options";
+ LoggerInfo() << "\t\t\t\t\t\t1: unreliable ";
+ LoggerInfo() << "\t\t\t\t\t\t2: rtx only ";
+ LoggerInfo() << "\t\t\t\t\t\t3: fec only ";
+ LoggerInfo() << "\t\t\t\t\t\t4: delay based ";
+ LoggerInfo() << "\t\t\t\t\t\t5: low rate ";
+ LoggerInfo() << "\t\t\t\t\t\t6: low rate and best path ";
+ LoggerInfo() << "\t\t\t\t\t\t7: low rate and replication";
+ LoggerInfo() << "\t\t\t\t\t\t8: low rate and best path/replication ";
+ LoggerInfo() << "\t\t\t\t\t\t9: only fec low residual losses ";
+ LoggerInfo() << "\t\t\t\t\t\t10: delay and best path ";
+ LoggerInfo() << "\t\t\t\t\t\t11: delay and replication ";
+ LoggerInfo() << "\t\t\t\t\t\t(default: 2 = rtx only) ";
+ LoggerInfo() << "-H\t\t\t\t\t"
+ << "Disable periodic print headers in stats report.";
+ LoggerInfo() << "-n\t<nb_iterations>\t\t\t"
+ << "Print the stats report <nb_iterations> times and exit.\n"
+ << "\t\t\t\t\tThis option limits the duration of the run to "
+ "<nb_iterations> * <stats_interval> milliseconds.";
}
int main(int argc, char *argv[]) {
@@ -447,7 +427,7 @@ int main(int argc, char *argv[]) {
} else if (strncasecmp(optarg, "blake2s256", 10) == 0) {
hash_algorithm = CryptoHashType::BLAKE2S256;
} else {
- std::cerr << "Unknown hash algorithm. Using SHA 256." << std::endl;
+ LoggerWarn() << "Unknown hash algorithm. Using SHA 256.";
}
server_configuration.hash_algorithm_ = hash_algorithm;
options = -1;
@@ -488,27 +468,24 @@ int main(int argc, char *argv[]) {
}
if (options > 0 && role < 0) {
- std::cerr << "Client options cannot be used when using the "
- "software in server mode"
- << std::endl;
+ LoggerErr() << "Client options cannot be used when using the "
+ "software in server mode";
usage();
return EXIT_FAILURE;
} else if (options < 0 && role > 0) {
- std::cerr << "Server options cannot be used when using the "
- "software in client mode"
- << std::endl;
+ LoggerErr() << "Server options cannot be used when using the "
+ "software in client mode";
usage();
return EXIT_FAILURE;
} else if (!role) {
- std::cerr << "Please specify if running hiperf as client "
- "or server."
- << std::endl;
+ LoggerErr() << "Please specify if running hiperf as client "
+ "or server.";
usage();
return EXIT_FAILURE;
}
if (argv[optind] == 0) {
- std::cerr << "Please specify the name/prefix to use." << std::endl;
+ LoggerErr() << "Please specify the name/prefix to use.";
usage();
return EXIT_FAILURE;
} else {
diff --git a/apps/hiperf/src/server.cc b/apps/hiperf/src/server.cc
index afaf5423b..ee236f358 100644
--- a/apps/hiperf/src/server.cc
+++ b/apps/hiperf/src/server.cc
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2021 Cisco and/or its affiliates.
+ * Copyright (c) 2021-2022 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:
@@ -297,10 +297,10 @@ class HIperfServer::Impl {
!configuration_.multiphase_produce_, suffix);
utils::SteadyTime::TimePoint t1 = utils::SteadyTime::Clock::now();
- Logger() << "Written " << total
- << " data packets in output buffer (Segmentation time: "
- << utils::SteadyTime::getDurationUs(t0, t1).count() << " us)"
- << std::endl;
+ LoggerInfo() << "Written " << total
+ << " data packets in output buffer (Segmentation time: "
+ << utils::SteadyTime::getDurationUs(t0, t1).count() << " us)"
+ << std::endl;
}
/**
@@ -313,8 +313,8 @@ class HIperfServer::Impl {
configuration_.content_lifetime_);
produceContent(p, interest.getName(), interest.getName().getSuffix());
- Logger() << "Received interest " << interest.getName().getSuffix()
- << std::endl;
+ LoggerInfo() << "Received interest " << interest.getName().getSuffix()
+ << std::endl;
}
/**
@@ -552,11 +552,11 @@ class HIperfServer::Impl {
}
if (rtc_running_) {
- Logger() << "stop real time content production" << std::endl;
+ LoggerInfo() << "stop real time content production" << std::endl;
rtc_running_ = false;
rtc_timer_.cancel();
} else {
- Logger() << "start real time content production" << std::endl;
+ LoggerInfo() << "start real time content production" << std::endl;
rtc_running_ = true;
rtc_timer_.expires_from_now(
config_.production_rate_.getMicrosecondsForPacket(
@@ -593,13 +593,13 @@ class HIperfServer::Impl {
std::bind(&Impl::handleInput, this, std::placeholders::_1,
std::placeholders::_2));
} else if (config_.trace_based_) {
- Logger() << "trace-based mode enabled" << std::endl;
+ LoggerInfo() << "trace-based mode enabled" << std::endl;
if (config_.trace_file_ == nullptr) {
- Logger() << "cannot find the trace file" << std::endl;
+ LoggerErr() << "cannot find the trace file" << std::endl;
return ERROR_SETUP;
}
if (parseTraceFile() < 0) {
- Logger() << "cannot parse the trace file" << std::endl;
+ LoggerErr() << "cannot parse the trace file" << std::endl;
return ERROR_SETUP;
}
rtc_running_ = true;