def single_flow_test(substrate_topology): the_trial_provider = trial_provider.TrialProvider("single-flow-tests") flow_set = FlowSet() the_trial = trial_provider.Trial("single-flow-test") flows = flow_allocation.single_flow(substrate_topology) flow_set.add_flows(flows) the_trial.add_parameter("180") the_trial.add_parameter("flow-set", flow_set) the_trial_provider.add_trial(the_trial)
def sanity_test_trial(target_graph): the_trial_provider = trial_provider.TrialProvider("sanity-test-trial") flow_set = FlowSet() the_trial = trial_provider.Trial("sanity-test") the_trial.add_parameter("duration", 180) flow_allocation_seed_number, flows = flow_allocation.single_flow( target_graph) flow_set.add_flows(flows) the_trial.add_parameter("flow-set", flow_set) the_trial.add_parameter("seed-number", flow_allocation_seed_number) the_trial_provider.add_trial(the_trial) return the_trial_provider
def mk_trial_provider_with_params(basis_params, per_trial_params, title_fmt_string, provider_name): the_trial_provider = trial_provider.TrialProvider(provider_name) for run_idx, parameter_pack in enumerate(itertools.product(*basis_params)): parameter_pack = {key: value for key, value in parameter_pack} all_parameters = {**parameter_pack, **per_trial_params} all_parameters["run_idx"] = run_idx the_trial = trial_provider.Trial( title_fmt_string.format(**all_parameters)) for param_name, param_value in all_parameters.items(): the_trial.add_parameter(param_name, param_value) the_trial_provider.add_trial(the_trial) return the_trial_provider
def build_tuiti_trial_provider(): id_to_dpid = topo_mapper.get_and_validate_onos_topo_x(EXPECTED_TOPO) source_node, destination_node = (0, 1) disjoint_paths = list(node_disjoint_paths(EXPECTED_TOPO, source_node, destination_node)) the_trial_provider = trial_provider.TrialProvider("tuiti-trial-provider") trial_file_directory = path.Path("/home/alexj/repos/inter-dc/trial-parameters/") trials = TuitiTrial.batch_from_directory(trial_file_directory, id_to_dpid, EXPECTED_TOPO) for the_trial in [t for t in trials # if t.get_parameter("maximum-bandwidth-variation") == 50 # and t.name == "eb-99" ]: the_trial_provider.add_trial(the_trial) return the_trial_provider
def single_path_routing(target_graph): the_trial_provider = trial_provider.TrialProvider("single-path-routing") flow_set = FlowSet() the_trial = trial_provider.Trial("single-path-routing") flow_allocation_seed_number, flows = flow_allocation.compute_equal_flow_allocations( target_graph, 1) flow_set.add_flows(flows) the_trial.add_parameter("K", 1) the_trial.add_parameter("duration", 180) the_trial.add_parameter("flow-set", flow_set) the_trial.add_parameter("seed-number", flow_allocation_seed_number) the_trial_provider.add_trial(the_trial) return the_trial_provider
def ilp_flows(target_graph): def uniform_selection(node_list): [source_node, destination_node] = np.random.choice(node_list, 2, replace=False) return source_node, destination_node def non_uniform_selection(discrete_probability_distribution, node_list): [source_node, destination_node ] = np.random.choice(node_list, size=2, replace=False, p=discrete_probability_distribution) return source_node, destination_node def mk_binomial_probability_distribution(node_set): discrete_probability_distribution = [ ss.binom.pmf(node_id, len(node_set), 0.5) for node_id in node_set ] discrete_probability_distribution[-1] += 1 - sum( discrete_probability_distribution) return discrete_probability_distribution def mk_uniform_probability_distribution(node_set): discrete_probability_distribution = [ 1.0 / len(node_set) for _ in node_set ] return discrete_probability_distribution flow_selection_fn = lambda node_list: non_uniform_selection( mk_uniform_probability_distribution(node_list), node_list) # flow_selection_fn = lambda node_list: non_uniform_selection( # mk_binomial_probability_distribution(node_list), node_list) the_trial_provider = trial_provider.TrialProvider("ilp-flows") flow_set = FlowSet() the_trial = trial_provider.Trial("ilp") # flow_allocation_seed_number = 0xCAFE_BABE flow_allocation_seed_number = 0xDEAD_BEEF flows, link_utilization = flow_allocation.compute_ilp_flows( target_graph, flow_selection_fn, seed_number=flow_allocation_seed_number) flow_set.add_flows(flows) the_trial.add_parameter("duration", 180) the_trial.add_parameter("flow-set", flow_set) the_trial.add_parameter("seed-number", flow_allocation_seed_number) the_trial.add_parameter("link-utilization", link_utilization) the_trial_provider.add_trial(the_trial) return the_trial_provider
def path_hopping_various_k_values(target_graph): the_trial_provider = trial_provider.TrialProvider("varying-k-values") for k_value in range(3, 11, 2): flow_set = FlowSet() the_trial = trial_provider.Trial("varying-k-values-%d" % k_value) the_trial.add_parameter("K", k_value) flow_allocation_seed_number, flows = flow_allocation.compute_equal_flow_allocations( target_graph, k_value) flow_set.add_flows(flows) the_trial.add_parameter("duration", 180) the_trial.add_parameter("flow-set", flow_set) the_trial.add_parameter("seed-number", flow_allocation_seed_number) the_trial_provider.add_trial(the_trial) return the_trial_provider
def flow_allocation_tests(target_graph, number_of_flows): the_trial_provider = trial_provider.TrialProvider("testing") flow_set = FlowSet() the_trial = trial_provider.Trial("testing") flow_allocation_seed_number, flows, link_utilization = flow_allocation.compute_test_flow_allocations( target_graph, number_of_flows) flow_set.add_flows(flows) the_trial.add_parameter("K", 3) the_trial.add_parameter("duration", 180) the_trial.add_parameter("flow-set", flow_set) the_trial.add_parameter("seed-number", flow_allocation_seed_number) the_trial.add_parameter("link-utilization", link_utilization) the_trial_provider.add_trial(the_trial) return the_trial_provider
def greedy_path_hopping_flows(target_graph, K=3): the_trial_provider = trial_provider.TrialProvider("greedy") flow_set = FlowSet() the_trial = trial_provider.Trial("greedy") flow_allocation_seed_number, flows, link_utilization = flow_allocation.compute_optimal_flow_allocations( target_graph, K) flow_set.add_flows(flows) the_trial.add_parameter("K", K) the_trial.add_parameter("duration", 180) the_trial.add_parameter("flow-set", flow_set) the_trial.add_parameter("seed-number", flow_allocation_seed_number) the_trial.add_parameter("link-utilization", link_utilization) the_trial_provider.add_trial(the_trial) return the_trial_provider
def path_hopping_mcf_flows(target_graph, K=3): the_trial_provider = trial_provider.TrialProvider("multiflow-tests") flow_set = FlowSet() the_trial = trial_provider.Trial("path-hopping-mcf") flow_allocation_seed_number, flows, link_utilization = flow_allocation.compute_path_hopping_flows_ilp( target_graph, K) flow_set.add_flows(flows) the_trial.add_parameter("duration", 180) the_trial.add_parameter("flow-set", flow_set) the_trial.add_parameter("seed-number", flow_allocation_seed_number) the_trial.add_parameter("link-utilization", link_utilization) the_trial.add_parameter("K", K) the_trial_provider.add_trial(the_trial) return the_trial_provider
def attempted_optimal_flows(target_graph): the_trial_provider = trial_provider.TrialProvider("optimal-varying-k") flow_set = FlowSet() for K in range(3, 4): the_trial = trial_provider.Trial("optimal-%d" % K) flow_allocation_seed_number, flows, link_utilization = flow_allocation.compute_optimal_flow_allocations( target_graph, K) flow_set.add_flows(flows) the_trial.add_parameter("K", K) the_trial.add_parameter("duration", 180) the_trial.add_parameter("flow-set", flow_set) the_trial.add_parameter("seed-number", flow_allocation_seed_number) the_trial.add_parameter("link-utilization", link_utilization) the_trial_provider.add_trial(the_trial) return the_trial_provider
def varying_number_of_paths_fast_hopping(): NUMBER_OF_RUNS = 10 the_trial_provider = trial_provider.TrialProvider("sim-number-of-paths-fast-hops") for number_of_paths in [i*10 for i in range(1, 11)]: for run_idx, seed_number in enumerate([rand.randint(0, 2**32) for _ in range(NUMBER_OF_RUNS)]): the_trial = trial_provider.Trial(f"number-of-paths-{number_of_paths}-run-{run_idx}") the_trial.add_parameter("path_length", 5) the_trial.add_parameter("K", number_of_paths // 2) the_trial.add_parameter("N", number_of_paths) the_trial.add_parameter("attacker_hop_period", 1) the_trial.add_parameter("seed_number", seed_number) the_trial.add_parameter("sim_duration", 10**4) the_trial_provider.add_trial(the_trial) return the_trial_provider
def test_with_single_trial(): the_trial_provider = trial_provider.TrialProvider("attacker-testing-latency") the_trial = trial_provider.Trial("attacker-testing") the_trial.add_parameter("K", 5) the_trial.add_parameter("N", 9) the_trial.add_parameter("port", 11111) the_trial.add_parameter("input-file", path.Path("/home/cpsc-net-user/repos/mtd-crypto-impl/data/random_byte_20MB.dat")) the_trial.add_parameter("output-file", path.Path("./out.dat")) the_trial.add_parameter("message-size", 256) the_trial.add_parameter("timestep", 100) the_trial.add_parameter("lambda", 0) the_trial.add_parameter("reliable", "False") the_trial.add_parameter("hop", "host") the_trial_provider.add_trial(the_trial) return the_trial_provider
def test_with_varying_delta_values(): the_trial_provider = trial_provider.TrialProvider("delta-values-discrete-delay") for delta_value in [10, 100, 1000]: the_trial = trial_provider.Trial("delta-%d" % delta_value) the_trial.add_parameter("K", 5) the_trial.add_parameter("port", 11111) the_trial.add_parameter("N", 9) the_trial.add_parameter("input-file", path.Path("/home/cpsc-net-user/repos/mtd-crypto-impl/data/random_byte_20MB.dat")) the_trial.add_parameter("output-file", path.Path("./out.dat")) the_trial.add_parameter("timestep", delta_value) the_trial.add_parameter("lambda", 0) the_trial.add_parameter("reliable", "False") the_trial.add_parameter("hop", "host") the_trial.add_parameter("message-size", 256) the_trial_provider.add_trial(the_trial) return the_trial_provider
def build_mininet_test_trial_provider(): id_to_dpid = topo_mapper.get_and_validate_onos_topo_x(EXPECTED_TOPO) source_node, destination_node = (0, 1) print(source_node, destination_node) disjoint_paths = list(node_disjoint_paths(EXPECTED_TOPO, source_node, destination_node)) the_trial_provider = trial_provider.TrialProvider("mininet-trial") flow_set = trial_provider.FlowSet() the_trial = trial_provider.Trial("mininet-test") the_trial.add_parameter("duration", 120) flow_tx_rate = 131072 * 100 the_flow = trial_provider.Flow( source_node = source_node , destination_node = destination_node , flow_tx_rate = flow_tx_rate , paths = disjoint_paths , splitting_ratio = [1.0] + [0]*(len(disjoint_paths)-1) ) flow_set.add_flows([the_flow]) the_trial.add_parameter("seed-number", 0) the_trial.add_parameter("flow-set", flow_set) the_trial.add_parameter("traffic-sampling-distribution", "uniform") the_trial_provider.add_trial(the_trial) return the_trial_provider
def k_flows_tests(substrate_topology): DEFAULT_FLOW_ALLOCATION_SEED_NUMBER = 0xCAFE_BABE node_selection_type = "constant" def uniform_selection(node_list): [source_node, destination_node] = np.random.choice(node_list, 2, replace=False) return source_node, destination_node def non_uniform_selection(discrete_probability_distribution, node_list): [source_node, destination_node ] = np.random.choice(node_list, size=2, replace=False, p=discrete_probability_distribution) return source_node, destination_node def constant_selection(node_list): node_list = list(node_list) print(node_list) print(node_list[0], node_list[1]) return node_list[0], node_list[1] def mk_binomial_probability_distribution(node_set): discrete_probability_distribution = [ ss.binom.pmf(node_id, len(node_set), 0.5) for node_id in node_set ] discrete_probability_distribution[-1] += 1 - sum( discrete_probability_distribution) return discrete_probability_distribution def mk_uniform_probability_distribution(node_set): discrete_probability_distribution = [ 1.0 / len(node_set) for _ in node_set ] return discrete_probability_distribution if node_selection_type == "binomial": discrete_probability_distribution = mk_binomial_probability_distribution( substrate_topology.nodes) FLOW_SELECTOR = lambda node_list: non_uniform_selection( discrete_probability_distribution, node_list) elif node_selection_type == "uniform": discrete_probability_distribution = mk_uniform_probability_distribution( substrate_topology.nodes) FLOW_SELECTOR = uniform_selection elif node_selection_type == "constant": FLOW_SELECTOR = constant_selection the_trial_provider = trial_provider.TrialProvider("k-paths-testing") flow_set = FlowSet() k_paths_trial = trial_provider.Trial("k-paths-allocation") flows, link_utilization = flow_allocation.testing_k_paths_flow_allocation( substrate_topology, FLOW_SELECTOR, DEFAULT_FLOW_ALLOCATION_SEED_NUMBER) flow_set.add_flows(flows) k_paths_trial.add_parameter("duration", 180) k_paths_trial.add_parameter("flow-set", flow_set) k_paths_trial.add_parameter("seed-number", DEFAULT_FLOW_ALLOCATION_SEED_NUMBER) k_paths_trial.add_parameter("link-utilization", link_utilization) the_trial_provider.add_metadata("node-selection-type", node_selection_type) the_trial_provider.add_trial(k_paths_trial) return the_trial_provider
def multiflow_tests(target_graph, node_selection_type, K=3): NUMBER_OF_TRIALS = 10 TRIAL_DURATION = 180 def uniform_selection(node_list): [source_node, destination_node] = np.random.choice(node_list, 2, replace=False) return source_node, destination_node def non_uniform_selection(discrete_probability_distribution, node_list): [source_node, destination_node ] = np.random.choice(node_list, size=2, replace=False, p=discrete_probability_distribution) return source_node, destination_node def mk_binomial_probability_distribution(node_set): discrete_probability_distribution = [ ss.binom.pmf(node_id, len(node_set), 0.5) for node_id in node_set ] discrete_probability_distribution[-1] += 1 - sum( discrete_probability_distribution) return discrete_probability_distribution def mk_uniform_probability_distribution(node_set): discrete_probability_distribution = [ 1.0 / len(node_set) for _ in node_set ] return discrete_probability_distribution if node_selection_type == "binomial": discrete_probability_distribution = mk_binomial_probability_distribution( target_graph.nodes) FLOW_SELECTOR = lambda node_list: non_uniform_selection( discrete_probability_distribution, node_list) elif node_selection_type == "uniform": discrete_probability_distribution = mk_uniform_probability_distribution( target_graph.nodes) FLOW_SELECTOR = uniform_selection def k_paths_allocation(target_graph, K, flow_allocation_seed_number): flow_set = FlowSet() k_paths_trial = trial_provider.Trial("k-paths-allocation") flows, link_utilization = flow_allocation.compute_ilp_flows( target_graph, FLOW_SELECTOR, seed_number=flow_allocation_seed_number) flow_set.add_flows(flows) k_paths_trial.add_parameter("duration", TRIAL_DURATION) k_paths_trial.add_parameter("flow-set", flow_set) k_paths_trial.add_parameter("seed-number", flow_allocation_seed_number) k_paths_trial.add_parameter("link-utilization", link_utilization) k_paths_trial.add_parameter("K", K) return k_paths_trial def path_hopping_allocation(target_graph, K, flow_allocation_seed_number): flow_set = FlowSet() path_hopping_trial = trial_provider.Trial("path-hopping-allocation") flows, link_utilization = flow_allocation.compute_path_hopping_flows_ilp( target_graph, K, FLOW_SELECTOR, seed_number=flow_allocation_seed_number) flow_set.add_flows(flows) path_hopping_trial.add_parameter("duration", TRIAL_DURATION) path_hopping_trial.add_parameter("flow-set", flow_set) path_hopping_trial.add_parameter("seed-number", flow_allocation_seed_number) path_hopping_trial.add_parameter("link-utilization", link_utilization) path_hopping_trial.add_parameter("K", K) return path_hopping_trial def mcf_allocation(target_graph, flow_allocation_seed_number): flow_set = FlowSet() mcf_trial = trial_provider.Trial("mcf-trial") flows, link_utilization = flow_allocation.compute_mcf_flows( target_graph, FLOW_SELECTOR, seed_number=flow_allocation_seed_number) flow_set.add_flows(flows) mcf_trial.add_parameter("duration", TRIAL_DURATION) mcf_trial.add_parameter("flow-set", flow_set) mcf_trial.add_parameter("seed-number", flow_allocation_seed_number) mcf_trial.add_parameter("link-utilization", link_utilization) return mcf_trial def greedy_path_hopping_allocation(target_graph, flow_allocation_seed_number): flow_set = FlowSet() path_hopping_trial = trial_provider.Trial("greedy-path-hopping") flows, link_utilization = flow_allocation.compute_greedy_flow_allocations( target_graph, FLOW_SELECTOR, seed_number=flow_allocation_seed_number) flow_set.add_flows(flows) path_hopping_trial.add_parameter("duration", TRIAL_DURATION) path_hopping_trial.add_parameter("flow-set", flow_set) path_hopping_trial.add_parameter("seed-number", flow_allocation_seed_number) path_hopping_trial.add_parameter("link-utilization", link_utilization) return path_hopping_trial the_trial_provider = trial_provider.TrialProvider("multiflow-tests-%s" % node_selection_type) for _ in range(NUMBER_OF_TRIALS): flow_allocation_seed_number = rand.randint(0, 2**32) the_trial_provider.add_trial( k_paths_allocation(target_graph, K, flow_allocation_seed_number)) the_trial_provider.add_trial( mcf_allocation(target_graph, flow_allocation_seed_number)) the_trial_provider.add_trial( greedy_path_hopping_allocation(target_graph, flow_allocation_seed_number)) the_trial_provider.add_metadata("node-probability-distribution", discrete_probability_distribution) the_trial_provider.add_metadata("substrate-topology", target_graph) the_trial_provider.add_metadata("node-selection-type", node_selection_type) return the_trial_provider