Example #1
0
def main():
    network = Network.get_instance()

    nodes = ["Alice", "Bob"]
    network.x_error_rate = 0
    network.delay = 0.5
    network.start(nodes)

    host_alice = Host('Alice')
    host_alice.add_connection('Bob')
    host_alice.max_ack_wait = 10
    host_alice.delay = 0.2
    host_alice.start()

    host_bob = Host('Bob')
    host_bob.max_ack_wait = 10
    host_bob.delay = 0.2
    host_bob.add_connection('Alice')
    host_bob.start()

    network.add_host(host_alice)
    network.add_host(host_bob)

    q_size = 6

    host_alice.run_protocol(qudp_sender, (q_size, host_bob.host_id))
    host_bob.run_protocol(qudp_receiver, (q_size, host_alice.host_id))

    start_time = time.time()
    while time.time() - start_time < 50:
        pass

    network.stop(stop_hosts=True)
def main():

    Y = 2
    M = 2

    network = Network.get_instance()
    nodes = ['Alice','C0','Bob']
    network.use_ent_swap = True
    network.start(nodes)
#0.01549
    alice = Host('Alice')
    alice.add_connection('C0', 100)
    alice.coherence_time = 1
    alice.max_ack_wait = 5
    alice.start()

    repeater0 = Host('C0')
    repeater0.add_connection('Alice', 100)
    repeater0.add_connection('Bob', 100)
    repeater0.coherence_time = 1
    repeater0.max_ack_wait = 5
    repeater0.start()

    # repeater1 = Host('C1')
    # repeater1.add_connection('C0')
    # repeater1.add_connection('C2')
    # repeater1.max_ack_wait = 5
    # repeater1.start()

    # repeater2 = Host('C2')
    # repeater2.add_connection('C1')
    # repeater2.add_connection('Bob')
    # repeater2.max_ack_wait = 5
    # repeater2.start()

    bob = Host('Bob')
    bob.add_connection('C0', 100)
    bob.coherence_time = 1
    bob.max_ack_wait = 5
    bob.start()

    network.add_host(alice)
    network.add_host(repeater0)
    #network.add_host(repeater1)
    #network.add_host(repeater2)
    network.add_host(bob)
    
    t1 = alice.run_protocol(AliceProtocol, (repeater0.host_id, Y, M))
    t2 = repeater0.run_protocol(RepeaterProtocol, (alice.host_id, bob.host_id, 0, 1, Y, M))
    #repeater1.run_protocol(RepeaterProtocol, (repeater0.host_id, repeater2.host_id, 1, 2, Y, M))
    #repeater2.run_protocol(RepeaterProtocol, (repeater1.host_id, bob.host_id, 2, 2, Y, M))
    t3 = bob.run_protocol(BobProtocol, (repeater0.host_id, Y, M))

    t1.join()
    t2.join()
    t3.join()

    network.stop(True)
Example #3
0
def main():
    network = Network.get_instance()
    nodes = ["Alice", "Bob", "Eve", "Dean"]
    network.start(nodes)
    network.delay = 0.5

    host_alice = Host('Alice')
    host_alice.add_connection('Bob')
    host_alice.max_ack_wait = 30
    host_alice.delay = 0.2
    host_alice.start()

    host_bob = Host('Bob')
    host_bob.max_ack_wait = 30
    host_bob.delay = 0.2
    host_bob.add_connection('Alice')
    host_bob.add_connection('Eve')
    host_bob.start()

    host_eve = Host('Eve')
    host_eve.max_ack_wait = 30
    host_eve.delay = 0.2
    host_eve.add_connection('Bob')
    host_eve.add_connection('Dean')
    host_eve.start()

    host_dean = Host('Dean')
    host_dean.max_ack_wait = 30
    host_dean.delay = 0.2
    host_dean.add_connection('Eve')
    host_dean.start()

    network.add_host(host_alice)
    network.add_host(host_bob)
    network.add_host(host_eve)
    network.add_host(host_dean)

    network.x_error_rate = 0
    network.packet_drop_rate = 0

    q_size = 6
    checksum_per_qubit = 2

    host_alice.run_protocol(checksum_sender,
                            (q_size, host_dean.host_id, checksum_per_qubit))
    host_dean.run_protocol(checksum_receiver,
                           (q_size, host_alice.host_id, checksum_per_qubit))

    start_time = time.time()
    while time.time() - start_time < 150:
        pass

    network.stop(stop_hosts=True)
    exit()
Example #4
0
def main():
    global thread_1_return
    global thread_2_return

    network = Network.get_instance()
    nodes = ["Alice", "Bob", "Eve", "Dean"]
    network.start(nodes)
    network.delay = 0.5

    host_alice = Host('alice')
    host_alice.add_connection('bob')
    host_alice.max_ack_wait = 30
    host_alice.delay = 0.2
    host_alice.start()

    host_bob = Host('bob')
    host_bob.max_ack_wait = 30
    host_bob.delay = 0.2
    host_bob.add_connection('alice')
    host_bob.add_connection('eve')
    host_bob.start()

    host_eve = Host('eve')
    host_eve.max_ack_wait = 30
    host_eve.delay = 0.2
    host_eve.add_connection('bob')
    host_eve.add_connection('dean')
    host_eve.start()

    host_dean = Host('dean')
    host_dean.max_ack_wait = 30
    host_dean.delay = 0.2
    host_dean.add_connection('eve')
    host_dean.start()

    network.add_host(host_alice)
    network.add_host(host_bob)
    network.add_host(host_eve)
    network.add_host(host_dean)

    host_alice.run_protocol(retransmission_sender,
                            (host_dean.host_id, MAX_TRIAL_NUM))
    host_dean.run_protocol(retransmission_receiver,
                           (host_alice.host_id, MAX_TRIAL_NUM))

    start_time = time.time()
    while time.time() - start_time < 150:
        pass

    network.stop(stop_hosts=True)
    exit()
def main() :

    network = Network.get_instance()
    nodes = ['Alice', 'R', 'Bob']
    network.use_ent_swap = True
    network.delay = 0
    network.start(nodes)

    alice = Host('Alice')
    alice.add_connection('R', 100)
    alice.max_ack_wait = 5
    #alice.coherence_time = 0.0003
    alice.start()

    repeater = Host('R')
    repeater.add_connection('Alice', 100)
    repeater.add_connection('Bob', 100)
    repeater.max_ack_wait = 5
    #repeater.coherence_time = 0.0003
    repeater.start()

    bob = Host('Bob')
    bob.add_connection('R', 100)
    bob.max_ack_wait = 5
    #bob.coherence_time = 0.0003
    bob.start()

    network.add_host(alice)
    network.add_host(repeater)
    network.add_host(bob)

    t1 = alice.run_protocol(AliceProtocol, (repeater.host_id,))
    t2 = repeater.run_protocol(RepeaterProtocol, (alice.host_id, bob.host_id))
    t3 = bob.run_protocol(BobProtocol, (repeater.host_id,))

    t1.join()
    t2.join()
    t3.join()

    network.stop(True)
    sys.exit()
Example #6
0
def main():
    global thread_1_return
    global thread_2_return

    network = Network.get_instance()
    nodes = ["Alice", "Bob", "Eve", "Dean"]
    network.start(nodes)
    network.delay = 0.5

    host_alice = Host('Alice')
    host_alice.add_connection('bob')
    host_alice.max_ack_wait = 30
    host_alice.delay = 0.2
    host_alice.start()

    host_bob = Host('Bob')
    host_bob.max_ack_wait = 30
    host_bob.delay = 0.2
    host_bob.add_connection('Alice')
    host_bob.add_connection('Eve')
    host_bob.start()

    host_eve = Host('Eve')
    host_eve.max_ack_wait = 30
    host_eve.delay = 0.2
    host_eve.add_connection('Bob')
    host_eve.add_connection('Dean')
    host_eve.start()

    host_dean = Host('Dean')
    host_dean.max_ack_wait = 30
    host_dean.delay = 0.2
    host_dean.add_connection('Eve')
    host_dean.start()

    network.add_host(host_alice)
    network.add_host(host_bob)
    network.add_host(host_eve)
    network.add_host(host_dean)

    network.x_error_rate = 0
    network.packet_drop_rate = 0

    q_size = 6
    checksum_per_qubit = 2

    host_alice.run_protocol(qtcp_sender,
                            (q_size, host_dean.host_id, checksum_per_qubit))
    host_dean.run_protocol(qtcp_receiver,
                           (q_size, host_alice.host_id, checksum_per_qubit))

    while thread_1_return is None or thread_2_return is None:
        if thread_1_return is False or thread_2_return is False:
            Logger.get_instance().log(
                'TCP Connection not successful : EXITING')
            sys.exit(1)
        pass

    thread_1_return = None
    thread_2_return = None

    Logger.get_instance().log('PACKET 1')

    host_alice.run_protocol(qtcp_sender,
                            (q_size, host_dean.host_id, checksum_per_qubit))
    host_dean.run_protocol(qtcp_receiver,
                           (q_size, host_alice.host_id, checksum_per_qubit))

    while thread_1_return is None or thread_2_return is None:
        if thread_1_return is False or thread_2_return is False:
            Logger.get_instance().log(
                'TCP Connection not successful : EXITING')
            sys.exit(1)
        pass

    Logger.get_instance().log('PACKET 2')

    host_alice.run_protocol(qtcp_sender,
                            (q_size, host_dean.host_id, checksum_per_qubit))
    host_dean.run_protocol(qtcp_receiver,
                           (q_size, host_alice.host_id, checksum_per_qubit))

    while thread_1_return is None or thread_2_return is None:
        if thread_1_return is False or thread_2_return is False:
            Logger.get_instance().log(
                'TCP Connection not successful : EXITING')
            sys.exit(1)
        pass

    start_time = time.time()
    while time.time() - start_time < 150:
        pass

    network.stop(stop_hosts=True)
    exit()