Example #1
0
    link_layer.add_link(Link(router_a, 3, router_c, 0))
    link_layer.add_link(Link(router_b, 1, router_d, 0))
    link_layer.add_link(Link(router_c, 1, router_d, 1))
    link_layer.add_link(Link(router_d, 2, host_3, 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()
    
    #create some send events    
    print('\nSending first message from H1. Path should be:\n\n    H1-RA-RC-RD-H3\n')
    host_1.udt_send('h3', 'MESSAGE_1_FROM_H1')
    # give time for message to be received 
    sleep(3)
    print('\nSending second message from H2. Path should be:\n\n    H2-RA-RB-RD-H3\n')
    host_2.udt_send('h3', 'message_2_from_h2')
    sleep(3)
    print('\nSending third message from H3. Path should be:\n\n    H3-RD-RC-RA-H2\n')
    host_3.udt_send('h2', 'message_3_from_h3')
#    for i in range(5):
#        priority = i%2
#        host_1.udt_send('h2', 'message_%d_from_h1' % i, priority)
        
    #give the network sufficient time to transfer all packets before quitting
    sleep(simulation_time)

    
    link_layer.add_link(Link(router_a, 2, router_b, 0))
    link_layer.add_link(Link(router_a, 3, router_c, 0))
    link_layer.add_link(Link(router_b, 1, router_d, 0))
    link_layer.add_link(Link(router_c, 1, router_d, 1))
    link_layer.add_link(Link(router_d, 2, host_3, 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()

    # create some send events
    for i in range(5):
        priority = i % 2
        host_1.udt_send('H3', 'MESSAGE_%d_FROM_H1' % i, priority)
        host_2.udt_send('H3', 'MESSAGE_%d_FROM_H2' % i, priority)

    # give the network sufficient time to transfer all packets before quitting
    sleep(simulation_time)

    # join all threads
    for o in object_L:
        o.stop = True
    for t in thread_L:
        t.join()

    print("All simulation threads joined")
Example #3
0
    link_layer.add_link(Link(router_d, 2, router_b, 0))
    link_layer.add_link(Link(router_d, 1, router_c, 1))

    link_layer.add_link(Link(host_3, 0, router_d, 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()

    #Currently, h1 and h2 will send through the same path, but h3 will send through different. Should be improved.
    host_1.udt_send('H2', 'MESSAGE_%d_FROM_H1' % 0, 0)
    host_1.udt_send('H3', 'MESSAGE_%d_FROM_H1' % 1, 1)
    host_2.udt_send('H3', 'MESSAGE_%d_FROM_H2' % 0, 0)
    host_3.udt_send('H1', 'MESSAGE_%d_FROM_H3' % 0, 1)

    #create some send events
    # for i in range(5):
    #     priority = i%2
    #     host_1.udt_send('H2', 'MESSAGE_%d_FROM_H1' % i, priority)

    #give the network sufficient time to transfer all packets before quitting
    sleep(simulation_time)

    #join all threads
    for o in object_L:
        o.stop = True
Example #4
0
    link_layer.add_link(Link(router_a, 3, router_c, 0))
    link_layer.add_link(Link(router_b, 1, router_d, 0))
    link_layer.add_link(Link(router_c, 1, router_d, 2))
    link_layer.add_link(Link(router_d, 1, host_3, 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()

    # create some send events
    priority = i = 2
    host_1.udt_send('H3', 'MESSAGE_FROM_H1', priority)

    print("Sending message: 'MESSAGE_FROM_H1'")
    print("To: H3 From H1.")
    print("With Priority: %d." % priority)

    host_2.udt_send('H3', 'MESSAGE_FROM_H2', priority)

    print("Sending message: 'MESSAGE_FROM_H2'")
    print("To: H3 From H2.")
    print("With Priority: %d." % priority)

    # give the network sufficient time to transfer all packets before quitting
    sleep(simulation_time)

    # join all threads
Example #5
0
                             0))  # router a to router b connections
    link_layer.add_link(Link(router_b, 1, router_d, 0))  # router b to router d
    link_layer.add_link(Link(router_c, 1, router_d, 1))  # router c to router d
    link_layer.add_link(Link(router_d, 2, host_3, 0))  # host 3 to router d

    #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()

    #create some send events
    for i in range(1):
        priority = i % 2
        host_1.udt_send('H3', 'MESSAGE_%d_FROM_H1' % i, 1)
        # sleep tp give time for host 1's messege to reach host 3
        sleep(2)
        host_2.udt_send('H3', 'MESSAGE_%d_FROM_H2' % i, 0)
    #give the network sufficient time to transfer all packets before quitting
    sleep(simulation_time)

    #join all threads
    for o in object_L:
        o.stop = True
    for t in thread_L:
        t.join()

    print("All simulation threads joined")
Example #6
0
    link_layer.add_link(Link(router_b, 1, router_d, 1))
    link_layer.add_link(Link(router_c, 1, router_d, 2))
    link_layer.add_link(Link(router_d, 0, host_3, 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()

    #create some send events
    for i in range(1):
        priority = i % 2
        host_1.udt_send('H2', 'FIRST_%d_FROM_H1' % i, priority)
        host_2.udt_send('H3', 'SECOND%d_FROM_H2' % i, priority)
        host_1.udt_send('H3', 'THIRD%d_FROM_H1' % i, priority)
        host_3.udt_send('H1', 'FOURTH%d_FROM_H3' % i, priority)
        host_3.udt_send('H2', 'FIFTH%d_FROM_H3' % i, priority)

    #give the network sufficient time to transfer all packets before quitting
    sleep(simulation_time)

    #join all threads
    for o in object_L:
        o.stop = True
    for t in thread_L:
        t.join()

    print("All simulation threads joined")