update 0.0.2

This commit is contained in:
2021-10-24 12:51:25 +02:00
parent d80e285bb4
commit c2c321eb9b
30 changed files with 1689 additions and 1333 deletions

View File

@@ -1,11 +1,28 @@
/**
* @file StatisticsThread.hpp
* @author Jakob
* @brief
* @version 0.1
* @date 2021-07-12
*
* @copyright Copyright (c) 2021
*
*/
#pragma once
#include <rte_ring_core.h>
#include <rte_ring_elem.h>
#include <cstdint>
#include <cstdio>
#include <iostream>
#include <ostream>
#include <rte_errno.h>
#include <rte_lcore.h>
#include <rte_ring.h>
//#include <rte_ring_core.h>
//#include <rte_ring_elem.h>
#include <string>
#include "Threads/Thread.hpp"
#include "Definitions.hpp"
struct Stats {
uint64_t attacks;
@@ -13,11 +30,12 @@ struct Stats {
uint64_t dropped;
uint64_t packets;
uint64_t work_time;
uint64_t syn_level;
Stats* operator+=(const Stats* new_stats);
Stats& operator+=(const Stats& new_stats);
void reset_stats();
};
// all current stats which can be displayed
struct StatsMonitor {
double attacks_per_second;
double attacks_percent;
@@ -25,19 +43,32 @@ struct StatsMonitor {
double dropped_per_second;
double dropped_percent;
double packets_per_second;
double proc_speed; // process speed
double process_speed;
double total_time;
};
class StatisticsThread : public Thread {
public:
StatisticsThread();
static int s_run(void* thread_vptr);
void enqueue_statistics(int& id, Stats* new_stats);
void update_statistics(Stats* new_stats);
void enqueue_statistics(const unsigned int& id, Stats* new_stats);
void update_statistics_monitor();
void print_stats_monitor();
private:
void run();
static rte_ring* _s_queue[16];
static Stats* _s_stats;
static rte_ring* _s_queue[16]; // todo : dynamic
Stats* _s_stats;
StatsMonitor* _s_stats_monitor;
uint64_t timer_get_seconds();
void timer_reset();
// timer variables
uint64_t cycles_old = 0;
uint64_t cycles = 0;
uint64_t seconds = 0;
uint64_t delta_t = 0;
uint64_t hz;
};