示例#1
0
                        node4 = Node(env, 'N4', r, k)

                        link13 = Link(env, 'L1-3', B, k)
                        link23 = Link(env, 'L2-3', B, k)
                        link34 = Link(env, 'L3-4', B, k)
                        link4I = Link(env, 'L4-I', B, k)

                        txA.out = node1
                        txB.out = node2

                        node1.add_conn(link13, 'I')
                        node2.add_conn(link23, 'I')
                        node3.add_conn(link34, 'I')
                        node4.add_conn(link4I, 'I')

                        link13.out = node3
                        link23.out = node3
                        link34.out = node4
                        link4I.out = rxI

                        simtime = 200

                        env.run(simtime)

                        all_packets_sent = txA.packets_sent + txB.packets_sent
                        all_packets_lost_node = node1.lost_pkts + node2.lost_pkts + node3.lost_pkts + node4.lost_pkts
                        all_packets_lost_links = link13.lost_pkts + link23.lost_pkts + link34.lost_pkts + link4I.lost_pkts

                        loss_probability_nodes += 100.0 * (all_packets_lost_node * 1.0 / all_packets_sent)
                        loss_probability_links += 100.0 * (all_packets_lost_links * 1.0 / all_packets_sent)
                        loss_probability_all += 100.0 * (
示例#2
0
                                txIB.out = node4

                                node1.add_conn(link13, 'I')
                                node1.add_conn(link1A, 'A')

                                node2.add_conn(link23, 'I')
                                node2.add_conn(link2B, 'B')

                                node3.add_conn(link34, 'I')
                                node3.add_conn(link31, 'A')
                                node3.add_conn(link32, 'B')

                                node4.add_conn(link4I, 'I')
                                node4.add_conn(link43, ['A', 'B'])

                                link13.out = node3
                                link23.out = node3
                                link34.out = node4
                                link4I.out = rxI

                                link31.out = node1
                                link32.out = node2
                                link43.out = node3
                                link1A.out = rxA
                                link2B.out = rxB

                                simtime = 200

                                env.run(simtime)

                                all_packets_sent = txA.packets_sent + txB.packets_sent + txIA.packets_sent + txIB.packets_sent
示例#3
0
    for K in K_arr:
        print Fore.BLUE + Style.BRIGHT + "NODE 1" + Style.RESET_ALL

        env = simpy.Environment()
        B = 2e6

        # Sender (tx) -> Node1 -> Link -> Receiver (rx)

        rx = pkt_Receiver(env, 'B')
        tx = pkt_Sender(env, 'A', 'B', time_packets)
        node1 = Node(env, 'N1', np.inf)
        link = Link(env, 'L', B, K)

        tx.out = node1
        node1.add_conn(link, 'B')
        link.out = rx

        env.run()

        print((Fore.LIGHTBLUE_EX + "Loss probability:" + Fore.GREEN + " %.2f%%" + Style.RESET_ALL) % round((100.0 * (tx.packets_sent-rx.packets_recv) / tx.packets_sent), 5))
        print((Fore.LIGHTBLUE_EX + 'Average delay:' + Fore.GREEN + ' %f sec' + Style.RESET_ALL) % round((1.0 * rx.overalldelay / rx.packets_recv), 5))
        print((Fore.LIGHTBLUE_EX + 'Transmitted bandwidth:' + Fore.GREEN + ' %.1f Bytes/sec' + Style.RESET_ALL) % round((1.0 * rx.overallbytes / simtime), 5))

        mu = B * 1.0 / (tmp * 8)

        Wmm1 = 1.0 / (mu - lamb)
        print((Fore.LIGHTBLUE_EX + 'M/M/1:' + Fore.GREEN + ' %f' + Style.RESET_ALL) % Wmm1)

        Wmd1 = 1.0 * (2 * mu - lamb) / (2 * mu * (mu - lamb))

        print((Fore.LIGHTBLUE_EX + 'M/D/1:' + Fore.GREEN + ' %f' + Style.RESET_ALL) % Wmd1)
示例#4
0
            loss_probability = 0
            average_delay = 0
            trans_band = 0
            for i in range(1, 4):
                env = simpy.Environment()

                rx = pkt_Receiver(env, 'B')
                tx = pkt_Sender(env, 'A', lam, 'B')
                node1 = Node(env, 'N1', np.inf)
                node2 = Node(env, 'N2', np.inf)
                link1 = Link(env, 'L1', B, k)
                link2 = Link(env, 'L2', B, k)

                tx.out = node1
                node1.add_conn(link1, 'B')
                link1.out = node2
                node2.add_conn(link2, 'B')
                link2.out = rx

                if k == 10000:
                    simtime = 500
                else:
                    simtime = 30
                env.run(simtime)

                loss_probability += 100.0 * (tx.packets_sent-rx.packets_recv)/tx.packets_sent
                average_delay += 1.0 * rx.overalldelay / rx.packets_recv
                trans_band += 1.0 * rx.overallbytes / simtime

                print("---- lambda: %d, queue size: %d, B: %d, simtime: %d ----" % (lam, k, B, simtime))
                print('Loss probability: %.2f%%' % loss_probability)
示例#5
0
                        node4 = Node(env, 'N4', r, k)

                        link13 = Link(env, 'L1-3', B, k)
                        link23 = Link(env, 'L2-3', B, k)
                        link34 = Link(env, 'L3-4', B, k)
                        link4I = Link(env, 'L4-I', B, k)

                        txA.out = node1
                        txB.out = node2

                        node1.add_conn(link13, 'I')
                        node2.add_conn(link23, 'I')
                        node3.add_conn(link34, 'I')
                        node4.add_conn(link4I, 'I')

                        link13.out = node3
                        link23.out = node3
                        link34.out = node4
                        link4I.out = rxI

                        simtime = 200

                        env.run(simtime)

                        all_packets_sent = txA.packets_sent + txB.packets_sent
                        all_packets_lost_node = node1.lost_pkts + node2.lost_pkts + node3.lost_pkts + node4.lost_pkts
                        all_packets_lost_links = link13.lost_pkts + link23.lost_pkts + link34.lost_pkts + link4I.lost_pkts

                        loss_probability_nodes += 100.0 * (
                            all_packets_lost_node * 1.0 / all_packets_sent)
                        loss_probability_links += 100.0 * (
示例#6
0
            Wmmk = 0
            pb = 0
            loss_probability = 0
            average_delay = 0
            trans_band = 0
            for i in range(1, 4):
                env = simpy.Environment()

                rx = pkt_Receiver(env, 'B')
                tx = pkt_Sender(env, 'A', lam, 'B')
                node2 = Node(env, 'N1', 350, k)
                link = Link(env, 'L', B, np.inf)

                tx.out = node2
                node2.add_conn(link, 'B')
                link.out = rx

                if k == 10000:
                    simtime = 500
                else:
                    simtime = 30
                env.run(simtime)

                loss_probability += 100.0 * (tx.packets_sent -
                                             rx.packets_recv) / tx.packets_sent
                average_delay += 1.0 * rx.overalldelay / rx.packets_recv
                trans_band += 1.0 * rx.overallbytes / simtime

                print(
                    "---- lambda: %d, queue size: %d, B: %d, simtime: %d ----"
                    % (lam, k, B, simtime))
示例#7
0
                                txIB.out = node4

                                node1.add_conn(link13, 'I')
                                node1.add_conn(link1A, 'A')

                                node2.add_conn(link23, 'I')
                                node2.add_conn(link2B, 'B')

                                node3.add_conn(link34, 'I')
                                node3.add_conn(link31, 'A')
                                node3.add_conn(link32, 'B')

                                node4.add_conn(link4I, 'I')
                                node4.add_conn(link43, ['A', 'B'])

                                link13.out = node3
                                link23.out = node3
                                link34.out = node4
                                link4I.out = rxI

                                link31.out = node1
                                link32.out = node2
                                link43.out = node3
                                link1A.out = rxA
                                link2B.out = rxB

                                simtime = 200

                                env.run(simtime)

                                all_packets_sent = txA.packets_sent + txB.packets_sent + txIA.packets_sent + txIB.packets_sent
示例#8
0
        for k in K:
            Wk = 0
            loss_probability = 0
            average_delay = 0
            trans_band = 0
            for i in range(1, 4):
                env = simpy.Environment()

                rx = pkt_Receiver(env, 'B')
                tx = pkt_Sender(env, 'A', lam, 'B')
                node1 = Node(env, 'N1', 300, k)
                link1 = Link(env, 'L1', B, k)

                tx.out = node1
                node1.add_conn(link1, 'B')
                link1.out = rx

                if k == 10000:
                    simtime = 500
                else:
                    simtime = 30

                env.run(simtime)

                loss_probability += 100.0 * (tx.packets_sent -
                                             rx.packets_recv) / tx.packets_sent
                average_delay += 1.0 * rx.overalldelay / rx.packets_recv
                trans_band += 1.0 * rx.overallbytes / simtime

                print(
                    "---- lambda: %d, queue size: %d, B: %d, simtime: %d ----"