コード例 #1
0
def find_probes_in_country(cc):
    probes = {}
    if cc:
        probes = ProbeInfo.query(country_code=cc, is_public=True)
    else:
        probes = ProbeInfo.query(is_public=True)
    '''
   asns_v4 = Counter()
   asns_v6 = Counter()
   for prb_id in probes:
      if probes[prb_id]['asn_v4'] != None:
         asns_v4[ probes[prb_id]['asn_v4'] ] += 1
      if probes[prb_id]['asn_v6'] != None:
         asns_v6[ probes[prb_id]['asn_v6'] ] += 1
   return asns_v4,asns_v6,probes
   '''
    return probes
コード例 #2
0
ファイル: prepare.py プロジェクト: slowr/ixp-country-jedi
def find_probes_in_country( cc ):
    probes = {}
    if cc:
        probes = ProbeInfo.query(country_code=cc, is_public=True)
    else:
        probes = ProbeInfo.query(is_public=True)
    '''
    asns_v4 = Counter()
    asns_v6 = Counter()
    for prb_id in probes:
      if probes[prb_id]['asn_v4'] != None:
         asns_v4[ probes[prb_id]['asn_v4'] ] += 1
      if probes[prb_id]['asn_v6'] != None:
         asns_v6[ probes[prb_id]['asn_v6'] ] += 1
    return asns_v4,asns_v6,probes
    '''
    return probes
コード例 #3
0
def find_probes_in_country(cc, eyeball=False, threshold=90):
    probes = {}
    base_url = (
        'http://data.labs.apnic.net/ipv6-measurement/Economies/{}/{}.asns.json'
    )
    coverage = 0
    if cc:
        if eyeball:
            url = base_url.format(cc, cc)
            eyeball_distribution = json.loads(urllib2.urlopen(url).read())
            for asn in eyeball_distribution:
                if coverage >= threshold:
                    break
                probes.update(
                    ProbeInfo.query(country_code=cc,
                                    asn_v4=asn['as'],
                                    is_public=True))
                probes.update(
                    ProbeInfo.query(country_code=cc,
                                    asn_v6=asn['as'],
                                    is_public=True))
                coverage += asn['percent']
        else:
            probes = ProbeInfo.query(country_code=cc, is_public=True)
    else:
        probes = ProbeInfo.query(is_public=True)
    '''
   asns_v4 = Counter()
   asns_v6 = Counter()
   for prb_id in probes:
      if probes[prb_id]['asn_v4'] != None:
         asns_v4[ probes[prb_id]['asn_v4'] ] += 1
      if probes[prb_id]['asn_v6'] != None:
         asns_v6[ probes[prb_id]['asn_v6'] ] += 1
   return asns_v4,asns_v6,probes
   '''
    return probes
コード例 #4
0
def countries_with_enough_diversity(min_asn_v4_diversity=2):
    cc_probe_diversity = {}
    probes = ProbeInfo.query(status=1, is_public=True)
    for prb_id in probes:
        prb_info = probes[prb_id]
        if 'tags' in prb_info and 'system-auto-geoip-country' in prb_info[
                'tags']:
            continue
        else:
            cc = prb_info['country_code']
            if not cc in cc_probe_diversity:
                cc_probe_diversity[cc] = set()
            if 'asn_v4' in prb_info and prb_info['asn_v4']:
                cc_probe_diversity[cc].add(prb_info['asn_v4'])
    diverse_cc = []
    for cc in cc_probe_diversity:
        if len(cc_probe_diversity[cc]) >= min_asn_v4_diversity:
            diverse_cc.append(cc)
    return diverse_cc
コード例 #5
0
def do_probe_selection_from_ids(ids):
    probes = ProbeInfo.query(id__in=ids, status=1)
    return map(_to_probedata, probes.values())
コード例 #6
0
def do_probe_selection_from_tag(tag):
    probes = ProbeInfo.query(tags=tag, status=1)
    return map(_to_probedata, probes.values())
コード例 #7
0
from Atlas import ProbeInfo
import time
from ripe.atlas.sagan import TracerouteResult
from collections import Counter
import ipaddr
import json

measurements = {
   1767679: {'irr':True, 'size':24, 'idx':0},
   1767680: {'irr':True, 'size':25, 'idx':1},
   1767681: {'irr':True, 'size':28, 'idx':2},
   1767682: {'irr':False, 'size':24, 'idx':3},
   1767683: {'irr':False, 'size':25, 'idx':4},
   1767684: {'irr':False, 'size':28, 'idx':5},
}
probes = ProbeInfo.query()

interval=3600*8 # msm is every 8hrs
msm_start = int( 1412236086 / interval ) * interval

def to_geojson( probes, probe_prop ):
   geojson = {
      "type": "FeatureCollection",
      "features": []
   }
   for p,props in probe_prop.items():
      if p in probes:
         lat = probes[ p ]['lat']
         lon = probes[ p ]['lon']
         geojson['features'].append({
            "geometry": {