Hi,
I'm trying to create an application to monitor a topology SDN with Ryu
controller, like as topology discovery application in
https://sdn-lab.com/2014/12/31/topology-discovery-with-ryu/. But, the
application that I need updates in a periodic time (3 seconds) to print
the information of hosts. How can i implement that code in controller?
Below its the code:
from ryu.base import app_manager
from ryu.controller import ofp_event
from ryu.controller.handler import CONFIG_DISPATCHER, MAIN_DISPATCHER
from ryu.controller.handler import set_ev_cls
from ryu.controller import ofp_handler
from ryu.ofproto import ofproto_v1_3
from ryu.lib.packet import packet
from ryu.lib.packet import ethernet
from ryu.lib.packet import ether_types
from pprint import pprint
from ryu.topology.api import get_link, get_switch, get_host, get_all_host
from ryu.topology import event, switches
import struct
import threading
from scapy import *
import os
import time
from ryu.app import simple_switch_13
from ryu.lib import hub
class SimpleMonitor13(simple_switch_13.SimpleSwitch13):
def __init__(self, *args, **kwargs):
super(SimpleMonitor13, self).__init__(*args, **kwargs)
self.datapaths = {}
self.monitor_thread = hub.spawn(self.get_topology_data)
self.mac_to_port = {}
@set_ev_cls(event.EventHostAdd)
def get_topology_data(self, ev):
switch_list = get_switch(self, None) #.topology_api_app
switches=[switch.dp.id for switch in switch_list]
print "switches: ", switches
hosts = get_host(self, None)
for host in hosts:
if host.port.name[0] != 's' and 'eth' not in host.port.name:
print host.mac #Prints host mac
print host.port.dpid #The switch(or AP)
print host.port.name #Interface Name
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Ryu-devel mailing list
Ryu-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ryu-devel