def get_gi(ymd, msm_id): print("===> ymd %s, msm_id %d" % (ymd, msm_id)) asnf = None node_dir = {} # Dictionary IPprefix -> ASN no_asn_nodes = {} asn_ids = {"unknown": 0} if not no_ASNs: #asns_fn = dgs_ld.find_usable_file(c.asns_fn(msm_id)) # Read prefix->ASN from file asns_fn = find_file("asns", ymd, msm_id) print("msm_id %d, asns_fn %s" % (msm_id, asns_fn)) if asns_fn: asnf = open(asns_fn, "r", encoding='utf-8') for line in asnf: la = line.strip().split() node = la[0] asn = la[1] # Ignore la[2] (in_count) node_dir[node] = asn if asn not in asn_ids: asn_ids[asn] = len(asn_ids) print("%d nodes, %d asns" % (len(node_dir), len(asn_ids) - 1)) else: print("asn file = %s <<< Couldn't find asn file" % asns_fn) exit() n_asns = len(asn_ids) - 1 # Don't count "unknown" print("n_asns = %d" % n_asns) c.set_ymd(ymd) print("start_ymd = %s" % c.start_ymd) gi = graph_info.GraphInfo( # The msm_id's Graphinfo for all bins msm_id, node_dir, n_bins, asn_graphs, n_asns, no_asn_nodes, 0, mn_trpkts) # All depths and all trpkts #print("gi.depth_16 = %s" % gi.depth_16) #print("msm_id %s, len(asn_ids <===) %d" % (msm_id, len(asn_ids))) #print("len(gi.edges) = %d" % len(gi.edges)) return gi
elif ix == 3: # mntr specify min trpkts mn_trpkts = pp_values[n] else: exit() if len(reqd_ymds) == 0: reqd_ymds = [c.start_ymd] if len(reqd_msms) == 0: reqd_msms = [c.msm_id] print("reqd_ymds = %s, reqd_msms = %s, mxd = %d, mntr = %d\n" % (reqd_ymds, reqd_msms, mx_depth, mn_trpkts)) if not c.full_graphs: c.set_full_graphs() if len(reqd_ymds) > 1: print("asn-filter.py only handles one ymd <<<") exit() c.set_ymd(reqd_ymds[0]) class E_ASN: # ASN where edges end types = ['normal', 'sub-root', 'root'] def __init__(self, asnbr, depth): self.e_asn = asnbr self.s_asns = {} # Key: s_ASN, value: incoming tr pkts self.type = -1 # 1 for root, 0 for sub-roots, else -1 self.d_total = depth self.n_depths = 1 self.depth = float(depth) # Av depth while building E_ASN self.prefix = asnbr # So dgs_ld can dump an E_ASN def update_depth(self, depth): # Compute running average depth
print("Missing statement!"); errcnt += 1 if errcnt != 0: print("%d errors in %s.txt file" % (errcnt, clip_spec[0])); exit() #print("clip name: %s, scale factors %f, %f" % (clip_name, xf, yf)) #print("clip_bins: lo %d, hi %d" % (clip_bn_lo, clip_bn_hi)) #print("nodes_to_keep: %s" % nodes_to_keep) return pb_type, about_lines def print_clip_info(clip_files): for fn in sorted(clip_files): print("\n%s" % fn) pbtype, about_lines = parse_clip_file(fn) print(" pbtype: %s" % pbtype) print(" about: %s" % "\n".join(about_lines)) for msm_id in reqd_msms: for ymd in reqd_ymds: c.set_ymd(ymd) asn_graphs = True; c.set_full_graphs(False) # full graphs clip_dir = c.clip_spec_dir(msm_id, mn_trpkts) clip_files = glob.glob("%s/*.txt" % clip_dir) print_clip_info(clip_files) asn_graphs = False; c.set_full_graphs(True) # ASN graphs clip_dir = c.clip_spec_dir(msm_id, mn_trpkts) clip_files = glob.glob("%s/*.txt" % clip_dir) print_clip_info(clip_files)