1 /* See the DRL-LICENSE file for this file's software license. */
3 /** Defines a structure that is common to all of the flow accounting
4 * mechanisms. This includes the aggregate rate and the time it was last
7 #ifndef _COMMON_ACCOUNTING_H_
8 #define _COMMON_ACCOUNTING_H_
14 /** Representation of a flow that is to be used as a key into the table. */
15 typedef struct key_flow {
17 /* Identification information. Some or all of this information is used
18 * by the accounting table hash functions to identify flows. */
20 /** The source IP address. */
23 /** The destination IP address. */
26 /** The source TCP/UDP port. */
29 /** The destination TCP/UDP port. */
32 /** The value of the IP header protocol field. */
36 * Packet information. This is not used by the accounting tables for
37 * hashing, but is useful when sampling a new packet.
40 /** The size of the packet (in bytes). */
43 /** The time at which the packet was sent. */
49 * This structure is used to store information common to all flow accounting
50 * mechanisms. It includes the aggregate rate information that will be read
51 * by the estimation and allocation functions.
54 /** The best estimate of the rate for the current estimate interval. This
55 * includes EWMA smoothing. */
58 /** The best estimate of the rate for the previous estimate inteval. This
59 * includes EWMA smoothing. */
62 /** The instantaneous rate for the current estimate interval.*/
65 /** The instantaneous rate for the previous estimate interval.*/
66 uint32_t last_inst_rate;
68 /** The rate of the largest flow being tracked by the table. */
69 uint32_t max_flow_rate;
71 /** The time at which this structure was last updated. */
72 struct timeval last_update;
74 /** The number of bytes sent since the last_update time. */
77 /* Statistics below. */
79 /** The current number of flows. */
82 /** The number of flows sending above 5KB/s. */
83 uint32_t num_flows_5k;
85 /** The number of flows sending above 10KB/s. */
86 uint32_t num_flows_10k;
88 /** The number of flows sending above 20KB/s. */
89 uint32_t num_flows_20k;
91 /** The number of flows sending above 50KB/s. */
92 uint32_t num_flows_50k;
94 /** The average flow rate. */
97 } common_accounting_t;
99 /** Determines the difference between two timeval structs (in seconds, with
101 #define timeval_subtract(big, small) ((double) (big.tv_sec - small.tv_sec) + (big.tv_usec - small.tv_usec) / 1000000.0)
103 #endif /* _COMMON_ACCOUNTING_H_ */