Hi, I have an event defined in a POX controller. I need to have the same functionality on a Ryu controller, but I can't figure it out.
*The event is defined below:* ############################################# #!/usr/bin/python # -*- coding: utf-8 -*- # Copyright 2019 Matthew Robinson, STRI, University of Hertfordshire. # """ A POX component that recieved routing information from Matlab. This calls an event that the main POX application can listen to. Threading is used to stop blocking while listening to the UDP socket. """ from pox.core import core from pox.lib.revent import * import socket import threading log = core.getLogger() class MatlabReceiveEvent (Event): """ Matlab Receive event. This is the event that we can trigger for our main application to act on. """ def __init__(self, multicast_path): self.multicast_path = multicast_path # We are just putting the matlab path data into event.multicast_path. class MatlabRX (EventMixin): """ The component that is launched by the launch function. EventMixin means it can trigger events. """ _core_name = "MatlabRX" # The name of this module. _eventMixin_events = set([ # Telling POX that that MatlabReceiveEvent is an Event function. MatlabReceiveEvent, ]) def __init__ (self, matlab_port, matlab_ip): # The IP and port for our Matlab connection. self.matlab_port = matlab_port self.matlab_ip = matlab_ip self.sock_matlab = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) # The UDP socket to receive from. self.sock_matlab.bind((self.matlab_ip, self.matlab_port)) self.listen_matlab = threading.Thread(target=self._check_matlab_rx) # Starting a Thread so the socket can be self.listen_matlab.start() # checked continuously in parallel to POX. def _check_matlab_rx(self): # This is the Thread that is started. while True: # Continuously check if data is available data, addr = self.sock_matlab.recvfrom(1024) # from the UDP port. self.raiseEventNoErrors(MatlabReceiveEvent, data) # If it is available, raise the event function above. def launch (matlab_ip = '192.168.56.1', matlab_port = 10000): # This function is called by POX to start the matlab_ip = matlab_ip # component. matlab_port = matlab_port # Register the component with POX. core.registerNew(MatlabRX, matlab_port = matlab_port, matlab_ip = matlab_ip) ################# *Handling of event is defined below:* class FECNetwork(EventMixin): _core_name = 'sdn_fec' def __init__(self): # Listen to dependencies def startup(): core.openflow.addListeners(self, priority=99) #core.MatlabRX.addListeners(self, priority=50) core.call_when_ready(startup, ('openflow')) #core.call_when_ready(startup, ('openflow', 'MatlabRX')) def _handle_ConnectionUp(self, event): switches[event.connection.dpid] = Switch(event) log.info("Connection up, added object: %s" % (event.connection,)) def _handle_ConnectionDown(self, event): try: del switches[event.connection.dpid] log.info("Connection down, removed object: %s" % (event.connection,)) except KeyError: log.info("Tried to delete connection object but did not exist: %s" % (event.connection,)) def _handle_MatlabReceiveEvent(self, event): # What to do when we receive a matlab packet # Get the SatIP mac and AP mac and call data_received = event.multicast_path data_received = data_received[1:-1] string = data_received.split(',') ap = string[0] vf = EthAddr(string[1]) value = int(string[2]) switch_mac = AP_to_switch_map[EthAddr(ap)] dpid = Connection_to_DPID[switch_mac] switches[dpid].update_num_layers(vf, value) ##################### I would appreciate it if you can help me. Thank you. Kind regards
_______________________________________________ Ryu-devel mailing list Ryu-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/ryu-devel