Beispiel #1
0
def generate_flow_plot_data(input_file,
                            home_ip,
                            website='youtube.com',
                            is_incoming=True):
    stream_set = set()
    closed_set = set()
    start_timestamp = None
    connection_list = GaplessList()

    with open(input_file, 'rb') as csv_file:
        data_reader = csv.DictReader(csv_file, delimiter=',')
        for row in data_reader:
            # set start_timestamp if not set
            start_timestamp = float(
                row['timestamp']
            ) if start_timestamp is None else start_timestamp
            if website in row['website'] and row['protocol'] == 'TCP':
                if row['dst' if is_incoming else 'src'] == home_ip:
                    stream_id = make_stream_id(row)
                    if row['is_rst'] == 'False' and row[
                            'is_fin'] == 'False' and stream_id not in closed_set:
                        stream_set.add(stream_id)
                    else:
                        stream_set.discard(stream_id)
                        closed_set.add(stream_id)
                    packet_time = int(
                        float(row['timestamp']) - start_timestamp)
                    connection_list.set_element(packet_time, len(stream_set))
    return connection_list.get_list()
def generate_bitrate_plot_data(input_file, home_ip, website='youtube.com', is_incoming=True, protocols=None):
    if protocols is None:
        protocols = ['TCP']
    start_timestamp = None
    byte_rate_list = GaplessList(fill=0)

    with open(input_file, 'rb') as csv_file:
        data_reader = csv.DictReader(csv_file, delimiter=',')
        for row in data_reader:
            # set start_timestamp if not set
            start_timestamp = float(row['timestamp']) if start_timestamp is None else start_timestamp
            if website in row['website'] and (row['protocol'] in protocols):
                if row['dst' if is_incoming else 'src'] == home_ip:
                    packet_time = int(float(row['timestamp']) - start_timestamp)
                    byte_rate_list.increment_element(packet_time, int(row['len']))
    return byte_rate_list.get_list()
Beispiel #3
0
def generate_flow_plot_data(input_file, home_ip, website="youtube.com", is_incoming=True):
    stream_set = set()
    closed_set = set()
    start_timestamp = None
    connection_list = GaplessList()

    with open(input_file, "rb") as csv_file:
        data_reader = csv.DictReader(csv_file, delimiter=",")
        for row in data_reader:
            # set start_timestamp if not set
            start_timestamp = float(row["timestamp"]) if start_timestamp is None else start_timestamp
            if website in row["website"] and row["protocol"] == "TCP":
                if row["dst" if is_incoming else "src"] == home_ip:
                    stream_id = make_stream_id(row)
                    if row["is_rst"] == "False" and row["is_fin"] == "False" and stream_id not in closed_set:
                        stream_set.add(stream_id)
                    else:
                        stream_set.discard(stream_id)
                        closed_set.add(stream_id)
                    packet_time = int(float(row["timestamp"]) - start_timestamp)
                    connection_list.set_element(packet_time, len(stream_set))
    return connection_list.get_list()
Beispiel #4
0
def generate_bitrate_plot_data(input_file,
                               home_ip,
                               website='youtube.com',
                               is_incoming=True,
                               protocols=None):
    if protocols is None:
        protocols = ['TCP']
    start_timestamp = None
    byte_rate_list = GaplessList(fill=0)

    with open(input_file, 'rb') as csv_file:
        data_reader = csv.DictReader(csv_file, delimiter=',')
        for row in data_reader:
            # set start_timestamp if not set
            start_timestamp = float(
                row['timestamp']
            ) if start_timestamp is None else start_timestamp
            if website in row['website'] and (row['protocol'] in protocols):
                if row['dst' if is_incoming else 'src'] == home_ip:
                    packet_time = int(
                        float(row['timestamp']) - start_timestamp)
                    byte_rate_list.increment_element(packet_time,
                                                     int(row['len']))
    return byte_rate_list.get_list()