summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/bin/perfdhcp/avalanche_scen.cc17
-rw-r--r--src/bin/perfdhcp/avalanche_scen.h3
-rw-r--r--src/bin/perfdhcp/basic_scen.h2
-rw-r--r--src/bin/perfdhcp/stats_mgr.cc13
-rw-r--r--src/bin/perfdhcp/stats_mgr.h24
-rw-r--r--src/bin/perfdhcp/test_control.cc5
-rw-r--r--src/bin/perfdhcp/test_control.h6
-rw-r--r--src/lib/dhcp/pkt.h8
8 files changed, 38 insertions, 40 deletions
diff --git a/src/bin/perfdhcp/avalanche_scen.cc b/src/bin/perfdhcp/avalanche_scen.cc
index 3c96946305..c796c46e7f 100644
--- a/src/bin/perfdhcp/avalanche_scen.cc
+++ b/src/bin/perfdhcp/avalanche_scen.cc
@@ -27,6 +27,7 @@ AvalancheScen::resendPackets(ExchangeType xchg_type) {
auto end_it = std::get<1>(sent_packets_its);
auto& retrans = retransmissions_[xchg_type];
+ auto& start_times = start_times_[xchg_type];
int still_left_cnt = 0;
int resent_cnt = 0;
@@ -34,10 +35,15 @@ AvalancheScen::resendPackets(ExchangeType xchg_type) {
still_left_cnt++;
dhcp::PktPtr pkt = *it;
auto trans_id = pkt->getTransid();
+ bool first_resend = false;
+ auto start_time = pkt->getTimestamp();
int rx_times = 0;
auto r_it = retrans.find(trans_id);
if (r_it != retrans.end()) {
rx_times = (*r_it).second;
+ start_time = (*start_times.find(trans_id)).second;
+ } else {
+ first_resend = true;
}
int delay = (1 << rx_times); // in seconds
@@ -47,10 +53,14 @@ AvalancheScen::resendPackets(ExchangeType xchg_type) {
delay *= 1000; // to miliseconds
delay += random() % 2000 - 1000; // adjust by random from -1000..1000 range
auto now = microsec_clock::universal_time();
- if (now - pkt->getTimestamp() > milliseconds(delay)) {
+ if (now - start_time > milliseconds(delay)) {
resent_cnt++;
total_resent_++;
+ boost::posix_time::ptime original_timestamp;
+ if (!first_resend) {
+ original_timestamp = pkt->getTimestamp();
+ }
if (options.getIpVersion() == 4) {
Pkt4Ptr pkt4 = boost::dynamic_pointer_cast<Pkt4>(pkt);
IfaceMgr::instance().send(pkt4);
@@ -58,6 +68,11 @@ AvalancheScen::resendPackets(ExchangeType xchg_type) {
Pkt6Ptr pkt6 = boost::dynamic_pointer_cast<Pkt6>(pkt);
IfaceMgr::instance().send(pkt6);
}
+ if (first_resend) {
+ start_times[trans_id] = pkt->getTimestamp();
+ } else {
+ pkt->setTimestamp(original_timestamp);
+ }
rx_times++;
retrans[trans_id] = rx_times;
diff --git a/src/bin/perfdhcp/avalanche_scen.h b/src/bin/perfdhcp/avalanche_scen.h
index 66cf040286..037ee7daed 100644
--- a/src/bin/perfdhcp/avalanche_scen.h
+++ b/src/bin/perfdhcp/avalanche_scen.h
@@ -18,7 +18,7 @@ namespace perfdhcp {
class AvalancheScen : public boost::noncopyable {
public:
- AvalancheScen(): tc_(true), total_resent_(0) {};
+ AvalancheScen(): total_resent_(0) {};
/// brief\ Run performance test.
///
@@ -36,6 +36,7 @@ private:
TestControl tc_;
std::unordered_map<ExchangeType, std::unordered_map<uint32_t, int>> retransmissions_;
+ std::unordered_map<ExchangeType, std::unordered_map<uint32_t, boost::posix_time::ptime>> start_times_;
int total_resent_;
int resendPackets(ExchangeType xchg_type);
diff --git a/src/bin/perfdhcp/basic_scen.h b/src/bin/perfdhcp/basic_scen.h
index 7a5d115d4e..336be7eeca 100644
--- a/src/bin/perfdhcp/basic_scen.h
+++ b/src/bin/perfdhcp/basic_scen.h
@@ -18,7 +18,7 @@ namespace perfdhcp {
class BasicScen : public boost::noncopyable {
public:
- BasicScen() : tc_(false) {};
+ BasicScen() {};
/// \brief Check if test exit conditions fulfilled.
///
diff --git a/src/bin/perfdhcp/stats_mgr.cc b/src/bin/perfdhcp/stats_mgr.cc
index bc8fe641a1..bd741e31ed 100644
--- a/src/bin/perfdhcp/stats_mgr.cc
+++ b/src/bin/perfdhcp/stats_mgr.cc
@@ -37,8 +37,7 @@ std::ostream& operator<<(std::ostream& os, ExchangeType xchg_type)
ExchangeStats::ExchangeStats(const ExchangeType xchg_type,
const double drop_time,
const bool archive_enabled,
- const boost::posix_time::ptime boot_time,
- bool ignore_timestamp_reorder)
+ const boost::posix_time::ptime boot_time)
: xchg_type_(xchg_type),
sent_packets_(),
rcvd_packets_(),
@@ -56,8 +55,7 @@ ExchangeStats::ExchangeStats(const ExchangeType xchg_type,
ordered_lookups_(0),
sent_packets_num_(0),
rcvd_packets_num_(0),
- boot_time_(boot_time),
- ignore_timestamp_reorder_(ignore_timestamp_reorder)
+ boot_time_(boot_time)
{
next_sent_ = sent_packets_.begin();
}
@@ -89,7 +87,7 @@ ExchangeStats::updateDelays(const dhcp::PktPtr& sent_packet,
double delta =
static_cast<double>(period.length().total_nanoseconds()) / 1e9;
- if (!ignore_timestamp_reorder_ && delta < 0) {
+ if (delta < 0) {
isc_throw(Unexpected, "Sent packet's timestamp must not be "
"greater than received packet's timestamp in "
<< xchg_type_ << ".\nTime difference: "
@@ -315,10 +313,9 @@ ExchangeStats::printTimestamps() {
}
}
-StatsMgr::StatsMgr(bool ignore_timestamp_reorder) :
+StatsMgr::StatsMgr() :
exchanges_(),
- boot_time_(boost::posix_time::microsec_clock::universal_time()),
- ignore_timestamp_reorder_(ignore_timestamp_reorder)
+ boot_time_(boost::posix_time::microsec_clock::universal_time())
{
CommandOptions& options = CommandOptions::instance();
diff --git a/src/bin/perfdhcp/stats_mgr.h b/src/bin/perfdhcp/stats_mgr.h
index adc028177a..b05a75b800 100644
--- a/src/bin/perfdhcp/stats_mgr.h
+++ b/src/bin/perfdhcp/stats_mgr.h
@@ -260,14 +260,10 @@ public:
/// \param archive_enabled if true packets archive mode is enabled.
/// In this mode all packets are stored throughout the test execution.
/// \param boot_time Holds the timestamp when perfdhcp has been started.
- /// \param ignore_timestamp_reorder if true then while matching
- /// response packets to request ones negative time difference is ignored
- /// otherwise exception is raised.
ExchangeStats(const ExchangeType xchg_type,
const double drop_time,
const bool archive_enabled,
- const boost::posix_time::ptime boot_time,
- bool ignore_timestamp_reorder);
+ const boost::posix_time::ptime boot_time);
/// \brief Add new packet to list of sent packets.
///
@@ -614,11 +610,6 @@ private:
uint64_t sent_packets_num_; ///< Total number of sent packets.
uint64_t rcvd_packets_num_; ///< Total number of received packets.
boost::posix_time::ptime boot_time_; ///< Time when test is started.
-
- /// If true then while matching
- /// response packets to request ones negative time difference is ignored
- /// otherwise exception is raised.
- bool ignore_timestamp_reorder_;
};
/// Pointer to ExchangeStats.
@@ -658,10 +649,7 @@ public:
/// the test. If this is not selected archiving should be disabled
/// for performance reasons and to avoid waste of memory for storing
/// large list of archived packets.
- /// \param ignore_timestamp_reorder if true then while matching
- /// response packets to request ones negative time difference is ignored
- /// otherwise exception is raised.
- StatsMgr(bool ignore_timestamp_reorder);
+ StatsMgr();
/// \brief Specify new exchange type.
///
@@ -682,8 +670,7 @@ public:
ExchangeStatsPtr(new ExchangeStats(xchg_type,
drop_time,
archive_enabled_,
- boot_time_,
- ignore_timestamp_reorder_));
+ boot_time_));
}
/// \brief Check if the exchange type has been specified.
@@ -1122,11 +1109,6 @@ private:
bool archive_enabled_;
boost::posix_time::ptime boot_time_; ///< Time when test is started.
-
- /// If true then while matching
- /// response packets to request ones negative time difference is ignored
- /// otherwise exception is raised.
- bool ignore_timestamp_reorder_;
};
/// Pointer to Statistics Manager;
diff --git a/src/bin/perfdhcp/test_control.cc b/src/bin/perfdhcp/test_control.cc
index a37394c78c..9a5cad8310 100644
--- a/src/bin/perfdhcp/test_control.cc
+++ b/src/bin/perfdhcp/test_control.cc
@@ -966,9 +966,8 @@ TestControl::reset() {
interrupted_ = false;
}
-TestControl::TestControl(bool ignore_timestamp_reorder) :
- number_generator_(0, CommandOptions::instance().getMacsFromFile().size()),
- stats_mgr_(ignore_timestamp_reorder)
+TestControl::TestControl() :
+ number_generator_(0, CommandOptions::instance().getMacsFromFile().size())
{
// Reset singleton state before test starts.
reset();
diff --git a/src/bin/perfdhcp/test_control.h b/src/bin/perfdhcp/test_control.h
index bb496e8c6c..4ece6157fa 100644
--- a/src/bin/perfdhcp/test_control.h
+++ b/src/bin/perfdhcp/test_control.h
@@ -124,11 +124,7 @@ public:
class TestControl : public boost::noncopyable {
public:
/// \brief Default constructor.
- ///
- /// \param ignore_timestamp_reorder if true then while matching
- /// response packets to request ones negative time difference is ignored
- /// otherwise exception is raised.
- TestControl(bool ignore_timestamp_reorder);
+ TestControl();
/// Packet template buffer.
typedef std::vector<uint8_t> TemplateBuffer;
diff --git a/src/lib/dhcp/pkt.h b/src/lib/dhcp/pkt.h
index cf90eb4073..959eaf9a81 100644
--- a/src/lib/dhcp/pkt.h
+++ b/src/lib/dhcp/pkt.h
@@ -396,6 +396,14 @@ public:
return timestamp_;
}
+ /// @brief Set packet timestamp.
+ ///
+ /// Sets packet timestamp to arbitrary value.
+ /// It is used by perfdhcp tool and should be used elsewhere.
+ void setTimestamp(boost::posix_time::ptime& timestamp) {
+ timestamp_ = timestamp;
+ }
+
/// @brief Copies content of input buffer to output buffer.
///
/// This is mostly a diagnostic function. It is being used for sending