TypeError:ord预期的字符串长度为1,但在Pox Controller中发现int错误

问题描述

  1. 我使用以下命令运行pox:/pox.py log.level openflow.of_01 Forwarding.topo_proactive openflow.discovery
  2. 使用自定义的python脚本启动mininet:sudo python3 proactive_p1.py

到目前为止,一切正常,直到我从mininet提示符运行:h1 dhclient h1-eth0

mininet提示符挂起几分钟,并在pox提示符下显示以下内容

INFO:core:POX 0.7.0 (gar) is up.
INFO:openflow.of_01:[00-00-00-00-00-01 2] connected
ERROR:core:Exception while handling OpenFlowNexus!PacketIn...
Traceback (most recent call last):
  File "/home/abdirahman/pox/pox/lib/revent/revent.py",line 242,in raiseEventNoErrors
    return self.raiseEvent(event,*args,**kw)
  File "/home/abdirahman/pox/pox/lib/revent/revent.py",line 295,in raiseEvent
    rv = event._invoke(handler,line 168,in _invoke
    return handler(self,**kw)
  File "/home/abdirahman/pox/pox/openflow/discovery.py",line 347,in _handle_openflow_PacketIn
    packet = event.parsed
  File "/home/abdirahman/pox/pox/openflow/__init__.py",line 193,in parsed
    return self.parse()
  File "/home/abdirahman/pox/pox/openflow/__init__.py",line 185,in parse
    self._parsed = ethernet(self.data)
  File "/home/abdirahman/pox/pox/lib/packet/ethernet.py",line 106,in __init__
    self.parse(raw)
  File "/home/abdirahman/pox/pox/lib/packet/ethernet.py",line 127,in parse
    self.next = ethernet.parse_next(self,self.type,raw,ethernet.MIN_LEN)
  File "/home/abdirahman/pox/pox/lib/packet/ethernet.py",line 134,in parse_next
    return parser(raw[offset:],prev)
  File "/home/abdirahman/pox/pox/lib/packet/ipv4.py",line 93,in __init__
    self.parse(raw)
  File "/home/abdirahman/pox/pox/lib/packet/ipv4.py",line 158,in parse
    self.next = udp(raw=raw[self.hl*4:length],prev=self)
  File "/home/abdirahman/pox/pox/lib/packet/udp.py",line 68,in __init__
    self.parse(raw)
  File "/home/abdirahman/pox/pox/lib/packet/udp.py",line 100,in parse
    self.next = dhcp(raw=raw[udp.MIN_LEN:],prev=self)
  File "/home/abdirahman/pox/pox/lib/packet/dhcp.py",line 142,in __init__
    self.parse(raw)
  File "/home/abdirahman/pox/pox/lib/packet/dhcp.py",line 215,in parse
    self.parSEOptions()
  File "/home/abdirahman/pox/pox/lib/packet/dhcp.py",line 232,in parSEOptions
    self.parSEOptionSegment(self._raw_options)
  File "/home/abdirahman/pox/pox/lib/packet/dhcp.py",line 248,in parSEOptionSegment
    opt = ord(barr[ofs])
TypeError: ord() expected string of length 1,but int found

解决方法

这是已知的痘痘错误,实际上有一个open issue,已有几周的历史,可能需要经过一段时间后才能设置。因为这不是关于此问题的第一个问题,所以我在这里将其链接起来,添加应该解决该问题的线程答复:

解决方法是按照文件heredns.py所述删除ord,但是随后会出现新错误,可以通过在字节中添加b来解决(390行):

def read_dns_name_from_index(cls,l,index):
    retlist = []
    next = cls._read_dns_name_from_index(l,index,retlist)
    return (next + 1,b".".join(retlist))

但是,这是一个非常复杂的解决方案,因此您可以在fangtooth分支中使用Python 2版本的POX。