Hi,

On Tue, 25 Mar 2014 14:53:13 -0400
"Charles F." <[email protected]> wrote:

> 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?

Ryu can give the info links between switches by using LLDP (I don't
know but I guess that other controllers do the similar).

The following code needs the latest git head.

$ ryu-manager ~/a.py --observe-links
loading app /Users/fujita/a.py
loading app ryu.controller.ofp_handler
loading app ryu.topology.switches
loading app ryu.controller.ofp_handler
instantiating app None of DPSet
creating context dpset
instantiating app ryu.topology.switches of Switches
instantiating app ryu.controller.ofp_handler of OFPHandler
instantiating app /Users/fujita/a.py of OF13
Port<dpid=2, port_no=3, LIVE> Port<dpid=1, port_no=1, LIVE>
46:a1:59:ee:16:15
Port<dpid=1, port_no=2, LIVE> Port<dpid=3, port_no=3, LIVE>
66:06:74:41:20:b8
Port<dpid=1, port_no=1, LIVE> Port<dpid=2, port_no=3, LIVE>
4a:8c:a6:3d:c2:d6
Port<dpid=3, port_no=3, LIVE> Port<dpid=1, port_no=2, LIVE>
32:3a:3a:f0:f5:28

=
from ryu.controller import handler
from ryu.controller import dpset
from ryu.controller import ofp_event
from ryu.ofproto import ofproto_v1_3
from ryu.ofproto import ofproto_v1_3_parser
from ryu.base import app_manager
from ryu.ofproto.ofproto_parser import MsgBase, msg_pack_into, msg_str_attr
from ryu.topology import api
from ryu.topology import event

class OF13(app_manager.RyuApp):
    OFP_VERSIONS = [ofproto_v1_3.OFP_VERSION]

    _CONTEXTS = {
        'dpset': dpset.DPSet,
        }
    
    def __init__(self, *args, **kwargs):
        super(OF13, self).__init__(*args, **kwargs)
        self.dpset = kwargs['dpset']

    def _get_hwaddr(self, dpid, port_no):
        return self.dpset.get_port(dpid, port_no).hw_addr

    @handler.set_ev_cls(event.EventLinkAdd)
    def link_add(self, ev):
        print ev.link.src, ev.link.dst
        print self._get_hwaddr(ev.link.src.dpid, ev.link.src.port_no)

------------------------------------------------------------------------------
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