在Ryu控制器中处理eventtofpflowstatsreply消息时出现Keyerror



我试图在Simple_monitor_13 (Ryu SDN控制器)中获得请求的FlowStat信息,但是当使用简单的mininet拓扑和"pingall"运行时,应用程序不断报告来自非常基本的匹配字段(如Ipv4_src, eth_type)的Keyerrors。我是否误解了这个活动的运作方式?怎样才能满足这个要求呢?

for stat in sorted([flow for flow in body if (flow.priority == 1)], key=lambda flow: 
(flow.match['in_port'], flow.match['eth_dst'],flow.match['ipv4_src'],flow.match['ipv4_dst'],flow.match['ip_proto'])):
flow_stat['table_id']= stat.table_id
flow_stat['priority'] = stat.priority
flow_stat['in_port'] = stat.match['in_port']
flow_stat['ip_proto'] = stat.match['ip_proto']
flow_stat['ipv4_src'] = stat.match['ipv4_src']
flow_stat['ipv4_dst'] = stat.match['ipv4_dst']
File "c:usersacerappdatalocalprogramspythonpython38-32libsite-packagesryubaseapp_manager.py", line 290, in _event_loop
handler(ev)
File "E:SDN_ML_Anacondaryuryuappsimple_monitor_13_fetch.py", line 91, in _flow_stats_reply_handler
for stat in sorted([flow for flow in body if (flow.priority == 1)], key=lambda flow:
File "E:SDN_ML_Anacondaryuryuappsimple_monitor_13_fetch.py", line 92, in <lambda>
(flow.match['in_port'], flow.match['eth_dst'],flow.match['ipv4_src'],flow.match['ipv4_dst'],flow.match['ip_proto'])):
File "c:usersacerappdatalocalprogramspythonpython38-32libsite-packagesryuofprotoofproto_v1_3_parser.py", line 904, in __getitem__
return dict(self._fields2)[key]
KeyError: 'ipv4_src'

FlowStatsReply

FlowStatsReply包含交换机上安装的每个流的统计信息。由于流没有专用的唯一标识符,因此它们由匹配字段标识。如果一个流规则在某个报头字段上不匹配,它在FlowStatsReply中的相应流条目也不会包含该字段。

SimpleMonitor13

如果您查看SimpleSwitch13 (SimpleMonitor13继承自它),您将发现控制器在其_packet_in_handler中安装流,并具有以下匹配项:

match = parser.OFPMatch(in_port=in_port, eth_dst=dst, eth_src=src)

因此,SimpleMonitor13中的FlowStatsReply将只包含in_port,eth_dsteth_src字段,而不包含ipv4_srceth_type

最新更新