#create network hosts client = network.Host(1) object_L.append(client) server = network.Host(2) object_L.append(server) #create routers and routing tables for connected clients (subnets) router_a_rt_tbl_D = { 1: { 0: 1 } } # packet to host 1 through interface 0 for cost 1 router_a = network.Router(name='A', intf_cost_L=[1, 1], intf_capacity_L=[500, 500], rt_tbl_D=router_a_rt_tbl_D, max_queue_size=router_queue_size) object_L.append(router_a) router_b_rt_tbl_D = { 2: { 1: 3 } } # packet to host 2 through interface 1 for cost 3 router_b = network.Router(name='B', intf_cost_L=[1, 3], intf_capacity_L=[500, 100], rt_tbl_D=router_b_rt_tbl_D, max_queue_size=router_queue_size) object_L.append(router_b)
if __name__ == '__main__': object_L = [] # keeps track of objects, so we can kill their threads aTable = {1:0, 2:1} bTable = {0:0} cTable = {0:0} dTable = {1:0, 2:0} # create network nodes host1 = network.Host(1) object_L.append(host1) host2 = network.Host(2) object_L.append(host2) host3 = network.Host(3) object_L.append(host3) router_a = network.Router(name='A', intf_count_in=2, intf_count_out=2, max_queue_size=router_queue_size, inLUT=aTable) object_L.append(router_a) router_b = network.Router(name='B', intf_count_in=1, intf_count_out=1, max_queue_size=router_queue_size, inLUT=bTable) object_L.append(router_b) router_c = network.Router(name='C', intf_count_in=1, intf_count_out=1, max_queue_size=router_queue_size, inLUT=cTable) object_L.append(router_c) router_d = network.Router(name='D', intf_count_in=2, intf_count_out=1, max_queue_size=router_queue_size, inLUT=dTable) object_L.append(router_d) # 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 link_layer.add_link(link.Link(host1, 0, router_a, 0, 50)) #H1:0 - RA:0 link_layer.add_link(link.Link(host2, 0, router_a, 1, 50)) #H2:0 - RA:1
simulation_time = 1 #give the network sufficient time to execute transfers if __name__ == '__main__': object_L = [ ] #keeps track of objects, so we can kill their threads at the end #create network hosts host_1 = network.Host('H1') object_L.append(host_1) host_2 = network.Host('H2') object_L.append(host_2) #create routers and cost tables for reaching neighbors cost_D = {'H1': {0: 1}, 'RB': {1: 1}} # {neighbor: {interface: cost}} router_a = network.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.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.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))
object_L = [] #keeps track of objects, so we can kill their threads #create network nodes client1 = network.Host(1) object_L.append(client1) client2 = network.Host(2) object_L.append(client2) server1 = network.Host(3) object_L.append(server1) server2 = network.Host(4) object_L.append(server2) router_a = network.Router(name='A', intf_count=4, max_queue_size=router_queue_size, routing_table=routing_table) object_L.append(router_a) router_b = network.Router(name='B', intf_count=2, max_queue_size=router_queue_size, routing_table=routing_table) object_L.append(router_b) router_c = network.Router(name='C', intf_count=2, max_queue_size=router_queue_size, routing_table=routing_table) object_L.append(router_c) router_d = network.Router(name='D', intf_count=4, max_queue_size=router_queue_size, routing_table=routing_table) object_L.append(router_d) #create a Link Layer to keep track of links between network nodes link_layer = link.LinkLayer() object_L.append(link_layer)
import threading from time import sleep ##configuration parameters router_queue_size = 0 #0 means unlimited simulation_time = 1 #give the network sufficient time to transfer all packets before quitting if __name__ == '__main__': object_L = [] #keeps track of objects, so we can kill their threads #create network nodes client = network.Host(1) object_L.append(client) server = network.Host(2) object_L.append(server) router_a = network.Router(name='A', intf_count=1, max_queue_size=router_queue_size) object_L.append(router_a) #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 link_layer.add_link(link.Link(client, 0, router_a, 0, 20)) link_layer.add_link(link.Link(router_a, 0, server, 0, 20)) #start all the objects thread_L = [] thread_L.append(threading.Thread(name=client.__str__(), target=client.run)) thread_L.append(threading.Thread(name=server.__str__(), target=server.run))
router_queue_size = 0 #0 means unlimited simulation_time = 1 #give the network sufficient time to transfer all packets before quitting if __name__ == '__main__': object_L = [] #keeps track of objects, so we can kill their threads #create network hosts client = network.Host(1) object_L.append(client) server = network.Host(2) object_L.append(server) #create routers and routing tables for connected clients (subnets) router_a_rt_tbl_D = {2: {1: 1}} # packet to host 1 through interface 1 for cost 1 router_a = network.Router(name='A', num_intf = 2, rt_tbl_D = router_a_rt_tbl_D, max_queue_size=router_queue_size) object_L.append(router_a) router_b_rt_tbl_D = {2: {1: 3}} # packet to host 2 through interface 1 for cost 3 router_b = network.Router(name='B', num_intf = 2, rt_tbl_D = router_b_rt_tbl_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.LinkLayer() object_L.append(link_layer) #add all the links link_layer.add_link(link.Link(client, 0, router_a, 0))
if __name__ == '__main__': object_L = [] #keeps track of objects, so we can kill their threads #create network nodes client1 = network.Host(1) object_L.append(client1) client2 = network.Host(2) object_L.append(client2) server1 = network.Host(3) object_L.append(server1) server2 = network.Host(4) object_L.append(server2) Router_a_Table = {'2': ['1:0', '2:1']} router_a = network.Router(name='A', intf_count=2, max_queue_size=router_queue_size, routingTable=Router_a_Table) Router_b_Table = {'2': ['3:0', '4:0']} router_b = network.Router(name='B', intf_count=1, max_queue_size=router_queue_size, routingTable=Router_b_Table) Router_c_Table = {'2': ['3:0', '4:0']} router_c = network.Router(name='C', intf_count=1, max_queue_size=router_queue_size, routingTable=Router_c_Table) Router_d_Table = {'2': ['3:0', '4:1']} router_d = network.Router(name='D', intf_count=2, max_queue_size=router_queue_size,
#create network nodes client1 = network.Host(1) object_L.append(client1) client2 = network.Host(2) object_L.append(client2) server1 = network.Host(3) object_L.append(server1) server2 = network.Host(4) object_L.append(server2) router_a = network.Router(name='A', intf_count=2, max_queue_size=router_queue_size) object_L.append(router_a) router_b = network.Router(name='B', intf_count=1, max_queue_size=router_queue_size) object_L.append(router_b) router_c = network.Router(name='C', intf_count=1, max_queue_size=router_queue_size) object_L.append(router_c) router_d = network.Router(name='D', intf_count=2,
'in2': 0 } table_rule_b = {'source': 1, 'next': 0, 'in': 0} table_rule_c = {'source': 2, 'next': 0, 'in': 1} table_rule_d = { 'source': 1, 'next': 0, 'in': 0, 'source2': 2, 'next2': 0, 'in2': 0 } #next2 could be 1? ##interface count is the number of input and output interfaces (needs to be 2 for A)? router_a = network.Router(name='A', intf_count=2, max_queue_size=router_queue_size, table_rule=table_rule_a) object_L.append(router_a) router_b = network.Router(name='B', intf_count=1, max_queue_size=router_queue_size, table_rule=table_rule_b) object_L.append(router_b) router_c = network.Router(name='C', intf_count=1, max_queue_size=router_queue_size, table_rule=table_rule_c) object_L.append(router_c)
# create network hosts host1 = network.Host(1) object_L.append(host1) host2 = network.Host(2) object_L.append(host2) host3 = network.Host(3) object_L.append(host3) # create routers and routing tables for connected clients (subnets) router_a = network.Router(name='A', intf_cost_L=[1, 1, 1, 1], rt_tbl_D={ 1: { 0: 1 }, 2: { 1: 1 } }, max_queue_size=router_queue_size) object_L.append(router_a) router_b = network.Router(name='B', intf_cost_L=[1, 1], rt_tbl_D={}, max_queue_size=router_queue_size) object_L.append(router_b) router_c = network.Router(name='C', intf_cost_L=[1, 1],