I am currently working on developing some code to work with the topology of
a Ryu network. I am trying (if possible) to avoid using the REST API, and
have the whole thing self-contained.

I have looked at some other SDN controllers (Floodlight) that allow one to
easily get a list of links. I noticed that the MAC addresses pulled back
from the switches are not the mac addresses of the hosts. I am doing
everything in Mininet for testing. I can use ARP to get the MACs of hosts
on certain ports, but for the switch-to-switch connection, how can that be
done in Ryu?

For example:

host1 attaches to switch1 port1
host2 attaches to switch2 port1
switch1 linked to switch2 on port 2 of each.

Since I am only getting the MAC of the interface, and not what is attached
to it, I am having some trouble finding the links between switches. This is
all new to me, so any help or suggestions would be appreciated.

Below is a sample of the code I was playing with. Some of it may seem
verbose, but it was used for debugging (better methods could be used once I
have things figured out).


    # this is called if there are no mac_to_ports entries
    def switchHookups(self):
        switches = self.dpset.get_all()
        pa = []
        SwitchHookup = namedtuple('SwitchHookup','dpid,mac,port')

        for switch in switches:
            for p in self.dpset.get_ports(switch[0]):
                sh =
SwitchHookup(dpid=switch[0],mac=p.hw_addr,port=p.port_no)
                self.switch_hookups.append(sh)
                # learn a mac address to avoid FLOOD next time.
                self.mac_to_port.setdefault(sh.dpid,{})
                self.mac_to_port[sh.dpid][sh.mac] = sh.port

    # this is called when an ARP request comes in, this was how I was able
to
    # map things backwards using the in_port, mapping it to the dpset HW
address
    # and then following the links. This is also where I am unable to
identify the links
    # made between switches
    def do_arp(self, ar, in_port, dpid):

        self.mac_to_ip.setdefault(ar.src_mac,{})
        self.mac_to_ip[ar.src_mac] = ar.src_ip

        self.ip_to_port.setdefault(ar.src_ip, {})
        self.ip_to_port[ar.src_ip]["port_no"] = in_port


My goal is to have a function that would return the following: { "dpid":
"id", "links": [ {"port_no","mac_addr_host","ip_host"} ] }. That would at
least be a start. Thanks in advance for your assistance (and better
solution(s)).
------------------------------------------------------------------------------
Learn Graph Databases - Download FREE O'Reilly Book
"Graph Databases" is the definitive new guide to graph databases and their
applications. Written by three acclaimed leaders in the field,
this first edition is now available. Download your free book today!
http://p.sf.net/sfu/13534_NeoTech
_______________________________________________
Ryu-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ryu-devel

Reply via email to