From: Marcin Siodelski Date: Thu, 13 Sep 2012 11:23:00 +0000 (+0200) Subject: [1960] Calculate late received packets. X-Git-Tag: trac2351_base~40^2~18 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=f13266d9802fa12a8bf223d94b6fe97923ca384a;p=thirdparty%2Fkea.git [1960] Calculate late received packets. --- diff --git a/tests/tools/perfdhcp/stats_mgr.h b/tests/tools/perfdhcp/stats_mgr.h index a8dfa8b7bd..5ee4f0502a 100644 --- a/tests/tools/perfdhcp/stats_mgr.h +++ b/tests/tools/perfdhcp/stats_mgr.h @@ -73,14 +73,19 @@ public: /// \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. @@ -824,6 +829,20 @@ public: 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. @@ -844,11 +863,13 @@ public: /// /// 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. diff --git a/tests/tools/perfdhcp/test_control.cc b/tests/tools/perfdhcp/test_control.cc index 77d2f0c78d..0bfd5cd8d4 100644 --- a/tests/tools/perfdhcp/test_control.cc +++ b/tests/tools/perfdhcp/test_control.cc @@ -515,12 +515,12 @@ TestControl::initializeStatsMgr() { 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"); } } } @@ -786,7 +786,7 @@ TestControl::processReceivedPacket6(const TestControlSocket& socket, } } -void +uint64_t TestControl::receivePackets(const TestControlSocket& socket) { int timeout = 0; bool receiving = true; @@ -819,6 +819,7 @@ TestControl::receivePackets(const TestControlSocket& socket) { } } } + return received; } void @@ -992,12 +993,6 @@ TestControl::run() { 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(); @@ -1012,6 +1007,14 @@ TestControl::run() { // @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) { @@ -1035,6 +1038,15 @@ TestControl::run() { 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. diff --git a/tests/tools/perfdhcp/test_control.h b/tests/tools/perfdhcp/test_control.h index 389f4de829..def354fdad 100644 --- a/tests/tools/perfdhcp/test_control.h +++ b/tests/tools/perfdhcp/test_control.h @@ -504,7 +504,8 @@ protected: /// \param socket socket to be used. /// \throw isc::BadValue if unknown message type received. /// \throw isc::Unexpected if unexpected error occured. - void receivePackets(const TestControlSocket& socket); + /// \return number of received packets. + uint64_t receivePackets(const TestControlSocket& socket); /// \brief Register option factory functions for DHCPv4 ///