def test(config_name=None, is_export=True, is_simulate=False): cfgHelper = ConfigDataHelper(config_name, is_export) cfgHelper.init_task_graph() cfgHelper.update_topo_device_graph() cfgHelper.update_task_map() _topo, topo_device_graph, Gd, G_map = cfgHelper.get_graphs() # simulate if is_simulate: control_plane, data_plane = _init_netsim(topo_device_graph, Gd, G_map) # cleanup data_plane.start(is_validate=True) data_plane.stop()
def test(config_name=None, is_export=True, is_simulate=False): if not config_name: config_name = 'sample_configs/config_ddflow_demo' _check_support_config(config_name) cfgHelper = ConfigDataHelper(Config(config_name), is_export) cfgHelper.init_task_graph() cfgHelper.update_topo_device_graph() cfgHelper.update_task_map() _topo, topo_device_graph, Gd, G_map = cfgHelper.get_graphs() # simulate if is_simulate: control_plane, data_plane = _init_netsim(topo_device_graph, Gd, G_map) # cleanup data_plane.start(is_validate=True) data_plane.start_workers() data_plane.stop_workers() data_plane.stop()
def test(cls, config_name=None, is_export=True, is_update_map=True, is_simulate=True): if not config_name: config_name = 'sample_configs/config_ddflow_demo' _check_support_config(config_name) cfgHelper = ConfigDataHelper(Config(config_name), is_export) cfgHelper.init_task_graph() cfgHelper.update_topo_device_graph() cfgHelper.update_task_map() cfgHelper.update_max_latency_log() # scenarios: # (1) initial deployment, all links are alive # (2) P3.X2LARGE.0 poor connection # (3) T3.XLARGE.0 poor connection # (4) P3.X2LARGE.0 back online if is_simulate: log.info("=== start mininet ===") _topo, topo_device_graph, Gd, G_map = cfgHelper.get_graphs() _control_plane, data_plane = _init_netsim(topo_device_graph, Gd, G_map) raw_input('press any key to start the network') data_plane.start(is_validate=True) data_plane.print_net_info() raw_input('press any key to start scenario 1') log.info('=== running scenario 1: initial deployment ===') data_plane.start_workers() data_plane.print_net_info() raw_input('press any key to start scenario 2') log.info('=== running scenario 2: P3_2XLARGE.0 poor connection ===') nw_dev1 = 'BB_SWITCH.0' nw_dev2 = 'CENTER_SWITCH.1' new_latency = Unit.ms(1000) cls.update_nw_latency(cfgHelper, data_plane, nw_dev1, nw_dev2, new_latency, is_simulate) if is_update_map: cls.update_placement(cfgHelper, data_plane, is_simulate) data_plane.print_net_info() raw_input('press any key to start scenario 3') log.info('=== running scenario 3: T3_LARGE.0 poor connection ===') nw_dev1 = 'BB_SWITCH.1' nw_dev2 = 'FIELD_SWITCH.1' new_latency = Unit.ms(2000) cls.update_nw_latency(cfgHelper, data_plane, nw_dev1, nw_dev2, new_latency, is_simulate) if is_update_map: cls.update_placement(cfgHelper, data_plane, is_simulate) data_plane.print_net_info() raw_input('press any key to start scenario 4') log.info('=== running scenario 4: P3_2XLARGE.0 back online ===') nw_dev1 = 'BB_SWITCH.0' nw_dev2 = 'CENTER_SWITCH.1' new_latency = Unit.ms(2) cls.update_nw_latency(cfgHelper, data_plane, nw_dev1, nw_dev2, new_latency, is_simulate) if is_update_map: cls.update_placement(cfgHelper, data_plane, is_simulate) raw_input('press any key to end test') if is_simulate: data_plane.stop_workers() data_plane.stop() log.info('latency trend: {}'.format(cfgHelper.get_max_latency_log()))
def test(cls, config_name=None, is_export=True, is_update_map=True, is_simulate=True): if not config_name: config_name = 'sample_configs/config_ddflow_demo' _check_support_config(config_name) #Config(config_name): This reads the file and all the json data in devices, nw_devices and tasks cfgHelper = ConfigDataHelper(Config(config_name), is_export) #Task graph is generated, let us print it cfgHelper.init_task_graph() # Task Name with the node names. # Task links is the connectivity, used for data flow # Task attributes are the attributes from task file about how to invoke the task. # Task attributed also have the resources required #Device graph along with links cfgHelper.update_topo_device_graph() # # # raw_input('Sandeep Task Graph: Press enter to continue: ') # # print('*'*100) # print('*'*100) # print('Nodes in the task graph') # print(list(cfgHelper.Gt.nodes)) # # print('*'*100) # print('*'*100) # print('Edges in the task graph') # print(list(cfgHelper.Gt.edges)) # # # raw_input('Sandeep Device Graphs: Press enter to continue: ') # # print('*'*100) # print('*'*100) # #print('Nodes in the graphs') # # print(list(cfgHelper.Gn.nodes)) # print('*'*100) # print(list(cfgHelper.Gn.edges)) # print('*'*100) # print('*'*100) # # print(list(cfgHelper.Gnd.nodes)) # print('*'*100) # print(list(cfgHelper.Gnd.edges)) # print('*'*100) # print('*'*100) # # # print(list(cfgHelper.Gd.nodes)) # print('*'*100) # print(list(cfgHelper.Gd.edges)) # # # # exit(0) # This is the ILP ilp_solver # Katie is solving for all but updating only for the unique_id=0 #ILP solver is using Gt and Gd. Gd is devices connectivity and has nothing about network. network # is included in the terms of devices connectivity cfgHelper.update_task_map() # This is again some ILP functionality # Getting the maximum latency for the current mapping # Max latency canbe obtained only once the solution is fully mapped cfgHelper.update_max_latency_log() log.info("=== start mininet ===") # Gd is the devices graphs (All has the network devices (switches,AP) and links) # G_map is the ILP solved mapping of the tasks to devices # _topo: this is not used. Is the network graph, only network devices # topo_device_graph: network devices + devices (We use this for the creation of mininet) _topo, topo_device_graph, Gd, G_map = cfgHelper.get_graphs() #Printing the graphs which we are using in the AirSim # raw_input('Sandeep Task Graph: Press enter to continue: ') # # print('*'*100) # print('*'*100) # print('Nodes in the topo_device_graph graph') # print(list(topo_device_graph.nodes)) # # print('*'*100) # print('*'*100) # print('Edges in the topo_device_graph graph') # print(list(topo_device_graph.edges)) # print('*'*100) # print('*'*100) # print('Nodes in the Gd graph') # print(list(Gd.nodes)) # # print('*'*100) # print('*'*100) # print('Edges in the Gd graph') # print(list(Gd.edges)) # # # print('*'*100) # print('*'*100) # print('Nodes in the G_map graph') # print(list(G_map.nodes)) # # print('*'*100) # print('*'*100) # print('Edges in the G_map graph') # print(list(G_map.edges)) #exit(0) #We are getting some graphs and then calling the _init_netsim # To every device container/host container in the Mininet, we # have two IPS: Mininer_ip = ip, and docker_ip. ip is used # to talk containers with each other (so that they follow the Mininet network characteristics) # docker_ip is used by the external process in the same machine to forward data to the mininet hosts(docker container) # Docker containers by default have access to outside network (external machines, internet) data_plane = _init_netsim(topo_device_graph, Gd, G_map) # raw_input('press any key to start the network') data_plane.start(is_validate=True) data_plane.print_net_info() # raw_input('press any key to start scenario') log.info('=== running scenario: initial deployment ===') data_plane.start_workers() raw_input('press any key to end test') if is_simulate: data_plane.stop_workers() data_plane.stop() log.info('latency trend: {}'.format(cfgHelper.get_max_latency_log()))
def test( cls, config_name=None, is_export=True, is_update_map=False, is_simulate=False): cfgHelper = ConfigDataHelper(config_name, is_export) cfgHelper.init_task_graph() cfgHelper.update_topo_device_graph() cfgHelper.update_task_map() cfgHelper.update_max_latency_log() _topo, topo_device_graph, Gd, G_map = cfgHelper.get_graphs() if is_simulate: cls._simulate(topo_device_graph, Gd, G_map) update_id = 0 log.info('=== update round {} ==='.format(update_id)) dev = 'PHONE.0' nw_dev = 'BB_AP.0' new_nw_dev = 'HOME_IOTGW.0' new_latency = Unit.ms(3) cfgHelper.update_dev_link(dev, nw_dev, new_nw_dev, new_latency) cfgHelper.update_topo_device_graph() if is_update_map: cfgHelper.update_task_map() cfgHelper.update_max_latency_log() _topo, topo_device_graph, Gd, G_map = cfgHelper.get_graphs() if is_simulate: cls._simulate(topo_device_graph, Gd, G_map) # update device graph update_id += 1 log.info('=== update round {} ==='.format(update_id)) nw_dev1 = 'BB_SWITCH.0' nw_dev2 = 'CLOUD_SWITCH.0' latency = Unit.sec(5) cfgHelper.update_nw_link_latency(nw_dev1, nw_dev2, latency) cfgHelper.update_topo_device_graph() if is_update_map: cfgHelper.update_task_map() cfgHelper.update_max_latency_log() _topo, topo_device_graph, Gd, G_map = cfgHelper.get_graphs() if is_simulate: cls._simulate(topo_device_graph, Gd, G_map) # update device graph update_id += 1 log.info('=== update round {} ==='.format(update_id)) dev = 'PHONE.0' nw_dev = 'HOME_IOTGW.0' new_nw_dev = 'BB_AP.0' new_latency = Unit.ms(3) cfgHelper.update_dev_link(dev, nw_dev, new_nw_dev, new_latency) cfgHelper.update_topo_device_graph() if is_update_map: cfgHelper.update_task_map() cfgHelper.update_max_latency_log() _topo, topo_device_graph, Gd, G_map = cfgHelper.get_graphs() if is_simulate: cls._simulate(topo_device_graph, Gd, G_map) log.info('latency trend: {}'.format(cfgHelper.get_max_latency_log()))
def test(cls, config_name, is_export=False, is_update_map=False, is_simulate=False): assert config_name == 'config_ddflow_phase2' # TODO: clean this shit cfg1 = Config('{}.1'.format(config_name)) cfg2 = Config('{}.2'.format(config_name)) cfgHelper = ConfigDataHelper(cfg1, is_export) cfgHelper.init_task_graph() cfgHelper.update_topo_device_graph() cfgHelper.update_task_map() cfgHelper.update_max_latency_log() cfgHelper2 = ConfigDataHelper(cfg2, is_export) cfgHelper2.init_task_graph() cfgHelper2.update_topo_device_graph() cfgHelper2.update_task_map() cfgHelper2.update_max_latency_log() all_mobiles = ['CAMERA.0'] all_aps = ['BB_AP.0', 'BB_AP.1', 'BB_AP.2'] update_id = -1 for i in range(1, 100): update_id += 1 log.info('=== update {}: mobile-ap link ==='.format(update_id)) dev = random.sample(all_mobiles, 1)[0] _, topo_device_graph, _, _ = cfgHelper.get_graphs() edges = list(topo_device_graph.edges(dev)) assert len(edges) == 1 nw_dev = edges[0][1] assert nw_dev in all_aps, '{} not in {}'.format(nw_dev, all_aps) new_nw_dev = random.sample(all_aps, 1)[0] new_latency = Unit.ms(random.randint(30, 50)) cfgHelper.update_dev_link(dev, nw_dev, new_nw_dev, new_latency) cfgHelper2.update_dev_link(dev, nw_dev, new_nw_dev, new_latency) log.info('=== update {}: ap-bb link ==='.format(update_id)) ap_bb_links = [ # ('BB_AP.0', 'BB_SWITCH.0'), ('BB_AP.1', 'BB_SWITCH.1'), ('BB_AP.2', 'BB_SWITCH.2') ] [which_link] = random.sample(ap_bb_links, 1) which_rand = random.randint(0, 9) if which_rand < 5: latency = Unit.ms(random.randint(5000, 6000)) else: latency = Unit.ms(random.randint(30, 50)) nw_dev1, nw_dev2 = which_link cfgHelper.update_nw_link_latency(nw_dev1, nw_dev2, latency) cfgHelper2.update_nw_link_latency(nw_dev1, nw_dev2, latency) log.info('=== update {}: ap-ap link ==='.format(update_id)) # _, topo_device_graph, _, _ = cfgHelper2.get_graphs() # edges = list(topo_device_graph.edges()) ap_ap_links = [('BB_AP.0', 'BB_AP.1'), ('BB_AP.1', 'BB_AP.2')] [which_link] = random.sample(ap_ap_links, 1) latency = Unit.ms(random.randint(30, 50)) nw_dev1, nw_dev2 = which_link cfgHelper2.update_nw_link_latency(nw_dev1, nw_dev2, latency) log.info('=== update {}: update graphs ==='.format(update_id)) cfgHelper.update_topo_device_graph() cfgHelper2.update_topo_device_graph() if is_update_map: cfgHelper.update_task_map() cfgHelper2.update_task_map() cfgHelper.update_max_latency_log() cfgHelper2.update_max_latency_log() _, latency_static = cfgHelper.get_max_latency_log() _, latency_static2 = cfgHelper2.get_max_latency_log() print('static\tdynamic\tdiff') for t1, t2 in zip(latency_static, latency_static2): print('{}\t{}\t{}'.format(t1, t2, t2 - t1))
def test(cls, config_name, is_export=False, is_update_map=True, is_simulate=False): assert config_name == 'config_ddflow_phase1' cfg = Config(config_name) cfgHelper = ConfigDataHelper(cfg, is_export) cfgHelper.init_task_graph() cfgHelper.update_topo_device_graph() cfgHelper.update_task_map() cfgHelper.update_max_latency_log() topo, topo_device_graph, Gd, G_map = cfgHelper.get_graphs() if is_simulate: cls._simulate(topo_device_graph, Gd, G_map) # all_devices = [ # 'P3_2XLARGE.0', # 'T3_LARGE.0', # 'T2_MICRO.0'] # all_sws = [ # 'CENTER_SWITCH.0', # 'FIELD_SWITCH.0', # 'FIELD_SWITCH.1', # 'BB_SWITCH.0', # 'BB_SWITCH.1', # 'BB_SWITCH.2'] update_id = -1 for i in range(1, 100): update_id += 1 log.info('=== update {}: dev-nw_dev link ==='.format(update_id)) dev = 'P3_2XLARGE.0' nw_dev = 'CENTER_SWITCH.0' latency = Unit.ms(random.randint(2, 2000)) cfgHelper.update_dev_link_latency(dev, nw_dev, latency) dev = 'CONTROLLER.0' nw_dev = 'CENTER_SWITCH.0' latency = Unit.ms(random.randint(2, 200)) cfgHelper.update_dev_link_latency(dev, nw_dev, latency) dev = 'T3_LARGE.0' nw_dev = 'FIELD_SWITCH.1' latency = Unit.ms(random.randint(2, 200)) cfgHelper.update_dev_link_latency(dev, nw_dev, latency) # update graph and map cfgHelper.update_topo_device_graph() if is_update_map: cfgHelper.update_task_map() cfgHelper.update_max_latency_log() topo, topo_device_graph, Gd, G_map = cfgHelper.get_graphs() if is_simulate: cls._simulate(topo_device_graph, Gd, G_map) latency_dynamic, latency_static = cfgHelper.get_max_latency_log() print('static\tdynamic\tdiff') for t1, t2 in zip(latency_static, latency_dynamic): print('{}\t{}\t{}'.format(t1, t2, t2 - t1))
def test(cls, config_name, is_export=True, is_update_map=True, is_simulate=False): assert config_name == 'config_line' cfgHelper = ConfigDataHelper(config_name, is_export) cfgHelper.init_task_graph() cfgHelper.update_topo_device_graph() cfgHelper.update_task_map() cfgHelper.update_max_latency_log() topo, topo_device_graph, Gd, G_map = cfgHelper.get_graphs() if is_simulate: cls._simulate(topo_device_graph, Gd, G_map) all_mobiles = ['CAMERA.0', 'CAMERA.1', 'PHONE.0'] all_aps = ['BB_AP.0', 'BB_AP.1', 'BB_AP.2', 'BB_AP.3', 'BB_AP.4'] all_sws = [ 'BB_SWITCH.0', 'BB_SWITCH.1', 'BB_SWITCH.2', 'BB_SWITCH.3', 'BB_SWITCH.4' ] update_id = -1 for i in range(1, 50): update_id += 1 log.info('=== update {}: change link dst ==='.format(update_id)) dev = random.sample(all_mobiles, 1)[0] edges = list(topo_device_graph.edges(dev)) assert len(edges) == 1 nw_dev = edges[0][1] assert nw_dev in all_aps, '{} not in {}'.format(nw_dev, all_aps) new_nw_dev = random.sample(all_aps, 1)[0] new_latency = Unit.ms(random.randint(1, 500)) cfgHelper.update_dev_link(dev, nw_dev, new_nw_dev, new_latency) cfgHelper.update_topo_device_graph() if is_update_map: cfgHelper.update_task_map() cfgHelper.update_max_latency_log() topo, topo_device_graph, Gd, G_map = cfgHelper.get_graphs() if is_simulate: cls._simulate(topo_device_graph, Gd, G_map) # update device graph update_id += 1 log.info('=== update {}: change latency ==='.format(update_id)) edges = list(topo_device_graph.edges()) [nw_dev1, nw_dev2] = random.sample(all_aps + all_sws, 2) while (nw_dev1, nw_dev2) not in edges: [nw_dev1, nw_dev2] = random.sample(all_aps + all_sws, 2) latency = Unit.ms(random.randint(20, 5000)) cfgHelper.update_nw_link_latency(nw_dev1, nw_dev2, latency) cfgHelper.update_topo_device_graph() if is_update_map: cfgHelper.update_task_map() cfgHelper.update_max_latency_log() topo, topo_device_graph, Gd, G_map = cfgHelper.get_graphs() if is_simulate: cls._simulate(topo_device_graph, Gd, G_map) latency_dynamic, latency_static = cfgHelper.get_max_latency_log() log.info('latency_dynamic: {}'.format(latency_dynamic)) log.info('latency_static: {}'.format(latency_static))