/// \param xchg_type exchange type
/// \param archive_enabled if true packets archive mode is enabled.
/// In this mode all packets are stored throughout the test execution.
- ExchangeStats(const ExchangeType xchg_type, const bool archive_enabled)
+ ExchangeStats(const ExchangeType xchg_type,
+ const double drop_time,
+ const bool archive_enabled)
: xchg_type_(xchg_type),
- sent_packets_(),
- rcvd_packets_(),
- archived_packets_(),
- archive_enabled_(archive_enabled),
- min_delay_(std::numeric_limits<double>::max()),
- max_delay_(0.),
- sum_delay_(0.),
- sum_delay_squared_(0.),
- orphans_(0),
- unordered_lookup_size_sum_(0),
- unordered_lookups_(0),
- ordered_lookups_(0),
- sent_packets_num_(0),
- rcvd_packets_num_(0)
+ sent_packets_(),
+ rcvd_packets_(),
+ archived_packets_(),
+ archive_enabled_(archive_enabled),
+ drop_time_(drop_time),
+ min_delay_(std::numeric_limits<double>::max()),
+ max_delay_(0.),
+ sum_delay_(0.),
+ sum_delay_squared_(0.),
+ orphans_(0),
+ collected_(0),
+ unordered_lookup_size_sum_(0),
+ unordered_lookups_(0),
+ ordered_lookups_(0),
+ sent_packets_num_(0),
+ rcvd_packets_num_(0)
{
next_sent_ = sent_packets_.begin();
}
/// not found
boost::shared_ptr<T>
matchPackets(const boost::shared_ptr<T>& rcvd_packet) {
+ using namespace boost::posix_time;
+
if (!rcvd_packet) {
isc_throw(BadValue, "Received packet is null");
}
sent_packets_.template project<0>(it);
break;
}
+ ptime now = microsec_clock::universal_time();
+ ptime packet_time = (*it)->getTimestamp();
+ time_period packet_period(packet_time, now);
+ if (!packet_period.is_null()) {
+ double period_fractional =
+ packet_period.length().total_seconds() +
+ (static_cast<double>(packet_period.length().fractional_seconds())
+ / packet_period.length().ticks_per_second());
+ if (drop_time_ > 0 &&
+ (period_fractional > drop_time_)) {
+ eraseSent(sent_packets_.template project<0>(it));
+ ++collected_;
+ }
+ }
}
}
/// \return number of orphant received packets.
uint64_t getOrphans() const { return(orphans_); }
+ /// \brief Return number of garbage collected packets.
+ ///
+ /// Method returns number of garbage collected timed out
+ /// packets. Packet is assumed timed out when duration
+ /// between sending it to server and receiving server's
+ /// response is greater than value specified with -d<value>
+ /// command line argument.
+ ///
+ /// \return number of garbage collected packets.
+ uint64_t getCollectedNum() const { return(collected_); }
+
/// \brief Return average unordered lookup set size.
///
/// Method returns average unordered lookup set size.
<< "avg delay: " << getAvgDelay() * 1e3 << " ms" << endl
<< "max delay: " << getMaxDelay() * 1e3 << " ms" << endl
<< "std deviation: " << getStdDevDelay() * 1e3 << " ms"
- << endl;
+ << endl
+ << "collected packets: " << getCollectedNum() << endl;
} catch (const Exception& e) {
- cout << "Unavailable! No packets received." << endl;
+ cout << "Delay summary unavailable! No packets received." << endl;
}
}
/// to keep all packets archived throughout the test.
bool archive_enabled_;
+ /// Maxmimum time elapsed between sending and receiving packet
+ /// before packet is assumed dropped.
+ double drop_time_;
+
double min_delay_; ///< Minimum delay between sent
///< and received packets.
double max_delay_; ///< Maximum delay between sent
uint64_t orphans_; ///< Number of orphant received packets.
+ uint64_t collected_; ///< Number of garbage collected packets.
+
/// Sum of unordered lookup sets. Needed to calculate mean size of
/// lookup set. It is desired that number of unordered lookups is
/// minimal for performance reasons. Tracking number of lookups and
/// for performance reasons and to avoid waste of memory for storing
/// large list of archived packets.
///
+ /// \param drop_time maximum time elapsed before packet is
+ /// assumed dropped. Negative value disables it.
/// \param archive_enabled true indicates that packets
/// archive mode is enabled.
StatsMgr(const bool archive_enabled = false) :
exchanges_(),
- custom_counters_(),
archive_enabled_(archive_enabled),
boot_time_(boost::posix_time::microsec_clock::universal_time()) {
}
///
/// \param xchg_type exchange type.
/// \throw isc::BadValue if exchange of specified type exists.
- void addExchangeStats(const ExchangeType xchg_type) {
+ void addExchangeStats(const ExchangeType xchg_type,
+ const double drop_time = -1) {
if (exchanges_.find(xchg_type) != exchanges_.end()) {
isc_throw(BadValue, "Exchange of specified type already added.");
}
exchanges_[xchg_type] =
- ExchangeStatsPtr(new ExchangeStats(xchg_type, archive_enabled_));
+ ExchangeStatsPtr(new ExchangeStats(xchg_type,
+ drop_time,
+ archive_enabled_));
}
/// \brief Add named custom uint64 counter.
return(xchg_stats->getDroppedPacketsNum());
}
+ /// \brief Return number of garbage collected packets.
+ ///
+ /// Method returns number of garbage collected timed out
+ /// packets. Packet is assumed timed out when duration
+ /// between sending it to server and receiving server's
+ /// response is greater than value specified with -d<value>
+ /// command line argument.
+ ///
+ /// \throw isc::BadValue if invalid exchange type specified.
+ /// \return number of garbage collected packets.
+ uint64_t getCollectedNum(const ExchangeType xchg_type) const {
+ ExchangeStatsPtr xchg_stats = getExchangeStats(xchg_type);
+ return(xchg_stats->getCollectedNum());
+ }
+
+
/// \brief Get time period since the start of test.
///
/// Calculate dna return period since the test start. This
stream_rcvd << sep << it->second->getRcvdPacketsNum();
stream_drops << sep << it->second->getDroppedPacketsNum();
}
- std::cout << "sent: " << stream_sent.str()
+ std::cout << "sent: " << stream_sent.str()
<< "; received: " << stream_rcvd.str()
<< "; drops: " << stream_drops.str()
<< std::endl;
if (options.getIpVersion() == 4) {
stats_mgr4_.reset();
stats_mgr4_ = StatsMgr4Ptr(new StatsMgr4(archive_mode));
- stats_mgr4_->addExchangeStats(StatsMgr4::XCHG_DO);
+ stats_mgr4_->addExchangeStats(StatsMgr4::XCHG_DO,
+ options.getDropTime()[0]);
if (options.getExchangeMode() == CommandOptions::DORA_SARR) {
- stats_mgr4_->addExchangeStats(StatsMgr4::XCHG_RA);
+ stats_mgr4_->addExchangeStats(StatsMgr4::XCHG_RA,
+ options.getDropTime()[1]);
}
} else if (options.getIpVersion() == 6) {
stats_mgr6_.reset();
stats_mgr6_ = StatsMgr6Ptr(new StatsMgr6(archive_mode));
- stats_mgr6_->addExchangeStats(StatsMgr6::XCHG_SA);
+ stats_mgr6_->addExchangeStats(StatsMgr6::XCHG_SA,
+ options.getDropTime()[0]);
if (options.getExchangeMode() == CommandOptions::DORA_SARR) {
- stats_mgr6_->addExchangeStats(StatsMgr6::XCHG_RR);
+ stats_mgr6_->addExchangeStats(StatsMgr6::XCHG_RR,
+ options.getDropTime()[1]);
}
}
if (testDiags('i')) {
}
std::cout << "***Rate statistics***" << std::endl;
if (options.getRate() > 0) {
- std::cout << "Rate: " << rate << ", expected rate: "
- << options.getRate() << std::endl << std::endl;
+ std::cout << "Rate: " << rate << " exchanges/second, expected rate: "
+ << options.getRate() << " exchanges/second" << std::endl << std::endl;
} else {
std::cout << "Rate: " << rate << std::endl << std::endl;
}