Example #1
0
 def __init__(self, config):
     self.arg = config
     self._type_problem = config['type']
     self._dim = config['dimension']
     self._elasticity_quotient = config['elasticity_quotient']
     self._lamda_matrix = \
         matrix.get_matrix(self._dim, self._type_problem, [config['elasticity_quotient'], config['rho']])
     self._omega_matrix = \
         matrix.get_eign_matrix(self._dim, self._type_problem, [config['elasticity_quotient'], config['rho']])
     self._inverse_omega_matrix = \
         matrix.get_inv_eign_matrix(self._dim, self._type_problem, [config['elasticity_quotient'], config['rho']])
     self.env_prop = env.EnvironmentProperties(
         config['rho'], config['elasticity_quotient'], 0,
         config['x_velocity'], config['x_velocity'])
Example #2
0
def main():
    if not os.path.isdir(FIGS_FILE):
        os.makedirs(FIGS_FILE)
    # Show Conf
    print "<===============>"
    if IS_MULTIPATH:
        print "Multipath Mode"
    else:
        print "Single Path Mode"
    if IS_BURSTY:
        print "In Bursty Loss Environment"
    else:
        print "In Non-bursty Loss Environment"
    np.random.seed(RANDOM_SEED)

    # Intial sending time
    encoded_pkts, total_n_fecs, pre_encoding_pkts = generate_sending_encoding_pkts(
    )
    call_back_pkts = pre_encoding_pkts[:]
    if IS_MULTIPATH:
        splited_traces = split_trace(encoded_pkts)
        recv_traces = []
        # print splited_traces
        for trace in splited_traces[:]:
            trace_idx = splited_traces.index(trace)
            assert len(splited_traces) == len(MUL_LOSSES)
            assert len(splited_traces) == len(MUL_BURSTYS)
            loss = MUL_LOSSES[trace_idx]
            temp_bursty = MUL_BURSTYS[trace_idx]
            prob_mat = matrix.get_matrix(temp_bursty, loss)

            e_val, e_vec = sla.eigs(np.array(prob_mat).T, k=1, which='LM')
            cum_e_vec = np.cumsum(e_vec)
            cum_mat = [np.cumsum(prob) for prob in prob_mat]
            exp_ratio, loss_show = ratio_testing(cum_e_vec, cum_mat)
            print "Steady Matrix:", e_vec
            print "Expected loss ratio on path" + str(
                trace_idx + 1) + " is ", exp_ratio, "%"
            print "<===============>"

            recv_trace = single_path_deliver(trace, cum_e_vec, cum_mat)
            # if len(recv_trace) > 0:
            recv_traces.append(recv_trace)
        # Before combination, check the loss on each path
        loss_rec, loss_plot_real, ratio_rec = calculate_loss_of_path(
            splited_traces, recv_traces)
        plot_traces_len = [len(trace) for trace in recv_traces]
        rec_trace = combine_traces(recv_traces)

    else:
        prob_mat = matrix.get_matrix(IS_BURSTY, PATH_LOSS)
        e_val, e_vec = sla.eigs(np.array(prob_mat).T, k=1, which='LM')
        cum_e_vec = np.cumsum(e_vec)
        cum_mat = [np.cumsum(prob) for prob in prob_mat]
        exp_ratio, loss_show = ratio_testing(cum_e_vec, cum_mat)
        print "Steady Matrix:", e_vec
        print "Expected loss ratio (single path) is", exp_ratio, "%"
        print "<===============>"

        rec_trace = single_path_deliver(encoded_pkts, cum_e_vec, cum_mat)

    decoded_trace, n_wasted_pkts = fec_decoding(rec_trace, call_back_pkts)
    # print decoded_trace
    # Get delay here
    throughput = get_tp(decoded_trace)
    latency, jitter = get_delay_info(decoded_trace)

    print SIM_LEN, "source packets and", total_n_fecs, "FEC packets,", SIM_LEN + total_n_fecs, "packets in total"
    print "Overhead ratio is: ", float(total_n_fecs) / SIM_LEN
    print len(rec_trace), "packets are received."
    # print len(decoded_trace), "source packets are recoved"
    print len(decoded_trace) + n_wasted_pkts, "source packets are received"
    if IS_MULTIPATH:
        for i in range(len(loss_rec)):
            print "Packets lost on path", i, "is", len(
                loss_rec[i]), ", loss ratio is", ratio_rec[i]
    print "Total loss ratio is:", (
        1.0 - (float(len(decoded_trace)) + n_wasted_pkts) / SIM_LEN) * 100, "%"
    print "Average delay:", latency
    print "Receiving Jitter:", jitter

    if IS_PLOT:
        figs = []
        names = []
        # Matrix evaluation
        name = "Matrix Loss_" + str(IS_BURSTY)
        mat_eva = show.single_loss_show(TESTING_LEN, loss_show, name)
        names.append(name)
        figs.append(mat_eva)

        # For multipath:
        if IS_MULTIPATH:
            for i in range(len(plot_traces_len)):
                name = "Multipath Loss Path" + str(i)
                p = show.single_loss_show(MULTI_SHOW_LEN, loss_plot_real[i],
                                          name)
                names.append(name)
                figs.append(p)

        for i in range(len(figs)):
            figs[i].savefig(FIGS_FILE + names[i] + '.eps',
                            format='eps',
                            dpi=1000,
                            figsize=(30, 10))

    return
Example #3
0
 def test_not_eq_matrices(self):
     assert asyncio.run(get_matrix(
         self.source_url)) != self.traversal_bad, "matrices are equally"
Example #4
0
 def test_500(self):
     assert asyncio.run(get_matrix(
         "https://httpstat.us/500")) == [], "matrices are not equally"
Example #5
0
 def test_eq_matrices(self):
     assert asyncio.run(get_matrix(
         self.source_url)) == self.traversal_ok, "matrices are not equally"