assert isinstance(data,of.ofp_header)失败

时间:2014-05-07 05:53:59

标签: python pox openflow

我正在修改flow_stats.py文件中的流,然后发送消息以切换到将它们排队。但在openflow.of_01.Connection.send()中断言isinstance(data,of.ofp_header)失败。我已经阅读了pox-dev邮件列表上的帖子并修复了我的导入名称。有人可以指导我。

这是我的代码

#flow_stats.py
def _handle_flowstats_received (event):
     stats = flow_stats_to_list(event.stats)
     log.debug("FlowStatsReceived from %s: %s", dpidToStr(event.connection.dpid), stats)

     msg = of.ofp_flow_mod()
     msg.command = of.OFPFC_MODIFY_STRICT
     connection = event.connection

     for f in event.stats:
        if f.match.nw_proto == 1:
           f.actions.append(of.ofp_action_enqueue(port = my_port, queue_id = 0))

     msg = f
     connection.send(msg)

这是发生错误的代码。这是痘文件。我没有更改此文件中的任何内容。

#of_01
#def send (self, data):
   if self.disconnected: return
   if type(data) is not bytes:
   # There's actually no reason the data has to be an instance of
   # ofp_header, but this check is likely to catch a lot of bugs,
   # so we check it anyway.
      assert isinstance(data, of.ofp_header)
      data = data.pack()

0 个答案:

没有答案