/src/ntopng/include/BehaviouralCounter.h
Line | Count | Source |
1 | | /* |
2 | | * |
3 | | * (C) 2013-26 - ntop.org |
4 | | * |
5 | | * |
6 | | * This program is free software; you can redistribute it and/or modify |
7 | | * it under the terms of the GNU General Public License as published by |
8 | | * the Free Software Foundation; either version 3 of the License, or |
9 | | * (at your option) any later version. |
10 | | * |
11 | | * This program is distributed in the hope that it will be useful, |
12 | | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 | | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
14 | | * GNU General Public License for more details. |
15 | | * |
16 | | * You should have received a copy of the GNU General Public License |
17 | | * along with this program; if not, write to the Free Software Foundation, |
18 | | * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
19 | | * |
20 | | */ |
21 | | |
22 | | #ifndef _BEHAVIOURAL_COUNTER_H_ |
23 | | #define _BEHAVIOURAL_COUNTER_H_ |
24 | | |
25 | | #include "ntop_includes.h" |
26 | | |
27 | | class BehaviouralCounter { |
28 | | protected: |
29 | | bool is_anomaly; |
30 | | u_int64_t tot_num_anomalies, last_lower, last_upper, last_value; |
31 | | |
32 | | public: |
33 | | /* Number of points to be used by the algorithm in the learning phase */ |
34 | 178k | BehaviouralCounter() { |
35 | 178k | is_anomaly = false, |
36 | 178k | tot_num_anomalies = last_lower = last_upper = last_value = 0; |
37 | 178k | } |
38 | 224k | virtual ~BehaviouralCounter() {}; |
39 | | |
40 | | /* |
41 | | In Parameters: |
42 | | - value The measurement to evaluate |
43 | | |
44 | | Return: |
45 | | true An anomaly has been detected (i.e. prediction < lower_bound, or |
46 | | prediction > upper_bound) false The value is within the expected range |
47 | | */ |
48 | 0 | virtual bool addObservation(u_int64_t value) { return (false); }; |
49 | 0 | inline u_int64_t getTotNumAnomalies() { return (tot_num_anomalies); }; |
50 | | |
51 | | /* Last measurement */ |
52 | 0 | inline bool anomalyFound() { return (is_anomaly); }; |
53 | 0 | inline u_int64_t getLastValue() { return (last_value); }; |
54 | 0 | inline u_int64_t getTotAnomalies() { return (tot_num_anomalies); }; |
55 | 0 | inline u_int64_t getLastLowerBound() { return (last_lower); }; |
56 | 0 | inline u_int64_t getLastUpperBound() { return (last_upper); }; |
57 | | }; |
58 | | |
59 | | #endif /* _BEHAVIOURAL_COUNTER_H_ */ |