diff options
Diffstat (limited to 'utils/src/ping_client.cc')
-rw-r--r-- | utils/src/ping_client.cc | 198 |
1 files changed, 104 insertions, 94 deletions
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); |