renew_rate_ = 0;
release_rate_ = 0;
report_delay_ = 0;
+ clean_report_ = false;
clients_num_ = 0;
mac_template_.assign(mac, mac + 6);
duid_template_.clear();
// they will be tuned and validated elsewhere
while((opt = getopt_long(argc, argv,
"huv46A:r:t:R:b:n:p:d:D:l:P:a:L:N:M:s:iBc1"
- "J:T:X:O:o:E:S:I:x:W:w:e:f:F:g:",
+ "J:T:X:O:o:E:S:I:x:W:w:e:f:F:g:C",
long_options, NULL)) != -1) {
stream << " -" << static_cast<char>(opt);
if (optarg) {
rapid_commit_ = true;
break;
+ case 'C':
+ clean_report_ = true;
+ break;
+
case 'd':
check(drop_time_set_ > 1,
"maximum number of drops already specified, "
server_name_ = ALL_DHCP_SERVERS;
}
}
+ if (!getCleanReport()) {
+ if (print_cmd_line) {
+ std::cout << "Running: " << stream.str() << std::endl;
+ }
- if (print_cmd_line) {
- std::cout << "Running: " << stream.str() << std::endl;
- }
-
- if (scenario_ == Scenario::BASIC) {
- std::cout << "Scenario: basic." << std::endl;
- } else if (scenario_ == Scenario::AVALANCHE) {
- std::cout << "Scenario: avalanche." << std::endl;
- }
+ if (scenario_ == Scenario::BASIC) {
+ std::cout << "Scenario: basic." << std::endl;
+ } else if (scenario_ == Scenario::AVALANCHE) {
+ std::cout << "Scenario: avalanche." << std::endl;
+ }
- if (!isSingleThreaded()) {
- std::cout << "Multi-thread mode enabled." << std::endl;
+ if (!isSingleThreaded()) {
+ std::cout << "Multi-thread mode enabled." << std::endl;
+ }
}
// Handle the local '-l' address/interface
void
CommandOptions::usage() const {
std::cout <<
- "perfdhcp [-huv] [-4|-6] [-A<encapsulation-level>] [-e<lease-type>]\n"
+ "perfdhcp [-huvC] [-4|-6] [-A<encapsulation-level>] [-e<lease-type>]\n"
" [-r<rate>] [-f<renew-rate>]\n"
" [-F<release-rate>] [-t<report>] [-R<range>] [-b<base>]\n"
" [-n<num-request>] [-p<test-period>] [-d<drop-time>]\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<report>: Delay in seconds between two periodic reports.\n"
+ "-C: Output reduced, periodic reports generated in easy parsable mode.\n"
"\n"
"Errors:\n"
"- tooshort: received a too short message\n"
/// \return delay between two consecutive performance reports.
int getReportDelay() const { return report_delay_; }
+ /// \brief Returns clean report mode.
+ ///
+ /// \return true if cleaner report is enabled.
+ int getCleanReport() const { return clean_report_; }
+
/// \brief Returns number of simulated clients.
///
/// \return number of simulated clients.
/// Delay between generation of two consecutive performance reports.
int report_delay_;
+ /// Enable cleaner, easy to parse, output of performance reports.
+ bool clean_report_;
+
/// Number of simulated clients (aka randomization range).
uint32_t clients_num_;
/// Method prints intermediate statistics for all exchanges.
/// Statistics includes sent, received and dropped packets
/// counters.
- void printIntermediateStats() const {
+ ///
+ /// \param clean_report value to generate easy to parse report.
+ void printIntermediateStats(bool clean_report) const {
std::ostringstream stream_sent;
std::ostringstream stream_rcvd;
std::ostringstream stream_drops;
it != exchanges_.end(); ++it) {
if (it != exchanges_.begin()) {
- sep = "/";
+ if (clean_report) {
+ sep = " ";
+ } else {
+ sep = "/";
+ }
}
stream_sent << sep << it->second->getSentPacketsNum();
stream_rcvd << sep << it->second->getRcvdPacketsNum();
stream_drops << sep << it->second->getDroppedPacketsNum();
stream_reject << sep << it->second->getRejLeasesNum();
- }
+ }//teraz
+
+ if (clean_report) {
+ std::cout << stream_sent.str()
+ << " " << stream_rcvd.str()
+ << " " << stream_drops.str()
+ << " " << stream_reject.str()
+ << std::endl;
+
+ } else {
std::cout << "sent: " << stream_sent.str()
<< "; received: " << stream_rcvd.str()
<< "; drops: " << stream_drops.str()
<< "; rejected: " << stream_reject.str()
<< std::endl;
+ }
}
/// \brief Print timestamps of all packets.
ptime now = microsec_clock::universal_time();
time_period time_since_report(last_report_, now);
if (time_since_report.length().total_seconds() >= delay) {
- stats_mgr_.printIntermediateStats();
+ stats_mgr_.printIntermediateStats(options_.getCleanReport());
last_report_ = now;
}
}
EXPECT_TRUE(opt.isUseFirst());
}
+TEST_F(CommandOptionsTest, UseCleanOutput) {
+ CommandOptions opt;
+ EXPECT_NO_THROW(process(opt, "perfdhcp -6 -C -l ethx all"));
+ EXPECT_TRUE(opt.getCleanReport());
+}
+
TEST_F(CommandOptionsTest, UseRelayV6) {
CommandOptions opt;
EXPECT_NO_THROW(process(opt, "perfdhcp -6 -A1 -l ethx all"));