Hi Helcio,
On 2016年12月16日 22:13, helcio wagner wrote:
> Hi, Iwase.
>
> I've copy-pasted your code. Nothing has happened to me.
>
> I'm running ryu-manager (version 4.8) with a single script to print the OF
> messages Hello, FeaturesReply, MultipartReply and EchoRequest. I can see all
> of them in Wireshark, but I still can't log reception of the MultipartReply
> message. I think I should assume that this is a bug in ryu API, because I
> can't see any reason for that.
I don't think it is a bug...
For breaking down the issue, does the attached app work well on your
environment?
If not, this problem is not on Ryu, and might be on your enviroment setup, I
guess.
$ ryu-manager --verbose ryu/app/simple_switch_13.py ryu/app/ofctl_rest.py
loading app ryu/app/simple_switch_13.py
loading app ryu/app/ofctl_rest.py
loading app ryu.controller.ofp_handler
creating context wsgi
instantiating app None of DPSet
creating context dpset
instantiating app ryu/app/ofctl_rest.py of RestStatsApi
instantiating app ryu/app/simple_switch_13.py of SimpleSwitch13
instantiating app ryu.controller.ofp_handler of OFPHandler
BRICK RestStatsApi
CONSUMES EventOFPQueueGetConfigReply
CONSUMES EventOFPPortDescStatsReply
CONSUMES EventOFPGroupStatsReply
CONSUMES EventOFPQueueStatsReply
CONSUMES EventOFPStatsReply
CONSUMES EventOFPGroupDescStatsReply
CONSUMES EventOFPAggregateStatsReply
CONSUMES EventOFPPortStatsReply
CONSUMES EventOFPTableStatsReply
CONSUMES EventOFPFlowStatsReply
CONSUMES EventOFPGroupFeaturesStatsReply
CONSUMES EventOFPMeterFeaturesStatsReply
CONSUMES EventOFPMeterStatsReply
CONSUMES EventOFPMeterConfigStatsReply
CONSUMES EventOFPSwitchFeatures
CONSUMES EventOFPTableFeaturesStatsReply
CONSUMES EventOFPDescStatsReply
CONSUMES EventOFPQueueDescStatsReply
BRICK dpset
CONSUMES EventOFPStateChange
CONSUMES EventOFPPortStatus
CONSUMES EventOFPSwitchFeatures
BRICK ofp_event
PROVIDES EventOFPQueueGetConfigReply TO {'RestStatsApi': {'main'}}
PROVIDES EventOFPPortStatus TO {'dpset': {'main'}}
PROVIDES EventOFPStateChange TO {'dpset': {'main', 'dead'}}
PROVIDES EventOFPPortDescStatsReply TO {'RestStatsApi': {'main'},
'SimpleSwitch13': {'main'}}
PROVIDES EventOFPGroupStatsReply TO {'RestStatsApi': {'main'},
'SimpleSwitch13': {'main'}}
PROVIDES EventOFPQueueStatsReply TO {'RestStatsApi': {'main'},
'SimpleSwitch13': {'main'}}
PROVIDES EventOFPStatsReply TO {'RestStatsApi': {'main'}, 'SimpleSwitch13':
{'main'}}
PROVIDES EventOFPGroupDescStatsReply TO {'RestStatsApi': {'main'},
'SimpleSwitch13': {'main'}}
PROVIDES EventOFPAggregateStatsReply TO {'RestStatsApi': {'main'},
'SimpleSwitch13': {'main'}}
PROVIDES EventOFPPortStatsReply TO {'RestStatsApi': {'main'},
'SimpleSwitch13': {'main'}}
PROVIDES EventOFPTableStatsReply TO {'RestStatsApi': {'main'},
'SimpleSwitch13': {'main'}}
PROVIDES EventOFPPacketIn TO {'SimpleSwitch13': {'main'}}
PROVIDES EventOFPFlowStatsReply TO {'RestStatsApi': {'main'},
'SimpleSwitch13': {'main'}}
PROVIDES EventOFPGroupFeaturesStatsReply TO {'RestStatsApi': {'main'},
'SimpleSwitch13': {'main'}}
PROVIDES EventOFPMeterFeaturesStatsReply TO {'RestStatsApi': {'main'},
'SimpleSwitch13': {'main'}}
PROVIDES EventOFPMeterStatsReply TO {'RestStatsApi': {'main'},
'SimpleSwitch13': {'main'}}
PROVIDES EventOFPMeterConfigStatsReply TO {'RestStatsApi': {'main'},
'SimpleSwitch13': {'main'}}
PROVIDES EventOFPSwitchFeatures TO {'RestStatsApi': {'main'}, 'dpset':
{'config'}, 'SimpleSwitch13': {'config'}}
PROVIDES EventOFPTableFeaturesStatsReply TO {'RestStatsApi': {'main'},
'SimpleSwitch13': {'main'}}
PROVIDES EventOFPDescStatsReply TO {'RestStatsApi': {'main'},
'SimpleSwitch13': {'main'}}
PROVIDES EventOFPQueueDescStatsReply TO {'RestStatsApi': {'main'},
'SimpleSwitch13': {'main'}}
CONSUMES EventOFPEchoRequest
CONSUMES EventOFPErrorMsg
CONSUMES EventOFPPortDescStatsReply
CONSUMES EventOFPSwitchFeatures
CONSUMES EventOFPHello
CONSUMES EventOFPEchoReply
CONSUMES EventOFPPortStatus
BRICK SimpleSwitch13
CONSUMES EventOFPPortDescStatsReply
CONSUMES EventOFPGroupStatsReply
CONSUMES EventOFPQueueStatsReply
CONSUMES EventOFPStatsReply
CONSUMES EventOFPGroupDescStatsReply
CONSUMES EventOFPAggregateStatsReply
CONSUMES EventOFPPortStatsReply
CONSUMES EventOFPTableStatsReply
CONSUMES EventOFPPacketIn
CONSUMES EventOFPFlowStatsReply
CONSUMES EventOFPGroupFeaturesStatsReply
CONSUMES EventOFPMeterFeaturesStatsReply
CONSUMES EventOFPMeterStatsReply
CONSUMES EventOFPMeterConfigStatsReply
CONSUMES EventOFPSwitchFeatures
CONSUMES EventOFPTableFeaturesStatsReply
CONSUMES EventOFPDescStatsReply
CONSUMES EventOFPQueueDescStatsReply
(10285) wsgi starting up on http://0.0.0.0:8080
connected socket:<eventlet.greenio.base.GreenSocket object at 0x7f2d887ff940>
address:('127.0.0.1', 55370)
hello ev <ryu.controller.ofp_event.EventOFPHello object at 0x7f2d888103c8>
move onto config mode
EVENT ofp_event->dpset EventOFPSwitchFeatures
EVENT ofp_event->SimpleSwitch13 EventOFPSwitchFeatures
switch features ev
version=0x4,msg_type=0x6,msg_len=0x20,xid=0x5de4730e,OFPSwitchFeatures(auxiliary_id=0,capabilities=79,datapath_id=1,n_buffers=256,n_tables=254)
move onto main mode
EVENT ofp_event->dpset EventOFPStateChange
DPSET: register datapath <ryu.controller.controller.Datapath object at
0x7f2d887ffa90>
(10285) accepted ('127.0.0.1', 36724)
Sending message with xid(5de47311) to datapath(0000000000000001):
version=None,msg_type=None,msg_len=None,xid=0x5de47311,OFPFlowStatsRequest(cookie=0,cookie_mask=0,flags=0,match=OFPMatch(oxm_fields={}),out_group=4294967295,out_port=4294967295,table_id=255,type=1)
EVENT ofp_event->RestStatsApi EventOFPFlowStatsReply
EVENT ofp_event->SimpleSwitch13 EventOFPFlowStatsReply
>>> OpenFlow 0x4 MultipartReply message (type 0x1) has been received from
>>> switch 1
127.0.0.1 - - [19/Dec/2016 10:44:15] "GET /stats/flow/1 HTTP/1.1" 200 355
0.018633
$ curl -X GET http://localhost:8080/stats/flow/1
...
Thanks,
Iwase
>
> Thanks again for you help.
>
> Helcio.
>
> 2016-12-16 1:22 GMT-03:00 Iwase Yusuke <iwase.yusu...@gmail.com
> <mailto:iwase.yusu...@gmail.com>>:
>
> 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 <http://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
> <http://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
> <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> <http://datapath.id>)
> > ---
> > Best regards.
> >
> > Helcio
> >
> > 2016-12-15 2:50 GMT-03:00 Iwase Yusuke <iwase.yusu...@gmail.com
> <mailto:iwase.yusu...@gmail.com> <mailto:iwase.yusu...@gmail.com
> <mailto:iwase.yusu...@gmail.com>>>:
> >
> > 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>
> <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> <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
> > > Ryu-devel@lists.sourceforge.net
> <mailto:Ryu-devel@lists.sourceforge.net>
> <mailto:Ryu-devel@lists.sourceforge.net
> <mailto:Ryu-devel@lists.sourceforge.net>>
> > > https://lists.sourceforge.net/lists/listinfo/ryu-devel
> <https://lists.sourceforge.net/lists/listinfo/ryu-devel>
> <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
> > Ryu-devel@lists.sourceforge.net <mailto:Ryu-devel@lists.sourceforge.net>
> > 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
> Ryu-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/ryu-devel
>
# Copyright (C) 2011 Nippon Telegraph and Telephone Corporation.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
# implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from ryu.base import app_manager
from ryu.controller import ofp_event
from ryu.controller.handler import CONFIG_DISPATCHER, MAIN_DISPATCHER
from ryu.controller.handler import set_ev_cls
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
class SimpleSwitch13(app_manager.RyuApp):
OFP_VERSIONS = [ofproto_v1_3.OFP_VERSION]
def __init__(self, *args, **kwargs):
super(SimpleSwitch13, self).__init__(*args, **kwargs)
self.mac_to_port = {}
@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
# install table-miss flow entry
#
# We specify NO BUFFER to max_len of the output action due to
# OVS bug. At this moment, if we specify a lesser number, e.g.,
# 128, OVS will send Packet-In with invalid buffer_id and
# truncated packet data. In that case, we cannot output packets
# correctly. The bug has been fixed in OVS v2.1.0.
match = parser.OFPMatch()
actions = [parser.OFPActionOutput(ofproto.OFPP_CONTROLLER,
ofproto.OFPCML_NO_BUFFER)]
self.add_flow(datapath, 0, match, actions)
def add_flow(self, datapath, priority, match, actions, buffer_id=None):
ofproto = datapath.ofproto
parser = datapath.ofproto_parser
inst = [parser.OFPInstructionActions(ofproto.OFPIT_APPLY_ACTIONS,
actions)]
if buffer_id:
mod = parser.OFPFlowMod(datapath=datapath, buffer_id=buffer_id,
priority=priority, match=match,
instructions=inst)
else:
mod = parser.OFPFlowMod(datapath=datapath, priority=priority,
match=match, instructions=inst)
datapath.send_msg(mod)
@set_ev_cls(ofp_event.EventOFPPacketIn, MAIN_DISPATCHER)
def _packet_in_handler(self, ev):
# If you hit this you might want to increase
# the "miss_send_length" of your switch
if ev.msg.msg_len < ev.msg.total_len:
self.logger.debug("packet truncated: only %s of %s bytes",
ev.msg.msg_len, ev.msg.total_len)
msg = ev.msg
datapath = msg.datapath
ofproto = datapath.ofproto
parser = datapath.ofproto_parser
in_port = msg.match['in_port']
pkt = packet.Packet(msg.data)
eth = pkt.get_protocols(ethernet.ethernet)[0]
if eth.ethertype == ether_types.ETH_TYPE_LLDP:
# ignore lldp packet
return
dst = eth.dst
src = eth.src
dpid = datapath.id
self.mac_to_port.setdefault(dpid, {})
self.logger.info("packet in %s %s %s %s", dpid, src, dst, in_port)
# learn a mac address to avoid FLOOD next time.
self.mac_to_port[dpid][src] = in_port
if dst in self.mac_to_port[dpid]:
out_port = self.mac_to_port[dpid][dst]
else:
out_port = ofproto.OFPP_FLOOD
actions = [parser.OFPActionOutput(out_port)]
# install a flow to avoid packet_in next time
if out_port != ofproto.OFPP_FLOOD:
match = parser.OFPMatch(in_port=in_port, eth_dst=dst)
# verify if we have a valid buffer_id, if yes avoid to send both
# flow_mod & packet_out
if msg.buffer_id != ofproto.OFP_NO_BUFFER:
self.add_flow(datapath, 1, match, actions, msg.buffer_id)
return
else:
self.add_flow(datapath, 1, match, actions)
data = None
if msg.buffer_id == ofproto.OFP_NO_BUFFER:
data = msg.data
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)
------------------------------------------------------------------------------
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
Ryu-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ryu-devel