Example #1
0
def constructGraph(prefix, nexthop, path):
    global g_transfreq;
    if not bgplib.validRoute(prefix, path):
        return;
    addPrefix(prefix);
    if len(path) >= 2:
        for i in range(len(path) - 1):
            addEdge(path[i], path[i+1]);
            if i != 0:
                g_transfreq[path[i]] = g_transfreq.get(path[i], 0) + 1;
        addExit(int(path[-1]), int(path[-2]));    
Example #2
0
def identifyNotPeerLink(prefix, nexthop, path):
    global g_asgraph;
    if not bgplib.validRoute(prefix, path):
        return;
    if not isPopularPrefix(prefix):
        return;
    if len(path) >= 2:
        topidx = findMaxDegree(path);
        if topidx >= 2:
            for i in range(topidx-1):
                g_asgraph[path[i]][path[i+1]][1] = False;
        if topidx + 2 < len(path):
            for i in range(topidx+1, len(path) - 1):
                g_asgraph[path[i]][path[i+1]][1] = False;
        if topidx > 0 and topidx < len(path) - 1 and not isSibling(path[topidx-1], path[topidx]) and not isSibling(path[topidx], path[topidx+1]):
            if getDegree(path[topidx-1]) > getDegree(path[topidx+1]):
                g_asgraph[path[topidx]][path[topidx+1]][1] = False;
            else:
                g_asgraph[path[topidx-1]][path[topidx]][1] = False;
Example #3
0
def statisTransitNumber(prefix, nexthop, path):
    global g_asgraph;
    if not bgplib.validRoute(prefix, path):
        return;
    if not isPopularPrefix(prefix):
        return;
    #print path;
    if len(path) >= 2:
        topidx = findMaxDegree(path);
        if topidx > 0:
            for i in range(topidx):
                g_asgraph[path[i]][path[i+1]][0] = g_asgraph[path[i]][path[i+1]][0] + 1;
                #print path[i], path[i+1];
                #if path[i] == 32756 and path[i+1] == 26677:
                #    print path[i], path[i+1], g_asgraph[path[i]][path[i+1]];

        if topidx + 1 < len(path):
            for i in range(topidx+1, len(path)):
                g_asgraph[path[i]][path[i-1]][0] = g_asgraph[path[i]][path[i-1]][0] + 1;