def trigger(self): print "Starting experiment..." for nc in self.network_configurations: print "network_configuration:", nc self.data["initial_time"][nc.nc_topo_str][nc.topo_params["num_hosts_per_switch"]] = [] self.data["incremental_time"][nc.nc_topo_str][nc.topo_params["num_hosts_per_switch"]] = [] self.data["validation_time"][nc.nc_topo_str][nc.topo_params["num_hosts_per_switch"]] = [] for i in xrange(self.num_iterations): print "iteration:", i + 1 fv = FlowValidator(nc.ng) with Timer(verbose=True) as t: fv.init_network_port_graph() self.data["initial_time"][nc.nc_topo_str][nc.topo_params["num_hosts_per_switch"]].append(t.secs) self.dump_data() incr_time = self.perform_incremental_times_experiment(fv, self.link_fraction_to_sample) self.data["incremental_time"][nc.nc_topo_str][nc.topo_params["num_hosts_per_switch"]].append(incr_time) self.dump_data()
def trigger(self): for nc in self.nc_list: with Timer(verbose=True) as t: fv = FlowValidator(nc.ng) fv.init_network_port_graph() policy_statements = construct_security_policy_statements(nc) policy_len_str = "# Policy Statements:" + str( len(policy_statements)) print "Total statements:", len(policy_statements) self.data["initialization_time"][policy_len_str][ nc.topo_params["nHostsPerSwitch"]] = [] self.data["validation_time"][policy_len_str][ nc.topo_params["nHostsPerSwitch"]] = [] self.data["initialization_time"][policy_len_str][ nc.topo_params["nHostsPerSwitch"]].append(t.secs) self.dump_data() for i in range(self.num_iterations): with Timer(verbose=True) as t: violations = fv.validate_policy(policy_statements) self.data["validation_time"][policy_len_str][ nc.topo_params["nHostsPerSwitch"]].append(t.secs) self.dump_data() print "Total violations:", len(violations)
def setUpClass(cls): ip_str = "172.17.0.2" port_str = "8181" num_switches_per_grid = 3 num_grids = 1 num_hosts_per_switch = 3 cls.nc_microgrid = NetworkConfiguration( "onos", ip_str, int(port_str), "http://" + ip_str + ":" + port_str + "/onos/v1/", "karaf", "karaf", "microgrid_topo", { "num_switches": 1 + 1 * num_switches_per_grid, "nGrids": num_grids, "nSwitchesPerGrid": num_switches_per_grid, "nHostsPerSwitch": num_hosts_per_switch }, conf_root="configurations/", synthesis_name=None, synthesis_params=None) cls.ng_microgrid = cls.nc_microgrid.setup_network_graph( mininet_setup_gap=1, synthesis_setup_gap=1) cls.fv = FlowValidator(cls.ng_microgrid) cls.fv.init_network_port_graph()
def trigger(self): ng = self.nc.setup_network_graph(mininet_setup_gap=1, synthesis_setup_gap=1) # fv = FlowValidator(ng) # specific_traffic = Traffic(init_wildcard=True) # specific_traffic.set_field("ethernet_type", 0x0800) fv = FlowValidator(ng, use_sdnsim=True, nc=self.nc) specific_traffic = dict() specific_traffic["eth_type"] = 0x0800 src_zone = [fv.network_graph.get_node_object(h_id).switch_port for h_id in fv.network_graph.host_ids] dst_zone = [fv.network_graph.get_node_object(h_id).switch_port for h_id in fv.network_graph.host_ids] lmbdas = list(itertools.permutations(ng.L, 2)) constraints = [PolicyConstraint(CONNECTIVITY_CONSTRAINT, None)] # l = tuple(ng.get_switch_link_data(sw=ng.get_node_object("s3"))) # l = l[:-1] # print l # # src_zone = [fv.network_graph.get_node_object(h_id).switch_port for h_id in ['h41']] # dst_zone = [fv.network_graph.get_node_object(h_id).switch_port for h_id in ['h11']] lmbdas = [(ng.get_link_data('s3', 's1'), ng.get_link_data('s3', 's4'), ng.get_link_data('s3', 's2') )] s = PolicyStatement(self.nc.ng, src_zone, dst_zone, specific_traffic, constraints, lmbdas=lmbdas) violations = fv.validate_policy([s]) for v in violations: print v.src_port, v.dst_port, v.constraint print "Total violations:", len(violations)
def trigger(self): for nc in self.network_configurations: print "Configuration:", nc sL = str(len(list(nc.ng.get_switch_link_data()))) total_host_pairs = (nc.topo_params["num_switches"] * nc.topo_params["num_hosts_per_switch"] * nc.topo_params["num_switches"] * nc.topo_params["num_hosts_per_switch"]) self.data["initial_time"]["|L|: " + sL][str(total_host_pairs)] = [] with Timer(verbose=True) as t: fv = FlowValidator(nc.ng) fv.init_network_port_graph() self.data["initial_time"]["|L|: " + sL][str(total_host_pairs)].append(t.secs) print "Initialized analysis." for k in self.k_values: policy_statements = self.construct_policy_statements(nc, k) self.data["validation_time"]["k: " + str(k) + ", |L|: " + sL][str(total_host_pairs)] = [] for i in range(self.num_iterations): with Timer(verbose=True) as t: violations = fv.validate_policy(policy_statements) self.data["validation_time"][ "k: " + str(k) + ", |L|: " + sL][str(total_host_pairs)].append(t.secs) print "Total violations:", len(violations) print "Does the network configuration satisfy the given policy:", ( len(violations) == 0) self.dump_data()
def trigger(self): for nc in self.network_configurations: print "Configuration:", nc fv = FlowValidator(nc.ng) fv.init_network_port_graph() print "Initialized analysis." for k in self.k_values: policy_statements = self.construct_policy_statements(nc, k) sL = str(len(list(nc.ng.get_switch_link_data()))) for optimization_to_use in self.optimizations_to_use: self.data["validation_time"]["k: " + str(k) + ", |L|: " + sL][optimization_to_use] = [] for i in range(self.num_iterations): with Timer(verbose=True) as t: violations = fv.validate_policy( policy_statements, optimization_to_use) print "Total violations:", len(violations) print "Does the network configuration satisfy the given policy:", ( len(violations) == 0) self.data["validation_time"][ "k: " + str(k) + ", |L|: " + sL][optimization_to_use].append(t.secs) self.dump_data()
def trigger(self): print "Starting experiment..." for nc in self.network_configurations: print "network_configuration:", nc policy_statements = self.construct_policy_statements(nc) nhps = None if nc.topo_name == "microgrid_topo": nhps = nc.topo_params["nHostsPerSwitch"] else: nhps = nc.topo_params["num_hosts_per_switch"] self.data["initial_time"][nc.nc_topo_str][nhps] = [] self.data["active_path_computation_time"][ nc.nc_topo_str][nhps] = [] self.data["path_length"][nc.nc_topo_str][nhps] = [] for i in xrange(self.num_iterations): print "iteration:", i + 1 fv = FlowValidator(nc.ng) with Timer(verbose=True) as t: fv.init_network_port_graph() self.data["initial_time"][nc.nc_topo_str][nhps].append(t.secs) self.dump_data() with Timer(verbose=True) as t: violations = fv.validate_policy( policy_statements, active_path_computation_times=self. data["active_path_computation_time"][ nc.nc_topo_str][nhps], path_lengths=self.data["path_length"][ nc.nc_topo_str][nhps])