Thanks for the explanation.I have one more query
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.
On 23 April 2014 17:48, YAMADA Hideki <[email protected]> wrote:
> Hi,
>
> (2014/04/22 11:29), Karthik Sharma wrote:
> > This is the code for class Switches from
> > https://github.com/osrg/ryu/blob/master/ryu/topology/switches.py#L429
> >
> > The member variables of particular interest to me in the class Switches
> are
> > the following.
> >
> > self.dps = {} # datapath_id => Datapath class
> > self.port_state = {} # datapath_id => ports
> > self.ports = PortDataState() # Port class -> PortData class
> > self.links = LinkState() # Link class -> timestamp
> > self.is_active = True
> >
> > These are the member variables that the RYU uses to cache the topology
> > details.I am trying to figure out how a topology can be represented using
> > the following variables.
> >
> > 1) dps is a dictionary which maps datapath_id to datapath class?
> >
> > - Can someone explain to me what is a datapath_id and a
> > datapath class?
> >
> dps has instance objects of ryu.controller.controller.Datapath
> https://github.com/osrg/ryu/blob/master/ryu/controller/controller.py#L100
>
> > 2) port_state is a dictionary which maps datapath id to ports
> >
> > - As per my understanding on a switch without a VLAN all
> > the ports will belong to the same datapath id?In case of a switch with
> > VLAN ports on the switch can have multiple datapath id's. Is my
> > understanding correct?
> >
> Basically yes.
> To be exact, It's not VLAN that separates a physical switch into multiple
> datapath.
> I don't know what I call it.
> Something like VRF?
>
> > 3) ports is again a dictionary which maps Port class to PortData class?
> >
> > - what does this mean?
> >
> A Port has a PortData.
> Maybe PortData should be member variable of Port.
>
> > 4) links is again a dictionary which maps Link class to timestamp
> >
> > - again what does this mean?
> >
> Same as 3).
>
> > I am trying to get my head around how RYU controller stores the topology
> > information using the above structures.Any help in understanding or
> > explanation would be greatly appreciated.
> >
> > Thanks & 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
> >
>
>
>
> ------------------------------------------------------------------------------
> 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
>
------------------------------------------------------------------------------
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