コード例 #1
0
def get_hop_by_host(cdn_host):
    # filePath = os.path.split(os.path.realpath(__file__))[0]
    # parentPath = os.path.split(filePath)[0]
    # hop_data_folder = parentPath + '/hopData/'

    hops = traceroute(cdn_host)
    # print hops

    full_hops = []

    hop_ids = sorted(hops.keys(), key=int)
    for hop_id in hop_ids:
        cur_hop_ip = hops[hop_id]['ip']
        if cur_hop_ip is '*':
            continue

        if not is_reserved(cur_hop_ip):
            node_info = get_node_info(cur_hop_ip)
            if (is_ip(node_info['name'])) and ('No Host'
                                               not in hops[hop_id]['name']):
                node_info['name'] = hops[hop_id]['name']

            # save_ipinfo(hop_data_folder, node_info)
            full_hops.append(node_info)

    return full_hops
コード例 #2
0
def get_hop_by_host(cdn_host):
    # filePath = os.path.split(os.path.realpath(__file__))[0]
    # parentPath = os.path.split(filePath)[0]
    # hop_data_folder = parentPath + '/hopData/'

    hops = traceroute(cdn_host)
    # print hops

    full_hops = []

    hop_ids = sorted(hops.keys(), key=int)
    for hop_id in hop_ids:
        cur_hop_ip = hops[hop_id]['ip']
        if cur_hop_ip is '*':
            continue

        if not is_reserved(cur_hop_ip):
            node_info = get_node_info(cur_hop_ip)
            if (is_ip(node_info['name'])) and ('No Host' not in hops[hop_id]['name']):
                node_info['name'] = hops[hop_id]['name']

            # save_ipinfo(hop_data_folder, node_info)
            full_hops.append(node_info)

    return full_hops
コード例 #3
0
ファイル: get_hop_info.py プロジェクト: tudou2015/CDN-DASH
def get_route(server):
    srv_ip = host2ip(server)
    hops = traceroute(srv_ip)

    client_ip, client_info = get_ext_ip()
    hops[0] = {'ip': client_ip, 'name': client_info['name'], 'time': 0.0}

    last_hop_id = max(hops.keys())
    last_hop = hops[last_hop_id]

    if (server != last_hop['name']) and (srv_ip != last_hop['ip']):
        rtt, _ = getMnRTT(srv_ip, 3)
        hops[last_hop_id + 1] = {'ip': srv_ip, 'name': server, 'time': rtt}

    return hops
コード例 #4
0
def get_hop_by_host(cdn_host):
    hop_data_folder = os.getcwd() + '/hopData/'

    hops = traceroute(cdn_host)
    print hops

    hop_ids = sorted(hops.keys(), key=int)
    for hop_id in hop_ids:
        cur_hop_ip = hops[hop_id]['IP']
        if cur_hop_ip is '*':
            continue

        if not is_reserved(cur_hop_ip):
            hop_info = ipinfo(cur_hop_ip)
            save_ipinfo(hop_data_folder, hop_info)
            print hop_info
コード例 #5
0
import hosts
from ipinfo.ipinfo import *
from monitor.traceroute import *
from utils import *


startTime = time.time()
time_str = time.strftime('%m%d%H%M')
myName = getMyName()

traceroute_file = config.trace_path + myName + '_' + time_str + '.json'
host_traceroutes = {}

for hname in hosts.commercial_hosts.keys():
    cur_hostname = hosts.commercial_hosts[hname]
    cur_ip = host2ip(cur_hostname)
    cur_traceroute = traceroute(cur_ip)
    actual_host_name, host_info = ip2host(cur_ip)
    if not actual_host_name:
        actual_host_name = cur_hostname
    if host_info:
        save_ipinfo(config.info_path, host_info)

    host_traceroutes[hname] = {'hostname':actual_host_name, 'ip':cur_ip, 'routes':cur_traceroute}

writeJson(traceroute_file, host_traceroutes)

time_elapsed = time.time() - startTime
print "Hosts traceroute running time: ", time_elapsed