Ejemplo n.º 1
0
def get_sketch(sketch_type, hash_length, columns, rows, random_generator):
    if sketch_type == 'AGMS':
        if hash_length == 8:
            sketch = sketches.AGMS8(columns, rows, random_generator)
        elif hash_length == 16:
            sketch = sketches.AGMS16(columns, rows, random_generator)
        elif hash_length == 32:
            sketch = sketches.AGMS32(columns, rows, random_generator)
        elif hash_length == 64:
            sketch = sketches.AGMS64(columns, rows, random_generator)
        elif hash_length == 128:
            sketch = sketches.AGMS128(columns, rows, random_generator)
        else:
            raise AttributeError('Hash length not valid: %i' % hash_length)
    elif sketch_type == 'FAGMS':
        if hash_length == 8:
            sketch = sketches.FAGMS8(columns, rows, random_generator)
        elif hash_length == 16:
            sketch = sketches.FAGMS16(columns, rows, random_generator)
        elif hash_length == 32:
            sketch = sketches.FAGMS32(columns, rows, random_generator)
        elif hash_length == 64:
            sketch = sketches.FAGMS64(columns, rows, random_generator)
        elif hash_length == 128:
            sketch = sketches.FAGMS128(columns, rows, random_generator)
        else:
            raise AttributeError('Hash length not valid: %i' % hash_length)
    elif sketch_type == 'FastCount':
        if hash_length == 8:
            sketch = sketches.FastCount8(columns, rows, random_generator)
        elif hash_length == 16:
            sketch = sketches.FastCount16(columns, rows, random_generator)
        elif hash_length == 32:
            sketch = sketches.FastCount32(columns, rows, random_generator)
        elif hash_length == 64:
            sketch = sketches.FastCount64(columns, rows, random_generator)
        elif hash_length == 128:
            sketch = sketches.FastCount128(columns, rows, random_generator)
        else:
            raise AttributeError('Hash length not valid: %i' % hash_length)
    elif sketch_type == 'CountMin':
        if hash_length == 8:
            sketch = sketches.CountMin8(columns, rows, random_generator)
        elif hash_length == 16:
            sketch = sketches.CountMin16(columns, rows, random_generator)
        elif hash_length == 32:
            sketch = sketches.CountMin32(columns, rows, random_generator)
        elif hash_length == 64:
            sketch = sketches.CountMin64(columns, rows, random_generator)
        elif hash_length == 128:
            sketch = sketches.CountMin128(columns, rows, random_generator)
        else:
            raise AttributeError('Hash length not valid: %i' % hash_length)
    else:
        raise AttributeError('Sketch type not valid: %s' % sketch_type)
    return sketch
Ejemplo n.º 2
0
def get_sketch(hash_length, columns, rows, random_generator):
    if hash_length == 8:
        sketch = sketches.FastCount8(columns, rows, random_generator)
    elif hash_length == 16:
        sketch = sketches.FastCount16(columns, rows, random_generator)
    elif hash_length == 32:
        sketch = sketches.FastCount32(columns, rows, random_generator)
    elif hash_length == 64:
        sketch = sketches.FastCount64(columns, rows, random_generator)
    elif hash_length == 128:
        sketch = sketches.FastCount128(columns, rows, random_generator)
    else:
        raise AttributeError('Hash length not valid: %i' % hash_length)
    return sketch
Ejemplo n.º 3
0
globals().update(vars(parser.parse_args()))

pcap = "pcaps/morning_sagunt.pcap"
local_mac = "dc:9f:db:08:89:71"
local_address = "fe80::de9f:dbff:fe08:8971"
pattern = 'morning_sagunt'
interval = 5.
num_cols = 32
num_rows = 32
captured_length = 94

neigh_in = dict()
neigh_out = dict()
local_in = dict()
local_out = dict()
sketch = sketches.FastCount32(num_cols, num_rows, 'cw4')
net_sketch = NetworkSketch(sketch)
for neighbor in neighbors:
    neigh_in[neighbor] = net_sketch.copy()
    neigh_out[neighbor] = net_sketch.copy()
    local_in[neighbor] = net_sketch.copy()
    local_out[neighbor] = net_sketch.copy()

results = []
pkts = PcapReader(pcap)
next_interval = pkts.next().time + interval
pkts.close()
pkts = PcapReader(pcap)
global_in = net_sketch.copy()
global_out = net_sketch.copy()
i = -1