Exemplo n.º 1
0
def extract_resource_usage_plot_data(args):
    free_json_path = f"{args.prefix}/free_rusage.json"

    if not os.path.exists(free_json_path):
        free_json_path += ".xz"

    if not os.path.exists(free_json_path):
        logging.warning(
            f"Unable to find memory resource usage data at {free_json_path}.")
        return

    shadow_json_path = f"{args.prefix}/shadow_rusage.json"

    if not os.path.exists(shadow_json_path):
        shadow_json_path += ".xz"

    if not os.path.exists(shadow_json_path):
        logging.warning(
            f"Unable to find memory resource usage data at {shadow_json_path}."
        )
        return

    free_data = load_json_data(free_json_path)
    shadow_data = load_json_data(shadow_json_path)

    __extract_resource_usage(args, free_data, shadow_data)
Exemplo n.º 2
0
def __load_user_data(args):
    # geographical user info taken from stage command output, i.e., tor metrics
    user_data = load_json_data(args.user_info_path)

    country_codes = sorted(user_data.keys())
    country_probs = [float(user_data[code]) for code in country_codes]

    return country_codes, country_probs
Exemplo n.º 3
0
def get_relays(args):
    data = load_json_data(args.relay_info_path)

    relays = data['relays']
    stats = data['network_stats']

    # sample relays: take all relays that appeared in the input data, and select
    # a number that follows the median number of relays that are seen in a consensus.
    # this gives us the relays that would represent a full 100% Tor network
    sampled_relays, sampled_weights = __sample_relays(relays,
                                                      stats['med_count_total'])

    # log some info
    n_relays = len(sampled_relays['all'])
    total_capacity = sum([
        relay['bandwidth_capacity']
        for relay in sampled_relays['all'].values()
    ])
    gbit = total_capacity * 8.0 / 1000.0 / 1000.0 / 1000.0
    logging.info(
        "A full Tor network has {} relays with total capacity of {} Gbit/s".
        format(n_relays, gbit))

    # compute ratios of nodes for each position
    pos_ratios = {
        'g': len(sampled_relays['g']) / len(sampled_relays['all']),
        'e': len(sampled_relays['e']) / len(sampled_relays['all']),
        'ge': len(sampled_relays['ge']) / len(sampled_relays['all']),
        'm': len(sampled_relays['m']) / len(sampled_relays['all']),
    }

    # Now that we have a "full" Tor network, scale it down to the requested scale.
    n_relays_scaled = round(n_relays * args.network_scale)
    chosen_relays, divergence = __choose_relays(n_relays_scaled,
                                                sampled_relays,
                                                sampled_weights, pos_ratios)

    relay_count = len(chosen_relays['g']) + len(chosen_relays['e']) + len(
        chosen_relays['ge']) + len(chosen_relays['m'])
    logging.info("Chose {} of {} relays using scale factor {}".format(
        relay_count, n_relays, args.network_scale))

    # name the chosen relays
    relay_ctr = 1
    for pos in ['ge', 'e', 'g', 'm']:
        suffix = 'guard' if pos == 'g' else 'exit' if pos == 'e' else 'exitguard' if pos == 'ge' else 'middle'
        # use reverse to sort each class from fastest to slowest when assigning the id counter
        for (fp, relay) in sorted(chosen_relays[pos].items(),
                                  key=lambda kv: kv[1]['weight'],
                                  reverse=True):
            relay['nickname'] = "relay{}{}".format(relay_ctr, suffix)
            relay_ctr += 1

    return chosen_relays, relay_count
Exemplo n.º 4
0
def __load_torperf_datasets(torperf_argset):
    torperf_dbs = []

    if torperf_argset != None:
        for torperf_args in torperf_argset:
            torperf_db = {
                'dataset': load_json_data(torperf_args[0]) if torperf_args[0] != None else None,
                'label': torperf_args[1] if torperf_args[1] != None else "Public Tor",
                'color': torperf_args[2],
            }
            torperf_dbs.append(torperf_db)

    return torperf_dbs
Exemplo n.º 5
0
def __load_tornet_datasets(args, filename):
    tornet_dbs = []

    print(args.labels)
    label_cycle = cycle(args.labels) if args.labels != None else None
    color_cycle = cycle(args.colors) if args.colors != None else None

    if args.tornet_collection_path != None:
        for collection_dir in args.tornet_collection_path:
            tornet_db = {
                'dataset': [load_json_data(p) for p in find_matching_files_in_dir(collection_dir, filename)],
                'label': next(label_cycle) if label_cycle != None else os.path.basename(collection_dir),
                'color': next(color_cycle) if color_cycle != None else None,
            }
            tornet_dbs.append(tornet_db)

    return tornet_dbs
Exemplo n.º 6
0
def extract_oniontrace_plot_data(args):
    json_path = f"{args.prefix}/oniontrace.analysis.json"

    if not os.path.exists(json_path):
        json_path += ".xz"

    if not os.path.exists(json_path):
        logging.warning(
            f"Unable to find oniontrace analysis data at {json_path}.")
        return

    data = load_json_data(json_path)

    # parse performance stats only after the network has reached steady state
    startts, stopts = args.converge_time, -1 if args.run_time < 0 else args.converge_time + args.run_time

    __extract_circuit_build_times(args, data, startts, stopts)
    __extract_relay_tput(args, data, startts, stopts)
Exemplo n.º 7
0
def extract_oniontrace_plot_data(args):
    json_path = f"{args.prefix}/oniontrace.analysis.json"

    if not os.path.exists(json_path):
        json_path += ".xz"

    if not os.path.exists(json_path):
        logging.warning(
            f"Unable to find oniontrace analysis data at {json_path}.")
        return

    data = load_json_data(json_path)

    # skip the first 20 minutes to allow the network to reach steady state
    startts, stopts = 1200, -1

    __extract_circuit_build_times(args, data, startts, stopts)
    __extract_relay_tput(args, data, startts, stopts)
Exemplo n.º 8
0
def extract_tgen_plot_data(args):
    json_path = f"{args.prefix}/tgen.analysis.json"

    if not os.path.exists(json_path):
        json_path += ".xz"

    if not os.path.exists(json_path):
        logging.warning(f"Unable to find tgen analysis data at {json_path}.")
        return

    data = load_json_data(json_path)

    # skip the first 20 minutes to allow the network to reach steady state
    startts, stopts = 1200, -1

    __extract_round_trip_time(args, data, startts, stopts)
    __extract_download_time(args, data, startts, stopts)
    __extract_error_rate(args, data, startts, stopts)
    __extract_client_goodput(args, data, startts, stopts)
Exemplo n.º 9
0
def extract_tgen_plot_data(args):
    json_path = f"{args.prefix}/tgen.analysis.json"

    if not os.path.exists(json_path):
        json_path += ".xz"

    if not os.path.exists(json_path):
        logging.warning(f"Unable to find tgen analysis data at {json_path}.")
        return

    data = load_json_data(json_path)

    # parse performance stats only after the network has reached steady state
    startts, stopts = args.converge_time, -1 if args.run_time < 0 else args.converge_time + args.run_time

    __extract_round_trip_time(args, data, startts, stopts)
    __extract_download_time(args, data, startts, stopts)
    __extract_error_rate(args, data, startts, stopts)
    __extract_client_goodput(args, data, startts, stopts)