コード例 #1
0
ファイル: thesismain.py プロジェクト: jonastheis/healthor
def attack_analysis():
    # exceed sending rate experiment
    for name in ['ExceedSendingRateAttack', 'ExceedSendingRateAttackDisabledDefense']:
        h = plot.PlotV1(name, 'Scenario1V1', 60, verbose_logs=True, run_simulation=args.run_simulation, plot_all=False)
        h.plot_allowed_receiving_rate(print_node='node[2]', malicious_node='node[7]', annotation=name)

    # sending nothing to neighbor
    h = plot.PlotV1('SubceedSendingRateAttack', 'Scenario1V1', 60, verbose_logs=True, run_simulation=args.run_simulation, plot_all=False)
    h.plot_allowed_receiving_rate(print_node='node[2]', malicious_node='node[7]', annotation='SubceedSendingRateAttack')

    # low health
    h = plot.PlotV1('LowHealthAttack', 'Scenario1V1', 60, verbose_logs=True, run_simulation=args.run_simulation, plot_all=False)
    h.plot_outboxes(print_node='node[3]', annotation='LowHealthAttack')
コード例 #2
0
def attack_analysis():
    # exceed sending rate experiment
    # for name in ['ExceedSendingRateAttack', 'ExceedSendingRateAttackDisabledDefense']:
    #     h = plot.PlotV1(name, 'Scenario1V1', 60, verbose_logs=True, run_simulation=True, plot_all=False)
    #     h.plot_allowedReceivingRate(print_node='node[2]', malicious_node='node[7]')
    #     h.plot_buffers()
    #     h.plot_sending_rate()
    #     h.plot_throughput()
    #     h.egalitarian_score()

    # sending nothing to neighbor
    # h = plot.PlotV1('SubceedSendingRateAttack', 'Scenario1V1', 60, verbose_logs=True, run_simulation=True, plot_all=False)
    # h.plot_allowedReceivingRate(print_node='node[2]', malicious_node='node[7]')
    # h.plot_buffers()
    # h.plot_sending_rate()
    # h.plot_throughput()
    # h.egalitarian_score()

    # low health
    h = plot.PlotV1('LowHealthAttack', 'Scenario1V1', 60, verbose_logs=True, run_simulation=True, plot_all=False)
    h.plot_outboxes(print_node='node[0]')
    h.plot_outboxes(print_node='node[2]')
    h.plot_outboxes(print_node='node[3]')
    h.plot_outboxes(print_node='node[8]')
    h.plot_outboxes(print_node=None)
    h.plot_sending_rate()
    h.plot_throughput()
    h.egalitarian_score()
コード例 #3
0
ファイル: thesismain.py プロジェクト: jonastheis/healthor
def utilization():
    # utilization N=100
    p = plot.PlotV1('MacroHealthorUtilizationN100T106', 'DynamicNetworkV1', 180, verbose_logs=False,
                    run_simulation=args.run_simulation, plot_all=False)
    # only print the necessary values for the table
    plot_throughput_mean(p, '', plot=False)
    plot_latency_percentile(p, '', plot=False)
    plot_egalitarian_gradient(p, '', plot=False)

    runs = [
        'MacroHealthorUtilizationN500T128',
        'MacroHealthorUtilizationN500T126',
        'MacroHealthorUtilizationN500T124',

        'MacroHealthorUtilizationN1000T116',
        'MacroHealthorUtilizationN1000T114',
        'MacroHealthorUtilizationN1000T112',

        'MacroHealthorUtilizationN2000T110',
        'MacroHealthorUtilizationN2000T108',
        'MacroHealthorUtilizationN2000T106',
    ]

    for name in runs:
        print('Plotting %s...' % name)
        if name.startswith('MacroHealthor'):
            network = 'DynamicNetworkV1'
            p = plot.PlotV1(name, network, 180, verbose_logs=False, run_simulation=args.run_simulation, plot_all=True)
        else:
            network = 'DynamicNetworkBasic'
            p = plot.PlotBasic(name, network, 180, verbose_logs=False, run_simulation=args.run_simulation, plot_all=True)

        # only print the necessary values for the table
        plot_throughput_mean(p, '', plot=False)
        plot_latency_percentile(p, '', plot=False)
        plot_egalitarian_gradient(p, '', plot=False)
        del p
        print('Plotting %s... done' % name)
        print('---------------------------------------')
コード例 #4
0
ファイル: thesismain.py プロジェクト: jonastheis/healthor
def centralization_score_sensitivity():
    runs = [
        'MacroBasicSensitivity100T102',
        'MacroBasicSensitivity100T104',
        'MacroBasicSensitivity100T98',
        'MacroBasicSensitivity100T96',
        'MacroBasicSensitivity100T94',
        'MacroBasicSensitivity100T92',

        'MacroHealthorSensitivity100T96',
        'MacroHealthorSensitivity100T98',
        'MacroHealthorSensitivity100T102',
        'MacroHealthorSensitivity100T104',
        'MacroHealthorSensitivity100T103',
        'MacroHealthorSensitivity100T106',
        'MacroHealthorSensitivity100T108',
        'MacroHealthorSensitivity100T110',
        'MacroHealthorSensitivity100T112',
        'MacroHealthorSensitivity100T114',
        'MacroHealthorSensitivity100T116',
        'MacroHealthorSensitivity100T118',
        'MacroHealthorSensitivity100T120',
        'MacroHealthorSensitivity100T122',
        'MacroHealthorSensitivity100T124',
        'MacroHealthorSensitivity100T126',
        'MacroHealthorSensitivity100T140',
        'MacroHealthorSensitivity100T160',
        'MacroHealthorSensitivity100T180',
        'MacroHealthorSensitivity100T200',
    ]

    for name in runs:
        print('Plotting %s...' % name)
        if name.startswith('MacroHealthor'):
            network = 'DynamicNetworkV1'
            p = plot.PlotV1(name, network, 180, verbose_logs=False, run_simulation=args.run_simulation, plot_all=True)
        else:
            network = 'DynamicNetworkBasic'
            p = plot.PlotBasic(name, network, 180, verbose_logs=False, run_simulation=args.run_simulation, plot_all=True)

        # only print the necessary values for the table
        plot_throughput_mean(p, '', plot=False)
        plot_latency_percentile(p, '', plot=False)
        plot_egalitarian_gradient(p, '', plot=False)
        del p
        print('Plotting %s... done' % name)
        print('---------------------------------------')
コード例 #5
0
ファイル: thesismain.py プロジェクト: jonastheis/healthor
def sec5_evaluation_macrobenchmarks():
    plot.PlotBasic('MacroBasic100', 'DynamicNetworkBasic', 180, verbose_logs=False, run_simulation=args.run_simulation, plot_all=False)
    plot.PlotBasic('MacroFFA100', 'DynamicNetworkBasic', 180, verbose_logs=False, run_simulation=args.run_simulation, plot_all=False)
    plot.PlotV1('MacroHealthor100', 'DynamicNetworkV1', 180, verbose_logs=False, run_simulation=args.run_simulation, plot_all=False)

    plot.PlotBasic('MacroBasic500', 'DynamicNetworkBasic', 180, verbose_logs=False, run_simulation=args.run_simulation, plot_all=False)
    plot.PlotBasic('MacroFFA500', 'DynamicNetworkBasic', 180, verbose_logs=False, run_simulation=args.run_simulation, plot_all=False)
    plot.PlotV1('MacroHealthor500', 'DynamicNetworkV1', 180, verbose_logs=False, run_simulation=args.run_simulation, plot_all=False)

    plot.PlotBasic('MacroBasic1000', 'DynamicNetworkBasic', 180, verbose_logs=False, run_simulation=args.run_simulation, plot_all=False)
    plot.PlotBasic('MacroFFA1000', 'DynamicNetworkBasic', 180, verbose_logs=False, run_simulation=args.run_simulation, plot_all=False)
    plot.PlotV1('MacroHealthor1000', 'DynamicNetworkV1', 180, verbose_logs=False, run_simulation=args.run_simulation, plot_all=False)

    basic = plot.PlotBasic('MacroBasic2000', 'DynamicNetworkBasic', 180, verbose_logs=False, run_simulation=args.run_simulation, plot_all=False)
    ffa = plot.PlotBasic('MacroFFA2000', 'DynamicNetworkBasic', 180, verbose_logs=False, run_simulation=args.run_simulation, plot_all=False)
    healthor = plot.PlotV1('MacroHealthor2000', 'DynamicNetworkV1', 180, verbose_logs=False, run_simulation=args.run_simulation, plot_all=False)
    # generate plots for macrobenchmark section
    sec5_throughput(basic, ffa, healthor, legend=False)
    sec5_egalitarian_gradient(basic, ffa, healthor, legend=True)
    sec5_latency_percentiles(basic, ffa, healthor, legend=False)

    plot.PlotBasic('MacroBasic5000', 'DynamicNetworkBasic', 180, verbose_logs=False, run_simulation=args.run_simulation, plot_all=False)
    plot.PlotBasic('MacroFFA5000', 'DynamicNetworkBasic', 180, verbose_logs=False, run_simulation=args.run_simulation, plot_all=False)
    plot.PlotV1('MacroHealthor5000', 'DynamicNetworkV1', 180, verbose_logs=False, run_simulation=args.run_simulation, plot_all=False)
    return

    # this can be utilized once all the runs are done (e.g. to populate the results table)
    runs = [
        # 'MacroBasic100',
        # 'MacroFFA100',
        # 'MacroHealthor100',
        #
        # 'MacroBasic500',
        # 'MacroFFA500',
        # 'MacroHealthor500',
        #
        # 'MacroBasic1000',
        # 'MacroFFA1000',
        # 'MacroHealthor1000',
        #
        # 'MacroBasic2000',
        # 'MacroFFA2000',
        # 'MacroHealthor2000',

        # 'MacroBasic5000',
        # 'MacroFFA5000',
        # 'MacroHealthor5000',
    ]

    # for name in runs:
    #     print('Plotting %s...' % name)
    #     if name.startswith('MacroHealthor'):
    #         network = 'DynamicNetworkV1'
    #         p = plot.PlotV1(name, network, 180, verbose_logs=False, run_simulation=False, plot_all=False)
    #     else:
    #         network = 'DynamicNetworkBasic'
    #         p = plot.PlotBasic(name, network, 180, verbose_logs=False, run_simulation=False, plot_all=False)
    #
    #     # only print the necessary values for the table
    #     # plot_throughput_mean(p, '', plot=False)
    #     plot_latency_percentile(p, '', plot=False)
    #     # plot_egalitarian_gradient(p, '', plot=False)
    #     del p
    #     print('Plotting %s... done' % name)
    #     print('---------------------------------------')

    # calculate values for 5000 FFA (too big to run normally)
    def throughput_5000_special(path):
        df = pd.read_csv(path)

        all_nodes = list(filter(lambda x: x.startswith('node'), list(df)))
        print(len(all_nodes))

        # determine how many nodes were in sync and average
        total_count = None
        total_in_sync_nodes = None

        for node in all_nodes:
            count, division = np.histogram(df[node], bins=range(180))

            # sum up for throughput average
            if total_count is not None:
                total_count += count
                total_in_sync_nodes += (count > 0).astype(int)
            else:
                total_count = count
                total_in_sync_nodes = (count > 0).astype(int)

        # determine average
        # print(total_count[:-11])
        # print(total_in_sync_nodes[:-11])
        total_count = total_count[:-11] / total_in_sync_nodes[:-11]

        print('Throughput avg mean: %.2f' % np.mean(total_count))

    # throughput_5000_special('msgs-FFA-5000.csv')

    def latency_5000_special(path, percentile):
        df = pd.read_csv(path)
        all_nodes = list(filter(lambda x: x.startswith('node'), list(df)))
        print(len(all_nodes))

        difference_suffix = '_difference'
        msgs_count = df.shape[0]

        # determine which nodes CDF needs to be calculated
        nodes_in_sync = []

        # determine whether node was in sync (for most of the simulation)
        for node in all_nodes:
            msgs_node_missing = df[node].isnull().sum()
            if msgs_node_missing < msgs_count * 0.05:
                nodes_in_sync.append(node)

        print('nodes in sync count', len(nodes_in_sync))
        print('messages count', msgs_count)

        # calculate latency for every message on every in sync node
        # runtime: ~40s
        for node in nodes_in_sync:
            df[node + difference_suffix] = df[node].subtract(df['time'])
            print(node, 'done')

        #
        nodes_difference_columns = [x + difference_suffix for x in nodes_in_sync]
        percentile_name = 'percentile_' + str(percentile)
        percentile_name_difference = percentile_name + '_difference'
        percentile_df = pd.DataFrame(columns=[percentile_name_difference])
        percentile_df[percentile_name_difference] = df[nodes_difference_columns].quantile(percentile, axis=1)

        def calculate_cdf(d, n):
            node_difference = n + '_difference'
            stats_df = d.groupby([node_difference])[node_difference].agg('count').pipe(pd.DataFrame).rename(
                columns={node_difference: 'frequency'})
            stats_df['pdf'] = stats_df['frequency'] / sum(stats_df['frequency'])
            stats_df['cdf'] = stats_df['pdf'].cumsum()
            stats_df = stats_df.reset_index()
            return stats_df

        cdf_df = calculate_cdf(percentile_df, percentile_name)

        # print 0.95 percentile latency of CDF
        np_arr = cdf_df['cdf'].to_numpy()
        m_index = np.where(np_arr >= 0.95)[0][0]
        print('Percentile CDF %.2f 0.95th: %.2f' % (percentile, cdf_df[percentile_name_difference][m_index]))
コード例 #6
0
ファイル: thesismain.py プロジェクト: jonastheis/healthor
def sec5_evaluation_microbenchmarks():
    # main example, inbox250
    basic = plot.PlotBasic('Scenario1', 'Scenario1', 180, verbose_logs=True, run_simulation=args.run_simulation, plot_all=False)
    basic.thesismain_micro_latency()
    basic.thesismain_micro_inbox_solidification_buffer()
    basic.thesismain_micro_throughput(annotation='Scenario1')
    healthor = plot.PlotV1('Scenario1V1', 'Scenario1V1', 180, verbose_logs=True, run_simulation=args.run_simulation, plot_all=False)
    healthor.thesismain_micro_inbox_solidification_buffer()
    healthor.thesismain_micro_latency()
    healthor.thesismain_micro_available_processing()
    healthor.thesismain_micro_throughput()

    # Scenario2
    # main example, inbox250
    basic = plot.PlotBasic('Scenario2', 'Scenario1', 180, verbose_logs=True, run_simulation=args.run_simulation, plot_all=False)
    print_latency_percentile_node(basic, 'node[2]')
    print_latency_percentile_node(basic, 'node[6]')
    plot_latency_percentile(basic, '', plot=False)  # only print network latency percentile
    basic.thesismain_micro_latency()
    basic.thesismain_micro_inbox_solidification_buffer('Scenario2')
    basic.thesismain_micro_throughput('Scenario2')
    healthor = plot.PlotV1('Scenario2V1', 'Scenario1V1', 180, verbose_logs=True, run_simulation=args.run_simulation, plot_all=False)
    print_latency_percentile_node(healthor, 'node[2]')
    print_latency_percentile_node(healthor, 'node[6]')
    plot_latency_percentile(healthor, '', plot=False)  # only print network latency percentile
    healthor.thesismain_micro_inbox_solidification_buffer()
    healthor.thesismain_micro_latency()
    healthor.thesismain_micro_available_processing(annotation='Scenario2')
    healthor.thesismain_micro_throughput()

    # inbox test series
    plot.PlotBasic('Scenario2Inbox100', 'Scenario1', 180, verbose_logs=True, run_simulation=args.run_simulation, plot_all=True)
    plot.PlotV1('Scenario2V1Inbox100', 'Scenario1V1', 180, verbose_logs=True, run_simulation=args.run_simulation, plot_all=True)
    plot.PlotBasic('Scenario2Inbox500', 'Scenario1', 180, verbose_logs=True, run_simulation=args.run_simulation, plot_all=True)
    plot.PlotV1('Scenario2V1Inbox500', 'Scenario1V1', 180, verbose_logs=True, run_simulation=args.run_simulation, plot_all=True)
    plot.PlotBasic('Scenario2Inbox1000', 'Scenario1', 180, verbose_logs=True, run_simulation=args.run_simulation, plot_all=True)
    plot.PlotV1('Scenario2V1Inbox1000', 'Scenario1V1', 180, verbose_logs=True, run_simulation=args.run_simulation, plot_all=True)
    plot.PlotBasic('Scenario2Inbox2000', 'Scenario1', 180, verbose_logs=True, run_simulation=args.run_simulation, plot_all=True)
    plot.PlotV1('Scenario2V1Inbox2000', 'Scenario1V1', 180, verbose_logs=True, run_simulation=args.run_simulation, plot_all=True)

    # outbox test series
    healthor = plot.PlotV1('Scenario2V1Outbox100', 'Scenario1V1', 180, verbose_logs=True, run_simulation=args.run_simulation, plot_all=True)
    healthor.plot_buffers(to_node='node[4]')
    healthor.plot_buffers(to_node='node[6]')
    healthor = plot.PlotV1('Scenario2V1', 'Scenario1V1', 180, verbose_logs=True, run_simulation=args.run_simulation, plot_all=True)
    healthor.plot_buffers(to_node='node[4]')
    healthor.plot_buffers(to_node='node[6]')
    healthor = plot.PlotV1('Scenario2V1Outbox500', 'Scenario1V1', 180, verbose_logs=True, run_simulation=args.run_simulation, plot_all=True)
    healthor.plot_buffers(to_node='node[4]')
    healthor.plot_buffers(to_node='node[6]')
    healthor = plot.PlotV1('Scenario2V1Outbox1000', 'Scenario1V1', 180, verbose_logs=True, run_simulation=args.run_simulation, plot_all=True)
    healthor.plot_buffers(to_node='node[4]')
    healthor.plot_buffers(to_node='node[6]')
    healthor = plot.PlotV1('Scenario2V1Outbox2000', 'Scenario1V1', 180, verbose_logs=True, run_simulation=args.run_simulation, plot_all=True)
    healthor.plot_buffers(to_node='node[4]')
    healthor.plot_buffers(to_node='node[6]')
コード例 #7
0
def test_series():
    plot.PlotBasic('BasicInbox100', 'DynamicNetworkBasic', 180, verbose_logs=False, run_simulation=True)
    plot.PlotBasic('BasicInbox100FFA', 'DynamicNetworkBasic', 180, verbose_logs=False, run_simulation=True)
    plot.PlotV1('V1Inbox100Outbox50', 'DynamicNetworkV1', 180, verbose_logs=False, run_simulation=True)
    plot.PlotV1('V1Inbox100Outbox100', 'DynamicNetworkV1', 180, verbose_logs=False, run_simulation=True)
    plot.PlotV1('V1Inbox100Outbox200', 'DynamicNetworkV1', 180, verbose_logs=False, run_simulation=True)

    plot.PlotBasic('BasicInbox500', 'DynamicNetworkBasic', 180, verbose_logs=False, run_simulation=True)
    plot.PlotBasic('BasicInbox500FFA', 'DynamicNetworkBasic', 180, verbose_logs=False, run_simulation=True)
    plot.PlotV1('V1Inbox500Outbox100', 'DynamicNetworkV1', 180, verbose_logs=False, run_simulation=True)
    plot.PlotV1('V1Inbox500Outbox500', 'DynamicNetworkV1', 180, verbose_logs=False, run_simulation=True)
    plot.PlotV1('V1Inbox500Outbox1000', 'DynamicNetworkV1', 180, verbose_logs=False, run_simulation=True)

    plot.PlotBasic('BasicInbox100Generation90', 'DynamicNetworkBasic', 180, verbose_logs=False, run_simulation=True)
    plot.PlotBasic('BasicInbox100Generation90FFA', 'DynamicNetworkBasic', 180, verbose_logs=False, run_simulation=True)
    plot.PlotV1('V1Inbox100Outbox50Generation90', 'DynamicNetworkV1', 180, verbose_logs=False, run_simulation=True)
    plot.PlotV1('V1Inbox100Outbox100Generation90', 'DynamicNetworkV1', 180, verbose_logs=False, run_simulation=True)
    plot.PlotV1('V1Inbox100Outbox200Generation90', 'DynamicNetworkV1', 180, verbose_logs=False, run_simulation=True)

    plot.PlotBasic('BasicInbox500Generation90', 'DynamicNetworkBasic', 180, verbose_logs=False, run_simulation=True)
    plot.PlotBasic('BasicInbox500Generation90FFA', 'DynamicNetworkBasic', 180, verbose_logs=False, run_simulation=True)
    plot.PlotV1('V1Inbox500Outbox100Generation90', 'DynamicNetworkV1', 180, verbose_logs=False, run_simulation=True)
    plot.PlotV1('V1Inbox500Outbox500Generation90', 'DynamicNetworkV1', 180, verbose_logs=False, run_simulation=True)
    plot.PlotV1('V1Inbox500Outbox1000Generation90', 'DynamicNetworkV1', 180, verbose_logs=False, run_simulation=True)