RyuでMultipart Messagesをハンドリングしたくて
RyuのWiki を参考に実装してみたが、どうもうまくいかず、
Ryuのcontroller、app_managerあたりを調査していたら、ハンドラーの実装がいけていなかったようだった。(Ryuの開発コミュニティのメーリングリストにでも質問を投げてみようと思っている)
例:EventOFPPortStatsReplyの場合
def send_port_stats_request(self, datapath):
ofp = datapath.ofproto
ofp_parser = datapath.ofproto_parser
req = ofp_parser.OFPPortStatsRequest(datapath, 0, ofp.OFPP_ANY)
datapath.send_msg(req)
@set_ev_cls(ofp_event.EventOFPPortStatsReply, MAIN_DISPATCHER)
def multipart_reply_handler(self, ev):
msg = ev.msg
self.show_port_stats(msg.body)
def show_port_stats(self, body):
ports = []
for stat in body:
ports.append('port_no=%d '
'rx_packets=%d tx_packets=%d '
'rx_bytes=%d tx_bytes=%d '
'rx_dropped=%d tx_dropped=%d '
'rx_errors=%d tx_errors=%d '
'rx_frame_err=%d rx_over_err=%d rx_crc_err=%d '
'collisions=%d duration_sec=%d duration_nsec=%d' %
(stat.port_no,
stat.rx_packets, stat.tx_packets,
stat.rx_bytes, stat.tx_bytes,
stat.rx_dropped, stat.tx_dropped,
stat.rx_errors, stat.tx_errors,
stat.rx_frame_err, stat.rx_over_err, stat.rx_crc_err,
stat.collisions,
stat.duration_sec, stat.duration_nsec))
self.logger.debug('PortStats: %s', ports)
BRICK ofp_event
PROVIDES EventOFPPortStatsReply TO {'L2Switch': ['main']}
PROVIDES EventOFPSwitchFeatures TO {'L2Switch': ['config']}
PROVIDES EventOFPBarrierReply TO {'L2Switch': ['main']}
PROVIDES EventOFPPacketIn TO {'L2Switch': ['main']}
CONSUMES EventOFPErrorMsg
CONSUMES EventOFPHello
CONSUMES EventOFPEchoRequest
CONSUMES EventOFPSwitchFeatures
BRICK L2Switch
CONSUMES EventOFPPortStatsReply
CONSUMES EventOFPSwitchFeatures
CONSUMES EventOFPBarrierReply
CONSUMES EventOFPPacketIn
Info: mininet starting...
*** Creating network
*** Adding controller
connected socket:<eventlet.greenio.GreenSocket object at 0x19d99d0> address:('127.0.0.1', 46511)
*** Adding hosts:
c1 h1 h2 h3 h4
*** Adding switches:
s1 s2 s3 s4 s5 s6
*** Adding links:
(c1, s1) (h1, s3) (h2, s4) (h3, s5) (h4, s6) (s1, s2) (s1, s3) (s1, s4) (s1, s5) (s1, s6) (s2, s3) (s2, s4) (s2, s5) (s2, s6)
*** Configuring hosts
c1 h1 h2 h3 h4
*** Starting CLI:
----------------------------------
----------------------------------
*** Starting controller
*** Starting 6 switches
s1 s2 s3 s4 connected socket:<eventlet.greenio.GreenSocket object at 0x19d9a90> address:('127.0.0.1', 46512)
msg_type:0
hello ev <ryu.controller.ofp_event.EventOFPHello object at 0x19d9e10>
move onto config mode
s5 s6
*** Starting CLI:
mininet> connected socket:<eventlet.greenio.GreenSocket object at 0x19d9850> address:('127.0.0.1', 46513)
msg_type:0
hello ev <ryu.controller.ofp_event.EventOFPHello object at 0x195f290>
move onto config mode
connected socket:<eventlet.greenio.GreenSocket object at 0x19d9f50> address:('127.0.0.1', 46514)
msg_type:0
hello ev <ryu.controller.ofp_event.EventOFPHello object at 0x195f710>
move onto config mode
connected socket:<eventlet.greenio.GreenSocket object at 0x195f3d0> address:('127.0.0.1', 46515)
msg_type:0
hello ev <ryu.controller.ofp_event.EventOFPHello object at 0x195fbd0>
move onto config mode
connected socket:<eventlet.greenio.GreenSocket object at 0x195f850> address:('127.0.0.1', 46516)
msg_type:0
hello ev <ryu.controller.ofp_event.EventOFPHello object at 0x1964090>
move onto config mode
connected socket:<eventlet.greenio.GreenSocket object at 0x195fd10> address:('127.0.0.1', 46517)
msg_type:0
hello ev <ryu.controller.ofp_event.EventOFPHello object at 0x19644d0>
move onto config mode
msg_type:6
EVENT ofp_event->L2Switch EventOFPSwitchFeatures
switch features ev version: 0x4 msg_type 0x6 xid 0x674a5667 OFPSwitchFeatures(auxiliary_id=0,capabilities=79,datapath_id=5,n_buffers=256,n_tables=64,reserved=0)
move onto main mode
msg_type:19
msg_type:21
EVENT ofp_event->L2Switch EventOFPBarrierReply
msg_type:6
EVENT ofp_event->L2Switch EventOFPSwitchFeatures
switch features ev version: 0x4 msg_type 0x6 xid 0x58699132 OFPSwitchFeatures(auxiliary_id=0,capabilities=79,datapath_id=1,n_buffers=256,n_tables=64,reserved=0)
move onto main mode
msg_type:19
msg_type:6
EVENT ofp_event->L2Switch EventOFPSwitchFeatures
switch features ev version: 0x4 msg_type 0x6 xid 0x93cfa3ca OFPSwitchFeatures(auxiliary_id=0,capabilities=79,datapath_id=6,n_buffers=256,n_tables=64,reserved=0)
move onto main mode
msg_type:19
msg_type:6
EVENT ofp_event->L2Switch EventOFPSwitchFeatures
switch features ev version: 0x4 msg_type 0x6 xid 0xb3c407f4 OFPSwitchFeatures(auxiliary_id=0,capabilities=79,datapath_id=4,n_buffers=256,n_tables=64,reserved=0)
move onto main mode
msg_type:19
msg_type:6
EVENT ofp_event->L2Switch EventOFPSwitchFeatures
switch features ev version: 0x4 msg_type 0x6 xid 0xb917dc4d OFPSwitchFeatures(auxiliary_id=0,capabilities=79,datapath_id=3,n_buffers=256,n_tables=64,reserved=0)
move onto main mode
EVENT ofp_event->L2Switch EventOFPSwitchFeatures
switch features ev version: 0x4 msg_type 0x6 xid 0x3bdafa19 OFPSwitchFeatures(auxiliary_id=0,capabilities=79,datapath_id=2,n_buffers=256,n_tables=64,reserved=0)
move onto main mode
EVENT ofp_event->L2Switch EventOFPPortStatsReply
PortStats: ['port_no=1 rx_packets=0 tx_packets=0 rx_bytes=0 tx_bytes=0 rx_dropped=0 tx_dropped=0 rx_errors=0 tx_errors=0 rx_frame_err=0 rx_over_err=0 rx_crc_err=0 collisions=0 duration_sec=1 duration_nsec=104000', 'port_no=2 rx_packets=0 tx_packets=0 rx_bytes=0 tx_bytes=0 rx_dropped=0 tx_dropped=0 rx_errors=0 tx_errors=0 rx_frame_err=0 rx_over_err=0 rx_crc_err=0 collisions=0 duration_sec=1 duration_nsec=104000', 'port_no=3 rx_packets=0 tx_packets=0 rx_bytes=0 tx_bytes=0 rx_dropped=0 tx_dropped=0 rx_errors=0 tx_errors=0 rx_frame_err=0 rx_over_err=0 rx_crc_err=0 collisions=0 duration_sec=1 duration_nsec=104000', 'port_no=4294967294 rx_packets=2 tx_packets=0 rx_bytes=168 tx_bytes=0 rx_dropped=0 tx_dropped=0 rx_errors=0 tx_errors=0 rx_frame_err=0 rx_over_err=0 rx_crc_err=0 collisions=0 duration_sec=1 duration_nsec=104000']
msg_type:19
EVENT ofp_event->L2Switch EventOFPPortStatsReply
msg_type:19
EVENT ofp_event->L2Switch EventOFPPortStatsReply
msg_type:19
EVENT ofp_event->L2Switch EventOFPPortStatsReply
msg_type:19
EVENT ofp_event->L2Switch EventOFPPortStatsReply
msg_type:19
EVENT ofp_event->L2Switch EventOFPPortStatsReply
PortStats: ['port_no=1 rx_packets=0 tx_packets=0 rx_bytes=0 tx_bytes=0 rx_dropped=0 tx_dropped=0 rx_errors=0 tx_errors=0 rx_frame_err=0 rx_over_err=0 rx_crc_err=0 collisions=0 duration_sec=1 duration_nsec=36000', 'port_no=2 rx_packets=0 tx_packets=0 rx_bytes=0 tx_bytes=0 rx_dropped=0 tx_dropped=0 rx_errors=0 tx_errors=0 rx_frame_err=0 rx_over_err=0 rx_crc_err=0 collisions=0 duration_sec=1 duration_nsec=36000', 'port_no=3 rx_packets=0 tx_packets=0 rx_bytes=0 tx_bytes=0 rx_dropped=0 tx_dropped=0 rx_errors=0 tx_errors=0 rx_frame_err=0 rx_over_err=0 rx_crc_err=0 collisions=0 duration_sec=1 duration_nsec=36000', 'port_no=4 rx_packets=0 tx_packets=0 rx_bytes=0 tx_bytes=0 rx_dropped=0 tx_dropped=0 rx_errors=0 tx_errors=0 rx_frame_err=0 rx_over_err=0 rx_crc_err=0 collisions=0 duration_sec=1 duration_nsec=36000', 'port_no=5 rx_packets=0 tx_packets=0 rx_bytes=0 tx_bytes=0 rx_dropped=0 tx_dropped=0 rx_errors=0 tx_errors=0 rx_frame_err=0 rx_over_err=0 rx_crc_err=0 collisions=0 duration_sec=1 duration_nsec=36000', 'port_no=6 rx_packets=0 tx_packets=0 rx_bytes=0 tx_bytes=0 rx_dropped=0 tx_dropped=0 rx_errors=0 tx_errors=0 rx_frame_err=0 rx_over_err=0 rx_crc_err=0 collisions=0 duration_sec=1 duration_nsec=36000', 'port_no=4294967294 rx_packets=2 tx_packets=0 rx_bytes=168 tx_bytes=0 rx_dropped=0 tx_dropped=0 rx_errors=0 tx_errors=0 rx_frame_err=0 rx_over_err=0 rx_crc_err=0 collisions=0 duration_sec=1 duration_nsec=36000']
PortStats: ['port_no=1 rx_packets=0 tx_packets=0 rx_bytes=0 tx_bytes=0 rx_dropped=0 tx_dropped=0 rx_errors=0 tx_errors=0 rx_frame_err=0 rx_over_err=0 rx_crc_err=0 collisions=0 duration_sec=1 duration_nsec=128000', 'port_no=2 rx_packets=0 tx_packets=0 rx_bytes=0 tx_bytes=0 rx_dropped=0 tx_dropped=0 rx_errors=0 tx_errors=0 rx_frame_err=0 rx_over_err=0 rx_crc_err=0 collisions=0 duration_sec=1 duration_nsec=15000', 'port_no=3 rx_packets=0 tx_packets=0 rx_bytes=0 tx_bytes=0 rx_dropped=0 tx_dropped=0 rx_errors=0 tx_errors=0 rx_frame_err=0 rx_over_err=0 rx_crc_err=0 collisions=0 duration_sec=1 duration_nsec=15000', 'port_no=4294967294 rx_packets=2 tx_packets=0 rx_bytes=168 tx_bytes=0 rx_dropped=0 tx_dropped=0 rx_errors=0 tx_errors=0 rx_frame_err=0 rx_over_err=0 rx_crc_err=0 collisions=0 duration_sec=1 duration_nsec=15000']
PortStats: ['port_no=1 rx_packets=0 tx_packets=0 rx_bytes=0 tx_bytes=0 rx_dropped=0 tx_dropped=0 rx_errors=0 tx_errors=0 rx_frame_err=0 rx_over_err=0 rx_crc_err=0 collisions=0 duration_sec=1 duration_nsec=37000', 'port_no=2 rx_packets=0 tx_packets=0 rx_bytes=0 tx_bytes=0 rx_dropped=0 tx_dropped=0 rx_errors=0 tx_errors=0 rx_frame_err=0 rx_over_err=0 rx_crc_err=0 collisions=0 duration_sec=1 duration_nsec=37000', 'port_no=3 rx_packets=0 tx_packets=0 rx_bytes=0 tx_bytes=0 rx_dropped=0 tx_dropped=0 rx_errors=0 tx_errors=0 rx_frame_err=0 rx_over_err=0 rx_crc_err=0 collisions=0 duration_sec=1 duration_nsec=37000', 'port_no=4294967294 rx_packets=2 tx_packets=0 rx_bytes=168 tx_bytes=0 rx_dropped=0 tx_dropped=0 rx_errors=0 tx_errors=0 rx_frame_err=0 rx_over_err=0 rx_crc_err=0 collisions=0 duration_sec=1 duration_nsec=37000']
PortStats: ['port_no=1 rx_packets=0 tx_packets=0 rx_bytes=0 tx_bytes=0 rx_dropped=0 tx_dropped=0 rx_errors=0 tx_errors=0 rx_frame_err=0 rx_over_err=0 rx_crc_err=0 collisions=0 duration_sec=1 duration_nsec=41000', 'port_no=2 rx_packets=0 tx_packets=0 rx_bytes=0 tx_bytes=0 rx_dropped=0 tx_dropped=0 rx_errors=0 tx_errors=0 rx_frame_err=0 rx_over_err=0 rx_crc_err=0 collisions=0 duration_sec=1 duration_nsec=41000', 'port_no=3 rx_packets=1 tx_packets=0 rx_bytes=90 tx_bytes=0 rx_dropped=0 tx_dropped=0 rx_errors=0 tx_errors=0 rx_frame_err=0 rx_over_err=0 rx_crc_err=0 collisions=0 duration_sec=1 duration_nsec=41000', 'port_no=4294967294 rx_packets=2 tx_packets=0 rx_bytes=168 tx_bytes=0 rx_dropped=0 tx_dropped=0 rx_errors=0 tx_errors=0 rx_frame_err=0 rx_over_err=0 rx_crc_err=0 collisions=0 duration_sec=1 duration_nsec=41000']
PortStats: ['port_no=1 rx_packets=0 tx_packets=0 rx_bytes=0 tx_bytes=0 rx_dropped=0 tx_dropped=0 rx_errors=0 tx_errors=0 rx_frame_err=0 rx_over_err=0 rx_crc_err=0 collisions=0 duration_sec=1 duration_nsec=40000', 'port_no=2 rx_packets=0 tx_packets=0 rx_bytes=0 tx_bytes=0 rx_dropped=0 tx_dropped=0 rx_errors=0 tx_errors=0 rx_frame_err=0 rx_over_err=0 rx_crc_err=0 collisions=0 duration_sec=1 duration_nsec=40000', 'port_no=3 rx_packets=0 tx_packets=0 rx_bytes=0 tx_bytes=0 rx_dropped=0 tx_dropped=0 rx_errors=0 tx_errors=0 rx_frame_err=0 rx_over_err=0 rx_crc_err=0 collisions=0 duration_sec=1 duration_nsec=40000', 'port_no=4 rx_packets=0 tx_packets=0 rx_bytes=0 tx_bytes=0 rx_dropped=0 tx_dropped=0 rx_errors=0 tx_errors=0 rx_frame_err=0 rx_over_err=0 rx_crc_err=0 collisions=0 duration_sec=1 duration_nsec=40000', 'port_no=5 rx_packets=0 tx_packets=0 rx_bytes=0 tx_bytes=0 rx_dropped=0 tx_dropped=0 rx_errors=0 tx_errors=0 rx_frame_err=0 rx_over_err=0 rx_crc_err=0 collisions=0 duration_sec=1 duration_nsec=40000', 'port_no=4294967294 rx_packets=2 tx_packets=0 rx_bytes=168 tx_bytes=0 rx_dropped=0 tx_dropped=0 rx_errors=0 tx_errors=0 rx_frame_err=0 rx_over_err=0 rx_crc_err=0 collisions=0 duration_sec=1 duration_nsec=40000']
受け取れたようだ。
CPqD ofsoftswitch13で全てのMultipart Messagesをサポートしているかは
不明だが、同様にほかのMultipart Messagesもハンドリングできるはずだ。
Comments
Add Comment