From 59cfb6233614fa5093c0d3ae2de277829f2da01f Mon Sep 17 00:00:00 2001 From: "Valeriano A.R." Date: Tue, 5 Aug 2025 22:32:34 +0200 Subject: [PATCH] Connection: Fix double counting of packet sizes on diferent intervals. --- src/connection.cpp | 5 ++++- src/connection.h | 2 ++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/connection.cpp b/src/connection.cpp index 0959fa2..060bb81 100644 --- a/src/connection.cpp +++ b/src/connection.cpp @@ -58,6 +58,10 @@ u_int64_t PackList::sumanddel(timeval t) { PackListNode *previous = NULL; while (current != NULL) { + if(current->is_sum == false){ + retval += current->val->len; + current->is_sum = true; + } // std::cout << "Comparing " << current->val->time.tv_sec << " <= " << // t.tv_sec - PERIOD << endl; if (current->val->time.tv_sec <= t.tv_sec - PERIOD) { @@ -68,7 +72,6 @@ u_int64_t PackList::sumanddel(timeval t) { delete current; return retval; } - retval += current->val->len; previous = current; current = current->next; } diff --git a/src/connection.h b/src/connection.h index 1d3b224..c78bd06 100644 --- a/src/connection.h +++ b/src/connection.h @@ -30,6 +30,7 @@ public: PackListNode(Packet *m_val, PackListNode *m_next = NULL) { val = m_val; next = m_next; + is_sum = false; } ~PackListNode() { delete val; @@ -38,6 +39,7 @@ public: } PackListNode *next; Packet *val; + bool is_sum; }; class PackList {