def make_fig_13(): # if not os.path.exists(PLOTS_DIR): # os.makedirs(PLOTS_DIR) # if not os.path.exists('output'): # os.makedirs('output') for num_flows in [2, 20]: for congestion_alg in ['TCP','DCTCP']: out_q_file = congestion_alg + '_q_size.out' K = 20 link_cap = '100Mbps' link_delay = '0.25ms' # run NS-2 simulation print "debug: running %s congestion_alg k=%d ..." % (congestion_alg, K) os.system('ns ../../run_sim.tcl {0} {1} {2} {3} {4} {5}'.format(congestion_alg, out_q_file, num_flows, K, link_cap, link_delay)) # parse and plot queue size time, q_size = ns_tools.parse_qfile(os.path.join('./', out_q_file), t_min=4.0, t_max=9.0) plt_label = congestion_alg + '_' + str(num_flows) + '_flows' # Compute the CDF sorted_data = np.sort(q_size) yvals=np.arange(len(sorted_data))/float(len(sorted_data)-1) plt.plot(sorted_data, yvals, linestyle='-', marker='', label=plt_label) ns_tools.config_plot('queue size (packets)', 'Cumulative Fraction', 'Queue Length CDF', legend_loc='upper center') ns_tools.save_plot('figure_13', PLOTS_DIR) plt.cla()
def make_fig_14(): # if not os.path.exists(PLOTS_DIR): # os.makedirs(PLOTS_DIR) # if not os.path.exists('output'): # os.makedirs('output') for congestion_alg in ['TCP', 'DCTCP']: throughputs = [] # orginal step Ks = [i for i in range(1,2)] Ks += [i for i in range(4,11,3)] Ks += [i for i in range(15,35,5)] Ks += [i for i in range(40,101,10)] for K in Ks: out_q_file = congestion_alg + '_q_size.out' # run NS-2 simulation num_flows = 2 link_cap = '100Mbps' link_delay = '10ms' # run NS-2 simulation print "debug: running %s congestion_alg k=%d ..." % (congestion_alg, K) os.system('ns ../../run_sim.tcl {0} {1} {2} {3} {4} {5}'.format(congestion_alg, out_q_file, num_flows, K, link_cap, link_delay)) # Save throughput throughputs.append(1e-06 * ns_tools.parse_namfile(os.path.join('./', 'out.nam'), t_min=4.0, t_max=9.0)) plt.plot(Ks, throughputs, linestyle='-', marker='o', label=congestion_alg) ns_tools.config_plot('K', 'Throughput (Mbps)', 'Throughput over K') ns_tools.save_plot('figure_14', PLOTS_DIR) plt.cla()
def make_fig_1(): if not os.path.exists(PLOTS_DIR): os.makedirs(PLOTS_DIR) if not os.path.exists('tcl/out'): os.makedirs('tcl/out') for congestion_alg in ['TCP', 'DCTCP']: out_q_file = congestion_alg + '_q_size.out' # run NS-2 simulation num_flows = 2 K = 20 link_cap = '100Mbps' link_delay = '0.25ms' os.system('ns tcl/run_sim.tcl {0} {1} {2} {3} {4} {5}'.format( congestion_alg, out_q_file, num_flows, K, link_cap, link_delay)) # parse and plot queue size time, q_size = ns_tools.parse_qfile(os.path.join( 'tcl/out/', out_q_file), t_min=4.0, t_max=9.0) plt.plot(time, q_size, linestyle='-', marker='', label=congestion_alg) ns_tools.config_plot('time (sec)', 'queue size (packets)', 'Queue Size over Time') ns_tools.save_plot('figure_1', PLOTS_DIR) plt.cla()
def make_fig_1(): # if not os.path.exists(PLOTS_DIR): # os.makedirs(PLOTS_DIR) # if not os.path.exists('output'): # os.makedirs('output') for congestion_alg in ['TCP', 'DCTCP']: out_q_file = congestion_alg + '_q_size.out' # run NS-2 simulation K = 20 print "debug: running %s congestion_alg k=%d ..." % (congestion_alg, K) os.system('ns ../../run_sim.tcl {0} {1} {2} {3} {4} {5}'.format( congestion_alg, out_q_file, num_flows, K, link_cap, link_delay)) # parse and plot queue size time, q_size = ns_tools.parse_qfile(os.path.join('./', out_q_file), t_min=tmin, t_max=9.0) plt.plot(time, q_size, linestyle='-', marker='', label=congestion_alg) ns_tools.config_plot('time (sec)', 'queue size (packets)', 'Queue Size over Time') ns_tools.save_plot('figure_1', PLOTS_DIR) plt.cla()
def parse_logs(): t, t2 = ns_tools.get_throughputs(os.path.join('tcl/out/', 'out.nam')) for i, val in enumerate(t): plt.plot(t2, val, linestyle='-', marker='', label=i) ns_tools.config_plot('Time', 'Throughput (Mbps)', 'Convergence Test') ns_tools.save_plot('dctcp_figure_16', PLOTS_DIR)
def make_fig_12(): # if not os.path.exists(PLOTS_DIR): # os.makedirs(PLOTS_DIR) # if not os.path.exists('output'): # os.makedirs('output') # 链路大小 # congestion_algs=(os_getenv("congestion_algs")) congestion_algs = "DCTCP" #for congestion_alg in congestion_algs: for num_flows in [2, 10, 20]: congestion_alg = congestion_algs out_q_file = congestion_alg + '_q_size.out' # run NS-2 simulation # 调试绘图数据区间 tmin, tmax = 0.0, 3.0 # 正式绘图参数 tmin, tmax = 1.5, 2.0 K = 45 print "debug: running %s congestion_alg k=%d ..." % (congestion_alg, K) os.system('ns ../../run_sim.tcl {0} {1} {2} {3} {4} {5}'.format( congestion_alg, out_q_file, num_flows, K, link_cap, link_delay)) # parse and plot queue size time, q_size = ns_tools.parse_qfile(os.path.join('./', out_q_file), t_min=tmin, t_max=tmax) plt.ylim((0, 100)) plt.plot(time, q_size, linestyle='-', marker='', label=congestion_alg) ns_tools.config_plot('time (sec)', 'queue size (packets)', 'Queue Size over Time K=%d' % K) ns_tools.save_plot('figure_12_%d' % num_flows, PLOTS_DIR) plt.cla()