Its ok now. I am using the following code and i am getting the *datapath id*
along with the rest of the information.
*@set_ev_cls(dpset.EventDP, MAIN_DISPATCHER)*
* def _event_dp_handler(self, ev): *
* self.logger.info <http://self.logger.info>("dp.id <http://dp.id>=%i,
dp.address=%s", ev.dp.id <http://ev.dp.id>, ev.dp.address) *
* for p in ev.ports:*
* self.logger.info <http://self.logger.info>("port_no= %s,
hw_addr= %s, interface= %s", p.port_no, p.hw_addr, p.name <http://p.name>)*
Is this method correct?. If there is a better way kindly indicate.
Thanks
Hadem
On Mon, May 2, 2016 at 10:49 AM, Pynbiang Hadem <pynbiang.ha...@gmail.com>
wrote:
> Hi,
>
> Can i also get the corresponding *datapath id* for a switch in addition
> to the above parameters?:
>
> *ev.ports=[OFPPort(port_no=1,hw_addr='ce:f3:fc:94:a5:a9',name='s1-eth1',config=0,state=0,curr=2112,advertised=0,supported=0,peer=0,curr_speed=10000000,max_speed=0)*
>
> Thanks
> Hadem
>
> On Thu, Apr 21, 2016 at 10:25 AM, Pynbiang Hadem <pynbiang.ha...@gmail.com
> > wrote:
>
>> Thanks Iwase, very helpful and appropriate example indeed.
>>
>> Thanks
>> Hadem
>>
>>
>> On Thu, Apr 21, 2016 at 6:32 AM, Iwase Yusuke <iwase.yusu...@gmail.com>
>> wrote:
>>
>>> Hi,
>>>
>>> With EventOFPSwitchFeatures, Ryu notify receiving OFPT_FEATURES_REPLY
>>> messages.
>>> In this OpenFlow (ver 1.3) message, there is no field about the port
>>> number.
>>>
>>> If you want to get the port information at starting of switch connection,
>>> how about using dpset.EventDP instead?
>>> https://github.com/osrg/ryu/blob/master/ryu/controller/dpset.py#L46
>>>
>>>
>>> $ git diff
>>> diff --git a/ryu/app/simple_switch_13.py b/ryu/app/simple_switch_13.py
>>> index 3e7c598..c11b667 100644
>>> --- a/ryu/app/simple_switch_13.py
>>> +++ b/ryu/app/simple_switch_13.py
>>> @@ -21,14 +21,21 @@ from ryu.ofproto import ofproto_v1_3
>>> from ryu.lib.packet import packet
>>> from ryu.lib.packet import ethernet
>>> from ryu.lib.packet import ether_types
>>> +from ryu.controller import dpset
>>> class SimpleSwitch13(app_manager.RyuApp):
>>> OFP_VERSIONS = [ofproto_v1_3.OFP_VERSION]
>>> + _CONTEXTS = {'dpset': dpset.DPSet}
>>> def __init__(self, *args, **kwargs):
>>> super(SimpleSwitch13, self).__init__(*args, **kwargs)
>>> self.mac_to_port = {}
>>> + self.dpset = kwargs['dpset']
>>> +
>>> + @set_ev_cls(dpset.EventDP, MAIN_DISPATCHER)
>>> + def _event_dp_handler(self, ev):
>>> + print('ev.ports=%s' % ev.ports)
>>> @set_ev_cls(ofp_event.EventOFPSwitchFeatures, CONFIG_DISPATCHER)
>>> def switch_features_handler(self, ev):
>>>
>>>
>>> $ ryu-manager ryu/app/simple_switch_13.py
>>> loading app ryu/app/simple_switch_13.py
>>> loading app ryu.controller.ofp_handler
>>> instantiating app None of DPSet
>>> creating context dpset
>>> instantiating app ryu/app/simple_switch_13.py of SimpleSwitch13
>>> instantiating app ryu.controller.ofp_handler of OFPHandler
>>> ev.ports=[OFPPort(port_no=1,hw_addr='ce:f3:fc:94:a5:a9',name='s1-eth1',config=0,state=0,curr=2112,advertised=0,supported=0,peer=0,curr_speed=10000000,max_speed=0),
>>> OFPPort(port_no=2,hw_addr='8e:0a:b6:62:3a:92',name='s1-eth2',config=0,state=0,curr=2112,advertised=0,supported=0,peer=0,curr_speed=10000000,max_speed=0),
>>> OFPPort(port_no=4294967294,hw_addr='de:8a:50:fd:42:43',name='s1',config=1,state=1,curr=0,advertised=0,supported=0,peer=0,curr_speed=0,max_speed=0)]
>>>
>>>
>>> Thanks,
>>> Iwase
>>>
>>>
>>> On 2016年04月19日 23:22, Pynbiang Hadem wrote:
>>>
>>>> Dear Iwase,
>>>>
>>>> When I added the code in "/def _packet_in_handler(self, ev):/" It works
>>>> fine.
>>>> However I wanted to put the code in
>>>> "/ofp_event.EventOFPSwitchFeatures/". When i did this i got the following
>>>> errrors:
>>>> /AttributeError: 'OFPSwitchFeatures' object has no attribute 'match' /
>>>> /
>>>> /
>>>> Pls suggest.
>>>>
>>>> Thanks
>>>> Hadem
>>>>
>>>>
>>>> On Tue, Apr 19, 2016 at 7:45 AM, Iwase Yusuke <iwase.yusu...@gmail.com
>>>> <mailto:iwase.yusu...@gmail.com>> wrote:
>>>>
>>>> Hi,
>>>>
>>>> How about using get_port() or get_ports() method of DPSet?
>>>>
>>>>
>>>> $ git diff
>>>> diff --git a/ryu/app/simple_switch_13.py
>>>> b/ryu/app/simple_switch_13.py
>>>> index 3e7c598..3f3ab64 100644
>>>> --- a/ryu/app/simple_switch_13.py
>>>> +++ b/ryu/app/simple_switch_13.py
>>>> @@ -21,14 +21,17 @@ from ryu.ofproto import ofproto_v1_3
>>>> from ryu.lib.packet import packet
>>>> from ryu.lib.packet import ethernet
>>>> from ryu.lib.packet import ether_types
>>>> +from ryu.controller import dpset
>>>> class SimpleSwitch13(app_manager.RyuApp):
>>>> OFP_VERSIONS = [ofproto_v1_3.OFP_VERSION]
>>>> + _CONTEXTS = {'dpset': dpset.DPSet}
>>>> def __init__(self, *args, **kwargs):
>>>> super(SimpleSwitch13, self).__init__(*args, **kwargs)
>>>> self.mac_to_port = {}
>>>> + self.dpset = kwargs['dpset']
>>>> @set_ev_cls(ofp_event.EventOFPSwitchFeatures,
>>>> CONFIG_DISPATCHER)
>>>> def switch_features_handler(self, ev):
>>>> @@ -76,6 +79,12 @@ class SimpleSwitch13(app_manager.RyuApp):
>>>> parser = datapath.ofproto_parser
>>>> in_port = msg.match['in_port']
>>>> + # Get port description by using DPSet API
>>>> + # Return value of get_port() is an instance of
>>>> ofproto_parser.OFPPort
>>>> + port_info = self.dpset.get_port(datapath.id <
>>>> http://datapath.id>, in_port)
>>>> + self.logger.info <http://self.logger.info>('port_info.name <
>>>> http://port_info.name>=%s', port_info.name <http://port_info.name>)
>>>> + self.logger.info <http://self.logger.info>('port_info.hw_addr=%s',
>>>> port_info.hw_addr)
>>>> +
>>>> pkt = packet.Packet(msg.data)
>>>> eth = pkt.get_protocols(ethernet.ethernet)[0]
>>>>
>>>>
>>>> $ ryu-manager ryu.app.simple_switch_13
>>>> loading app ryu.app.simple_switch_13
>>>> loading app ryu.controller.ofp_handler
>>>> instantiating app None of DPSet
>>>> creating context dpset
>>>> instantiating app ryu.app.simple_switch_13 of SimpleSwitch13
>>>> instantiating app ryu.controller.ofp_handler of OFPHandler
>>>> port_info.name <http://port_info.name>=s1-eth2
>>>> port_info.hw_addr=de:bd:64:0f:cb:0f
>>>> packet in 1 6a:50:d8:2c:cb:dc 33:33:00:00:00:02 2
>>>> port_info.name <http://port_info.name>=s1-eth1
>>>> port_info.hw_addr=4e:31:d2:9a:80:39
>>>> packet in 1 96:2b:f0:c2:3a:d9 33:33:00:00:00:02 1
>>>> port_info.name <http://port_info.name>=s1-eth2
>>>>
>>>> port_info.hw_addr=de:bd:64:0f:cb:0f
>>>> packet in 1 6a:50:d8:2c:cb:dc 33:33:00:00:00:02 2
>>>>
>>>>
>>>> Thanks,
>>>> Iwase
>>>>
>>>> On 2016年04月19日 00:35, Pynbiang Hadem wrote:
>>>>
>>>> Dear All,
>>>> The output of "sudo ovs-ofctl show s1" is as below:
>>>>
>>>> /---------------------------------------------------------------------------/
>>>> /mininet@mininet-vm:~$ sudo ovs-ofctl show s1
>>>> OFPT_FEATURES_REPLY (xid=0x2): dpid:0000000000000001/
>>>> /n_tables:254, n_buffers:256/
>>>> /..../
>>>> /actions: output enqueue set_vlan_vid set_vlan_pcp strip_vlan
>>>> mod_dl_src mod_dl_dst mod_nw_src mod_nw_dst mod_nw_tos mod_tp_src
>>>> mod_tp_dst/
>>>> / 1(s1-eth1): addr:46:8e:66:4f:b2:1d/
>>>> / ..../
>>>> / 2(s1-eth2): addr:46:49:f0:7f:49:68/
>>>> / ..../
>>>> / LOCAL(s1): addr:aa:75:65:c6:89:44/
>>>> / ..../
>>>>
>>>> -----------------------------------------------------------------
>>>> I need to get the hardware address of ports /s1-eth1,
>>>> //s1-eth2, /of switch///s1, s2 etc / from a ryu application. Is it possible
>>>> to get it using get_all() method of dpset.py?. If so Kindly guide and give
>>>> some reference examples.
>>>>
>>>> Thanks
>>>> Hadem
>>>>
>>>>
>>>>
>>>>
>>>> ------------------------------------------------------------------------------
>>>> Find and fix application performance issues faster with
>>>> Applications Manager
>>>> Applications Manager provides deep performance insights into
>>>> multiple tiers of
>>>> your business applications. It resolves application problems
>>>> quickly and
>>>> reduces your MTTR. Get your free trial!
>>>> https://ad.doubleclick.net/ddm/clk/302982198;130105516;z
>>>>
>>>>
>>>>
>>>> _______________________________________________
>>>> Ryu-devel mailing list
>>>> Ryu-devel@lists.sourceforge.net <mailto:
>>>> Ryu-devel@lists.sourceforge.net>
>>>> https://lists.sourceforge.net/lists/listinfo/ryu-devel
>>>>
>>>>
>>>>
>>>>
>>>>
>>>> ------------------------------------------------------------------------------
>>>> Find and fix application performance issues faster with Applications
>>>> Manager
>>>> Applications Manager provides deep performance insights into multiple
>>>> tiers of
>>>> your business applications. It resolves application problems quickly and
>>>> reduces your MTTR. Get your free trial!
>>>> https://ad.doubleclick.net/ddm/clk/302982198;130105516;z
>>>>
>>>>
>>>>
>>>> _______________________________________________
>>>> Ryu-devel mailing list
>>>> Ryu-devel@lists.sourceforge.net
>>>> https://lists.sourceforge.net/lists/listinfo/ryu-devel
>>>>
>>>>
>>
>
------------------------------------------------------------------------------
Find and fix application performance issues faster with Applications Manager
Applications Manager provides deep performance insights into multiple tiers of
your business applications. It resolves application problems quickly and
reduces your MTTR. Get your free trial!
https://ad.doubleclick.net/ddm/clk/302982198;130105516;z
_______________________________________________
Ryu-devel mailing list
Ryu-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ryu-devel