Exemple #1
0
'''
import network
import link
import threading
from time import sleep
import sys

##configuration parameters
router_queue_size = 0  #0 means unlimited
simulation_time = 10  #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 = {
        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)
Exemple #2
0
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

    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
Exemple #3
0
import network
import link
import threading
from time import sleep
import sys

##configuration parameters
router_queue_size = 0  #0 means unlimited
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)
Exemple #4
0
@author: mwitt_000
'''
import network
import link
import threading
from time import sleep
import sys

##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 hosts
    host1 = network.Host(1) #formerly client
    object_L.append(host1)
    host2 = network.Host(2) #formerly server
    object_L.append(host2)
    #host3 = network.Host(3)
    #object_L.append(host3)

    #first topology
    #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], 
                              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
Exemple #5
0
simulation_time = 10 #give the network sufficient time to transfer all packets before quitting

if __name__ == '__main__':
    #Routing tables
    Ra_table = {3:2, 4:3}       #router a's out interfaces by destination address of packet
    Rb_table = {3:1}            #router b's out interfaces by destination address of packet
    Rc_table = {4:1}            #router c's out interfaces by destination address of packet
    Rd_table = {3:2, 4:3}       #router d's out interfaces by destination address of packet
    #initial lookup picks the right table based on current router doing the looking
    routing_table = {'Router_A': Ra_table, 'Router_B' : Rb_table,
                     'Router_C' : Rc_table, 'Router_D' : Rd_table}

    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)
Exemple #6
0
 def setUp(self):
     self.host = network.Host('', PORT)
     self.client = network.Client('127.0.0.1', PORT)
Exemple #7
0
 def setUp(self):
     self.host = network.Host('', PORT)
     self.client1 = network.Client('127.0.0.1', PORT)
     self.client2 = network.Client('127.0.0.1', PORT)
     asyncore_loop()
'''
import network
import link
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
    #part 3, add hosts, etc. (and make sure to start the threads)
    client = network.Host(1)  #client has address 1
    object_L.append(client)
    server = network.Host(2)  #server has address 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
    #client is output, router_a is input, 50 is largest size a packet can be to be transferred over a link
    link_layer.add_link(link.Link(client, 0, router_a, 0, 50))
Exemple #9
0
    def __init__(self):
        self.greeter = network.Host(settings.host, settings.port)
        self.addresses = range(settings.map.get_players() + 1)

        self.offices = {}
        self.subscriptions = {}
Exemple #10
0
def host():
    reset_chat()
    root.host = network.Host('', PORT)
    connect(self=True)