]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[1960] Calculate late received packets.
authorMarcin Siodelski <marcin@isc.org>
Thu, 13 Sep 2012 11:23:00 +0000 (13:23 +0200)
committerMarcin Siodelski <marcin@isc.org>
Thu, 13 Sep 2012 11:23:00 +0000 (13:23 +0200)
tests/tools/perfdhcp/stats_mgr.h
tests/tools/perfdhcp/test_control.cc
tests/tools/perfdhcp/test_control.h

index a8dfa8b7bdbe2bf6b25962e0a82274208101331f..5ee4f0502a21813be823d1efaa01f457d15ee1df 100644 (file)
@@ -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.
index 77d2f0c78d9aef87fdbb21c5d7c0012fe089476d..0bfd5cd8d49d6d0e4a6282ac960dfe6275c805ae 100644 (file)
@@ -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.
index 389f4de829a8d43156423baee678f0fa55f2372a..def354fdadb14cfb76ca57a71e9d1de12350f34f 100644 (file)
@@ -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
     ///