forked from ranbenbasat/RHHH
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrandhhh2D.h
60 lines (44 loc) · 1.38 KB
/
randhhh2D.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
/*
Implementation of the 2-dimensional Randomized Hierarchical Heavy Hitters algorithm (RHHH) for IP addresses
-Ran Ben Basat ([email protected]) 2017-05-25
-Based on the "Hierarchical Heavy Hitters with the Space Saving Algorithm" paper implementation by Thomas Steinke -- http://people.seas.harvard.edu/~tsteinke/hhh/
*/
#ifndef RANDHHH2D_H
#define RANDHHH2D_H
#define NUM_COUNTERS 25 //number of masks
#define MAX_DEPTH 5 //depth of masks lattice
#define MAX_DESCENDANTS 512 //maximum number of direct descendents of a given ip pair
#include "prng.h"
//make sure we are passing the right #def around
#ifndef DIMENSION2
#error Invalid dimension
#endif
#ifndef SEED
#define SEED 3421
#endif
#if VMULT>1
#define PROB
#endif
//still define things as in lossycount.h
#define LCLitem_t uint64__t
//The masks associated with the counters
//Note that we must ensure that they are in increasing order of generality
extern LCLitem_t masks[NUM_COUNTERS];
//initialise
#ifdef RANDHHH
void init(double SSepsilon, double prob);
#else
void init(double epsilon);
#endif
//deinitialise
void deinit();
void update(LCLitem_t item);
//struct to store a heavy hitter output
typedef struct heavyhitter {
LCLitem_t item; //The item
int mask; //The mask id
int upper, lower; //Upper and lower count bounds
} HeavyHitter;
//the two-dimensional output
HeavyHitter * output2(int threshold, int * numhitters);
#endif