I have slightly modified the simple_switch.py to print out switch and link
information using

ryu.topology.api.get_all_switch(switch)
AND
ryu.topology.api.get_all_link(switch)

The above two functions are defined in ryu/topology/api.py

{noformat}
   @set_ev_cls(ofp_event.EventOFPPacketIn, MAIN_DISPATCHER)
    def _packet_in_handler(self, ev):
        sw_list = ryu.topology.api.get_all_switch(self)
        print('sw_list {}'.format(sw_list))
        link_list = ryu.topology.api.get_all_link(self)
        print('link_list {}'.format(link_list))

        msg = ev.msg
        datapath = msg.datapath
        ofproto = datapath.ofproto

        pkt = packet.Packet(msg.data)
        eth = pkt.get_protocol(ethernet.ethernet)

        dst = eth.dst
        src = eth.src

        dpid = datapath.id
        self.mac_to_port.setdefault(dpid, {})

        self.logger.info("packet in %s %s %s %s", dpid, src, dst,
msg.in_port)

        # learn a mac address to avoid FLOOD next time.
        self.mac_to_port[dpid][src] = msg.in_port

        if dst in self.mac_to_port[dpid]:
            out_port = self.mac_to_port[dpid][dst]
        else:
            out_port = ofproto.OFPP_FLOOD

        actions = [datapath.ofproto_parser.OFPActionOutput(out_port)]

        # install a flow to avoid packet_in next time
        if out_port != ofproto.OFPP_FLOOD:
            self.add_flow(datapath, msg.in_port, dst, actions)

        out = datapath.ofproto_parser.OFPPacketOut(
            datapath=datapath, buffer_id=msg.buffer_id, in_port=msg.in_port,
            actions=actions)
        datapath.send_msg(out)
{noformat}

The output comes as given below.

{noformat}
packet in 514 b6:0f:50:40:93:46 33:33:00:00:00:02 2
sw_list [<ryu.topology.switches.Switch object at 0x305ae90>,
<ryu.topology.switches.Switch object at 0x305a2d0>,
<ryu.topology.switches.Switch object at 0x305e110>,
<ryu.topology.switches.Switch object at 0x305e710>,
<ryu.topology.switches.Switch object at 0x305ee50>,
<ryu.topology.switches.Switch object at 0x305e310>]
link_list {}
packet in 516 42:1b:2f:bf:68:8b 33:33:00:00:00:fb 2
sw_list [<ryu.topology.switches.Switch object at 0x305a7d0>,
<ryu.topology.switches.Switch object at 0x305a1d0>,
<ryu.topology.switches.Switch object at 0x305ea50>,
<ryu.topology.switches.Switch object at 0x305e350>,
<ryu.topology.switches.Switch object at 0x305e810>,
<ryu.topology.switches.Switch object at 0x305ed90>]
link_list {}
packet in 515 f2:35:74:66:d9:f9 33:33:00:00:00:fb 2
sw_list [<ryu.topology.switches.Switch object at 0x305a2d0>,
<ryu.topology.switches.Switch object at 0x305ee50>,
<ryu.topology.switches.Switch object at 0x305e510>,
<ryu.topology.switches.Switch object at 0x305ed50>,
<ryu.topology.switches.Switch object at 0x305e690>,
<ryu.topology.switches.Switch object at 0x305e150>]
link_list {}
packet in 513 16:ef:fb:99:1b:96 33:33:00:00:00:fb 2
sw_list [<ryu.topology.switches.Switch object at 0x305a2d0>,
<ryu.topology.switches.Switch object at 0x305e810>,
<ryu.topology.switches.Switch object at 0x305ed90>,
<ryu.topology.switches.Switch object at 0x305e610>,
<ryu.topology.switches.Switch object at 0x305ebd0>,
<ryu.topology.switches.Switch object at 0x305e310>]
link_list {}
packet in 514 b6:0f:50:40:93:46 33:33:00:00:00:fb 2
sw_list [<ryu.topology.switches.Switch object at 0x305ab90>,
<ryu.topology.switches.Switch object at 0x305ec90>,
<ryu.topology.switches.Switch object at 0x305e150>,
<ryu.topology.switches.Switch object at 0x305ecd0>,
<ryu.topology.switches.Switch object at 0x305e710>,
<ryu.topology.switches.Switch object at 0x305e7d0>]
link_list {}
packet in 517 7a:de:82:e7:0b:e5 33:33:00:00:00:fb 2
sw_list [<ryu.topology.switches.Switch object at 0x305e3d0>,
<ryu.topology.switches.Switch object at 0x305ed50>,
<ryu.topology.switches.Switch object at 0x305e1d0>,
<ryu.topology.switches.Switch object at 0x305e510>,
<ryu.topology.switches.Switch object at 0x305e350>,
<ryu.topology.switches.Switch object at 0x305eb90>]
link_list {}
{noformat}

ryu.topology.api.get_all_switch(switch) correctly seems to return the
switch information


ryu.topology.api.get_all_link(switch) doesn't seem to return any link
information as I would expect.?

What is the reason for this?

Thanks & Regards,
Karthik.
------------------------------------------------------------------------------
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/NeoTech
_______________________________________________
Ryu-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ryu-devel

Reply via email to