Hi,

I have added the following code to the packet_in event handler of
simple_switch.py to print out the topology (The new code is highlighted in
red.) to get the topology information from RYU.


 
----------------------------------------------------------------------------------------------
@set_ev_cls(ofp_event.EventOFPPacketIn, MAIN_DISPATCHER)
    def _packet_in_handler(self, ev):
        sw_list = ryu.topology.api.get_all_switch(self)
        for switch in sw_list:
                print('SWITCHES',switch.to_dict())
        link_list = ryu.topology.api.get_all_link(self)
        for link in link_list:
                print('LINKS' , link.to_dict())

        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


 
----------------------------------------------------------------------------------------------

The switch and the links information printed out using the above code is
given below.

{noformat}
('SWITCHES', {'ports': [{'hw_addr': 'ee:b1:ab:b1:0e:a0', 'name': 's1-eth1',
'port_no': '00000001', 'dpid': '0000000000000201'},
                        {'hw_addr': 'f6:83:4d:e4:41:7d', 'name': 's1-eth2',
'port_no': '00000002', 'dpid': '0000000000000201'}
                       ], 'dpid': '0000000000000201'})

('SWITCHES', {'ports': [{'hw_addr': '12:a8:4d:54:5f:77', 'name': 's2-eth1',
'port_no': '00000001', 'dpid': '0000000000000202'},
                        {'hw_addr': '9e:db:13:c8:a5:7c', 'name': 's2-eth2',
'port_no': '00000002', 'dpid': '0000000000000202'}
                       ], 'dpid': '0000000000000202'})

('SWITCHES', {'ports': [{'hw_addr': 'ba:aa:a7:c8:e2:35', 'name': 's3-eth1',
'port_no': '00000001', 'dpid': '0000000000000203'},
                        {'hw_addr': '56:3d:2a:62:b8:3e', 'name': 's3-eth2',
'port_no': '00000002', 'dpid': '0000000000000203'}
                       ], 'dpid': '0000000000000203'})

('SWITCHES', {'ports': [{'hw_addr': '92:8e:39:89:84:ff', 'name': 's4-eth1',
'port_no': '00000001', 'dpid': '0000000000000204'},
                        {'hw_addr': 'fe:70:ae:8b:41:bb', 'name': 's4-eth2',
'port_no': '00000002', 'dpid': '0000000000000204'}
                       ], 'dpid': '0000000000000204'})

('SWITCHES', {'ports': [{'hw_addr': '02:d1:71:d4:69:8c', 'name': 's5-eth1',
'port_no': '00000001', 'dpid': '0000000000000205'},
                        {'hw_addr': 'ea:48:90:9d:85:0d', 'name': 's5-eth2',
'port_no': '00000002', 'dpid': '0000000000000205'}
                       ], 'dpid': '0000000000000205'})

('SWITCHES', {'ports': [{'hw_addr': '92:db:be:e7:94:de', 'name': 's6-eth1',
'port_no': '00000001', 'dpid': '0000000000000206'},
                        {'hw_addr': 'f6:bd:18:1d:ad:be', 'name': 's6-eth2',
'port_no': '00000002', 'dpid': '0000000000000206'}
                       ], 'dpid': '0000000000000206'})

('LINKS', {
           'src': {'hw_addr': '56:3d:2a:62:b8:3e', 'name': 's3-eth2',
'port_no': '00000002', 'dpid': '0000000000000203'},
           'dst': {'hw_addr': 'f6:bd:18:1d:ad:be', 'name': 's6-eth2',
'port_no': '00000002', 'dpid': '0000000000000206'}
          })
('LINKS', {
           'src': {'hw_addr': 'f6:83:4d:e4:41:7d', 'name': 's1-eth2',
'port_no': '00000002', 'dpid': '0000000000000201'},
           'dst': {'hw_addr': 'fe:70:ae:8b:41:bb', 'name': 's4-eth2',
'port_no': '00000002', 'dpid': '0000000000000204'}
          })
('LINKS', {'src': {'hw_addr': 'ea:48:90:9d:85:0d', 'name': 's5-eth2',
'port_no': '00000002', 'dpid': '0000000000000205'},
           'dst': {'hw_addr': '9e:db:13:c8:a5:7c', 'name': 's2-eth2',
'port_no': '00000002', 'dpid': '0000000000000202'}
          })
('LINKS', {'src': {'hw_addr': 'f6:bd:18:1d:ad:be', 'name': 's6-eth2',
'port_no': '00000002', 'dpid': '0000000000000206'},
           'dst': {'hw_addr': '56:3d:2a:62:b8:3e', 'name': 's3-eth2',
'port_no': '00000002', 'dpid': '0000000000000203'}
          })
('LINKS', {'src': {'hw_addr': '9e:db:13:c8:a5:7c', 'name': 's2-eth2',
'port_no': '00000002', 'dpid': '0000000000000202'},
           'dst': {'hw_addr': 'ea:48:90:9d:85:0d', 'name': 's5-eth2',
'port_no': '00000002', 'dpid': '0000000000000205'}
          })
('LINKS', {'src': {'hw_addr': 'fe:70:ae:8b:41:bb', 'name': 's4-eth2',
'port_no': '00000002', 'dpid': '0000000000000204'},
           'dst': {'hw_addr': 'f6:83:4d:e4:41:7d', 'name': 's1-eth2',
'port_no': '00000002', 'dpid': '0000000000000201'}
          })
{noformat}

The above information is correct as expected.However as you can see above I
am using the function

 ryu.topology.api.get_all_switch(self)   from
https://github.com/osrg/ryu/blob/master/ryu/topology/api.py#L25

 ryu.topology.api.get_all_link(self)       from
https://github.com/osrg/ryu/blob/master/ryu/topology/api.py#L34

These functions sends the messages

eventSwitchRequest
eventLinkRequest

respectively.I expect the following functions to be called to handle the
above messages.

https://github.com/osrg/ryu/blob/master/ryu/topology/switches.py#L837

https://github.com/osrg/ryu/blob/master/ryu/topology/switches.py#L853

But if I put a print inside

switch_request_handler()

or

link_request_handler()

It is not showing up on my terminal ? Can someone explain why this is or
what I am doing wrong?


Regards,
Karthik.
------------------------------------------------------------------------------
Start Your Social Network Today - Download eXo Platform
Build your Enterprise Intranet with eXo Platform Software
Java Based Open Source Intranet - Social, Extensible, Cloud Ready
Get Started Now And Turn Your Intranet Into A Collaboration Platform
http://p.sf.net/sfu/ExoPlatform
_______________________________________________
Ryu-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ryu-devel

Reply via email to