def start_network(): if network_running(): logging.getLogger(__name__).info("Some network components already running...") stop_network() logging.getLogger(__name__).info("Starting simulated network...") # Create fake NICs logging.getLogger(__name__).info("Creating network interfaces...") autogen_click_conf(get_topo_file("servers"), get_topo_file("clients"), get_topo_file("dns")) if os.path.isfile(CLICK): run_bg("%s %s" % (CLICK, CLICK_CONF)) else: run_bg("%s %s" % (CLICK_LOCAL, CLICK_CONF)) # Set up traffic shaping logging.getLogger(__name__).info("Enabling traffic shaping...") try: check_output("%s start" % TC_SETUP) install_filters(get_topo_file("bottlenecks")) except Exception as e: logging.getLogger(__name__).error(e) # Launch apache instances logging.getLogger(__name__).info("Configuring apache...") try: configure_apache(get_server_ip_list()) restart_apache() except Exception as e: logging.getLogger(__name__).error(e) logging.getLogger(__name__).info("Network started.")
def start_network(): if network_running(): logging.getLogger(__name__).info('Some network components already running...') stop_network() logging.getLogger(__name__).info('Starting simulated network...') # Create fake NICs logging.getLogger(__name__).info('Creating network interfaces...') autogen_click_conf(get_topo_file('servers'), get_topo_file('clients'), get_topo_file('dns')) run_bg('%s %s' % (CLICK, CLICK_CONF)) # Set up traffic shaping logging.getLogger(__name__).info('Enabling traffic shaping...') try: check_output('%s start' % TC_SETUP) install_filters(get_topo_file('bottlenecks')) except Exception as e: logging.getLogger(__name__).error(e) # Launch apache instances logging.getLogger(__name__).info('Configuring apache...') try: configure_apache(get_server_ip_list()) restart_apache() except Exception as e: logging.getLogger(__name__).error(e) logging.getLogger(__name__).info('Network started.')
def run_events(self, events_file=None, bg=False): cmd = '%s %s run' % (NETSIM, self.topo_dir) if events_file: cmd += ' -e %s' % events_file if bg: run_bg(cmd) else: check_output(cmd)
def run_proxy(self, log, alpha, listenport, fakeip, dnsip, dnsport, serverip=''): check_both('rm %s' % log, False, False) run_bg('%s %s %s %s %s %s %s %s'\ % (PROXY, log, alpha, listenport, fakeip, dnsip, dnsport, serverip))
def start_servers(): if servers_running(): logging.getLogger(__name__).info('Some components already running...') stop_servers() logging.getLogger(__name__).info('Starting servers...') # Launch apache instances logging.getLogger(__name__).info('Configuring apache...') if args.topology == 'servers': with open(args.servers) as servers_file: for line in strip_comments(servers_file): servers.append('127.0.0.1:%d' % int(line)) servers_port.append(int(line)) servers_file.closed try: configure_apache(servers) restart_apache() except Exception as e: logging.getLogger(__name__).error(e) else: if args.topology == 'onelink': try: configure_apache(['127.0.0.1:8080']) restart_apache() except Exception as e: logging.getLogger(__name__).error(e) else: try: configure_apache(['127.0.0.1:8080', '127.0.0.1:8081']) restart_apache() except Exception as e: logging.getLogger(__name__).error(e) # Create click bandwidth shaper logging.getLogger(__name__).info('Creating bandwidth shaper...') autogen_click() run_bg('click %s.click' % args.topology) logging.getLogger(__name__).info('Network started.')
def start_network(): if network_running(): logging.getLogger(__name__).info( 'Some network components already running...') stop_network() logging.getLogger(__name__).info('Starting simulated network...') # Create fake NICs logging.getLogger(__name__).info('Creating network interfaces...') autogen_click_conf(get_topo_file('servers'), get_topo_file('clients'), get_topo_file('dns')) if os.path.isfile(CLICK): run_bg('sudo {} {}'.format(CLICK, CLICK_CONF)) else: run_bg('sudo %s %s' % (CLICK_LOCAL, CLICK_CONF)) # Set up traffic shaping logging.getLogger(__name__).info('Enabling traffic shaping...') try: check_output('%s start' % TC_SETUP) install_filters(get_topo_file('bottlenecks')) except Exception as e: logging.getLogger(__name__).error(e) # Launch apache instances logging.getLogger(__name__).info('Configuring apache...') try: configure_apache(get_server_ip_list()) restart_apache() except Exception as e: logging.getLogger(__name__).error(e) import traceback traceback.print_exc() logging.getLogger(__name__).info('Network started.')
def run_dns(self, rr, log, listenip, listenport, serverfile, lsafile): run_bg('%s %s %s %s %s %s %s'\ % (NAMESERVER, rr, log, listenip, listenport, serverfile, lsafile))