示例#1
0
def smallest_continent_probe_rtt_finder():
    path_to_store = os.path.join(FIGURE_PATH, 'Histogram', 'Smallest_RTT')
    try:
        os.stat(path_to_store)
    except:
        os.makedirs(path_to_store)

    start_index = min(probe_index_dict.values())
    stop_index = max(probe_index_dict.values()) + 1

    continent_probe_smallest_rtt_dict = {}
    report= ''
    if GENERATE_TYPE == 'ping':
        report = RTT_REPORT
    elif GENERATE_TYPE == 'traceroute':
        report = TRACEROUTE_REPORT

    with open(report) as rtt_report:
        next(rtt_report)
        for line in rtt_report:
            lines = [j.strip() for j in line.split(";")]
            temp_list = [float(k) for k in lines[start_index:stop_index]]

            for i in mt.minimum_value_index_explorer(temp_list):
                if lines[-1] not in continent_probe_smallest_rtt_dict.keys():
                    continent_probe_smallest_rtt_dict[lines[-1]] = {}
                    if index_probe_dict[i+2] not in continent_probe_smallest_rtt_dict[lines[-1]].keys():
                        continent_probe_smallest_rtt_dict[lines[-1]][index_probe_dict[i+2]] = 1
                else:
                    if index_probe_dict[i+2] not in continent_probe_smallest_rtt_dict[lines[-1]].keys():
                        continent_probe_smallest_rtt_dict[lines[-1]][index_probe_dict[i + 2]] = 1
                    else:
                     continent_probe_smallest_rtt_dict[lines[-1]][index_probe_dict[i + 2]] += 1

    smallest_rtt_percentage = {}
    for continent in continent_probe_smallest_rtt_dict.keys():
        if continent not in smallest_rtt_percentage.keys():
            smallest_rtt_percentage[continent] = {}
            for probe in continent_probe_smallest_rtt_dict[continent].keys():
                smallest_rtt_percentage[continent][probe] = float(continent_probe_smallest_rtt_dict[continent][probe])/float(sum(continent_probe_smallest_rtt_dict[continent].values()))

    df = pd.DataFrame(paa.reverse_dict_keys(smallest_rtt_percentage))
    df.plot(kind='bar')
    plt.xlabel(r"\textrm{Continents of requested destinations}", font)
    plt.ylabel(r"\textrm{Percentage}", font)
    plt.xticks(fontsize=30, fontname="Times New Roman")
    plt.yticks(fontsize=30, fontname="Times New Roman")
    plt.legend(loc='best', fontsize=30)
    if GENERATE_TYPE == 'ping':
        plt.savefig(os.path.join(path_to_store, 'Smallest_{0}_{1}(RTT)_proporation.eps'.format(CALCULATE_TYPE, RTT_TYPE)), dpi=300, transparent=True)
    elif GENERATE_TYPE == 'traceroute':
        plt.savefig(os.path.join(path_to_store, 'Smallest_hops_num_proporation.eps'.format(CALCULATE_TYPE, RTT_TYPE)), dpi=300, transparent=True)
    plt.close()

    print smallest_rtt_percentage
    print continent_probe_smallest_rtt_dict
    return continent_probe_smallest_rtt_dict
示例#2
0
def plot_probe_dest_rtt_geo():
    path_to_store = os.path.join(FIGURE_PATH, 'Bar', 'RTT_of_dest_by_probe', '{0}_{1}(RTT)'.format(CALCULATE_TYPE, RTT_TYPE))
    try:
        os.stat(path_to_store)
    except:
        os.makedirs(path_to_store)

    continent_probe_rtt_dict = get_probe_continent_rtt()
    probe_continent_rtt_dict = paa.reverse_dict_keys(continent_probe_rtt_dict)

    for probe in probe_continent_rtt_dict.keys():
        temp_list_to_plot = []
        geo_list = []
        xticks_list = []
        xticks_label_list = []
        for continent in probe_continent_rtt_dict[probe].keys():
            xticks_label_list.append('{0}:\n{1}'.format(continent,len(probe_continent_rtt_dict[probe][continent])))
            temp_list_to_plot.extend(probe_continent_rtt_dict[probe][continent])
            geo_list.append(len(temp_list_to_plot))
            plt.axvline(geo_list[-1], linewidth=5, color='gray', linestyle='--')
            if len(geo_list) > 1:
                xticks_list.append(geo_list[-2]+0.5*(geo_list[-1]-geo_list[-2]))
            else:
                xticks_list.append(0.5 * geo_list[-1])



        print "geo_list:", geo_list
        print "xticks_list:", xticks_list
        plt.bar(range(len(temp_list_to_plot)),temp_list_to_plot, color='yellow')
        plt.xlim(min(range(len(temp_list_to_plot))), max(range(len(temp_list_to_plot))))
        plt.xlabel(r"\textrm{Destinations}", font)
        plt.ylabel(r"\textrm{RTT (ms)}", font)
        plt.xticks(xticks_list, xticks_label_list, fontsize=20, fontname="Times New Roman")
        plt.yticks(fontsize=30, fontname="Times New Roman")
        plt.legend(loc='best', fontsize=30)
        plt.savefig(os.path.join(path_to_store, 'RTT_from_all_dest_for_{0}.eps'.format(probe)), dpi=300, transparent=True)
        plt.close()
示例#3
0
def proporation_rtt_probe_geo(target_file):

    return paa.reverse_dict_keys(proporation_rtt_geo_probe(target_file))