Example #1
0
'''
import network_2 as network
import link_2 as link
import threading
from time import sleep
from rprint import print

## configuration parameters
router_queue_size = 0  # 0 means unlimited
simulation_time = 3  # 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))
Example #2
0
import link_2 as link
import threading
from time import sleep
import sys
from numpy import inf
from typing import *

##configuration parameters
router_queue_size = 0 #0 means unlimited
simulation_time = 2   #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)
    # router_a.temp_routes_set_method(rt_tbl_D) # here table is set manually
    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,
Example #3
0
'''
import network_2 as network
import link_2 as link
import threading
from time import sleep
import sys

##configuration parameters
router_queue_size = 0  #0 means unlimited
simulation_time = 20  #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: {
Example #4
0
import network_2 as network
import link_2 as link
import threading
from time import sleep
import sys

INF = 9999999
##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
    host_1 = network.Host(1)
    object_L.append(host_1)
    host_2 = network.Host(2)
    object_L.append(host_2)
    host_3 = network.Host(2)
    object_L.append(host_3)

    #create routers and routing tables for connected clients (subnets)
    router_a_rt_tbl_D = {
        1: {
            0: 1,
            1: INF,
            2: INF,
            3: INF
        },
        2: {
Example #5
0
'''
import network_2
import link_2
import threading
from time import sleep
import sys

##configuration parameters
router_queue_size = 0  # 0 means unlimited
simulation_time = 3  # 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_2.Host(1)
    object_L.append(client)
    lazyguy = network_2.Host(2)
    object_L.append(lazyguy)
    server = network_2.Host(3)
    object_L.append(server)

    # create routers and routing tables for connected clients (subnets)
    router_a_rt_tbl_D = {
        1: {
            0: 1
        },
        2: {
            1: 1
        }
    }  # packet to host 1 through interface 0 for cost 1
@modified by: Megan Weller and Ashley Bertrand
'''
import network_2
import link_2
import threading
from time import sleep

##configuration parameters
router_queue_size = 0 #0 means unlimited
simulation_time = 6 #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_2.Host(1)
    object_L.append(host1)
    host2 = network_2.Host(2)
    object_L.append(host2)
    host3 = network_2.Host(3)
    object_L.append(host3)
    
    #create forwarding table for routers
    forwarding_table = [[['A', 2], ['B', 1], ['D', 2]], [['D', 1], ['C', 0], ['A', 0]]]
    #create routers and routing tables for connected clients (subnets)
    router_a_rt_tbl_D = {1: {0: 1}, 2: {1: 9}}
    router_a = network_2.Router(name='A', 
                              intf_cost_L=[1,9,1,2], 
                              rt_tbl_D = router_a_rt_tbl_D, 
                              max_queue_size=router_queue_size,
                              forwarding_table = forwarding_table)
Example #7
0
'''
import network_2 as network
import link_2 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
    client1 = network.Host(1)
    object_L.append(client1)
    client2 = network.Host(2)
    object_L.append(client2)
    server = network.Host(3)
    object_L.append(server)

    #create routers and routing tables for connected clients (subnets)
    router_a = network.Router(name='A',
                              intf_cost_L=[1, 1, 1, 1],
                              intf_capacity_L=[500, 500, 500, 500],
                              rt_tbl_D={
                                  0: {
                                      3: ('0', 2)
                                  },
                                  1: {
Example #8
0
import network_2
import link_2
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
mtu = 30

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_2.Host(1)    #client has address 1
    object_L.append(client)
    server = network_2.Host(2)    #server has address 2
    object_L.append(server)
    router_a = network_2.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_2.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_2.Link(client, 0, router_a, 0, 50))
    link_layer.add_link(link_2.Link(router_a, 0, server, 0, mtu))   #for part 2, change mtu to 30
    
Example #9
0
'''
import network_2
import link_2
import threading
from time import sleep
import sys

##configuration parameters
router_queue_size = 0 #0 means unlimited
simulation_time = 5 #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
    host_1 = network_2.Host(1)
    object_L.append(host_1)
    host_2 = network_2.Host(2)
    object_L.append(host_2)
    host_3 = network_2.Host(3)
    object_L.append(host_3)
    
    #create routers and routing tables for connected clients (subnets)
    router_a_rt_tbl_D = {
        1: {0: 1},
        2: {1: 1}
    } # packet to host 1 through interface 0 for cost 1
    router_a = network_2.Router(name='A',
                                intf_cost_L=[
                                    1,1,
                                    1,1