Beispiel #1
0
def test_Janus_scheduler():
    # in this test program, the Janus exchange period will be discussed and test the throughput under different traffic.
    throughput = []
    for i in range(5):
        throughput_t = []
        for numStation in numOfstations_list:
            stations_pos = np.array(
                genToplogy.rnd_top_square(num_node=numStation))
            matSIR = genMatSIR(stations_pos)
            matSIR = makeAllFullDuplex(matSIR)
            traffic_amount = 0
            for j in range(200):
                if i == 0:  # saturated traffic with the same packet length
                    upstream, downstream = trafficHandler.generateUDtraffic(
                        len(matSIR), 1, 1, True)
                elif i == 1:  # only upstream, nothing to download
                    upstream, downstream = trafficHandler.generateUDtraffic(
                        len(matSIR), 1, 0, True)
                elif i == 2:  # only downstream, nothing to upload
                    upstream, downstream = trafficHandler.generateUDtraffic(
                        len(matSIR), 0, 1, True)
                elif i == 3:  # typical asymmetric traffic
                    upstream, downstream = trafficHandler.genAsymmetricTraffic(
                        len(matSIR), True)
                elif i == 4:  # random traffic
                    upstream, downstream = trafficHandler.generateUDtraffic(
                        len(matSIR), 0.5, 0.5, True)

                traffic_amount += np.sum(np.array(upstream)) + np.sum(
                    np.array(downstream))

                # start the contention free period
                if j == 0:
                    [curr_down_time, curr_up_time, last_dSta, last_uSta, last_op_rate, last_packet_length] \
                        = Janus.Janus_sim_exchange_period(upstream, downstream,matSIR)
                    # print(curr_down_time, curr_up_time)
                else:
                    [curr_down_time, curr_up_time, last_dSta, last_uSta, last_op_rate, last_packet_length] \
                        = Janus.Janus_sim_exchange_period(upstream, downstream, matSIR,curr_down_time, curr_up_time,
                                                          last_dSta, last_uSta, last_op_rate, last_packet_length)

                # checkout whether the contention free period is over, period = 100ms, that is 10**5 us
                if max(curr_down_time, curr_up_time) > 10**5:
                    # print('time out!')
                    break

            # record the throughput
            throughput_t.append(traffic_amount * 8 /
                                max(curr_down_time, curr_up_time))
        throughput.append(throughput_t)
    # print(throughput, delay)
    return throughput
Beispiel #2
0
def test_PCF_traffic():
    throughput = []
    delay = []
    for i in range(5):
        throughput_tmp = []
        delay_tmp = []
        for Station_num in numOfstations_list:
            traffic_amount = 0
            for j in range(100):
                # saturated traffic with different packet length
                if i == 0:  # saturated traffic with the same packet length
                    upstream, downstream = trafficHandler.generateUDtraffic(
                        Station_num, 1, 1, True)
                elif i == 1:  # only upstream, nothing to download
                    upstream, downstream = trafficHandler.generateUDtraffic(
                        Station_num, 1, 0, True)
                elif i == 2:  # only downstream, nothing to upload
                    upstream, downstream = trafficHandler.generateUDtraffic(
                        Station_num, 0, 1, True)
                elif i == 3:  # typical asymmetric traffic
                    upstream, downstream = trafficHandler.genAsymmetricTraffic(
                        Station_num, True)
                elif i == 4:  # random traffic
                    upstream, downstream = trafficHandler.generateUDtraffic(
                        Station_num, 0.5, 0.5, True)
                traffic_amount += np.sum(np.array(upstream)) + np.sum(
                    np.array(downstream))

                if not j:
                    [PCF_timer, PCF_ACK] = PCF.PCF_sim(upstream,
                                                       downstream,
                                                       current_time=0,
                                                       need_ACK=False,
                                                       Vt=18)
                else:
                    [PCF_timer, PCF_ACK] = PCF.PCF_sim(upstream,
                                                       downstream,
                                                       current_time=PCF_timer,
                                                       need_ACK=PCF_ACK,
                                                       Vt=18)

            throughput_tmp.append(traffic_amount * 8 / PCF_timer)
            delay_tmp.append(PCF_timer / 100 / 1000)

        throughput.append(throughput_tmp.copy())
        delay.append(delay_tmp.copy())

    write2excel(throughput, delay)
Beispiel #3
0
def test_different_trafficType():
    throughput = []
    delay = []

    for i in range(5):
        throughput_t = []
        delay_t = []
        for numStation in numOfstations_list:
            stations_pos = np.array(
                genToplogy.rnd_top_square(num_node=numStation))
            matSIR = genMatSIR(stations_pos)
            # matSIR = makeAllFullDuplex(matSIR)
            # matSIR = genMatSIR_directional(stations_pos,AP_pos)
            # print(matSIR)
            traffic_amount = 0
            count_round = 0
            for j in range(20000):
                # saturated traffic with different packet length
                if i == 0:  # saturated traffic with the same packet length
                    upstream, downstream = trafficHandler.generateUDtraffic(
                        len(matSIR), 1, 1, True)
                elif i == 1:  # only upstream, nothing to download
                    upstream, downstream = trafficHandler.generateUDtraffic(
                        len(matSIR), 1, 0, True)
                elif i == 2:  # only downstream, nothing to upload
                    upstream, downstream = trafficHandler.generateUDtraffic(
                        len(matSIR), 0, 1, True)
                elif i == 3:  # typical asymmetric traffic
                    upstream, downstream = trafficHandler.genAsymmetricTraffic(
                        len(matSIR), True)
                elif i == 4:  # random traffic
                    upstream, downstream = trafficHandler.generateUDtraffic(
                        len(matSIR), 0.5, 0.5, True)
                traffic_amount += np.sum(np.array(upstream)) + np.sum(
                    np.array(downstream))

                # start the contention free period
                if j == 0:
                    [curr_down_time, curr_up_time
                     ] = pFHMAC.contention_free_inital_stage_sim(matSIR)
                    [
                        curr_up_time, curr_down_time, last_station, ACK_up,
                        ACK_down, oRateL, LDpay
                    ] = pFHMAC.greedyPolling(
                        matSIR, upstream, downstream, curr_up_time,
                        curr_down_time, [-1, -1],
                        np.zeros((len(matSIR), ), dtype=np.int32),
                        np.zeros((len(matSIR), ), dtype=np.int32))
                else:
                    [
                        curr_up_time, curr_down_time, last_station, ACK_up,
                        ACK_down, oRateL, LDpay
                    ] = pFHMAC.greedyPolling(matSIR, upstream, downstream,
                                             curr_up_time, curr_down_time,
                                             last_station, ACK_up, ACK_down,
                                             oRateL, LDpay)

                count_round += 1
                # checkout whether the contention free period is over, period = 100ms, that is 10**5 us
                if max(curr_down_time, curr_up_time) > 10**5:
                    # print('time out!')
                    break

            # record the throughput
            throughput_t.append(traffic_amount * 8 /
                                max(curr_down_time, curr_up_time))
            delay_t.append(max(curr_down_time, curr_up_time) / count_round)
        throughput.append(throughput_t)
        delay.append(delay_t)
    tmp1 = np.array(delay) / 1000
    delay = tmp1.tolist()
    # print(throughput, delay)
    return throughput, delay
Beispiel #4
0
def test_scheduler_gain():
    throughput = []
    for times in range(10):
        throughput_w = []
        throughput_wo = []
        for i in range(5):
            throughput_each_traffic_type = []
            throughput_each_traffic_type_wo = []
            for num_stations in [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]:
                top_rnd = genToplogy.getRandomTopology([300, 300],
                                                       num_stations)
                matSIR = np.array(genToplogy.calc_SIR(top_rnd, [150, 150],
                                                      100))
                for k in range(len(matSIR)):
                    matSIR[k][k] = 30
                traffic_amount = 0
                for j in range(20000):
                    if i == 0:  # saturated traffic with the same packet length
                        upstream, downstream = trafficHandler.generateUDtraffic(
                            len(matSIR), 1, 1, True)
                    elif i == 1:  # only downstream, nothing to upload
                        upstream, downstream = trafficHandler.generateUDtraffic(
                            len(matSIR), 1, 0, True)
                    elif i == 2:  # only upstream, nothing to download
                        upstream, downstream = trafficHandler.generateUDtraffic(
                            len(matSIR), 0, 1, True)
                    elif i == 3:  # typical asymmetric traffic
                        upstream, downstream = trafficHandler.genAsymmetricTraffic(
                            len(matSIR), True)
                    elif i == 4:  # random traffic
                        upstream, downstream = trafficHandler.generateUDtraffic(
                            len(matSIR), 0.5, 0.5, True)

                    traffic_amount += np.sum(np.array(upstream)) + np.sum(
                        np.array(downstream))

                    # start the contention free period
                    if j == 0:
                        [curr_down_time, curr_up_time
                         ] = pFDMAC.contention_free_inital_stage_sim(matSIR)
                        [
                            curr_up_time1, curr_down_time1, last_station1,
                            ACK_up1, ACK_down1, V_curr1
                        ] = pFDMAC.greedyPollingWithoutScheduler(
                            matSIR,
                            upstream,
                            downstream,
                            curr_up_time,
                            curr_down_time,
                            -1,
                            ACK_up=False,
                            ACK_down=False,
                            current_rate=18)

                        [
                            curr_up_time, curr_down_time, last_station, ACK_up,
                            ACK_down, V_curr
                        ] = pFDMAC.greedyPolling(matSIR,
                                                 upstream,
                                                 downstream,
                                                 curr_up_time,
                                                 curr_down_time,
                                                 -1,
                                                 ACK_up=False,
                                                 ACK_down=False,
                                                 current_rate=18)

                    else:
                        [
                            curr_up_time1, curr_down_time1, last_station1,
                            ACK_up1, ACK_down1, V_curr1
                        ] = pFDMAC.greedyPollingWithoutScheduler(
                            matSIR,
                            upstream,
                            downstream,
                            curr_up_time1,
                            curr_down_time1,
                            last_station1,
                            ACK_up1,
                            ACK_down1,
                            current_rate=V_curr1)
                        [
                            curr_up_time, curr_down_time, last_station, ACK_up,
                            ACK_down, V_curr
                        ] = pFDMAC.greedyPolling(matSIR,
                                                 upstream,
                                                 downstream,
                                                 curr_up_time,
                                                 curr_down_time,
                                                 last_station,
                                                 ACK_up,
                                                 ACK_down,
                                                 current_rate=V_curr)

                    # checkout whether the contention free period is over, period = 100ms, that is 10**5 us
                    if max(curr_down_time, curr_up_time) > 10**5:
                        # print('time out!')
                        break
                # record the throughput
                throughput_each_traffic_type.append(
                    traffic_amount * 8 / max(curr_down_time, curr_up_time))
                throughput_each_traffic_type_wo.append(
                    traffic_amount * 8 / max(curr_down_time1, curr_up_time1))

            throughput_w.append(throughput_each_traffic_type)
            throughput_wo.append(throughput_each_traffic_type_wo)
        throughput.append([throughput_w, throughput_wo])
    print("throghtput(with/without scheduler) of greedy polling:")
    print(throughput)
    print(
        "####################################################################################################"
    )
Beispiel #5
0
def test_performance_betweend_different_protocols_different_packet_length():
    throughputOfDifferentTrafficType = []
    delaOfDifferentTrafficType = []
    for i in range(6):
        throughput = []
        delay = []
        Janus_throughput = []
        Janus_delay = []
        PCF_throughput = []
        PCF_delay = []

        for Plength in [64, 128, 256, 512, 1024, 1500]:
            traffic_amount = 0
            count_round = 0
            PCF_timer = 0
            Janus_flag = True
            for j in range(20000):
                if i == 0:  # saturated traffic with the same packet length
                    upstream, downstream = trafficHandler.generateUDtraffic(
                        len(matSIR), 1, 1, False, Plength)
                elif i == 1:  # only upstream, nothing to download
                    upstream, downstream = trafficHandler.generateUDtraffic(
                        len(matSIR), 1, 0, False, Plength)
                elif i == 2:  # only downstream, nothing to upload
                    upstream, downstream = trafficHandler.generateUDtraffic(
                        len(matSIR), 0, 1, False, Plength)
                elif i == 3:  # typical asymmetric traffic
                    upstream, downstream = trafficHandler.genAsymmetricTraffic(
                        len(matSIR), False, Plength)
                elif i == 4:  # random traffic
                    upstream, downstream = trafficHandler.generateUDtraffic(
                        len(matSIR), 0.5, 0.5, False, Plength)
                elif i == 5:  # saturated traffic with different packet length
                    upstream, downstream = trafficHandler.generateUDtraffic(
                        len(matSIR), 1, 1, True, 1024)

                traffic_amount += np.sum(np.array(upstream)) + np.sum(
                    np.array(downstream))

                # start Janus simulator
                if Janus_flag:
                    Janus_time = Janus.Janus_sim(upstream, downstream, matSIR,
                                                 True)
                    Janus_delay.append(Janus_time)
                    Janus_throughput.append(traffic_amount * 16 / Janus_time)
                    Janus_flag = False
                # start the contention free period
                if j == 0:
                    [curr_down_time, curr_up_time
                     ] = pFDMAC.contention_free_inital_stage_sim(matSIR)
                    [
                        curr_up_time, curr_down_time, last_station, ACK_up,
                        ACK_down, V_curr
                    ] = pFDMAC.greedyPolling(matSIR,
                                             upstream,
                                             downstream,
                                             curr_up_time,
                                             curr_down_time,
                                             -1,
                                             ACK_up=False,
                                             ACK_down=False,
                                             current_rate=18)
                    [PCF_timer, PCF_ACK] = PCF.PCF_sim(upstream,
                                                       downstream,
                                                       current_time=0,
                                                       need_ACK=False,
                                                       Vt=18)
                else:
                    [
                        curr_up_time, curr_down_time, last_station, ACK_up,
                        ACK_down, V_curr
                    ] = pFDMAC.greedyPolling(matSIR,
                                             upstream,
                                             downstream,
                                             curr_up_time,
                                             curr_down_time,
                                             last_station,
                                             ACK_up,
                                             ACK_down,
                                             current_rate=V_curr)
                    [PCF_timer, PCF_ACK] = PCF.PCF_sim(upstream,
                                                       downstream,
                                                       PCF_timer,
                                                       PCF_ACK,
                                                       Vt=18)

                count_round += 1
                # checkout whether the contention free period is over, period = 100ms, that is 10**5 us
                if max(curr_down_time, curr_up_time) > 10**5:
                    # print('time out!')
                    break

            # record the throughput
            throughput.append(traffic_amount * 8 /
                              max(curr_down_time, curr_up_time))
            delay.append(max(curr_down_time, curr_up_time) / count_round)

            PCF_throughput.append(traffic_amount * 8 / PCF_timer)
            PCF_delay.append(PCF_timer / count_round)
            # if i == 5:
            #     break
        print("Type " + str(i + 1) +
              " throghtput and delay of greedy polling:")
        print(throughput)
        print(Janus_throughput)
        print(PCF_throughput)
        delay = list(np.array(delay) / 1000)
        Janus_delay = list(np.array(Janus_delay) / 1000)
        PCF_delay = list(np.array(PCF_delay) / 1000)
        print(delay)
        print(Janus_delay)
        print(PCF_delay)

        throughputOfDifferentTrafficType.append(
            [throughput, Janus_throughput, PCF_throughput])
        delaOfDifferentTrafficType.append([delay, Janus_delay, PCF_delay])
    print(throughputOfDifferentTrafficType)
    print(delaOfDifferentTrafficType)
    print(
        "####################################################################################################"
    )