def main(): if len(sys.argv) != 6: # print "input files: output_3a, ucla_rel, as_name_type_tier_rank, ip_to_coords, prefix_to_coords_dict" sys.exit() output_3a = sys.argv[1] ucla_rel = sys.argv[2] as_nttr = sys.argv[3] ip_coords = sys.argv[4] prefix_to_coords_dict = sys.argv[5] #get (set(neighbors), set(internal neighbors), set(external neighbors)) for each LG d_as_lg_set = utility.parse(output_3a) ases = [] for asn in d_as_lg_set: lgs = [] for as_lg_str in d_as_lg_set[asn]: lg_ = LG(as_lg_str) lg_.set_attr(NEI_SET, d_as_lg_set[asn][as_lg_str]) lgs.append(lg_) as_ = AS(asn, lgs=lgs) ases.append(as_) #get (#i, #unknown, #cp, #pc, #p2p) for each LG d_as_pair_type = utility.build_rel_dict(ucla_rel) utility.get_num_rel(ases, d_as_pair_type) #get ([],[],[],[],[]) d_type_ip_num_prefix = utility.build_num_prefix_d(output_3a, d_as_pair_type) utility.get_num_prefix_per_type(ases,d_type_ip_num_prefix) #get (name, type, tier, rank) for each AS d_nttr = utility.build_as_name_type_tier_rank_d(as_nttr) utility.get_nttr(ases,d_nttr) #get (lat,lon) for each LG d_iill = utility.build_ipint_lat_lon_d(ip_coords) utility.get_lat_lon(ases, d_iill) #build dictionary mapping prefixes in use to (lat,lon) d_prefix_lat_lon = utility.build_prefix_lat_lon_d(prefix_to_coords_dict) '''
def one_page_figure_twenty_more_lgs(ases): ''' using LG.dummy() to control ''' ases_in_use = [] for as_ in ases: if len(as_)>20: ases_in_use.append(as_) ases_in_use = sorted(ases_in_use, key=lambda x:len(x) ) lgs = [] for as_ in ases_in_use: lgs_tmp = sorted(as_.get_attr(LGS), key=lambda x:x.size_nei(), reverse=True) for lg_ in lgs_tmp: lgs.append(lg_) lgs.append(LG.dummy()) #dummy LG to separate ASes texts = [] for as_ in ases_in_use: type_ = as_.get_attr(INFO)[1] tier = as_.get_attr(INFO)[2] if tier == "\\N": tier = "na" texts.append(type_+"--"+tier) texts += ["" for i in range(len(as_)-1 +1)] title = "ASes with twenty or more LGs" draw_one_page_figure(lgs, texts, title)
def test(): lg1 = LG("1.1.1.1") lg2 = LG("1.1.1.1") lg3 = LG.dummy() print lg3 print lg3.get_attr(NUM_REL) print lg3.get_attr(LIST_PREFIX) #print lg1 == lg2 s = set() s.add(lg1) s.add(lg2)