Hi,
I guess there some syntax errors in your switch_multipart_reply_handler().
Here is my code which works well on my environment.
$ git diff
diff --git a/ryu/app/simple_switch_13.py b/ryu/app/simple_switch_13.py
index 3e7c598..7d08658 100644
--- a/ryu/app/simple_switch_13.py
+++ b/ryu/app/simple_switch_13.py
@@ -117,3 +117,28 @@ class SimpleSwitch13(app_manager.RyuApp):
out = parser.OFPPacketOut(datapath=datapath, buffer_id=msg.buffer_id,
in_port=in_port, actions=actions, data=data)
datapath.send_msg(out)
+
+ @set_ev_cls([ofp_event.EventOFPStatsReply,
+ ofp_event.EventOFPDescStatsReply,
+ ofp_event.EventOFPFlowStatsReply,
+ ofp_event.EventOFPAggregateStatsReply,
+ ofp_event.EventOFPTableStatsReply,
+ ofp_event.EventOFPTableFeaturesStatsReply,
+ ofp_event.EventOFPPortStatsReply,
+ ofp_event.EventOFPQueueStatsReply,
+ ofp_event.EventOFPQueueDescStatsReply,
+ ofp_event.EventOFPMeterStatsReply,
+ ofp_event.EventOFPMeterFeaturesStatsReply,
+ ofp_event.EventOFPMeterConfigStatsReply,
+ ofp_event.EventOFPGroupStatsReply,
+ ofp_event.EventOFPGroupFeaturesStatsReply,
+ ofp_event.EventOFPGroupDescStatsReply,
+ ofp_event.EventOFPPortDescStatsReply
+ ], MAIN_DISPATCHER)
+ def switch_multipart_reply_handler(self, ev):
+ multipart_reply = ev.msg
+ datapath = ev.msg.datapath
+ self.logger.info(
+ '>>> OpenFlow 0x%x MultipartReply message (type 0x%x) has been '
+ 'received from switch %d',
+ multipart_reply.version, multipart_reply.type, datapath.id)
$ ryu-manager ryu.app.simple_switch_13 ryu.app.ofctl_rest
loading app ryu.app.simple_switch_13
loading app ryu.app.ofctl_rest
loading app ryu.controller.ofp_handler
instantiating app None of DPSet
creating context dpset
creating context wsgi
instantiating app ryu.controller.ofp_handler of OFPHandler
instantiating app ryu.app.ofctl_rest of RestStatsApi
instantiating app ryu.app.simple_switch_13 of SimpleSwitch13
(7945) wsgi starting up on http://0.0.0.0:8080
...(snip)
# I executed the below command here
...(snip)
(7945) accepted ('127.0.0.1', 59734)
>>> OpenFlow 0x4 MultipartReply message (type 0x1) has been received from
>>> switch 1
127.0.0.1 - - [16/Dec/2016 13:15:45] "GET /stats/flow/1 HTTP/1.1" 200 359
0.019278
$ curl -X GET http://localhost:8080/stats/flow/1
...
Thanks,
Iwase
On 2016年12月16日 05:59, helcio wagner wrote:
> Hi, Iwase. Thanks for answering.
>
> Actually, I've explicitly added the types of MultipartReply messages as
> the code you shown. Unfortunately, I still don't see any of them (even though
> they exist). The trace below shows what I'm talking about:
> ---
> helcio@ojuara:~/ryu/bin$ ./ryu-manager --verbose
> ../ryu/app/simple_switch_13.py
> ../../Dropbox/EXA0186/Python/switch_commander.py
> loading app ../ryu/app/simple_switch_13.py
> loading app ../../Dropbox/EXA0186/Python/switch_commander.py
> loading app ryu.controller.ofp_handler
> instantiating app ../../Dropbox/EXA0186/Python/switch_commander.py of
> SwitchCommander
> instantiating app ../ryu/app/simple_switch_13.py of SimpleSwitch13
> instantiating app ryu.controller.ofp_handler of OFPHandler
> BRICK SimpleSwitch13
> CONSUMES EventOFPSwitchFeatures
> CONSUMES EventOFPPacketIn
> BRICK SwitchCommander
> CONSUMES EventOFPSwitchFeatures
> CONSUMES EventOFPStatsReply
> CONSUMES EventOFPQueueDescStatsReply
> CONSUMES EventOFPMeterStatsReply
> CONSUMES EventOFPPortStatsReply
> CONSUMES EventOFPAggregateStatsReply
> CONSUMES EventOFPFlowStatsReply
> CONSUMES EventOFPMeterFeaturesStatsReply
> CONSUMES EventOFPGroupDescStatsReply
> CONSUMES EventOFPGroupFeaturesStatsReply
> CONSUMES EventOFPMeterConfigStatsReply
> CONSUMES EventOFPTableFeaturesStatsReply
> CONSUMES EventOFPGroupStatsReply
> CONSUMES EventOFPHello
> CONSUMES EventOFPEchoRequest
> CONSUMES EventOFPQueueStatsReply
> CONSUMES EventOFPPortDescStatsReply
> CONSUMES EventOFPTableStatsReply
> CONSUMES EventOFPDescStatsReply
> BRICK ofp_event
> PROVIDES EventOFPSwitchFeatures TO {'SimpleSwitch13': set(['config']),
> 'SwitchCommander': set(['config'])}
> PROVIDES EventOFPStatsReply TO {'SwitchCommander': set(['main'])}
> PROVIDES EventOFPQueueDescStatsReply TO {'SwitchCommander': set(['main'])}
> PROVIDES EventOFPHello TO {'SwitchCommander': set(['handshake'])}
> PROVIDES EventOFPPortStatsReply TO {'SwitchCommander': set(['main'])}
> PROVIDES EventOFPAggregateStatsReply TO {'SwitchCommander': set(['main'])}
> PROVIDES EventOFPMeterStatsReply TO {'SwitchCommander': set(['main'])}
> PROVIDES EventOFPMeterFeaturesStatsReply TO {'SwitchCommander':
> set(['main'])}
> PROVIDES EventOFPPortDescStatsReply TO {'SwitchCommander': set(['main'])}
> PROVIDES EventOFPGroupDescStatsReply TO {'SwitchCommander': set(['main'])}
> PROVIDES EventOFPGroupFeaturesStatsReply TO {'SwitchCommander':
> set(['main'])}
> PROVIDES EventOFPMeterConfigStatsReply TO {'SwitchCommander': set(['main'])}
> PROVIDES EventOFPTableFeaturesStatsReply TO {'SwitchCommander':
> set(['main'])}
> PROVIDES EventOFPGroupStatsReply TO {'SwitchCommander': set(['main'])}
> PROVIDES EventOFPEchoRequest TO {'SwitchCommander': set(['main'])}
> PROVIDES EventOFPQueueStatsReply TO {'SwitchCommander': set(['main'])}
> PROVIDES EventOFPDescStatsReply TO {'SwitchCommander': set(['main'])}
> PROVIDES EventOFPFlowStatsReply TO {'SwitchCommander': set(['main'])}
> PROVIDES EventOFPTableStatsReply TO {'SwitchCommander': set(['main'])}
> PROVIDES EventOFPPacketIn TO {'SimpleSwitch13': set(['main'])}
> CONSUMES EventOFPHello
> CONSUMES EventOFPSwitchFeatures
> CONSUMES EventOFPPortStatus
> CONSUMES EventOFPErrorMsg
> CONSUMES EventOFPEchoRequest
> CONSUMES EventOFPEchoReply
> CONSUMES EventOFPPortDescStatsReply
> connected socket:<eventlet.greenio.base.GreenSocket object at 0xa8d748c>
> address:('127.0.0.1', 46673)
> EVENT ofp_event->SwitchCommander EventOFPHello
> hello ev <ryu.controller.ofp_event.EventOFPHello object at 0xa8bb9cc>
> move onto config mode
> connected socket:<eventlet.greenio.base.GreenSocket object at 0xa8d75ec>
> address:('127.0.0.1', 46674)
> EVENT ofp_event->SwitchCommander EventOFPHello
> hello ev <ryu.controller.ofp_event.EventOFPHello object at 0xa8bb56c>
> move onto config mode
>>>> openflow v1.3 Hello message has been received
>>>> openflow v1.3 Hello message has been received
> EVENT ofp_event->SimpleSwitch13 EventOFPSwitchFeatures
> EVENT ofp_event->SwitchCommander EventOFPSwitchFeatures
> switch features ev
> version=0x4,msg_type=0x6,msg_len=0x20,xid=0xf18d8275L,OFPSwitchFeatures(auxiliary_id=0,capabilities=79,datapath_id=1,n_buffers=256,n_tables=254)
>>>> openflow v1.3 FeaturesReply message has been received from switch 1
> move onto main mode
> EVENT ofp_event->SimpleSwitch13 EventOFPSwitchFeatures
> EVENT ofp_event->SwitchCommander EventOFPSwitchFeatures
> switch features ev
> version=0x4,msg_type=0x6,msg_len=0x20,xid=0xfe9e7591L,OFPSwitchFeatures(auxiliary_id=0,capabilities=79,datapath_id=2,n_buffers=256,n_tables=254)
>>>> openflow v1.3 FeaturesReply message has been received from switch 2
> move onto main mode
> EVENT ofp_event->SwitchCommander EventOFPEchoRequest
>>>> openflow v1.3 EchoRequest message has been received from swich 1
> EVENT ofp_event->SwitchCommander EventOFPEchoRequest
>>>> openflow v1.3 EchoRequest message has been received from swich 2
> EVENT ofp_event->SwitchCommander EventOFPEchoRequest
>>>> openflow v1.3 EchoRequest message has been received from swich 1
> EVENT ofp_event->SwitchCommander EventOFPEchoRequest
>>>> openflow v1.3 EchoRequest message has been received from swich 2
> EVENT ofp_event->SimpleSwitch13 EventOFPPacketIn
> packet in 1 9a:1e:65:66:82:6b 33:33:00:00:00:fb 3
> EVENT ofp_event->SimpleSwitch13 EventOFPPacketIn
> packet in 2 0a:da:e5:fe:b9:c9 33:33:00:00:00:fb 3
> EVENT ofp_event->SimpleSwitch13 EventOFPPacketIn
> packet in 1 9a:1e:65:66:82:6b 33:33:00:00:00:fb 3
> EVENT ofp_event->SimpleSwitch13 EventOFPPacketIn
> packet in 2 0a:da:e5:fe:b9:c9 33:33:00:00:00:fb 3
> EVENT ofp_event->SimpleSwitch13 EventOFPPacketIn
> packet in 1 9a:1e:65:66:82:6b 33:33:00:00:00:fb 3
> EVENT ofp_event->SimpleSwitch13 EventOFPPacketIn
> packet in 2 0a:da:e5:fe:b9:c9 33:33:00:00:00:fb 3
> EVENT ofp_event->SwitchCommander EventOFPEchoRequest
>>>> openflow v1.3 EchoRequest message has been received from swich 1
> EVENT ofp_event->SwitchCommander EventOFPEchoRequest
>>>> openflow v1.3 EchoRequest message has been received from swich 2
> EVENT ofp_event->SwitchCommander EventOFPEchoRequest
>>>> openflow v1.3 EchoRequest message has been received from swich 1
> EVENT ofp_event->SwitchCommander EventOFPEchoRequest
>>>> openflow v1.3 EchoRequest message has been received from swich 2
> EVENT ofp_event->SwitchCommander EventOFPEchoRequest
>>>> openflow v1.3 EchoRequest message has been received from swich 1
> EVENT ofp_event->SwitchCommander EventOFPEchoRequest
>>>> openflow v1.3 EchoRequest message has been received from swich 2
> ---
> As a final point, here is the event handler:
> ---
> @set_ev_cls([ofp_event.EventOFPStatsReply,
> ofp_event.EventOFPDescStatsReply,
> ofp_event.EventOFPFlowStatsReply,
> ofp_event.EventOFPAggregateStatsReply,
> ofp_event.EventOFPTableStatsReply,
> ofp_event.EventOFPTableFeaturesStatsReply,
> ofp_event.EventOFPPortStatsReply,
> ofp_event.EventOFPQueueStatsReply,
> ofp_event.EventOFPQueueDescStatsReply,
> ofp_event.EventOFPMeterStatsReply,
> ofp_event.EventOFPMeterFeaturesStatsReply,
> ofp_event.EventOFPMeterConfigStatsReply,
> ofp_event.EventOFPGroupStatsReply,
> ofp_event.EventOFPGroupFeaturesStatsReply,
> ofp_event.EventOFPGroupDescStatsReply,
> ofp_event.EventOFPPortDescStatsReply
> ], MAIN_DISPATCHER)
> def switch_multipart_reply_handler(self, ev):
> multipart_reply = ev.msg
> datapath = ev.msg.datapath
> print '>>> openflow %s MultipartReply message has been received from swich
> %i' %(self.print_version(echo_request.version), datapath.id
> <http://datapath.id>)
> ---
> Best regards.
>
> Helcio
>
> 2016-12-15 2:50 GMT-03:00 Iwase Yusuke <[email protected]
> <mailto:[email protected]>>:
>
> Hi,
>
> Which multipart message type or types you want to catch?
>
> I guess you need to specify multipart message type explicitly.
> The following sample app specifies each multipart message to catch.
> https://github.com/osrg/ryu/blob/master/ryu/app/ofctl_rest.py#L713-L730
> <https://github.com/osrg/ryu/blob/master/ryu/app/ofctl_rest.py#L713-L730>
>
> Thanks,
> Iwase
>
>
> On 2016年12月15日 05:40, helcio wagner wrote:
> > Hi everybody.
> >
> > I can't receive MultipartReply messages from switches, even though I
> had defined the handler below and watched those messages using wireshark.
> >
> > Does anybody have any idea about what is going on?
> >
> > ---
> > @set_ev_cls(ofp_event.EventOFPMultipartReply, [HANDSHAKE_DISPATCHER,
> CONFIG_DISPATCHER, MAIN_DISPATCHER])
> > def switch_multipart_reply_handler(self, ev):
> > multipart_reply = ev.msg
> > datapath = ev.msg.datapath
> > print '>>> openflow %s MultipartReply message has been received from
> swich %i' %(self.print_version(echo_request.version), datapath.id
> <http://datapath.id> <http://datapath.id>)
> > ---
> >
> > Here is the trace of execution of ryu using the 'SwitchCommander',
> an application built to watch some of the OpenFlow messages received by the
> controller.
> >
> > ---
> > helcio@ojuara:~/ryu/bin$ ./ryu-manager --verbose
> ../ryu/app/simple_switch_13.py
> ../../Dropbox/EXA0186/Python/switch_commander.py
> > loading app ../ryu/app/simple_switch_13.py
> > loading app ../../Dropbox/EXA0186/Python/switch_commander.py
> > loading app ryu.controller.ofp_handler
> > instantiating app ../../Dropbox/EXA0186/Python/switch_commander.py of
> SwitchCommander
> > instantiating app ../ryu/app/simple_switch_13.py of SimpleSwitch13
> > instantiating app ryu.controller.ofp_handler of OFPHandler
> > BRICK SimpleSwitch13
> > CONSUMES EventOFPPacketIn
> > CONSUMES EventOFPSwitchFeatures
> > BRICK SwitchCommander
> > CONSUMES EventOFPHello
> > CONSUMES EventOFPMultipartReply
> > CONSUMES EventOFPEchoRequest
> > CONSUMES EventOFPSwitchFeatures
> > BRICK ofp_event
> > PROVIDES EventOFPHello TO {'SwitchCommander': set(['handshake'])}
> > PROVIDES EventOFPMultipartReply TO {'SwitchCommander':
> set(['handshake', 'main', 'config'])}
> > PROVIDES EventOFPPacketIn TO {'SimpleSwitch13': set(['main'])}
> > PROVIDES EventOFPEchoRequest TO {'SwitchCommander': set(['main'])}
> > PROVIDES EventOFPSwitchFeatures TO {'SimpleSwitch13':
> set(['config']), 'SwitchCommander': set(['config'])}
> > CONSUMES EventOFPPortStatus
> > CONSUMES EventOFPErrorMsg
> > CONSUMES EventOFPEchoRequest
> > CONSUMES EventOFPEchoReply
> > CONSUMES EventOFPPortDescStatsReply
> > CONSUMES EventOFPSwitchFeatures
> > CONSUMES EventOFPHello
> > connected socket:<eventlet.greenio.base.GreenSocket object at
> 0xa2efbec> address:('192.168.56.101', 57014)
> > EVENT ofp_event->SwitchCommander EventOFPHello
> > hello ev <ryu.controller.ofp_event.EventOFPHello object at 0xa2ea92c>
> > move onto config mode
> > connected socket:<eventlet.greenio.base.GreenSocket object at
> 0xa2efd2c> address:('192.168.56.101', 57015)
> > EVENT ofp_event->SwitchCommander EventOFPHello
> > hello ev <ryu.controller.ofp_event.EventOFPHello object at 0xa2d654c>
> > move onto config mode
> >>>> openflow v1.3 Hello message has been received
> >>>> openflow v1.3 Hello message has been received
> > EVENT ofp_event->SimpleSwitch13 EventOFPSwitchFeatures
> > EVENT ofp_event->SwitchCommander EventOFPSwitchFeatures
> > switch features ev
> version=0x4,msg_type=0x6,msg_len=0x20,xid=0x3c009c3a,OFPSwitchFeatures(auxiliary_id=0,capabilities=71,datapath_id=2,n_buffers=256,n_tables=254)
> >>>> openflow v1.3 FeaturesReply message has been received from switch 2
> > EVENT ofp_event->SimpleSwitch13 EventOFPSwitchFeatures
> > EVENT ofp_event->SwitchCommander EventOFPSwitchFeatures
> > switch features ev
> version=0x4,msg_type=0x6,msg_len=0x20,xid=0x9685eb96L,OFPSwitchFeatures(auxiliary_id=0,capabilities=71,datapath_id=1,n_buffers=256,n_tables=254)
> >>>> openflow v1.3 FeaturesReply message has been received from switch 1
> > move onto main mode
> > move onto main mode
> > EVENT ofp_event->SwitchCommander EventOFPEchoRequest
> >>>> openflow v1.3 EchoRequest message has been received from swich 2
> > EVENT ofp_event->SwitchCommander EventOFPEchoRequest
> >>>> openflow v1.3 EchoRequest message has been received from swich 1
> > EVENT ofp_event->SwitchCommander EventOFPEchoRequest
> >>>> openflow v1.3 EchoRequest message has been received from swich 2
> > EVENT ofp_event->SwitchCommander EventOFPEchoRequest
> >>>> openflow v1.3 EchoRequest message has been received from swich 1
> > EVENT ofp_event->SwitchCommander EventOFPEchoRequest
> >>>> openflow v1.3 EchoRequest message has been received from swich 2
> > EVENT ofp_event->SwitchCommander EventOFPEchoRequest
> >>>> openflow v1.3 EchoRequest message has been received from swich 1
> > EVENT ofp_event->SwitchCommander EventOFPEchoRequest
> >>>> openflow v1.3 EchoRequest message has been received from swich 2
> > EVENT ofp_event->SwitchCommander EventOFPEchoRequest
> >>>> openflow v1.3 EchoRequest message has been received from swich 1
> > ---
> >
> > Thanks in advance.
> >
> > Helcio
> >
> >
> >
> ------------------------------------------------------------------------------
> > Check out the vibrant tech community on one of the world's most
> > engaging tech sites, SlashDot.org! http://sdm.link/slashdot
> >
> >
> >
> > _______________________________________________
> > Ryu-devel mailing list
> > [email protected] <mailto:[email protected]>
> > https://lists.sourceforge.net/lists/listinfo/ryu-devel
> <https://lists.sourceforge.net/lists/listinfo/ryu-devel>
> >
>
>
>
>
> ------------------------------------------------------------------------------
> Check out the vibrant tech community on one of the world's most
> engaging tech sites, SlashDot.org! http://sdm.link/slashdot
>
>
>
> _______________________________________________
> Ryu-devel mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/ryu-devel
>
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
_______________________________________________
Ryu-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ryu-devel