/// \brief Increment operator.
const CustomCounter& operator++() {
++counter_;
- return(*this);
+ return (*this);
}
/// \brief Increment operator.
const CustomCounter& operator++(int) {
CustomCounter& this_counter(*this);
operator++();
- return(this_counter);
+ return (this_counter);
+ }
+
+ const CustomCounter& operator+=(int val) {
+ counter_ = counter_ + val;
+ return (*this);
}
/// \brief Return counter value.
CustomCounterPtr(new CustomCounter(long_name));
}
+ /// \brief Check if any packet drops occured.
+ ///
+ // \return true, if packet drops occured.
+ bool droppedPackets() const {
+ for (ExchangesMapIterator it = exchanges_.begin();
+ it != exchanges_.end();
+ ++it) {
+ if (it->second->getDroppedPacketsNum() > 0) {
+ return (true);
+ }
+ }
+ return (false);
+ }
+
/// \brief Return specified counter.
///
/// Method returns specified counter.
///
/// Increement counter value by one.
///
- /// \param counter_key key poitinh to the counter in the counters map.
+ /// \param counter_key key poiting to the counter in the counters map.
/// \return pointer to specified counter after incrementation.
- const CustomCounter& incrementCounter(const std::string& counter_key) {
+ const CustomCounter& incrementCounter(const std::string& counter_key,
+ const uint64_t value = 1) {
CustomCounterPtr counter = getCounter(counter_key);
- return(++(*counter));
+ *counter += value;
+ return (*counter);
}
/// \brief Adds new packet to the sent packets list.
stats_mgr4_->addCustomCounter("latesend", "Late sent packets");
stats_mgr4_->addCustomCounter("shortwait", "Short waits for packets");
stats_mgr4_->addCustomCounter("multircvd", "Multiple packets receives");
- // stats_mgr4_->addCustomCounter("latercvd", "Late received packets");
+ stats_mgr4_->addCustomCounter("latercvd", "Late received packets");
} else if (options.getIpVersion() == 6) {
stats_mgr6_->addCustomCounter("latesend", "Late sent packets");
stats_mgr6_->addCustomCounter("shortwait", "Short waits for packets");
stats_mgr6_->addCustomCounter("multircvd", "Multiple packets receives");
- // stats_mgr6_->addCustomCounter("latercvd", "Late received packets");
+ stats_mgr6_->addCustomCounter("latercvd", "Late received packets");
}
}
}
}
}
-void
+uint64_t
TestControl::receivePackets(const TestControlSocket& socket) {
int timeout = 0;
bool receiving = true;
}
}
}
+ return received;
}
void
for (;;) {
// Calculate send due based on when last exchange was initiated.
updateSendDue();
- // If test period finished, maximum number of packet drops
- // has been reached or test has been interrupted we have to
- // finish the test.
- if (checkExitConditions()) {
- break;
- }
// Calculate number of packets to be sent to stay
// catch up with rate.
uint64_t packets_due = getNextExchangesNum();
// @todo: set non-zero timeout for packets once we implement
// microseconds timeout in IfaceMgr.
receivePackets(socket);
+
+ // If test period finished, maximum number of packet drops
+ // has been reached or test has been interrupted we have to
+ // finish the test.
+ if (checkExitConditions()) {
+ break;
+ }
+
// Send packets.
for (uint64_t i = packets_due; i > 0; --i) {
if (options.getIpVersion() == 4) {
sendSolicit6(socket, template_buffers_[0]);
}
}
+ // Receive late packets.
+ uint64_t latercvd = receivePackets(socket);
+ if (testDiags('i')) {
+ if (options.getIpVersion() == 4) {
+ stats_mgr4_->incrementCounter("latercvd", latercvd);
+ } else if (options.getIpVersion() == 6) {
+ stats_mgr6_->incrementCounter("latercvd", latercvd);
+ }
+ }
}
// Report delay means that user requested printing number
// of sent/received/dropped packets repeatedly.