#create routers and cost tables for reaching neighbors cost_D = {'H1': {0: 1}, 'RB': {1: 1}} # {neighbor: {interface: cost}} router_a = network_1.Router(name='RA', cost_D = cost_D, max_queue_size=router_queue_size) object_L.append(router_a) cost_D = {'H2': {1: 3}, 'RA': {0: 1}} # {neighbor: {interface: cost}} router_b = network_1.Router(name='RB', cost_D = cost_D, max_queue_size=router_queue_size) object_L.append(router_b) #create a Link Layer to keep track of links between network nodes link_layer = link_1.LinkLayer() object_L.append(link_layer) #add all the links - need to reflect the connectivity in cost_D tables above link_layer.add_link(link_1.Link(host_1, 0, router_a, 0)) link_layer.add_link(link_1.Link(router_a, 1, router_b, 0)) link_layer.add_link(link_1.Link(router_b, 1, host_2, 0)) #start all the objects thread_L = [] for obj in object_L: thread_L.append(threading.Thread(name=obj.__str__(), target=obj.run)) for t in thread_L: t.start()
for item in object_L: if isinstance(item, network.Host): N.append(item.addr) elif isinstance(item, network.Router): N.append(item.name) R.append(item.name) for item in object_L: if isinstance(item, network.Router): item.update_network_nodes(N,R) item.initialize_routing_table() #create a Link Layer to keep track of links between network nodes link_layer = link.LinkLayer() object_L.append(link_layer) #add all the links - need to reflect the connectivity in cost_D tables above link_layer.add_link(link.Link(host_1, 0, router_a, 0)) link_layer.add_link(link.Link(router_a, 1, router_b, 0)) link_layer.add_link(link.Link(router_b, 1, host_2, 0)) #link_layer.add_link(link.Link(host_2, 0, router_b, 1)) #link_layer.add_link(link.Link(router_b, 0, router_a, 1)) #link_layer.add_link(link.Link(router_a, 0, host_1, 0)) #start all the objects thread_L = [] for obj in object_L: thread_L.append(threading.Thread(name=obj.__str__(), target=obj.run))
# create routers and cost tables for reaching neighbors cost_D = {'H1': {0: 1}, 'RB': {1: 1}} # {neighbor: {interface: cost}} router_a = network_2.Router(name='RA', cost_D=cost_D, max_queue_size=router_queue_size) object_L.append(router_a) # {neighbor: {interface: cost}} cost_D = {'H2': {1: 3}, 'RA': {0: 1}} router_b = network_2.Router(name='RB', cost_D=cost_D, max_queue_size=router_queue_size) object_L.append(router_b) # create a Link Layer to keep track of links between network nodes link_layer = link_2.LinkLayer() object_L.append(link_layer) # add all the links - need to reflect the connectivity in cost_D tables above link_layer.add_link(link_2.Link(host_1, 0, router_a, 0)) link_layer.add_link(link_2.Link(router_a, 1, router_b, 0)) link_layer.add_link(link_2.Link(router_b, 1, host_2, 0)) # start all the objects thread_L = [] for obj in object_L: thread_L.append(threading.Thread(name=obj.__str__(), target=obj.run)) for t in thread_L: t.start()