From: Marcin Siodelski Date: Thu, 13 Sep 2012 10:37:50 +0000 (+0200) Subject: [1960] Command options code cleanup, fixed lines wraps and comments. X-Git-Tag: trac2351_base~40^2~21 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=a897e5cf38d32a41107f537bc8dace96813b06d8;p=thirdparty%2Fkea.git [1960] Command options code cleanup, fixed lines wraps and comments. --- diff --git a/tests/tools/perfdhcp/command_options.cc b/tests/tools/perfdhcp/command_options.cc index 24e7e790dc..d025c3c19e 100644 --- a/tests/tools/perfdhcp/command_options.cc +++ b/tests/tools/perfdhcp/command_options.cc @@ -18,13 +18,10 @@ #include #include -#include -#include #include #include #include -#include #include #include "command_options.h" @@ -129,7 +126,8 @@ CommandOptions::initialize(int argc, char** argv) { size_t percent_loc = 0; // Location of % sign in -D double drop_percent = 0; // % value (1..100) in -D int num_drops = 0; // Max number of drops specified in -D - int num_req = 0; // Max number of dropped requests in -n + int num_req = 0; // Max number of dropped + // requests in -n int offset_arg = 0; // Temporary variable holding offset arguments std::string sarg; // Temporary variable for string args @@ -138,7 +136,8 @@ CommandOptions::initialize(int argc, char** argv) { // In this section we collect argument values from command line // they will be tuned and validated elsewhere - while((opt = getopt(argc, argv, "hv46r:t:R:b:n:p:d:D:l:P:a:L:s:iBc1T:X:O:E:S:I:x:w:")) != -1) { + while((opt = getopt(argc, argv, "hv46r:t:R:b:n:p:d:D:l:P:a:L:" + "s:iBc1T:X:O:E:S:I:x:w:")) != -1) { stream << " -" << opt; if (optarg) { stream << " " << optarg; @@ -163,11 +162,13 @@ CommandOptions::initialize(int argc, char** argv) { break; case 'a': - aggressivity_ = positiveInteger("value of aggressivity: -a must be a positive integer"); + aggressivity_ = positiveInteger("value of aggressivity: -a" + " must be a positive integer"); break; case 'b': - check(base_.size() > 3, "-b already specified, unexpected occurence of 5th -b"); + check(base_.size() > 3, "-b already specified," + " unexpected occurence of 5th -b"); base_.push_back(optarg); decodeBase(base_.back()); break; @@ -181,41 +182,50 @@ CommandOptions::initialize(int argc, char** argv) { break; case 'd': - check(drop_time_set_ > 1, "maximum number of drops already specified, " + check(drop_time_set_ > 1, + "maximum number of drops already specified, " "unexpected 3rd occurence of -d"); try { - drop_time_[drop_time_set_] = boost::lexical_cast(optarg); + drop_time_[drop_time_set_] = + boost::lexical_cast(optarg); } catch (boost::bad_lexical_cast&) { isc_throw(isc::InvalidParameter, - "value of drop time: -d must be positive number"); + "value of drop time: -d" + " must be positive number"); } - check(drop_time_[drop_time_set_] <= 0., "drop-time must be a positive number"); + check(drop_time_[drop_time_set_] <= 0., + "drop-time must be a positive number"); drop_time_set_ = true; break; case 'D': drop_arg = std::string(optarg); percent_loc = drop_arg.find('%'); - check(max_pdrop_.size() > 1 || max_drop_.size() > 1, "values of maximum drops: -D already " + check(max_pdrop_.size() > 1 || max_drop_.size() > 1, + "values of maximum drops: -D already " "specified, unexpected 3rd occurence of -D,value>"); if ((percent_loc) != std::string::npos) { try { - drop_percent = boost::lexical_cast(drop_arg.substr(0, percent_loc)); + drop_percent = + boost::lexical_cast(drop_arg.substr(0, percent_loc)); } catch (boost::bad_lexical_cast&) { isc_throw(isc::InvalidParameter, - "value of drop percentage: -D must be 0..100"); + "value of drop percentage: -D" + " must be 0..100"); } check((drop_percent <= 0) || (drop_percent >= 100), "value of drop percentage: -D must be 0..100"); max_pdrop_.push_back(drop_percent); } else { - num_drops = positiveInteger("value of max drops number: -d must be a positive integer"); + num_drops = positiveInteger("value of max drops number:" + " -d must be a positive integer"); max_drop_.push_back(num_drops); } break; case 'E': - elp_offset_ = nonNegativeInteger("value of time-offset: -E must not be a negative integer"); + elp_offset_ = nonNegativeInteger("value of time-offset: -E" + " must not be a negative integer"); break; case 'h': @@ -227,7 +237,9 @@ CommandOptions::initialize(int argc, char** argv) { break; case 'I': - rip_offset_ = positiveInteger("value of ip address offset: -I must be a positive integer"); + rip_offset_ = positiveInteger("value of ip address offset:" + " -I must be a" + " positive integer"); break; case 'l': @@ -236,43 +248,55 @@ CommandOptions::initialize(int argc, char** argv) { break; case 'L': - local_port_ = nonNegativeInteger("value of local port: -L must not be a negative integer"); - check(local_port_ > static_cast(std::numeric_limits::max()), + local_port_ = nonNegativeInteger("value of local port:" + " -L must not be a" + " negative integer"); + check(local_port_ > + static_cast(std::numeric_limits::max()), "local-port must be lower than " + boost::lexical_cast(std::numeric_limits::max())); break; case 'n': - num_req = positiveInteger("value of num-request: -n must be a positive integer"); + num_req = positiveInteger("value of num-request:" + " -n must be a positive integer"); if (num_request_.size() >= 2) { - isc_throw(isc::InvalidParameter,"value of maximum number of requests: -n " - "already specified, unexpected 3rd occurence of -n"); + isc_throw(isc::InvalidParameter, + "value of maximum number of requests: -n " + "already specified, unexpected 3rd occurence" + " of -n"); } num_request_.push_back(num_req); break; case 'O': if (rnd_offset_.size() < 2) { - offset_arg = positiveInteger("value of random offset: -O must be greater than 3"); + offset_arg = positiveInteger("value of random offset: " + "-O must be greater than 3"); } else { isc_throw(isc::InvalidParameter, - "random offsets already specified, unexpected 3rd occurence of -O"); + "random offsets already specified," + " unexpected 3rd occurence of -O"); } - check(offset_arg < 3, "value of random random-offset: -O must be greater than 3 "); + check(offset_arg < 3, "value of random random-offset:" + " -O must be greater than 3 "); rnd_offset_.push_back(offset_arg); break; case 'p': - period_ = positiveInteger("value of test period: -p must be a positive integer"); + period_ = positiveInteger("value of test period:" + " -p must be a positive integer"); break; case 'P': - preload_ = nonNegativeInteger("number of preload packets: -P must not be " + preload_ = nonNegativeInteger("number of preload packets:" + " -P must not be " "a negative integer"); break; case 'r': - rate_ = positiveInteger("value of rate: -r must be a positive integer"); + rate_ = positiveInteger("value of rate:" + " -r must be a positive integer"); break; case 'R': @@ -281,42 +305,54 @@ CommandOptions::initialize(int argc, char** argv) { case 's': seed_ = static_cast - (nonNegativeInteger("value of seed: -s must be non-negative integer")); + (nonNegativeInteger("value of seed:" + " -s must be non-negative integer")); seeded_ = seed_ > 0 ? true : false; break; case 'S': - sid_offset_ = positiveInteger("value of server id offset: -S must be a positive integer"); + sid_offset_ = positiveInteger("value of server id offset:" + " -S must be a" + " positive integer"); break; case 't': - report_delay_ = positiveInteger("value of report delay: -t must be a positive integer"); + report_delay_ = positiveInteger("value of report delay:" + " -t must be a" + " positive integer"); break; case 'T': if (template_file_.size() < 2) { - sarg = nonEmptyString("template file name not specified, expected -T"); + sarg = nonEmptyString("template file name not specified," + " expected -T"); template_file_.push_back(sarg); } else { isc_throw(isc::InvalidParameter, - "template files are already specified, unexpected 3rd -T occurence"); + "template files are already specified," + " unexpected 3rd -T occurence"); } break; case 'w': - wrapped_ = nonEmptyString("command for wrapped mode: -w must be specified"); + wrapped_ = nonEmptyString("command for wrapped mode:" + " -w must be specified"); break; case 'x': - diags_ = nonEmptyString("value of diagnostics selectors: -x must be specified"); + diags_ = nonEmptyString("value of diagnostics selectors:" + " -x must be specified"); break; case 'X': if (xid_offset_.size() < 2) { - offset_arg = positiveInteger("value of transaction id: -X must be a positive integer"); + offset_arg = positiveInteger("value of transaction id:" + " -X must be a" + " positive integer"); } else { isc_throw(isc::InvalidParameter, - "transaction ids already specified, unexpected 3rd -X occurence"); + "transaction ids already specified," + " unexpected 3rd -X occurence"); } xid_offset_.push_back(offset_arg); break; @@ -362,7 +398,8 @@ CommandOptions::initialize(int argc, char** argv) { server_name_ = "255.255.255.255"; } else if ((ipversion_ == 6) && (server_name_.compare("all") == 0)) { server_name_ = "FF02::1:2"; - } else if ((ipversion_ == 6) && (server_name_.compare("servers") == 0)) { + } else if ((ipversion_ == 6) && + (server_name_.compare("servers") == 0)) { server_name_ = "FF05::1:3"; } } @@ -392,7 +429,8 @@ CommandOptions::initialize(int argc, char** argv) { void CommandOptions::initClientsNum() { - const std::string errmsg = "value of -R must be non-negative integer"; + const std::string errmsg = + "value of -R must be non-negative integer"; // Declare clients_num as as 64-bit signed value to // be able to detect negative values provided @@ -435,7 +473,8 @@ CommandOptions::decodeBase(const std::string& base) { decodeDuid(b); } else { isc_throw(isc::InvalidParameter, - "base value not provided as -b, expected -b mac= or -b duid="); + "base value not provided as -b," + " expected -b mac= or -b duid="); } } @@ -443,7 +482,8 @@ void CommandOptions::decodeMac(const std::string& base) { // Strip string from mac= size_t found = base.find('='); - static const char* errmsg = "expected -b format for mac address is -b mac=00::0C::01::02::03::04"; + static const char* errmsg = "expected -b format for" + " mac address is -b mac=00::0C::01::02::03::04"; check(found == std::string::npos, errmsg); // Decode mac address to vector of uint8_t @@ -476,7 +516,8 @@ CommandOptions::decodeDuid(const std::string& base) { // Strip argument from duid= std::vector duid_template; size_t found = base.find('='); - check(found == std::string::npos, "expected -b format for duid is -b duid="); + check(found == std::string::npos, "expected -b" + " format for duid is -b duid="); std::string b = base.substr(found + 1); // DUID must have even number of digits and must not be longer than 64 bytes @@ -492,7 +533,8 @@ CommandOptions::decodeDuid(const std::string& base) { ui = convertHexString(b.substr(i, 2)); } catch (isc::InvalidParameter&) { isc_throw(isc::InvalidParameter, - "invalid characters in DUID provided, exepected hex digits"); + "invalid characters in DUID provided," + " exepected hex digits"); } duid_template.push_back(static_cast(ui)); } @@ -518,7 +560,7 @@ CommandOptions::generateDuidTemplate() { duid_template_[1] = DUID_LLT & 0xff; duid_template_[2] = HWTYPE_ETHERNET >> 8; duid_template_[3] = HWTYPE_ETHERNET & 0xff; - + // As described in RFC3315: 'the time value is the time // that the DUID is generated represented in seconds // since midnight (UTC), January 1, 2000, modulo 2^32.' @@ -550,7 +592,8 @@ CommandOptions::convertHexString(const std::string& text) const { text_stream >> std::hex >> ui >> std::dec; // Check if for some reason we have overflow - this should never happen! if (ui > 0xFF) { - isc_throw(isc::InvalidParameter, "Can't convert more than two hex digits to byte"); + isc_throw(isc::InvalidParameter, "Can't convert more than" + " two hex digits to byte"); } return ui; } @@ -582,29 +625,29 @@ CommandOptions::validate() const { "-S is not compatible with -i\n"); check((getExchangeMode() == DO_SA) && (getRequestedIpOffset() >= 0), "-I is not compatible with -i\n"); - check((getExchangeMode() != DO_SA) && (isRapidCommit() != 0), + check((getExchangeMode() != DO_SA) && (isRapidCommit() != 0), "-i must be set to use -c\n"); - check((getRate() == 0) && (getReportDelay() != 0), + check((getRate() == 0) && (getReportDelay() != 0), "-r must be set to use -t\n"); - check((getRate() == 0) && (getNumRequests().size() > 0), + check((getRate() == 0) && (getNumRequests().size() > 0), "-r must be set to use -n\n"); - check((getRate() == 0) && (getPeriod() != 0), + check((getRate() == 0) && (getPeriod() != 0), "-r must be set to use -p\n"); - check((getRate() == 0) && + check((getRate() == 0) && ((getMaxDrop().size() > 0) || getMaxDropPercentage().size() > 0), "-r must be set to use -D\n"); - check((getTemplateFiles().size() < getTransactionIdOffset().size()), + check((getTemplateFiles().size() < getTransactionIdOffset().size()), "-T must be set to use -X\n"); - check((getTemplateFiles().size() < getRandomOffset().size()), + check((getTemplateFiles().size() < getRandomOffset().size()), "-T must be set to use -O\n"); - check((getTemplateFiles().size() < 2) && (getElapsedTimeOffset() >= 0), + check((getTemplateFiles().size() < 2) && (getElapsedTimeOffset() >= 0), "second/request -T must be set to use -E\n"); - check((getTemplateFiles().size() < 2) && (getServerIdOffset() >= 0), + check((getTemplateFiles().size() < 2) && (getServerIdOffset() >= 0), "second/request -T must be set to " "use -S\n"); - check((getTemplateFiles().size() < 2) && (getRequestedIpOffset() >= 0), - "second/request -T must be set to " - "use -I\n"); + check((getTemplateFiles().size() < 2) && (getRequestedIpOffset() >= 0), + "second/request -T must be set to " + "use -I\n"); } @@ -657,7 +700,7 @@ CommandOptions::printCommandLine() const { } else { std::cout << "SOLICIT-ADVERETISE only" << std::endl; } - } + } if (rate_ != 0) { std::cout << "rate[1/s]=" << rate_ << std::endl; } @@ -666,7 +709,7 @@ CommandOptions::printCommandLine() const { } if (clients_num_ != 0) { std::cout << "clients=" << clients_num_ << std::endl; - } + } for (int i = 0; i < base_.size(); ++i) { std::cout << "base[" << i << "]=" << base_[i] << std::endl; } @@ -742,127 +785,127 @@ CommandOptions::printCommandLine() const { void CommandOptions::usage() const { - fprintf(stdout, "%s", -"perfdhcp [-hv] [-4|-6] [-r] [-t] [-R] [-b]\n" -" [-n] [-p] [-d] [-D]\n" -" [-l] [-P] [-a]\n" -" [-L] [-s] [-i] [-B] [-c] [-1]\n" -" [-T] [-X] [-O] [-S] [-I]\n" -" [-x] [-w] [server]\n" -"\n" -"The [server] argument is the name/address of the DHCP server to\n" -"contact. For DHCPv4 operation, exchanges are initiated by\n" -"transmitting a DHCP DISCOVER to this address.\n" -"\n" -"For DHCPv6 operation, exchanges are initiated by transmitting a DHCP\n" -"SOLICIT to this address. In the DHCPv6 case, the special name 'all'\n" -"can be used to refer to All_DHCP_Relay_Agents_and_Servers (the\n" -"multicast address FF02::1:2), or the special name 'servers' to refer\n" -"to All_DHCP_Servers (the multicast address FF05::1:3). The [server]\n" -"argument is optional only in the case that -l is used to specify an\n" -"interface, in which case [server] defaults to 'all'.\n" -"\n" -"The default is to perform a single 4-way exchange, effectively pinging\n" -"the server.\n" -"The -r option is used to set up a performance test, without\n" -"it exchanges are initiated as fast as possible.\n" -"\n" -"Options:\n" -"-1: Take the server-ID option from the first received message.\n" -"-4: DHCPv4 operation (default). This is incompatible with the -6 option.\n" -"-6: DHCPv6 operation. This is incompatible with the -4 option.\n" -"-a: When the target sending rate is not yet reached,\n" -" control how many exchanges are initiated before the next pause.\n" -"-b: The base mac, duid, IP, etc, used to simulate different\n" -" clients. This can be specified multiple times, each instance is\n" -" in the = form, for instance:\n" -" (and default) mac=00:0c:01:02:03:04.\n" -"-d: Specify the time after which a request is treated as\n" -" having been lost. The value is given in seconds and may contain a\n" -" fractional component. The default is 1 second.\n" -"-E: Offset of the (DHCPv4) secs field / (DHCPv6)\n" -" elapsed-time option in the (second/request) template.\n" -" The value 0 disables it.\n" -"-h: Print this help.\n" -"-i: Do only the initial part of an exchange: DO or SA, depending on\n" -" whether -6 is given.\n" -"-I: Offset of the (DHCPv4) IP address in the requested-IP\n" -" option / (DHCPv6) IA_NA option in the (second/request) template.\n" -"-l: For DHCPv4 operation, specify the local\n" -" hostname/address to use when communicating with the server. By\n" -" default, the interface address through which traffic would\n" -" normally be routed to the server is used.\n" -" For DHCPv6 operation, specify the name of the network interface\n" -" via which exchanges are initiated.\n" -"-L: Specify the local port to use\n" -" (the value 0 means to use the default).\n" -"-O: Offset of the last octet to randomize in the template.\n" -"-P: Initiate first exchanges back to back at startup.\n" -"-r: Initiate DORA/SARR (or if -i is given, DO/SA)\n" -" exchanges per second. A periodic report is generated showing the\n" -" number of exchanges which were not completed, as well as the\n" -" average response latency. The program continues until\n" -" interrupted, at which point a final report is generated.\n" -"-R: Specify how many different clients are used. With 1\n" -" (the default), all requests seem to come from the same client.\n" -"-s: Specify the seed for randomization, making it repeatable.\n" -"-S: Offset of the server-ID option in the\n" -" (second/request) template.\n" -"-T: The name of a file containing the template to use\n" -" as a stream of hexadecimal digits.\n" -"-v: Report the version number of this program.\n" -"-w: Command to call with start/stop at the beginning/end of\n" -" the program.\n" -"-x: Include extended diagnostics in the output.\n" -" is a string of single-keywords specifying\n" -" the operations for which verbose output is desired. The selector\n" -" keyletters are:\n" -" * 'a': print the decoded command line arguments\n" -" * 'e': print the exit reason\n" -" * 'i': print rate processing details\n" -" * 'r': print randomization details\n" -" * 's': print first server-id\n" -" * 't': when finished, print timers of all successful exchanges\n" -" * 'T': when finished, print templates\n" -"-X: Transaction ID (aka. xid) offset in the template.\n" -"\n" -"DHCPv4 only options:\n" -"-B: Force broadcast handling.\n" -"\n" -"DHCPv6 only options:\n" -"-c: Add a rapid commit option (exchanges will be SA).\n" -"\n" -"The remaining options are used only in conjunction with -r:\n" -"\n" -"-D: Abort the test if more than requests have\n" -" been dropped. Use -D0 to abort if even a single request has been\n" -" dropped. If includes the suffix '%', it specifies a\n" -" maximum percentage of requests that may be dropped before abort.\n" -" In this case, testing of the threshold begins after 10 requests\n" -" have been expected to be received.\n" -"-n: Initiate transactions. No report is\n" -" generated until all transactions have been initiated/waited-for,\n" -" after which a report is generated and the program terminates.\n" -"-p: Send requests for the given test period, which is\n" -" specified in the same manner as -d. This can be used as an\n" -" alternative to -n, or both options can be given, in which case the\n" -" testing is completed when either limit is reached.\n" -"-t: Delay in seconds between two periodic reports.\n" -"\n" -"Errors:\n" -"- tooshort: received a too short message\n" -"- orphans: received a message which doesn't match an exchange\n" -" (duplicate, late or not related)\n" -"- locallimit: reached to local system limits when sending a message.\n" -"\n" -"Exit status:\n" -"The exit status is:\n" -"0 on complete success.\n" -"1 for a general error.\n" -"2 if an error is found in the command line arguments.\n" -"3 if there are no general failures in operation, but one or more\n" -" exchanges are not successfully completed.\n"); + std::cout << + "perfdhcp [-hv] [-4|-6] [-r] [-t] [-R] [-b]\n" + " [-n] [-p] [-d] [-D]\n" + " [-l] [-P] [-a]\n" + " [-L] [-s] [-i] [-B] [-c] [-1]\n" + " [-T] [-X] [-O] [-S] [-I]\n" + " [-x] [-w] [server]\n" + "\n" + "The [server] argument is the name/address of the DHCP server to\n" + "contact. For DHCPv4 operation, exchanges are initiated by\n" + "transmitting a DHCP DISCOVER to this address.\n" + "\n" + "For DHCPv6 operation, exchanges are initiated by transmitting a DHCP\n" + "SOLICIT to this address. In the DHCPv6 case, the special name 'all'\n" + "can be used to refer to All_DHCP_Relay_Agents_and_Servers (the\n" + "multicast address FF02::1:2), or the special name 'servers' to refer\n" + "to All_DHCP_Servers (the multicast address FF05::1:3). The [server]\n" + "argument is optional only in the case that -l is used to specify an\n" + "interface, in which case [server] defaults to 'all'.\n" + "\n" + "The default is to perform a single 4-way exchange, effectively pinging\n" + "the server.\n" + "The -r option is used to set up a performance test, without\n" + "it exchanges are initiated as fast as possible.\n" + "\n" + "Options:\n" + "-1: Take the server-ID option from the first received message.\n" + "-4: DHCPv4 operation (default). This is incompatible with the -6 option.\n" + "-6: DHCPv6 operation. This is incompatible with the -4 option.\n" + "-a: When the target sending rate is not yet reached,\n" + " control how many exchanges are initiated before the next pause.\n" + "-b: The base mac, duid, IP, etc, used to simulate different\n" + " clients. This can be specified multiple times, each instance is\n" + " in the = form, for instance:\n" + " (and default) mac=00:0c:01:02:03:04.\n" + "-d: Specify the time after which a requeqst is treated as\n" + " having been lost. The value is given in seconds and may contain a\n" + " fractional component. The default is 1 second.\n" + "-E: Offset of the (DHCPv4) secs field / (DHCPv6)\n" + " elapsed-time option in the (second/request) template.\n" + " The value 0 disables it.\n" + "-h: Print this help.\n" + "-i: Do only the initial part of an exchange: DO or SA, depending on\n" + " whether -6 is given.\n" + "-I: Offset of the (DHCPv4) IP address in the requested-IP\n" + " option / (DHCPv6) IA_NA option in the (second/request) template.\n" + "-l: For DHCPv4 operation, specify the local\n" + " hostname/address to use when communicating with the server. By\n" + " default, the interface address through which traffic would\n" + " normally be routed to the server is used.\n" + " For DHCPv6 operation, specify the name of the network interface\n" + " via which exchanges are initiated.\n" + "-L: Specify the local port to use\n" + " (the value 0 means to use the default).\n" + "-O: Offset of the last octet to randomize in the template.\n" + "-P: Initiate first exchanges back to back at startup.\n" + "-r: Initiate DORA/SARR (or if -i is given, DO/SA)\n" + " exchanges per second. A periodic report is generated showing the\n" + " number of exchanges which were not completed, as well as the\n" + " average response latency. The program continues until\n" + " interrupted, at which point a final report is generated.\n" + "-R: Specify how many different clients are used. With 1\n" + " (the default), all requests seem to come from the same client.\n" + "-s: Specify the seed for randomization, making it repeatable.\n" + "-S: Offset of the server-ID option in the\n" + " (second/request) template.\n" + "-T: The name of a file containing the template to use\n" + " as a stream of hexadecimal digits.\n" + "-v: Report the version number of this program.\n" + "-w: Command to call with start/stop at the beginning/end of\n" + " the program.\n" + "-x: Include extended diagnostics in the output.\n" + " is a string of single-keywords specifying\n" + " the operations for which verbose output is desired. The selector\n" + " keyletters are:\n" + " * 'a': print the decoded command line arguments\n" + " * 'e': print the exit reason\n" + " * 'i': print rate processing details\n" + " * 'r': print randomization details\n" + " * 's': print first server-id\n" + " * 't': when finished, print timers of all successful exchanges\n" + " * 'T': when finished, print templates\n" + "-X: Transaction ID (aka. xid) offset in the template.\n" + "\n" + "DHCPv4 only options:\n" + "-B: Force broadcast handling.\n" + "\n" + "DHCPv6 only options:\n" + "-c: Add a rapid commit option (exchanges will be SA).\n" + "\n" + "The remaining options are used only in conjunction with -r:\n" + "\n" + "-D: Abort the test if more than requests have\n" + " been dropped. Use -D0 to abort if even a single request has been\n" + " dropped. If includes the suffix '%', it specifies a\n" + " maximum percentage of requests that may be dropped before abort.\n" + " In this case, testing of the threshold begins after 10 requests\n" + " have been expected to be received.\n" + "-n: Initiate transactions. No report is\n" + " generated until all transactions have been initiated/waited-for,\n" + " after which a report is generated and the program terminates.\n" + "-p: Send requests for the given test period, which is\n" + " specified in the same manner as -d. This can be used as an\n" + " alternative to -n, or both options can be given, in which case the\n" + " testing is completed when either limit is reached.\n" + "-t: Delay in seconds between two periodic reports.\n" + "\n" + "Errors:\n" + "- tooshort: received a too short message\n" + "- orphans: received a message which doesn't match an exchange\n" + " (duplicate, late or not related)\n" + "- locallimit: reached to local system limits when sending a message.\n" + "\n" + "Exit status:\n" + "The exit status is:\n" + "0 on complete success.\n" + "1 for a general error.\n" + "2 if an error is found in the command line arguments.\n" + "3 if there are no general failures in operation, but one or more\n" + " exchanges are not successfully completed.\n"; } void diff --git a/tests/tools/perfdhcp/command_options.h b/tests/tools/perfdhcp/command_options.h index b9e2b9e70e..c1252a5e73 100644 --- a/tests/tools/perfdhcp/command_options.h +++ b/tests/tools/perfdhcp/command_options.h @@ -230,7 +230,7 @@ public: /// /// \return server name. std::string getServerName() const { return server_name_; } - + /// \brief Print command line arguments. void printCommandLine() const; @@ -349,7 +349,7 @@ private: /// \param base Base string given as -b duid=0F1234. /// \throws isc::InvalidParameter if DUID is invalid. void decodeDuid(const std::string& base); - + /// \brief Generates DUID-LLT (based on link layer address). /// /// Function generates DUID based on link layer address and @@ -364,65 +364,99 @@ private: /// \throw isc::InvalidParameter if string does not represent hex byte. uint8_t convertHexString(const std::string& hex_text) const; - uint8_t ipversion_; ///< IP protocol version to be used, expected values are: - ///< 4 for IPv4 and 6 for IPv6, default value 0 means "not set" - ExchangeMode exchange_mode_; ///< Packet exchange mode (e.g. DORA/SARR) - int rate_; ///< Rate in exchange per second - int report_delay_; ///< Delay between generation of two consecutive - ///< performance reports - uint32_t clients_num_; ///< Number of simulated clients (aka randomization range). - std::vector mac_template_; ///< MAC address template used to generate unique DUIDs - ///< for simulated clients. - std::vector duid_template_; ///< DUID template used to generate unique DUIDs for - ///< simulated clients - std::vector base_; ///< Collection of base values specified with -b - ///< options. Supported "bases" are mac= and duid= - std::vector num_request_; ///< Number of 2 or 4-way exchanges to perform - int period_; ///< Test period in seconds - uint8_t drop_time_set_; ///< Indicates number of -d parameters specified by user. - ///< If this value goes above 2, command line parsing fails. - std::vector drop_time_; ///< Time to elapse before request is lost. The fisrt value of - ///< two-element vector refers to DO/SA exchanges, - ///< second value refers to RA/RR. Default values are { 1, 1 } - std::vector max_drop_; ///< Maximum number of drops request before aborting test. - ///< First value of two-element vector specifies maximum - ///< number of drops for DO/SA exchange, second value - ///< specifies maximum number of drops for RA/RR. - std::vector max_pdrop_; ///< Maximal percentage of lost requests before aborting test. - ///< First value of two-element vector specifies percentage for - ///< DO/SA exchanges, second value for RA/RR. - std::string localname_; ///< Local address or interface specified with -l option. - bool is_interface_; ///< Indicates that specified value with -l is - ///< rather interface (not address) - int preload_; ///< Number of preload packets. Preload packets are used to - ///< initiate communication with server before doing performance - ///< measurements. - int aggressivity_; ///< Number of exchanges sent before next pause. - int local_port_; ///< Local port number (host endian) - bool seeded_; ///< Indicates that randomization seed was provided. - uint32_t seed_; ///< Randomization seed. - bool broadcast_; ///< Indicates that we use broadcast address. - bool rapid_commit_; ///< Indicates that we do rapid commit option. - bool use_first_; ///< Indicates that we take server id from first received packet. - std::vector template_file_; ///< Packet template file names. These files store template packets - ///< that are used for initiating echanges. Template packets - ///< read from files are later tuned with variable data. - std::vector xid_offset_; ///< Offset of transaction id in template files. First vector - ///< element points to offset for DISCOVER/SOLICIT messages, - ///< second element points to trasaction id offset for - ///< REQUEST messages - std::vector rnd_offset_; ///< Random value offset in templates. Random value offset - ///< points to last octet of DUID. Up to 4 last octets of - ///< DUID are randomized to simulate differnt clients. - int elp_offset_; ///< Offset of elapsed time option in template packet. - int sid_offset_; ///< Offset of server id option in template packet. - int rip_offset_; ///< Offset of requested ip data in template packet/ - std::string diags_; ///< String representing diagnostic selectors specified - ///< by user with -x. - std::string wrapped_; ///< Wrapped command specified as -w. Expected - ///< values are start and stop. - std::string server_name_; ///< Server name specified as last argument of command line. - std::string commandline_; ///< Entire command line as typed in by the user. + /// IP protocol version to be used, expected values are: + /// 4 for IPv4 and 6 for IPv6, default value 0 means "not set" + uint8_t ipversion_; + /// Packet exchange mode (e.g. DORA/SARR) + ExchangeMode exchange_mode_; + /// Rate in exchange per second + int rate_; + /// Delay between generation of two consecutive + /// performance reports + int report_delay_; + /// Number of simulated clients (aka randomization range). + uint32_t clients_num_; + /// MAC address template used to generate unique MAC + /// addresses for simulated clients. + std::vector mac_template_; + /// DUID template used to generate unique DUIDs for + /// simulated clients + std::vector duid_template_; + /// Collection of base values specified with -b + /// options. Supported "bases" are mac= and duid= + std::vector base_; + /// Number of 2 or 4-way exchanges to perform. + std::vector num_request_; + /// Test period in seconds + int period_; + /// Indicates number of -d parameters specified by user. + /// If this value goes above 2, command line parsing fails. + uint8_t drop_time_set_; + /// Time to elapse before request is lost. The fisrt value of + /// two-element vector refers to DO/SA exchanges, + /// second value refers to RA/RR. Default values are { 1, 1 } + std::vector drop_time_; + /// Maximum number of drops request before aborting test. + /// First value of two-element vector specifies maximum + /// number of drops for DO/SA exchange, second value + /// specifies maximum number of drops for RA/RR. + std::vector max_drop_; + /// Maximal percentage of lost requests before aborting test. + /// First value of two-element vector specifies percentage for + /// DO/SA exchanges, second value for RA/RR. + std::vector max_pdrop_; + /// Local address or interface specified with -l option. + std::string localname_; + /// Indicates that specified value with -l is + /// rather interface (not address) + bool is_interface_; + /// Number of preload packets. Preload packets are used to + /// initiate communication with server before doing performance + /// measurements. + int preload_; + /// Number of exchanges sent before next pause. + int aggressivity_; + /// Local port number (host endian) + int local_port_; + /// Randomization seed. + uint32_t seed_; + /// Indicates that randomization seed was provided. + bool seeded_; + /// Indicates that we use broadcast address. + bool broadcast_; + /// Indicates that we do rapid commit option. + bool rapid_commit_; + /// Indicates that we take server id from first received packet. + bool use_first_; + /// Packet template file names. These files store template packets + /// that are used for initiating echanges. Template packets + /// read from files are later tuned with variable data. + std::vector template_file_; + /// Offset of transaction id in template files. First vector + /// element points to offset for DISCOVER/SOLICIT messages, + /// second element points to trasaction id offset for + /// REQUEST messages + std::vector xid_offset_; + /// Random value offset in templates. Random value offset + /// points to last octet of DUID. Up to 4 last octets of + /// DUID are randomized to simulate differnt clients. + std::vector rnd_offset_; + /// Offset of elapsed time option in template packet. + int elp_offset_; + /// Offset of server id option in template packet. + int sid_offset_; + /// Offset of requested ip data in template packet + int rip_offset_; + /// String representing diagnostic selectors specified + /// by user with -x. + std::string diags_; + /// Command to be executed at the beginning/end of the test. + /// This command is expected to expose start and stop argument. + std::string wrapped_; + /// Server name specified as last argument of command line. + std::string server_name_; + /// Entire command line as typed in by the user. + std::string command_line_; }; } // namespace perfdhcp