def default_gfi(cp_num): cpNetworks = [] ispTopo = Topology('isp_network', './data/topologies/simple.graphml') for i in range(cp_num): cpNetworks.append( CpNetwork('Abilene', './data/topologies/Abilene.graphml')) trafficMatrix = {} for i in range(cp_num): trafficMatrix[i] = cpNetworks[i].egress_volume_shortest([0, 1], ispTopo) ispNet = IspNetwork('isp_network', './data/topologies/simple.graphml') pptc, throughput = ispNet.calc_path_shortest(trafficMatrix) ingress_bw_dict = {} for i in range(cp_num): ingress_bw_dict[i] = {} for tc, paths in pptc.iteritems(): for path in paths: nodes = path.getNodes() ingress = nodes[0] if ingress in ingress_bw_dict[tc.network_id]: ingress_bw_dict[tc.network_id][ingress] += path.bw else: ingress_bw_dict[tc.network_id][ingress] = path.bw for id, bw_dict in ingress_bw_dict.iteritems(): print "test network id:{}".format(id) for ingress, bw in bw_dict.iteritems(): print '{}:{}'.format(ingress, bw) pptc_dict = {} for i in range(cp_num): pptc_dict[i] = {} for tc, paths in pptc.iteritems(): pptc_dict[tc.network_id][copy.deepcopy(tc)] = copy.deepcopy(paths) pptc_iso_dict = {} for i in range(cp_num): ispNet_local = IspNetwork('isp_network', './data/topologies/simple.graphml') tm = {} pptc_iso_dict[i] = {} tm.update({i: trafficMatrix[i]}) pptc, throughput = ispNet_local.calc_path_shortest(tm) for tc, paths in pptc.iteritems(): pptc_iso_dict[i][copy.deepcopy(tc)] = copy.deepcopy(paths) gfi = calc_gfi(pptc_dict, pptc_iso_dict, cp_num, ispNet) #log to file with open(DEFAULT_LOG_DIR, 'a') as f: f.write(str(gfi)) f.write('\n') #f.write('default routing \n') '''for id, bw_dict in ingress_bw_dict.iteritems():
def independent_gfi(cp_num): cpNets = [] ispTopo = Topology('isp_network', './data/topologies/simple.graphml') for i in range(cp_num): cpNets.append(CpNetwork('Abilene', './data/topologies/Abilene.graphml')) trafficMatrix = {} for i in range(cp_num): trafficMatrix[i] = cpNets[i].egress_max_throughput(10000, ispTopo) ispNet = IspNetwork('isp_network', './data/topologies/simple.graphml') pptc, throughput = ispNet.calc_path_maxminfair(trafficMatrix) pptc_dict = {} for i in range(cp_num): pptc_dict[i] = {} for tc, paths in pptc.iteritems(): pptc_dict[tc.network_id][copy.deepcopy(tc)] = copy.deepcopy(paths) pptc_iso_dict = {} for i in range(cp_num): ispNet_local = IspNetwork('isp_network', './data/topologies/simple.graphml') tm = {} pptc_iso_dict[i] = {} tm.update({i: trafficMatrix[i]}) pptc, throughput = ispNet_local.calc_path_shortest(tm) for tc, paths in pptc.iteritems(): print tc print paths pptc_iso_dict[i][copy.deepcopy(tc)] = copy.deepcopy(paths) gfi = calc_gfi(pptc_dict, pptc_iso_dict, cp_num, ispNet) ingress_bw_dict = {} for i in range(cp_num): ingress_bw_dict[i] = {} for tc, paths in pptc.iteritems(): for path in paths: nodes = path.getNodes() ingress = nodes[0] if ingress in ingress_bw_dict[tc.network_id]: ingress_bw_dict[tc.network_id][ingress] += path.bw else: ingress_bw_dict[tc.network_id][ingress] = path.bw for id, bw_dict in ingress_bw_dict.iteritems(): print 'network id:{}'.format(id) for ingress, bw in bw_dict.iteritems(): print '{}:{}'.format(ingress, bw) with open(INDEPENDENT_LOG_DIR, 'a') as f: f.write(str(gfi)) f.write('\n') '''f.write('independent routing\n')
def default_routing(cp_num): cpNetworks = [] ispTopo = Topology('isp_network', ISP_TOPO_DIR) for i in range(cp_num): cpNetworks.append(CpNetwork('Abilene', CP_TOPO_DIR)) trafficMatrix = {} for i in range(cp_num): trafficMatrix[i] = cpNetworks[i].egress_volume_shortest([0, 1], ispTopo) ispNet = IspNetwork('isp_network', ISP_TOPO_DIR) ispNet.linkcaps = set_link_caps(ispNet.topo) pptc, throughput = ispNet.calc_path_shortest(trafficMatrix) ingress_bw_dict = {} for i in range(cp_num): ingress_bw_dict[i] = {} for tc, paths in pptc.iteritems(): for path in paths: nodes = path.getNodes() ingress = nodes[0] if ingress in ingress_bw_dict[tc.network_id]: ingress_bw_dict[tc.network_id][ingress] += path.bw else: ingress_bw_dict[tc.network_id][ingress] = path.bw for id, bw_dict in ingress_bw_dict.iteritems(): print "network id:{}".format(id) for ingress, bw in bw_dict.iteritems(): print '{}:{}'.format(ingress, bw) #log to file with open(DEFAULT_LOG_DIR, 'a') as f: f.write(str(throughput)) f.write('\n') '''f.write('default routing \n')
def negotiate_gfi(cp_num): cpNets = [] ispTopo = Topology('isp_network', './data/topologies/simple.graphml') for i in range(cp_num): cpNets.append(CpNetwork('Abilene', './data/topologies/Abilene.graphml')) trafficMatrix = {} for i in range(cp_num): trafficMatrix[i] = cpNets[i].egress_all(10000, ispTopo) ispNet = IspNetwork('isp_network', './data/topologies/simple.graphml') egress_bw_dict, throughput = ispNet.calc_path_singleinput( 10000, trafficMatrix, cp_num) '''with open(NEGO_LOG_DIR, 'a') as f: f.write('first isp throughput:{}\n'.format(throughput)) for id, bw_dict in egress_bw_dict.iteritems(): f.write('cp network:{}\n'.format(id)) for egress, bw in bw_dict.iteritems(): f.write('egress:{} bw:{}\n'.format(egress, bw)) ''' trafficMatrix = {} for id, bw_dict in egress_bw_dict.iteritems(): trafficMatrix[id] = cpNets[id].egress_ratio(10000, ispTopo, bw_dict) pptc, throughput = ispNet.calc_path_maxminfair(trafficMatrix) pptc_dict = {} for i in range(cp_num): pptc_dict[i] = {} for tc, paths in pptc.iteritems(): pptc_dict[tc.network_id][copy.deepcopy(tc)] = copy.deepcopy(paths) pptc_iso_dict = {} for i in range(cp_num): ispNet_local = IspNetwork('isp_network', './data/topologies/simple.graphml') tm = {} pptc_iso_dict[i] = {} tm.update({i: trafficMatrix[i]}) pptc, throughput = ispNet_local.calc_path_shortest(tm) for tc, paths in pptc.iteritems(): pptc_iso_dict[i][copy.deepcopy(tc)] = copy.deepcopy(paths) gfi = calc_gfi(pptc_dict, pptc_iso_dict, cp_num, ispNet) ingress_bw_dict = {} for i in range(cp_num): ingress_bw_dict[i] = {} for tc, paths in pptc.iteritems(): for path in paths: nodes = path.getNodes() ingress = nodes[0] if ingress in ingress_bw_dict[tc.network_id]: ingress_bw_dict[tc.network_id][ingress] += path.bw else: ingress_bw_dict[tc.network_id][ingress] = path.bw for id, bw_dict in ingress_bw_dict.iteritems(): print 'network id:{}'.format(id) for ingress, bw in bw_dict.iteritems(): print '{}:{}'.format(ingress, bw) with open(NEGO_LOG_DIR, 'a') as f: f.write(str(gfi)) f.write('\n') '''for id, bw_dict in ingress_bw_dict.iteritems():