Connection: Fix double counting of packet sizes on diferent intervals.

This commit is contained in:
2025-08-05 22:32:34 +02:00
parent 5bb454cb03
commit 59cfb62336
2 changed files with 6 additions and 1 deletions

View File

@@ -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;
}

View File

@@ -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 {