def launch (proactive_install=True, deneme_flow=False): global _install_schrules_proactively, _install_deneme_flow _install_schrules_proactively = str_to_bool(proactive_install) _install_deneme_flow = str_to_bool(deneme_flow) # core.registerNew(Actuator)
def launch(no_flow=False, explicit_drop=True, link_timeout=None): explicit_drop = str_to_bool(explicit_drop) install_flow = not str_to_bool(no_flow) if link_timeout: link_timeout = int(link_timeout) core.registerNew(Discovery, explicit_drop=explicit_drop, install_flow=install_flow, link_timeout=link_timeout)
def launch (no_flow = False, explicit_drop = True, link_timeout = None,eat_early_packets = False): explicit_drop = str_to_bool(explicit_drop) eat_early_packets = str_to_bool(eat_early_packets) install_flow = not str_to_bool(no_flow) if link_timeout: link_timeout = int(link_timeout) old_discovery = discovery.Discovery(explicit_drop=explicit_drop, install_flow=install_flow, link_timeout=link_timeout, eat_early_packets=eat_early_packets) core.register("slow_discovery", old_discovery) #register as core.slow_discovery core.registerNew(FastDiscovery) # register as core.openflow_discovery
def launch(timeout=ARP_TIMEOUT, no_flow=True, eat_packets=True, no_learn=False, *args,**kwargs): core.registerNew(ForwardingFunction, int(timeout), str_to_bool(no_flow), str_to_bool(eat_packets), str_to_bool(no_learn), *args,**kwargs)
def launch (eat_packets = True, install_flow=True, **kw): core.registerNew(host_tracker.host_tracker, eat_packets=str_to_bool(eat_packets), install_flow=str_to_bool(install_flow)) for k, v in kw.iteritems(): if k in host_tracker.timeoutSec: host_tracker.timeoutSec[k] = int(v) log.warn("Changing timer parameter: %s = %s",k,v) elif k == 'pingLim': host_tracker.PingCtrl.pingLim = int(v) log.warn("Changing ping limit to %s",v) else: log.warn("Unknown option: %s(=%s)",k,v)
def launch (no_flow = False, explicit_drop = True, link_timeout = None, eat_early_packets = False): explicit_drop = str_to_bool(explicit_drop) #default: True eat_early_packets = str_to_bool(eat_early_packets) #default: False install_flow = not str_to_bool(no_flow) #default: True if link_timeout: link_timeout = int(link_timeout) #default: None #print 'explicit_drop',explicit_drop #print 'eat_early_packets',eat_early_packets #print 'install_flow',install_flow #print 'link_timeout',link_timeout core.registerNew(Discovery, explicit_drop=explicit_drop, install_flow=install_flow, link_timeout=link_timeout, eat_early_packets=eat_early_packets)
def _set_debug (self, given_name, name, value): value = str_to_bool(value) if value: # Debug implies no openflow and no CLI and verbose #TODO: Is this really an option we need/want? self.verbose = True self.enable_openflow = False
def launch (transparent=False, hold_down=_flood_delay, rule = "cs589.firewall"): """ Starts an L2 switch. """ try: global _flood_delay _flood_delay = int(str(hold_down), 10) assert _flood_delay >= 0 except: raise RuntimeError("Expected hold-down to be a number") #import pdb; pdb.set_trace() # Check the firewall file exists locally and not empty log.info("*** Firewall file : %s", (rule)) if os.path.isfile(rule) == False: #log.debug("*** Firewall file %s not found!",(rule)) raise RuntimeError(" Firewall rules %s not found!" % (rule)) else: if os.stat(rule).st_size == 0: #raise RuntimeError(" Firewall rules %s empty!" % (rule)) log.info("*** Warning: empty firewall rules!") log.info("*** Firewall file: %s found!" % (rule)) # LID: Register l2_learning class with the core core.registerNew(l2_learning, str_to_bool(transparent), rule)
def launch (timeout=ARP_TIMEOUT, no_flow=False, eat_packets=True, no_learn=False, **kw): global ARP_TIMEOUT, _install_flow, _eat_packets, _learn ARP_TIMEOUT = timeout _install_flow = not no_flow _eat_packets = str_to_bool(eat_packets) _learn = not no_learn core.Interactive.variables['arp'] = _arp_table #Static ARP entries for avoiding ARP query in network with loops _arp_table[IPAddr("10.0.0.255")] = Entry("00:00:00:00:00:00", static=True) #for dts _arp_table[IPAddr("10.0.0.1")] = Entry("00:00:00:01:00:01", static=True) #for p _arp_table[IPAddr("10.0.0.2")] = Entry("00:00:00:01:00:02", static=True) #for c _arp_table[IPAddr("10.0.0.111")] = Entry("00:00:00:00:11:01", static=True) #for d _arp_table[IPAddr("10.0.0.11")] = Entry("00:00:00:00:01:01", static=True) #for t11 _arp_table[IPAddr("10.0.0.12")] = Entry("00:00:00:00:01:02", static=True) #for t12 _arp_table[IPAddr("10.0.0.13")] = Entry("00:00:00:00:01:03", static=True) #for t13 _arp_table[IPAddr("10.0.0.21")] = Entry("00:00:00:00:02:01", static=True) #for t21 _arp_table[IPAddr("10.0.0.22")] = Entry("00:00:00:00:02:02", static=True) #for t22 _arp_table[IPAddr("10.0.0.23")] = Entry("00:00:00:00:02:03", static=True) #for t23 _arp_table[IPAddr("10.0.0.31")] = Entry("00:00:00:00:03:01", static=True) #for t31 _arp_table[IPAddr("10.0.0.32")] = Entry("00:00:00:00:03:02", static=True) #for t32 _arp_table[IPAddr("10.0.0.33")] = Entry("00:00:00:00:03:03", static=True) #for t33 _arp_table[IPAddr("10.0.0.41")] = Entry("00:00:00:00:04:01", static=True) #for t41 _arp_table[IPAddr("10.0.0.42")] = Entry("00:00:00:00:04:02", static=True) #for t42 _arp_table[IPAddr("10.0.0.43")] = Entry("00:00:00:00:04:03", static=True) #for t43 # for k,v in kw.iteritems(): _arp_table[IPAddr(k)] = Entry(v, static=True) core.registerNew(ARPResponder)
def launch (fakeways="", arp_for_unknowns=None): fakeways = fakeways.replace(","," ").split() fakeways = [IPAddr(x) for x in fakeways] if arp_for_unknowns is None: arp_for_unknowns = len(fakeways) > 0 else: arp_for_unknowns = str_to_bool(arp_for_unknowns) core.registerNew(l3_switch, fakeways, arp_for_unknowns)
def launch(transparent=False, of_port_1="32", of_port_2="34"): """ Starts an L2 learning switch. """ SWITCH_PORT_LIST.append(int(of_port_1)) SWITCH_PORT_LIST.append(int(of_port_2)) core.registerNew(l2_learning, str_to_bool(transparent)) core.openflow.addListenerByName("FlowStatsReceived", handle_flow_stats)
def launch (transparent=False, hold_down=flood_delay): try: global flood_delay flood_delay = int(str(hold_down), 10) assert flood_delay >= 0 except: raise RuntimeError("Expected hold-down to be a number") core.registerNew(learning_switch, str_to_bool(transparent))
def launch (transparent=False, hold_down=_flood_delay): try: global _flood_delay _flood_delay = int(str(hold_down), 10) assert _flood_delay >= 0 except: raise RuntimeError("Expected hold-down to be a number") core.registerNew(IP_forger, str_to_bool(transparent))
def launch (transparent=True, hold_down=_flood_delay): """ Starts an L2 learning switch. """ try: global _flood_delay _flood_delay = int(str(hold_down), 10) assert _flood_delay >= 0 except: raise RuntimeError("Expected hold-down to be a number") core.registerNew(l2_learning, str_to_bool(transparent))
def launch(transparent=False, hold_down=_flood_delay): try: global _flood_delay _flood_delay = int(str(hold_down), 10) assert _flood_delay >= 0 except: raise RuntimeError("Expected hold-down to be a number") core.registerNew(HandOver, str_to_bool(transparent)) core.openflow.addListenerByName("PortStatsReceived", _handle_port_stats) Timer(10, request_PLR, recurring=True)
def launch(no_flows=False, explicit_drop=True, validate_link_timeout=VALIDATE_LINK_TIMEOUT, delete_link_timeout=DELETE_LINK_TIMEOUT, flow_priority = 65500, ttl = TTL, send_cycle = SEND_CYCLE, send_lldp_cycle_interval = SEND_LLDP_CYCLE_INTERVAL, raise_link_event_cycle_interval = RAISE_LINK_EVENT_CYCLE_INTERVAL): core.registerNew(LLDPUtil, str_to_bool(no_flows), str_to_bool(explicit_drop), int(validate_link_timeout), int(delete_link_timeout), int(flow_priority), ttl, send_cycle, send_lldp_cycle_interval, raise_link_event_cycle_interval)
def launch (transparent=False): """ Starts an cs144 - L2 learning switch. """ core.registerNew(cs144_ofhandler, str_to_bool(transparent)) r = get_ip_setting() if r == -1: log.debug("Couldn't load config file for ip addresses, check whether %s exists" % IPCONFIG_FILE) sys.exit(2) else: log.debug('*** ofhandler: Successfully loaded ip settings for hosts\n %s\n' % IP_SETTING)
def launch (timeout=ARP_TIMEOUT, no_flow=False, eat_packets=True, no_learn=False, **kw): global ARP_TIMEOUT, _install_flow, _eat_packets, _learn ARP_TIMEOUT = timeout _install_flow = not no_flow _eat_packets = str_to_bool(eat_packets) _learn = not no_learn core.Interactive.variables['arp'] = _arp_table for k,v in kw.iteritems(): _arp_table[IPAddr(k)] = Entry(v, static=True) core.registerNew(ARPResponder)
def launch (disable = False, completion = None, __INSTANCE__ = None): if not core.hasComponent("Interactive"): Interactive() import boot if not disable: boot.set_main_function(core.Interactive.interact) else: boot.set_main_function(None) core.Interactive.enabled = not disable if completion is not None: core.Interactive.completion = str_to_bool(completion)
def launch (transparent=False, wildcard=False): """ Starts an L2 learning switch. """ global WILDCARD WILDCARD = eval(str(wildcard)) if WILDCARD: print '*' * 80 print 'Wildcard mode' print '*' * 80 core.registerNew(l2_learning, str_to_bool(transparent))
def launch ( config_file, transparent=False, hold_down=_flood_delay): """ Starts an L2 learning switch. """ try: global _flood_delay _flood_delay = int(str(hold_down), 10) assert _flood_delay >= 0 except: raise RuntimeError("Expected hold-down to be a number") options = [ cfg.StrOpt('controller_ip', help = 'Controller interface IP', default='127.0.0.1'), cfg.IntOpt('capacity', help='Flooded interface capacity in bits', default=100000000), cfg.IntOpt('remaining_bw', help='Remaining bw', default=100000000), cfg.FloatOpt('alpha', help='alpha penalty parameter, min 0, max 1', default=0.0), cfg.IntOpt('response_port', help='Response port between controller and switch', default=23456), cfg.IntOpt('check_policy_time', help='Period of policy evaluation', default=30), cfg.IntOpt('bad_flow_count_th', help='Number between 0 and 1. Used to indicate switch between policies', default=0.9), cfg.StrOpt('server_target', help='Server to be protected', default= '10.1.2.1/32'), cfg.IntOpt('min_sla', help='Min bandwidth to be guaranteed to each client', default=10000000), cfg.IntOpt('flow_update_time', help='Period of flow stats update', default=5) ] CONF.register_opts(options) print "Check policy time",CONF.check_policy_time core.registerNew(flow_fence, str_to_bool(transparent)) core.openflow.addListenerByName("FlowStatsReceived", _handle_flowstats_received) Timer(CONF.check_policy_time, check_policies, recurring = True) print "FlowFence launched"
def launch (transparent=False): core.registerNew(l2_firewall, str_to_bool(transparent)) # Start MQTT system in separate thread -G mqttThread = Thread(target=mqttStart) mqttThread.daemon = True mqttThread.start() # Run server in separate thread -G serverThread = Thread(target=runServer) serverThread.daemon = True serverThread.start()
def launch (transparent=False): """ Starts an L2 learning switch. """ from pox.openflow.topology import OpenFlowTopology from pox.openflow.discovery import Discovery from pox.topology import topology if not core.hasComponent("openflow_topology"): core.register("openflow_topology", OpenFlowTopology()) core.registerNew(topology.Topology) core.registerNew(Discovery, explicit_drop=True, install_flow=True) core.registerNew(dumb_print, str_to_bool(transparent))
def launch (transparent=False, hold_down=_flood_delay): """ Starts an L2 learning switch. """ try: global _flood_delay _flood_delay = int(str(hold_down), 10) assert _flood_delay >= 0 except: raise RuntimeError("Expected hold-down to be a number") core.registerNew(l2_learning, str_to_bool(transparent)) printlist() flush()
def launch (transparent=False, hold_down=_flood_delay, ignore = None): """ Starts an L2 learning switch. """ try: global _flood_delay _flood_delay = int(str(hold_down), 10) assert _flood_delay >= 0 except: raise RuntimeError("Expected hold-down to be a number") if ignore: ignore = ignore.replace(',', ' ').split() ignore = set(str_to_dpid(dpid) for dpid in ignore) core.registerNew(l2_learning, str_to_bool(transparent), ignore)
def launch (transparent=False, hold_down=_flood_delay): """ Starts an L2 learning switch. """ try: global _flood_delay _flood_delay = int(str(hold_down), 10) assert _flood_delay >= 0 except: raise RuntimeError("Expected hold-down to be a number") core.openflow.addListenerByName("FlowStatsReceived", listarFluxosIp) core.openflow.addListenerByName("FlowStatsReceived", redistribuirFluxos) core.registerNew(l2_learning, str_to_bool(transparent))
def launch(fakeways="", arp_for_unknowns=None, wide=False, output="/home/jeffrey/minitest/output2", flows="", ss="True"): from pox.lib.recoco import Timer flows = flows.replace(",", " ").split() flows = [int(x) for x in flows] fakeways = fakeways.replace(",", " ").split() fakeways = [IPAddr(x) for x in fakeways] if arp_for_unknowns is None: arp_for_unknowns = len(fakeways) > 0 else: arp_for_unknowns = str_to_bool(arp_for_unknowns) ss = str_to_bool(ss) #print("This is the bool " + str(ss)) core.registerNew(l3_switch, fakeways, arp_for_unknowns, wide, output, flows, ss) # timer set to execute every five seconds which enforces stat messages from switches Timer(1, _timer_func, recurring=True)
def launch(fakeways="", arp_for_unknowns=None): #fakeways = fakeways.replace(","," ").split() #fakeways = [IPAddr(x) for x in fakeways] fakeways = [["10.0.1.1"], ["10.0.2.1"]] #firewall format #port,dl_src,dl_dst,dl_type,nw_proto,nw_src,nw_dst,tp_src,tp_dst firewall = [[None, None, None, 0x0800, 6, None, None, 6000, None], [None, None, None, 0x0800, 6, None, None, 6000, None]] if arp_for_unknowns is None: arp_for_unknowns = len(fakeways) > 0 else: arp_for_unknowns = str_to_bool(arp_for_unknowns) core.registerNew(l3_switch, fakeways, arp_for_unknowns, firewall)
def launch(transparent=False, hold_down=_flood_delay): """ Starts an L2 learning switch. """ try: global _flood_delay _flood_delay = int(str(hold_down), 10) assert _flood_delay >= 0 except: raise RuntimeError("Expected hold-down to be a number") ''' load: adjacency, mac_map, path_map, maybe as globals ''' core.registerNew(l2_learning, str_to_bool(transparent))
def launch(timeout=ARP_TIMEOUT, no_flow=False, eat_packets=True, no_learn=False, **kw): global ARP_TIMEOUT, _install_flow, _eat_packets, _learn ARP_TIMEOUT = timeout _install_flow = not no_flow _eat_packets = str_to_bool(eat_packets) _learn = not no_learn core.Interactive.variables['arp'] = _arp_table for k, v in kw.iteritems(): _arp_table[IPAddr(k)] = Entry(v, static=True) core.registerNew(ARPResponder)
def launch(pathExec, transparent=False, hold_down=_flood_delay): """ Starts an firewall switch. """ try: global _flood_delay global rPath print("Pathexec:" + pathExec) rPath = pathExec _flood_delay = int(str(hold_down), 10) assert _flood_delay >= 0 except: raise RuntimeError("Expected hold-down to be a number") core.registerNew(firewall, str_to_bool(transparent))
def launch(fakeways="", arp_for_unknowns=None, wide=False): fakeways = fakeways.replace(",", " ").split() fakeways = [IPAddr(x) for x in fakeways] if arp_for_unknowns is None: arp_for_unknowns = len(fakeways) > 0 else: arp_for_unknowns = str_to_bool(arp_for_unknowns) core.registerNew(l3_switch, fakeways, arp_for_unknowns, wide) try: arquivo = open('teste.txt', 'w') arquivo.write("aa") arquivo.close() log.info("Gravei") except Exception as erro: pass
def launch (timeout=ARP_TIMEOUT, no_flow=True, eat_packets=True, no_learn=False, virtual_servers="", real_servers=""): global ARP_TIMEOUT, _install_flow, _eat_packets, _learn, \ _virtual_servers, _real_servers ARP_TIMEOUT = timeout _install_flow = not no_flow _eat_packets = str_to_bool(eat_packets) _learn = not no_learn _virtual_servers = set([IPAddr(k) for k in virtual_servers.replace(",", " ").split()]) core.Interactive.variables['arp'] = _arp_table _real_servers.update([IPAddr(k) for k in real_servers.replace(",", " ").split()]) core.registerNew(ARPResponder)
def launch (transparent=False): """ Starts an L2 learning switch. """ #Topology shit host_nodes=[1,2,3,4] #reload(graph) reload (Topology) Topo=Topology.Topology() print "QWERTY" #Topo.test() print "??????????????????????????????????????????????" Topo.check_connection() Topo.new_topology() core.registerNew(l2_learning, str_to_bool(transparent), Topo._host_nodes)
def launch (transparent=False, hold_down=_flood_delay, address='', port=8000, static=False): """ Starts an L2 learning switch. """ try: global _flood_delay _flood_delay = int(str(hold_down), 10) assert _flood_delay >= 0 except: raise RuntimeError("Expected hold-down to be a number") core.registerNew(l2_learning, str_to_bool(transparent)) httpd = SplitThreadedServer((address, int(port)), SplitterRequestHandler) core.register("WebServer", httpd) httpd.set_handler("/", CoreHandler, httpd, True) if static is True: httpd.add_static_dir('static', 'www_root', relative=True) elif static is False: pass else: static = static.split(",") for entry in static: if entry.lower() == "": httpd.add_static_dir('static', 'www_root', relative=True) continue if ':' not in entry: directory = entry prefix = os.path.split(directory) if prefix[1] == '': prefix = os.path.split(prefix[0]) prefix = prefix[1] assert prefix != '' else: prefix,directory = entry.split(":") directory = os.path.expanduser(directory) httpd.add_static_dir(prefix, directory, relative=False) def run (): try: log.debug("Listening on %s:%i" % httpd.socket.getsockname()) httpd.serve_forever() except: pass log.info("Server quit") thread = threading.Thread(target=run) thread.daemon = True thread.start()
def launch (transparent=False, hold_down=_flood_delay): """ Starts an L2 learning switch. """ try: global _flood_delay _flood_delay = int(str(hold_down), 10) assert _flood_delay >= 0 except: raise RuntimeError("Expected hold-down to be a number") core.registerNew(l2_learning, str_to_bool(transparent)) #################### Start ###################################### #core.openflow.addListenerByName("FlowStatsReceived", _handle_flowstats_received) thread = threading.Thread(target=Collect, args = ()) thread.start()
def launch(transparent=False, hold_down=_flood_delay): """ Starts an L2 learning switch. """ #creates gre tunnels between c1,c2,r1,r2 gre_between_all() try: global _flood_delay _flood_delay = int(str(hold_down), 10) assert _flood_delay >= 0 except: raise RuntimeError("Expected hold-down to be a number") print 'running core' core.registerNew(l2_learning, str_to_bool(transparent))
def launch(transparent=False): """ Starts an Simple Router Topology """ core.registerNew(cs640_ofhandler, str_to_bool(transparent)) r = get_ip_setting() if r == -1: log.debug( "Couldn't load config file for ip addresses, check whether %s exists" % IPCONFIG_FILE) sys.exit(2) else: log.debug( '*** ofhandler: Successfully loaded ip settings for hosts\n %s\n' % IP_SETTING)
def launch (transparent=False, hold_down=_flood_delay): """ Starts an L2 learning switch. """ try: global _flood_delay _flood_delay = int(str(hold_down), 10) assert _flood_delay >= 0 except: raise RuntimeError("Expected hold-down to be a number") core.registerNew(flow_fence, str_to_bool(transparent)) #core.registerNew(ConnectTest) core.openflow.addListenerByName("FlowStatsReceived", _handle_flowstats_received) Timer(check_policy_time, check_policies, recurring = True) print "FlowFence launched"
def launch(transparent=False, hold_down=gFloodDelay, ignore=None): # # Now let's get started # try: global gFloodDelay # class int(x)->int or int(x, base=10) gFloodDelay = int(str(hold_down)) assert gFloodDelay >= 0 except: raise RuntimeError("Hold-down should be a real number") if ignore: ignore = ignore.replace(',', ' ').split() ignore = set(str_to_dpid(dpid) for dpid in ignore) core.registerNew(l2_learning, str_to_bool(transparent), ignore)
def launch(transparent=False, hold_down=_flood_delay): """ launch argument are parsed from command line """ try: global _flood_delay _flood_delay = int(str(hold_down), 10) # base 10 conversion assert _flood_delay >= 0 except: raise RuntimeError("Expected hold_down to be a number.") # create an instance of a l2_learning class # passing transparent to its constructor # assigning the classname as component name # eg: core.l2_learning core.registerNew(l2_learning, str_to_bool(transparent))
def launch(transparent=False, hold_down=_flood_delay): """ Starts an L2 learning switch. """ try: global _flood_delay _flood_delay = int(str(hold_down), 10) assert _flood_delay >= 0 except: raise RuntimeError("Expected hold-down to be a number") core.registerNew(flow_fence, str_to_bool(transparent)) #core.registerNew(ConnectTest) core.openflow.addListenerByName("FlowStatsReceived", _handle_flowstats_received) Timer(check_policy_time, check_policies, recurring=True) print "FlowFence launched"
def launch(fakeways="", arp_for_unknowns=None): def set_miss_length(event=None): if not core.hasComponent('openflow'): return core.openflow.miss_send_len = 0x7fff core.getLogger().info("Requesting full packet payloads") return EventRemove if set_miss_length() is None: core.addListenerByName("ComponentRegistered", set_miss_length) fakeways = fakeways.replace(",", " ").split() fakeways = [IPAddr(x) for x in fakeways] if arp_for_unknowns is None: arp_for_unknowns = len(fakeways) > 0 else: arp_for_unknowns = str_to_bool(arp_for_unknowns) core.registerNew(l3_switch, fakeways, arp_for_unknowns)
def launch(transparent=False, hold_down=_flood_delay): """ Starts an L2 learning switch. """ try: global _flood_delay _flood_delay = int(str(hold_down), 10) assert _flood_delay >= 0 except: raise RuntimeError("Expected hold-down to be a number") from pox.lib.recoco import Timer # attach handsers to listners core.openflow.addListenerByName("FlowStatsReceived", _handle_flowstats_received) # timer set to execute every five seconds Timer(1, _timer_func, recurring=True) core.registerNew(l2_learning, str_to_bool(transparent))
def launch(disable=False, completion=None, history=False, sync=False, __INSTANCE__=None): if not core.hasComponent("Interactive"): Interactive() from . import boot if not disable: boot.set_main_function(core.Interactive.interact) else: boot.set_main_function(None) core.Interactive.enabled = not disable if completion is not None: core.Interactive.completion = str_to_bool(completion) if history: core.Interactive.history = history core.Interactive.variables['sync'] = sync
def launch(): from pox.lib.recoco import Timer def start_switch(event): log.debug("Controlling %s" % (event.connection,)) Tutorial(event.connection) # attach handsers to listners core.registerNew(l2_learning, str_to_bool(False), None) core.openflow.addListenerByName("FlowStatsReceived", _handle_flowstats_received) core.openflow.addListenerByName("PortStatsReceived", _handle_portstats_received) # timer set to execute every five seconds Timer(10, _timer_func, recurring=True) global bw_util bw_util.extend(create_dataset()) bw_util = np.array(bw_util).reshape(-1, 20)
def launch(timeout=ARP_TIMEOUT, no_flow=False, eat_packets=True, no_learn=False, objname="arp_resp", **kw): global ARP_TIMEOUT, _install_flow, _eat_packets, _learn ARP_TIMEOUT = timeout _install_flow = not no_flow _eat_packets = str_to_bool(eat_packets) _learn = not no_learn core.Interactive.variables['arp'] = _arp_table for k, v in kw.iteritems(): _arp_table[IPAddr(k)] = Entry(v, static=True) # uncomment these 2 lines, and comment the registerNew line tempobj = ARPResponder() core.register(objname, tempobj)
def launch(timeout=ARP_TIMEOUT, no_flow=True, eat_packets=True, no_learn=False, virtual_servers="", real_servers=""): global ARP_TIMEOUT, _install_flow, _eat_packets, _learn, \ _virtual_servers, _real_servers ARP_TIMEOUT = timeout _install_flow = not no_flow _eat_packets = str_to_bool(eat_packets) _learn = not no_learn _virtual_servers = set( [IPAddr(k) for k in virtual_servers.replace(",", " ").split()]) core.Interactive.variables['arp'] = _arp_table _real_servers.update( [IPAddr(k) for k in real_servers.replace(",", " ").split()]) core.registerNew(ARPResponder)
def set(self, given_name, value): name = given_name.replace("-", "_") if name.startswith("_") or hasattr(Options, name): # Hey, what's that about? print("Illegal option:", given_name) return False has_field = hasattr(self, name) has_setter = hasattr(self, "_set_" + name) if has_field == False and has_setter == False: print("Unknown option:", given_name) return False if has_setter: setter = getattr(self, "_set_" + name) setter(given_name, name, value) else: if isinstance(getattr(self, name), bool): # Automatic bool-ization value = str_to_bool(value) setattr(self, name, value) return True
def launch(transparent=False, hold_down=_flood_delay): """ Starts an L2 learning switch. """ try: global _flood_delay _flood_delay = int(str(hold_down), 10) assert _flood_delay >= 0 except: raise RuntimeError("Expected hold-down to be a number") # def to_controller(): # msg = of.ofp_flow_mod() # msg.match = of.ofp_match.from_packet(packet, event.port) # msg.idle_timeout = 10 # msg.hard_timeout = 30 # msg.priority=65000 # msg.actions.append(of.ofp_action_output(port = of.OFPP_CONTROLLER)) # msg.data = event.ofp # 6a # self.connection.send(msg) core.registerNew(l2_learning, str_to_bool(transparent))
def launch(a=None): a = str_to_bool(a) core.registerNew(router, a)
def launch(debug="False"): if not core.hasComponent("topology_tracker"): core.register("topology_tracker", DynamicTopology(str_to_bool(debug)))
def launch (transparent=False, idleTime = 10, getStatInterval = 2, simulationTime=60, tableSize=50, markovModule="True", markovChain="defaultChain.txt", deletionInterval=2.0, smartTimeModule="False", smartTimeMinIdleTimeout=1, smartTimeMaxIdleTimeout=60, smartTimeTableUtilization=95, smartTimeIncreaseFunction="EXPONENTIAL"): """ Starts an L2 learning switch. """ random.seed() #print("Idle time: " + str(idleTime)) global PARAM_idleTime global PARAM_getStatInterval global PARAM_simulationTime global PARAM_tableSize PARAM_idleTime = idleTime PARAM_getStatInterval = getStatInterval PARAM_simulationTime = simulationTime PARAM_tableSize = int(tableSize) print("MAIN MODULE: Table size = " + str(PARAM_tableSize)) #Module to collect stats and update metrics from flow_stats import launch launch(getStatInterval) #Module to apply rule deletion according to a Markov model global PARAM_markovModule PARAM_markovModule = markovModule if PARAM_markovModule == "True": from markov_deletion import launch launch(markovChain, float(deletionInterval), int(tableSize)) print("Markov deletion module is ON") else: print("Markov deletion module is OFF") #-------------------------------------------- # SMART_TIME #-------------------------------------------- global PARAM_smartTimeModule global PARAM_smartTimeMinIdleTimeout global PARAM_smartTimeMaxIdleTimeout global PARAM_smartTimeTableUtilization global PARAM_smartTimeIncreaseFunction PARAM_smartTimeModule = smartTimeModule if PARAM_smartTimeModule == "True": PARAM_smartTimeMinIdleTimeout = int(smartTimeMinIdleTimeout) PARAM_smartTimeMaxIdleTimeout = int(smartTimeMaxIdleTimeout) PARAM_smartTimeTableUtilization = float(smartTimeTableUtilization) PARAM_smartTimeIncreaseFunction = smartTimeIncreaseFunction print("SmartTime module is ON") print("SmartTime - Min idle timeout: " + str(PARAM_smartTimeMinIdleTimeout)) print("SmartTime - Max idle timeout: " + str(PARAM_smartTimeMaxIdleTimeout)) print("SmartTime - Table utilization: " + str(PARAM_smartTimeTableUtilization)) print("SmartTime - Increase function: " + str(PARAM_smartTimeIncreaseFunction)) else: print("SmartTime module is OFF") core.registerNew(l2_learning, str_to_bool(transparent)) #Attach handlers to listeners core.openflow.addListenerByName("FlowStatsReceived", _handle_tableSizeStats_received)
def launch(transparent=False): """ Starts an Simple Router Topology """ core.registerNew(DefHalndler, str_to_bool(transparent))
def launch(no_flow=False, eat_packets=True, use_port_mac=False): core.registerNew(ARPHelper, str_to_bool(no_flow), str_to_bool(eat_packets), str_to_bool(use_port_mac))
def launch(transparent=False): """ Starts an L2 learning switch. """ core.registerNew(l2_learning, str_to_bool(transparent))
def _set_no_openflow(self, given_name, name, value): self.enable_openflow = not str_to_bool(value)
def _set_epoll_sh(self, given_name, name, value): self.epoll_selecthub = str_to_bool(value)