Tweaked the timing of flow expiration.
[distributedratelimiting.git] / drl / raterouter.h
1 /* See the DRL-LICENSE file for this file's software license. */
2
3 #ifndef _RATEROUTER_H_
4 #define _RATEROUTER_H_
5
6 #define _XOPEN_SOURCE 600 /* for pthread_rwlock_t */
7
8 #include <stdio.h>
9 #include <stdlib.h>
10 #include <netinet/in_systm.h>
11 #include <netinet/in.h>
12 #include <netinet/ip.h>
13 #include <netinet/tcp.h>
14 #include <netinet/udp.h>
15
16 #include <sys/types.h>
17 #include <sys/socket.h>
18 #include <sys/time.h>
19 #include <sys/un.h>
20 #include <sys/poll.h>
21
22 #include <arpa/inet.h>
23 #include <time.h>
24 #include <signal.h>
25 #include <math.h>
26 #include <limits.h>
27
28 #include <pthread.h>
29 #include <unistd.h>
30
31 #include <netdb.h>
32 #include <ifaddrs.h>  /* defines getifaddrs */
33 #include <string.h>
34
35 enum policies { POLICY_GRD = 1, POLICY_FPS = 2 };
36 enum commfabrics { COMM_MESH = 1, COMM_GOSSIP = 2 };
37 enum accountings { ACT_STANDARD = 1, ACT_SAMPLEHOLD = 2, ACT_SIMPLE = 3 };
38
39 /* The comm library also has definitions for comfabrics. This prevents us
40  * from defining them twice. */
41 #define COMM_DEFS
42
43 /* global constants */
44 #define IDENT_CLEAN_INTERVAL 10 /* in seconds */
45
46 #define LIMITER_LISTEN_PORT 9001
47
48 /**
49  * The weight percentage increase that must occur before FPS does increase
50  * dampening.
51  */
52 #define LARGE_INCREASE_PERCENTAGE (0.05)
53
54 /**
55  * Below this rate, a limiter is basically treated as idle, and its limit is
56  * raised to allow for increases should the limiter suddenly become active.
57  *
58  * This is used for FPS only.  See estimate.c
59  */
60 #define FLOW_START_THRESHOLD (6000)
61
62 #define CLOSE_ENOUGH (0.99)
63
64 /**
65  * All fields come from the ip protocol header.
66  *
67  * 1 byte for the protocol.
68  * 4 bytes for the source ip.
69  * 4 bytes for the destination ip.
70  * 2 bytes for the source port.
71  * 2 bytes for the destination port.
72  *
73  * 4+4+2+2+1 = 13.
74  */
75 #define FLOWKEYSIZE (13)
76
77 /* forward declare some structs */
78 struct limiter;
79 struct identity;
80
81 /* prototypes for threaded processing DRL model */
82 void handle_estimation(void *arg);
83
84 #endif