num_request_.clear();
exit_wait_time_ = 0;
period_ = 0;
+ wait_for_elapsed_time_ = -1;
+ increased_elapsed_time_ = -1;
drop_time_set_ = 0;
drop_time_.assign(dt, dt + 2);
max_drop_.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:C:",
+ "J:T:X:O:o:E:S:I:x:W:w:e:f:F:g:C:y:Y:",
long_options, NULL)) != -1) {
stream << " -" << static_cast<char>(opt);
if (optarg) {
xid_offset_.push_back(offset_arg);
break;
+ case 'Y':
+ wait_for_elapsed_time_ = nonNegativeInteger("value of time:"
+ " -Y<value> must be a non negative integer");
+ break;
+
+ case 'y':
+ increased_elapsed_time_ = positiveInteger("value of time:"
+ " -y<value> must be a positive integer");
+ break;
+
case LONG_OPT_SCENARIO: {
auto optarg_text = std::string(optarg);
if (optarg_text == "basic") {
"use -I<ip-offset>");
check((!getMacListFile().empty() && base_.size() > 0),
"Can't use -b with -M option");
-
+ check((getWaitForElapsedTime() == -1 && getIncreaseElapsedTime() != -1),
+ "Option -y can't be used without -Y");
+ check((getWaitForElapsedTime() != -1 && getIncreaseElapsedTime() == -1),
+ "Option -Y can't be used without -y");
auto nthreads = std::thread::hardware_concurrency();
if (nthreads == 1 && isSingleThreaded() == false) {
std::cout << "WARNING: Currently system can run only 1 thread in parallel." << std::endl
" * 't': when finished, print timers of all successful exchanges\n"
" * 'T': when finished, print templates\n"
"-X<xid-offset>: Transaction ID (aka. xid) offset in the template.\n"
- "\n"
+ "-Y<time>: time in seconds after which perfdhcp will start sending\n"
+ " messages with increased elapsed time option.\n"
+ "-y<time>: period of time in seconds in which perfdhcp will be sending\n"
+ " messages with increased elapsed time option.\n"
"DHCPv4 only options:\n"
"-B: Force broadcast handling.\n"
"\n"
/// \return test period before it is aborted.
int getPeriod() const { return period_; }
+ /// \brief Returns time to wait for elapsed time increase.
+ ///
+ /// \return how long perfdhp will wait before start sending
+ /// messages with increased elapsed time.
+ int getWaitForElapsedTime() const { return wait_for_elapsed_time_; }
+
+ /// \brief Returns increased elapsed time.
+ ///
+ /// \return how long perfdhcp will send messages with increased
+ /// elapsed time.
+ int getIncreaseElapsedTime() const { return increased_elapsed_time_; }
+
/// \brief Returns drop time.
///
/// The method returns maximum time elapsed from
/// Test period in seconds.
int period_;
+ // for how long perfdhcp will wait before start senging
+ // messages with increased elapsed time.
+ int wait_for_elapsed_time_;
+
+ // Amount of time after which perfdhcp will send messages with
+ // elapsed time increased.
+ int increased_elapsed_time_;
+
/// Indicates number of -d<value> parameters specified by user.
/// If this value goes above 2, command line parsing fails.
uint8_t drop_time_set_;
// Set client identifier
pkt4->addOption(generateClientId(pkt4->getHWAddr()));
+ if (options_.getWaitForElapsedTime() &&
+ stats_mgr_.getTestPeriod().length().total_seconds() >= options_.getWaitForElapsedTime() &&
+ stats_mgr_.getTestPeriod().length().total_seconds() <= options_.getWaitForElapsedTime() +
+ options_.getIncreaseElapsedTime()) {
+ // increase field elapsed time heree
+ pkt4->setSecs(static_cast<uint16_t>(10));
+ }
+
// Add any extra options that user may have specified.
addExtraOpts(pkt4);
if (!pkt6) {
isc_throw(Unexpected, "failed to create SOLICIT packet");
}
- pkt6->addOption(Option::factory(Option::V6, D6O_ELAPSED_TIME));
+ if (options_.getWaitForElapsedTime() &&
+ stats_mgr_.getTestPeriod().length().total_seconds() >= options_.getWaitForElapsedTime() &&
+ stats_mgr_.getTestPeriod().length().total_seconds() <= options_.getWaitForElapsedTime() +
+ options_.getIncreaseElapsedTime()) {
+ boost::shared_ptr<LocalizedOption>
+ opt_elapsed_time(new LocalizedOption(Option::V6, D6O_ELAPSED_TIME,
+ OptionBuffer(2, 10)));
+ pkt6->addOption(opt_elapsed_time);
+ } else {
+ pkt6->addOption(Option::factory(Option::V6, D6O_ELAPSED_TIME));
+ }
+
if (options_.isRapidCommit()) {
pkt6->addOption(Option::factory(Option::V6, D6O_RAPID_COMMIT));
}
EXPECT_FALSE(opt.isRapidCommit());
EXPECT_FALSE(opt.isUseFirst());
EXPECT_FALSE(opt.getAddrUnique());
+ EXPECT_EQ(-1, opt.getIncreaseElapsedTime());
+ EXPECT_EQ(-1, opt.getWaitForElapsedTime());
EXPECT_EQ(0, opt.getTemplateFiles().size());
EXPECT_EQ(0, opt.getTransactionIdOffset().size());
EXPECT_EQ(0, opt.getRandomOffset().size());
EXPECT_THROW(process(opt, "perfdhcp -M foo -b mac=1234 all"),
isc::InvalidParameter);
}
+
+TEST_F(CommandOptionsTest, ElapsedTime) {
+ CommandOptions opt;
+ EXPECT_NO_THROW(process(opt, "perfdhcp -y 3 -Y 10 192.168.0.1"));
+
+ EXPECT_EQ(3, opt.getIncreaseElapsedTime());
+ EXPECT_EQ(10, opt.getWaitForElapsedTime());
+}