def test_pkt_loss_analysis(): trial_name = '8_7_2018_1533690234' hm = mapper.HostMapper([cfg.dns_server_ip], cfg.of_controller_ip, cfg.of_controller_port) of_proc = ofp.OFProcessor(cfg.of_controller_ip, cfg.of_controller_port) st_proc = stp.StatsProcessor(hm, of_proc) st_proc.calc_loss_rates(trial_name)
def plot_test(): of_proc = ofp.OFProcessor(cfg.of_controller_ip, cfg.of_controller_port) hm = mapper.HostMapper([cfg.dns_server_ip], cfg.of_controller_ip, cfg.of_controller_port) st_proc = stp.StatsProcessor(hm, of_proc) grapher = stp.Grapher() trial_name = read_trial_name('./name_hints.txt') tx_file = './tx_stats.p' rx_file = './rx_stats.p' tx_stats = pickle.load(open(tx_file, 'rb')) rx_stats = pickle.load(open(rx_file, 'rb')) stats_list = st_proc.calc_link_util_per_t(tx_stats, cfg.pkt_size, cfg.time_slice, stp.Units.MegaBitsPerSecond) stats_avg = st_proc.calc_link_util(tx_stats, cfg.pkt_size, cfg.time_slice, stp.Units.MegaBitsPerSecond) stats_loss = st_proc.calc_loss_rates(read_trial_name('./name_hints.txt')) stats_uplink = st_proc.calc_ingress_util_per_t(rx_stats, cfg.pkt_size, cfg.time_slice, stp.Units.MegaBitsPerSecond) stats_tput = st_proc.calc_flow_rate(trial_name, cfg.pkt_size, cfg.sample_freq, cfg.trial_length) grapher.graph_util_over_time(stats_list, 'util_per_ts', show_plot=True) fig, ax = plt.subplots(1, 1) grapher.graph_loss_cdf(ax, stats_loss, 'loss_plot') fig.savefig('loss_plot.png') grapher.graph_util_over_time(stats_uplink, 'uplink_ports')
def print_loss_array(hm, of_proc, trial_length): trial_name = read_trial_name('./name_hints.txt') st_proc = stp.StatsProcessor(hm, of_proc) loss_dict = st_proc.calc_loss_rates(trial_name) loss_arr = [ v for d1 in loss_dict.values() for d2 in d1.values() for v in d2.values() ] p.pprint(loss_arr)
def print_local_loss(): st_proc = stp.StatsProcessor(None, None, '/home/alexj/packet_counts/') trial_name = '' print('LOSS RATES') p.pprint(st_proc.calc_loss_rates(trial_name)) print( '*******************************************************************') print('GOODPUT FOR FLOWS') p.pprint( st_proc.calc_flow_rate(trial_name, cfg.pkt_size, cfg.sample_freq, cfg.trial_length)) print( '*******************************************************************')
def test_stats_processor(hm, of_proc, trial_length): trial_name = read_trial_name('./name_hints.txt') tx_file = './tx_stats.p' rx_file = './rx_stats.p' stats = pickle.load(open(tx_file, 'rb')) rx_stats = pickle.load(open(rx_file, 'rb')) st_proc = stp.StatsProcessor(hm, of_proc) # p.pprint(stats) st_dict = st_proc.calc_link_util(stats, cfg.pkt_size, cfg.sample_freq, units=stp.Units.MegaBitsPerSecond) ingress_flows_dict = st_proc.calc_ingress_util( rx_stats, cfg.pkt_size, cfg.sample_freq, units=stp.Units.MegaBitsPerSecond) egress_flows_dict = st_proc.calc_ingress_util( stats, cfg.pkt_size, cfg.sample_freq, units=stp.Units.MegaBitsPerSecond) print( '*******************************************************************') print('CORE LINK UTILIZATION') #p.pprint(st_dict) print('test_driver: ' + str(st_dict)) print( '*******************************************************************') print('HOST UPLINK UTILIZATION') #p.pprint(ingress_flows_dict) print('test_driver: ' + str(ingress_flows_dict)) print( '*******************************************************************') print('HOST EGRESS UTILIZATION') #p.pprint(egress_flows_dict) print('test_driver: ' + str(egress_flows_dict)) print( '*******************************************************************') print('LOSS RATES') #p.pprint(st_proc.calc_loss_rates(trial_name)) print('test_driver: ' + str(st_proc.calc_loss_rates(trial_name))) print( '*******************************************************************') print('GOODPUT FOR FLOWS') #p.pprint(st_proc.calc_flow_rate(trial_name, cfg.pkt_size, cfg.sample_freq, trial_length)) print( st_proc.calc_flow_rate(trial_name, cfg.pkt_size, cfg.sample_freq, trial_length)) print( '*******************************************************************')
def gen_lossplot(input_files): of_proc = ofp.OFProcessor(cfg.of_controller_ip, cfg.of_controller_port) hm = mapper.HostMapper([cfg.dns_server_ip], cfg.of_controller_ip, cfg.of_controller_port) st_proc = stp.StatsProcessor(hm, of_proc) grapher = stp.Grapher() fig, ax = plt.subplots(1, 1) stats_avg = [] for i, f in enumerate(input_files): trial_name = f + '/name_hints.txt' loss_stats = st_proc.calc_loss_rates(read_trial_name(trial_name)) grapher.graph_loss_cdf(ax, loss_stats, f) legend = ax.legend(loc='bottom right', shadow=True, fontsize='medium') plt.show()
def calc_stats_list(): trial_name = read_trial_name('./name_hints.txt') hm = mapper.HostMapper([cfg.dns_server_ip], cfg.of_controller_ip, cfg.of_controller_port) tx_file = './tx_stats.p' rx_file = './rx_stats.p' stats = pickle.load(open(tx_file, 'rb')) rx_stats = pickle.load(open(rx_file, 'rb')) of_proc = ofp.OFProcessor(cfg.of_controller_ip, cfg.of_controller_port) st_proc = stp.StatsProcessor(hm, of_proc) st_dict = st_proc.calc_link_util_per_t(stats, cfg.pkt_size, cfg.sample_freq, units=stp.Units.MegaBitsPerSecond) p.pprint(st_dict)
def print_util_array(hm, of_proc, trial_length): tx_file = './tx_stats.p' tx_stats = pickle.load(open(tx_file, 'rb')) st_proc = stp.StatsProcessor(hm, of_proc) st_dict = st_proc.calc_link_util(tx_stats, cfg.pkt_size, cfg.sample_freq, units=stp.Units.MegaBitsPerSecond) # Print link utilization as a list of percentages. ordered = defaultdict(float) for src, d in st_dict.items(): for dst, util in d.items(): k = (src, dst) if src < dst else (dst, src) ordered[k] = ordered[k] + util util_arr = [v for v in ordered.values()] p.pprint(util_arr)
def gen_boxplot(input_files): of_proc = ofp.OFProcessor(cfg.of_controller_ip, cfg.of_controller_port) hm = mapper.HostMapper([cfg.dns_server_ip], cfg.of_controller_ip, cfg.of_controller_port) st_proc = stp.StatsProcessor(hm, of_proc) grapher = stp.Grapher() fig, ax = plt.subplots(1, 1) stats_avg = [] for i, f in enumerate(input_files): stat_path = f + '/tx_stats.p' tx_stats = pickle.load(open(stat_path, 'rb')) link_util = st_proc.calc_link_util(tx_stats, cfg.pkt_size, cfg.time_slice, stp.Units.MegaBitsPerSecond) flat = [util for v in link_util.values() for util in v.values()] stats_avg.append(flat) grapher.graph_timeframes(ax, stats_avg, input_files) plt.show() fig, ax = plt.subplots(1, 1) stats_avg = [] for i, f in enumerate(input_files): stat_path = f + '/tx_stats.p' tx_stats = pickle.load(open(stat_path, 'rb')) trial_name = read_trial_name(f + '/name_hints.txt') flow_rate = st_proc.calc_flow_rate(trial_name, cfg.pkt_size, cfg.sample_freq, cfg.trial_length) flat = [ rate for v in flow_rate.values() for u in v.values() for rate in u.values() ] stats_avg.append(flat) grapher.graph_timeframes(ax, stats_avg, input_files) plt.show()