示例#1
0
def check_weight_update(weight_file, topo_file, nbrs):
    global curr_table
    global label
    global t_start

    print "Checking for Topology Changes"
    path = './' + label + '/weights'
    update = Graph()
    update.init_config(label, weight_file, topo_file)
    lock.acquire()
    if curr_table.serialize != update.serialize:
        curr_table.serialize = copy.deepcopy(update.serialize)
        print "Topology update detected. Rerouting..."
        update.bellman_on_src(label)
        curr_table.routes[label] = copy.deepcopy(update.routes[label])
        curr_table.set_routes(copy.deepcopy(update.get_routes()))
        curr_table.hops[label] = copy.deepcopy(update.hops[label])
        curr_table.set_hops(copy.deepcopy(update.get_hops()))
        curr_table.start = datetime.now()
        curr_table.bellman_on_src(label)
        print curr_table.get_routes()
        send_to_nbrs(nbrs)
    lock.release()
    threading.Timer(
        period, check_weight_update,
        [weight_file, topo_file, nbrs]).start()  # Trigger Periodic Check
示例#2
0
def set_init_graph(weight_file, topo_file):
    global curr_table
    global label

    path = './' + label + '/weights'
    g = Graph()
    g.init_config(label, weight_file, topo_file)
    g.bellman_on_src(label)
    curr_table = g
    print "Initial Table:\n" + str(curr_table.get_routes())