def read_asns_file(msm_id, asn_ids):
    asns_fn = dgs_ld.find_usable_file(c.asns_fn(msm_id))
    print("read_asns_file(%s), asns_fn = %s" % (msm_id, asns_fn))
    if os.path.isfile(asns_fn):
        no_asn_nodes = 0
        asnf = open(asns_fn, "r", encoding='utf-8')
        for line in asnf:
            la = line.strip().split()
            name = la[0]
            asn = la[1]
            node_dir[name] = asn
            #print("node_dir key %s, val %s" % (name, node_dir[name]))
            if asn not in asn_ids:
                asn_ids[name] = asn
            else:
                asn_ids[name] = "Missing"
                no_asn_nodes += 1
        print("%d nodes missing from asns file" % no_asn_nodes)
        return no_asn_nodes, asn_ids
    else:
        print("asn file = %s <<< Couldn't find an asns file" % asns_fn)
        return ''
示例#2
0
        print("bin %3d, roots %s\n" % (self.bin_nbr, self.roots))

        self.tree = []
        for ask in self.e_asns:
            e_asn = self.e_asns[ask]
            if ask == dest_asn or ask == dest:
                if e_asn.sources() == 0:
                    continue  # Discard dest asn with no source trs
            self.tree.append(e_asn)
        self.as_nodes = None
        return None  # i.e. return an ASN_Graph


for msm_id in reqd_msms:
    no_asnf = no_whoisf = False
    asns_fn = c.asns_fn(msm_id)
    print("asns file >%s<" % asns_fn)
    if not os.path.isfile(asns_fn):
        print("No asns file; run pypy3 bulk-bgp-lookup.py <<<")
        exit()
    dgs_stem = c.dgs_stem
    # full_graphs adds "-asn" to dgs_stem !
    print("dgs_stem = >%s<" % dgs_stem)

    in_graphs_fn = c.msm_graphs_fn(msm_id)
    print("graph_fn = %s" % in_graphs_fn)
    n_bins_to_read = c.n_bins  # 3  ########################  c.n_bins

    dgs = dgs_ld.load_graphs(
        in_graphs_fn,  # Load a DestGraphs file (dgs)
        mx_depth,
示例#3
0
if os.path.exists(all_whois_fn):
    print("Will read all-whois file %s" % all_whois_fn)
    whois_info_f = open(all_whois_fn, 'r')
    for line in whois_info_f:  # Get dictionary of ASNs
        n, asn, colour, name, cc, registry = line.strip().split()
        if asn == "15895":
            print("%s  %s %s <1<" % (n, asn, name))
        all_whois_d[asn] = name + ' ' + cc + ' ' + registry
    whois_info_f.close()
n_whois_known = len(all_whois_d)
print("%d ASNS known in whois-all" % n_whois_known)

for msm_id in reqd_msms:
    print("\n>>> Starting msm_id %s\n" % msm_id)
    msm_id_asns = {}  # All ASNs (with in_counts) from asns-50xx file
    asnf = open(c.asns_fn(msm_id), 'r')
    n_nodes = mn_nodes = 0
    for line in asnf:
        n_nodes += 1
        la = line.strip().split()
        addr = la[0]
        asn = la[1]
        in_count = int(la[2])
        in_count = int(in_count)
        if in_count >= mn_trpkts:
            mn_nodes += 1
            if asn not in msm_id_asns:
                msm_id_asns[asn] = ASN(asn, addr, in_count)
            else:
                msm_id_asns[asn].count += 1  # Nbr of times the ASN appears
                msm_id_asns[
示例#4
0
    sni_fn = c.s_n_info_fn(msm_id)
    print("sni_fn = %s" % sni_fn)
    wg.write_s_node_info(sni_fn)

    last_bg = dg.bga[c.target_bn_lo]
    wg.draw_whole_graph(c.start_ymd, msm_id)  # Make plain.txt file
    print("---WholeGraph drawn ---")
    #input_var = input("Enter something: ")
    #print ("you entered " + input_var) 

    wg.read_whole_graph(c.start_ymd)  # Read x,y node co-ords from plain.txt
    #print("wg.nodes{} = %s" % wg.nodes)  # Now have (x,y) for each node[name]

    asn_dir = {}  # Make asn and whois directories
    no_asnf = no_whoisf = False
    asns_fn = dgs_ld.find_usable_file(c.asns_fn(msm_id))
    if asns_fn != '':
        print("Will use asns file %s" % asns_fn)
    else:
        print("No asns file; run  bulk-bgp-lookup.py <<<")
        no_asnf = True

    whois_fn = c.all_whois_fn()
    if os.path.exists(whois_fn):
        print("Will use whois-all-file %s" % whois_fn)
    else:
        whois_fn = dgs_ld.find_usable_file(c.whois_fn(msm_id))
        if whois_fn != '':
            print("Will use whois-file %s" % whois_fn)
        else:
            print("No whois file; run  get-whois-info.py <<<")