Dear All,
I am unable to observe links of all the switches. Following are the steps
which I have performed.
1. Start RYU-Manager with observe-links option.
./bin/ryu-manager --observe-links /home/ubuntu/PycharmProjects/XSDM/XSDMY.py
2. Start mininet with the below topology
sudo mn --topo=tree,3 --controller=remote --switch=ovsk,protocols=OpenFlow13
ubuntu@sdnhubvm:~[16:47]$ sudo mn --topo=tree,3 --controller=remote
--switch=ovsk,protocols=OpenFlow13
*** Creating network
*** Adding controller
*** Adding hosts:
h1 h2 h3 h4 h5 h6 h7 h8
*** Adding switches:
s1 s2 s3 s4 s5 s6 s7
*** Adding links:
(h1, s3) (h2, s3) (h3, s4) (h4, s4) (h5, s6) (h6, s6) (h7, s7) (h8, s7) (s1,
s2) (s1, s5) (s2, s3) (s2, s4) (s5, s6) (s5, s7)
3. In my XSDM.py file, I am deriving the list of switches using
self.datapaths.values(). Post this I iterate over each the list of switches
and try to derive the links of each of these switches by calling the
get_links(dpid=switch_id). While I am doing this, I am unable to retrieve
the links of all the switches. Below is my code snippet and the output that
I receive. The relevant methods are list_switches and list_links.
Snippet:
class XSDM(app_manager.RyuApp):
OFP_VERSIONS = [ofproto_v1_3.OFP_VERSION]
_CONTEXTS = {
'switches': switches.Switches
}
def __init__(self, *args, **kwargs):
super(XSDM, self).__init__(*args, **kwargs)
self.mac_to_port = {}
self.datapaths = {}
#self.monitor_thread = hub.spawn(self._monitor)
self.switches = kwargs['switches']
self.link=switches.Link
self.topology_unknown = True
self.number_of_switches = 0
self.number_of_links = 0
self.switch_bits={}
@set_ev_cls(ofp_event.EventOFPSwitchFeatures, CONFIG_DISPATCHER)
def switch_features_handler(self, ev):
datapath = ev.msg.datapath
ofproto = datapath.ofproto
parser = datapath.ofproto_parser
match = parser.OFPMatch()
actions = [parser.OFPActionOutput(ofproto.OFPP_CONTROLLER,
ofproto.OFPCML_NO_BUFFER)]
self.add_flow(datapath, 0, match, actions)
@set_ev_cls(ofp_event.EventOFPStateChange,
[MAIN_DISPATCHER, DEAD_DISPATCHER])
def _state_change_handler(self, ev):
self.packet_in_handler
datapath = ev.datapath
if ev.state == MAIN_DISPATCHER:
if not datapath.id in self.datapaths:
self.logger.debug('register datapath: %016x', datapath.id)
self.datapaths[datapath.id] = datapath
elif ev.state == DEAD_DISPATCHER:
if datapath.id in self.datapaths:
self.logger.debug('unregister datapath: %016x', datapath.id)
del self.datapaths[datapath.id]
def list_switches(self):
dpid = None
switch_list = get_switch(self, dpid)
if len(switch_list)>48:
self.logger.error('only 48 switches allowed inside a sub
domain')
else:
self.generatebits_forswitches(self.datapaths.values())
#self.logger.info('Bits generated')
switch_links={}
for dp in self.datapaths.values():
switch_id=dp.id
links=self.list_links(switch_id)
print 'Switch-----'+str(switch_id)
for link in links:
print link
source=str(link.src)
dest=str(link.dst)
dest_switch=dest[10]
dest_port=dest[21]
switchlink=Switchlinks()
switchlink.portnumber=dest_port
switchlink.switchid=dest_switch
switch_links[switch_id]=switchlink
#print switch_links
if self.topology_unknown:
self.number_of_switches = len(switch_list)
def list_links(self,datapathid):
dpid = datapathid
#link_list =
self.send_request(event.EventLinkRequest(dpid=datapathid))
link_list=get_link(self, dpid=datapathid)
return link_list
Output:
Switch-----1
Switch-----2
Switch-----3
Switch-----4
Switch-----5
Link: Port<dpid=5, port_no=1, LIVE> to Port<dpid=7, port_no=1, LIVE>
Link: Port<dpid=5, port_no=3, LIVE> to Port<dpid=6, port_no=1, LIVE>
Switch-----6
Link: Port<dpid=6, port_no=1, LIVE> to Port<dpid=5, port_no=3, LIVE>
Link: Port<dpid=6, port_no=1, LIVE> to Port<dpid=7, port_no=1, LIVE>
Switch-----7
Link: Port<dpid=7, port_no=1, LIVE> to Port<dpid=6, port_no=1, LIVE>
Link: Port<dpid=7, port_no=1, LIVE> to Port<dpid=5, port_no=1, LIVE>
Please help.
Thanks in advance
Yashas V Bharadwaj
------------------------------------------------------------------------------
Open source business process management suite built on Java and Eclipse
Turn processes into business applications with Bonita BPM Community Edition
Quickly connect people, data, and systems into organized workflows
Winner of BOSSIE, CODIE, OW2 and Gartner awards
http://p.sf.net/sfu/Bonitasoft
_______________________________________________
Ryu-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ryu-devel