Пример #1
0
def caida():
    # normal_sigs, normal_nodes = parseToCoo('../loc6-20070501-100.sigs',
    #         undirected=True)
    # model, para, debug_ret = select_model(len(normal_nodes), normal_sigs, 50, 50, True)
    # import ipdb;ipdb.set_trace()

    # ROOT = '/home/wangjing/LocalResearch/CyberData/caida-data/passive-2013/'
    ROOT = '../'
    normal_sigs, normal_nodes = parseToCoo(ROOT + \
            'equinix-sanjose.dirA.20130117-125912.UTC.anon-10.sigs',
            undirected=True, first_k=None)

    botnet_sigs, botnet_nodes = parseToCoo(
        '../ddostrace.20070804_134936-10.sigs', undirected=True)

    model, para, debug_ret = select_model(len(normal_nodes), normal_sigs, 4,
                                          1000, True)
    data_set = normal_sigs * 3 + botnet_sigs + normal_sigs * 3
    divs1 = monitor_deg_dis(data_set, 'CHJ', [debug_ret['CHJ'][1], 1e-10])
    divs3 = monitor_deg_dis(data_set, 'BA', [debug_ret['BA'][1], 1e-10])
    divs2 = monitor_deg_dis(data_set, 'ER', [debug_ret['ER'][1], 1e-10])
    dump_data = {'d1': divs1, 'd2': divs2, 'd3': divs3}
    dump(dump_data, './CHJ_overperform_BA.pk')
    P.subplot(311)
    P.plot(divs1)
    P.subplot(312)
    P.plot(divs2)
    P.subplot(313)
    P.plot(divs3)
    P.show()

    import ipdb
    ipdb.set_trace()
Пример #2
0
def old_caida():
    ROOT = '/home/wangjing/LocalResearch/CyberData/caida-data/'
    T = 4.33
    dur_set = np.linspace(0.1, T * 0.9, 20)

    lk_list = []
    for dur in dur_set:
        dat = load(ROOT + 'passive-2013-sigs-%f/sigs.pk' % (dur))
        sigs, nodes = old_pk_to_coo(dat, True)
        print('len sigs', len(sigs))
        # model, para, debug_ret = select_model(len(nodes), sigs, min([40, len(sigs)]), 200, True)
        model, para, debug_ret = select_model(len(nodes), sigs, len(sigs), 200,
                                              True)
        lk_list.append(debug_ret['ER'][2])
        print('log likelihood value', debug_ret['ER'][2])
        print('para', para)
        print('model', model)

    dump({
        'x': dur_set,
        'y': lk_list,
        'x_name': 'dur_set',
        'y_name': 'lk_list'
    }, './caida-backbone-er-different-window-size-large-sample.pk')

    P.plot(dur_set, lk_list)
    # P.plot(sdd)
    P.show()
    import ipdb
    ipdb.set_trace()
Пример #3
0
def caida():
    # normal_sigs, normal_nodes = parseToCoo('../loc6-20070501-100.sigs',
    #         undirected=True)
    # model, para, debug_ret = select_model(len(normal_nodes), normal_sigs, 50, 50, True)
    # import ipdb;ipdb.set_trace()

    # ROOT = '/home/wangjing/LocalResearch/CyberData/caida-data/passive-2013/'
    ROOT = '../'
    normal_sigs, normal_nodes = parseToCoo(ROOT + \
            'equinix-sanjose.dirA.20130117-125912.UTC.anon-10.sigs',
            undirected=True, first_k=None)

    botnet_sigs, botnet_nodes = parseToCoo('../ddostrace.20070804_134936-10.sigs', undirected=True)

    model, para, debug_ret = select_model(len(normal_nodes), normal_sigs, 4, 1000, True)
    data_set = normal_sigs * 3  + botnet_sigs + normal_sigs * 3
    divs1 = monitor_deg_dis(data_set, 'CHJ', [debug_ret['CHJ'][1], 1e-10])
    divs3 = monitor_deg_dis(data_set, 'BA', [debug_ret['BA'][1], 1e-10])
    divs2 = monitor_deg_dis(data_set, 'ER', [debug_ret['ER'][1], 1e-10])
    dump_data = {'d1': divs1, 'd2': divs2, 'd3': divs3}
    dump(dump_data, './CHJ_overperform_BA.pk')
    P.subplot(311)
    P.plot(divs1)
    P.subplot(312)
    P.plot(divs2)
    P.subplot(313)
    P.plot(divs3)
    P.show()


    import ipdb;ipdb.set_trace()
Пример #4
0
def validate_select_model_with_ER(N):
    p_set = np.linspace(0.0001, 0.05, 10)
    dat = dict()
    dat['p_set'] = p_set
    dat['ret'] = []
    for p in p_set:
        normal_sigs = gen_sigs('ER', 100, N, p)
        normal_nodes = range(N)
        model, para, debug_ret = select_model(len(normal_nodes), normal_sigs, 50, 50, True)
        dat['ret'].append(debug_ret)

    dump(dat, 'validate_select_model_with_ER-N-%s.pk' % (N))
Пример #5
0
def validate_select_model_with_ER(N):
    p_set = np.linspace(0.0001, 0.05, 10)
    dat = dict()
    dat['p_set'] = p_set
    dat['ret'] = []
    for p in p_set:
        normal_sigs = gen_sigs('ER', 100, N, p)
        normal_nodes = range(N)
        model, para, debug_ret = select_model(len(normal_nodes), normal_sigs,
                                              50, 50, True)
        dat['ret'].append(debug_ret)

    dump(dat, 'validate_select_model_with_ER-N-%s.pk' % (N))
Пример #6
0
def validate_select_model_with_BA(m):
    N_set = [50, 150, 250, 350]
    dat = dict()
    dat['N'] = N_set
    dat['ret'] = []
    for N in N_set:
        normal_sigs = gen_sigs('BA', 100, N, m)
        normal_nodes = range(N)
        model, para, debug_ret = select_model(len(normal_nodes), normal_sigs, 50, 50, True)

        dat['ret'].append(debug_ret)

    dump(dat, 'validate_select_model_with_BA-m-%i.pk' % (m))
Пример #7
0
def validate_select_model_with_BA(m):
    N_set = [50, 150, 250, 350]
    dat = dict()
    dat['N'] = N_set
    dat['ret'] = []
    for N in N_set:
        normal_sigs = gen_sigs('BA', 100, N, m)
        normal_nodes = range(N)
        model, para, debug_ret = select_model(len(normal_nodes), normal_sigs,
                                              50, 50, True)

        dat['ret'].append(debug_ret)

    dump(dat, 'validate_select_model_with_BA-m-%i.pk' % (m))
Пример #8
0
def validate_select_model_with_power_law(p):
    N_set = [50, 150, 250, 350]
    dat = dict()
    dat['N'] = N_set
    dat['ret'] = []
    for N in N_set:
        normal_sigs = gen_sigs('powerlaw_cluster_graph', 100, N, 2, p)
        normal_nodes = range(N)
        model, para, debug_ret = select_model(len(normal_nodes), normal_sigs, 50, 50, True)

        dat['ret'].append(debug_ret)
    # import ipdb;ipdb.set_trace()

    dump(dat, 'validate_select_model_with_power_law-p-%s.pk' % (p))
Пример #9
0
def validate_select_model_with_power_law(p):
    N_set = [50, 150, 250, 350]
    dat = dict()
    dat['N'] = N_set
    dat['ret'] = []
    for N in N_set:
        normal_sigs = gen_sigs('powerlaw_cluster_graph', 100, N, 2, p)
        normal_nodes = range(N)
        model, para, debug_ret = select_model(len(normal_nodes), normal_sigs,
                                              50, 50, True)

        dat['ret'].append(debug_ret)
    # import ipdb;ipdb.set_trace()

    dump(dat, 'validate_select_model_with_power_law-p-%s.pk' % (p))
Пример #10
0
def old_caida():
    ROOT = '/home/wangjing/LocalResearch/CyberData/caida-data/'
    T = 4.33
    dur_set = np.linspace(0.1, T*0.9, 20)

    lk_list = []
    for dur in dur_set:
        dat = load(ROOT+'passive-2013-sigs-%f/sigs.pk' % (dur))
        sigs, nodes = old_pk_to_coo(dat, True)
        print('len sigs', len(sigs))
        # model, para, debug_ret = select_model(len(nodes), sigs, min([40, len(sigs)]), 200, True)
        model, para, debug_ret = select_model(len(nodes), sigs, len(sigs), 200, True)
        lk_list.append(debug_ret['ER'][2])
        print('log likelihood value', debug_ret['ER'][2])
        print('para', para)
        print('model', model)

    dump({'x':dur_set, 'y':lk_list, 'x_name':'dur_set', 'y_name':'lk_list'},
            './caida-backbone-er-different-window-size-large-sample.pk')

    P.plot(dur_set, lk_list)
    # P.plot(sdd)
    P.show()
    import ipdb;ipdb.set_trace()