Пример #1
0
import network_1 as network
import link_1 as link
import threading
from time import sleep
from rprint import print

## configuration parameters
router_queue_size = 0  # 0 means unlimited
simulation_time = 2  # 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 parameters: from_node, from_intf_num, to_node, to_intf_num, mtu
    link_layer.add_link(link.Link(client, 0, router_a, 0, 50))
Пример #2
0
'''
import network_1
import link_1
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_1.Host(1)  #client has address 1
    object_L.append(client)
    server = network_1.Host(2)  #server has address 2
    object_L.append(server)
    router_a = network_1.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_1.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_1.Link(client, 0, router_a, 0, 50))
Пример #3
0
import network_1 as network
import link_1 as link
import threading
from time import sleep
from rprint import print

# configuration parameters
router_queue_size = 0  # 0 means unlimited
simulation_time = 1.5  # 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)
Пример #4
0
'''
import network_1 as network
import link_1 as 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
    h1 = network.Host(1)
    object_L.append(h1)
    h2 = network.Host(2)
    object_L.append(h2)
    h3 = network.Host(3)
    object_L.append(h3)

    #create routers and routing tables for connected clients (subnets)
    router_a_rt_tbl_D = {
        1: {
            0: 1
        },
        2: {
            1: 1
        },
        3: {