Reincarnated GRD. Changed mesh decay to go to 1/N rather than 0.
[distributedratelimiting.git] / drl / simple.h
1 /* See the DRL-LICENSE file for this file's software license. */
2
3 /**
4  * Defines the simplest flow accouting table.  It only keeps track of
5  * aggregate rate information in the common table.  It does no
6  * individual flow accounting.
7  *
8  */
9
10 #ifndef _SIMPLE_ACCOUNTING_H_
11 #define _SIMPLE_ACCOUNTING_H_
12
13 #include <inttypes.h>
14
15 /** The "table" that stores the aggregate information.  It's constructed of two
16  * main pieces.
17  */
18 struct sim_flow_table {
19
20     /* Pointer to the common flow information for the identity that owns this
21      * sampled flow table.  This is updated with aggregate information. */
22     common_accounting_t *common;
23
24     uint32_t (*hash_function)(const key_flow *key);
25
26 };
27
28 typedef struct sim_flow_table *simple_flow_table;
29
30 /**
31  * Creates a new table.  Note that the hash function is never used by this type
32  * of table.
33  *
34  * Returns the new table or NULL on failure.
35  */
36 simple_flow_table simple_table_create(common_accounting_t *common);
37
38 /**
39  * Destroys the specified table.
40  */
41 void simple_table_destroy(simple_flow_table table);
42
43 /**
44  * Updates the state of the table given a newly acquired packet.
45  *
46  * This function will always return zero because this type of table stores no
47  * flow information.
48  */
49 int simple_table_sample(simple_flow_table table, const key_flow *key);
50
51 /** Cleans the table.  This is a no-op for this type of table. */
52 int simple_table_cleanup(simple_flow_table table);
53
54 /** Updates the aggregate rate information. */
55 void simple_table_update_flows(simple_flow_table table, struct timeval now,
56 double ewma_weight);
57
58 #endif  /* _SIMPLE_ACCOUNTING_H_ */