noxrepo / pox

The POX network software platform
https://noxrepo.github.io/pox-doc/html/
Apache License 2.0
619 stars 470 forks source link

TypeError: ord() expected string of length 1, but int found Error in Pox Controller #251

Closed 0xabdi closed 3 years ago

0xabdi commented 3 years ago
  1. I ran pox using this command: /pox.py log.level openflow.of_01 forwarding.topo_proactive openflow.discovery
  2. Started mininet using a custom python script: sudo python3 proactive_p1.py

Up to this point, everything works fine until I ran this from the mininet prompt: h1 dhclient h1-eth0

The mininet prompt hangs for minutes and the following appears on the pox prompt:

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, *args, **kw)
  File "/home/abdirahman/pox/pox/lib/revent/revent.py", line 168, in _invoke
    return handler(self, *args, **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
MurphyMc commented 3 years ago

I think you can probably just remove the ord.

This looks like it had been missed until now in the Python 3 (#192) transition.

If removing the ord fixes it, we should push it.

Jaisaiarun commented 3 years ago

After removing ord() "ERROR:packet:(dns) parsing questions: sequence item 0: expected str instance, bytes found" this error is shown . what should be done?

MurphyMc commented 3 years ago

I don't have a lot of time to work on this right now. The basic issue is a Python2/Python3 conversion problem that didn't get caught yet. Here are some options:

Jaisaiarun commented 3 years ago

I added b in join and it worked . "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))"

MurphyMc commented 3 years ago

I'd forgotten about this issue, but have made a bunch of fixes to DNS (including the problem above) in this branch of my fork: https://github.com/MurphyMc/pox/tree/gar-wip3

... that stuff should probably eventually all get upstreamed.

SalarJamal commented 2 years ago

Hi dears does this issue effect the result of measuring RTT and Throughput of network working under Pox controller? or it can be neglected?

RiedelNicolas commented 2 years ago

Hey, firendly reminder to put this fix on main.

MohsenBs commented 1 year ago

The problem still persists

MohsenBs commented 1 year ago

I added b in join and it worked . "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))"

Can you share withus the code of DHCP after removing ord and DNS code

aperezleiras commented 1 year ago

I had to both add that "b" in read_dns_name_from_index and remove the ord's in _read_dns_name_from_index to get rid of the problem

MohsenBs commented 1 year ago

I had to both add that "b" in read_dns_name_from_index and remove the ord's in _read_dns_name_from_index to get rid of the problem

I don't have enough experience to edit, I tried and the error still appears

Can you send the code files after modification to make DHCP work?

aperezleiras commented 1 year ago

I had to both add that "b" in read_dns_name_from_index and remove the ord's in _read_dns_name_from_index to get rid of the problem

I don't have enough experience to edit, I tried and the error still appears

Can you send the code files after modification to make DHCP work?

I don't know about the DHCP problem, but it fixed the DNS problem for me, maybe you can do what I did to dns.py in dhcp.py, just replace pox/pox/lib/packet/dns.py with the dns.py in this zip dns.zip

MohsenBs commented 1 year ago

I had to both add that "b" in read_dns_name_from_index and remove the ord's in _read_dns_name_from_index to get rid of the problem

I don't have enough experience to edit, I tried and the error still appears Can you send the code files after modification to make DHCP work?

I don't know about the DHCP problem, but it fixed the DNS problem for me, maybe you can do what I did to dns.py in dhcp.py, just replace pox/pox/lib/packet/dns.py with the dns.py in this zip dns.zip

Thanks for the help, I appreciate it

But the problem persists, I think from the DHCP file


TypeError: ord() expected string of length 1, but int found ERROR:core:Exception while handling Connection!PacketIn... Traceback (most recent call last): File "/home/mohsen/pox/pox/lib/revent/revent.py", line 242, in raiseEventNoErrors return self.raiseEvent(event, *args, kw) File "/home/mohsen/pox/pox/lib/revent/revent.py", line 295, in raiseEvent rv = event._invoke(handler, *args, *kw) File "/home/mohsen/pox/pox/lib/revent/revent.py", line 168, in _invoke return handler(self, args, kw) File "/home/mohsen/pox/pox/forwarding/topo_proactive.py", line 382, in _handle_PacketIn packet = event.parsed File "/home/mohsen/pox/pox/openflow/init.py", line 193, in parsed return self.parse() File "/home/mohsen/pox/pox/openflow/init.py", line 185, in parse self._parsed = ethernet(self.data) File "/home/mohsen/pox/pox/lib/packet/ethernet.py", line 106, in init self.parse(raw) File "/home/mohsen/pox/pox/lib/packet/ethernet.py", line 127, in parse self.next = ethernet.parse_next(self, self.type, raw, ethernet.MIN_LEN) File "/home/mohsen/pox/pox/lib/packet/ethernet.py", line 134, in parse_next return parser(raw[offset:], prev) File "/home/mohsen/pox/pox/lib/packet/ipv4.py", line 93, in init self.parse(raw) File "/home/mohsen/pox/pox/lib/packet/ipv4.py", line 158, in parse self.next = udp(raw=raw[self.hl*4:length], prev=self) File "/home/mohsen/pox/pox/lib/packet/udp.py", line 68, in init self.parse(raw) File "/home/mohsen/pox/pox/lib/packet/udp.py", line 100, in parse self.next = dhcp(raw=raw[udp.MIN_LEN:],prev=self) File "/home/mohsen/pox/pox/lib/packet/dhcp.py", line 142, in init self.parse(raw) File "/home/mohsen/pox/pox/lib/packet/dhcp.py", line 215, in parse self.parseOptions() File "/home/mohsen/pox/pox/lib/packet/dhcp.py", line 232, in parseOptions self.parseOptionSegment(self._raw_options) File "/home/mohsen/pox/pox/lib/packet/dhcp.py", line 248, in parseOptionSegment opt = ord(barr[ofs]) TypeError: ord() expected string of length 1, but int found

aperezleiras commented 1 year ago

File "/home/mohsen/pox/pox/lib/packet/dhcp.py", line 248, in parseOptionSegment opt = ord(barr[ofs]) TypeError: ord() expected string of length 1, but int found

Try editing that file, line 248, and just remove that ord call, so it says opt = barr[ofs], do the same with other "ord"s you see in that same function

MurphyMc commented 1 year ago

Just a note that you are using an old version of POX. I suspect this problem is fixed in the halosaur branch.

MurphyMc commented 1 year ago

The Selecting a Branch / Version section of the manual hasn't been updated for a while, but describes the POX versioning scheme and the procedure to select them.

MohsenBs commented 1 year ago

The Selecting a Branch / Version section of the manual hasn't been updated for a while, but describes the POX versioning scheme and the procedure to select them.

MurphyMc commented 1 year ago

File a new issue and include relevant information (such as the command line / configuration you are using).

MohsenBs commented 1 year ago
  • after dhclient and dhclient -r commands the IP address is still the same on mininet hosts. How can change or renew with different IPs?

https://github.com/noxrepo/pox/issues/282#issue-1447733875

cloudlakecho commented 1 year ago

@Jaisaiarun Thanks for sharing the tip. Would you check the code line of return (next + 1,b".".join(retlist))"? The " isn't pair. The last " should by typo?

cloudlakecho commented 1 year ago

@aperezleiras I try to apply your tip of removing ord in the "_read_dns_name_from_index" function. I see two code lines with ord:      chunk_size = ord(l[index])      offset = ( (ord(l[index]) & 0x3) << 8 ) | ord(l[index + 1])

These lines should be like:      chunk_size = l[index]      offset = ( (l[index] & 0x3) << 8 ) | l[index + 1]?

My git branch: "gar-experimental"

MurphyMc commented 1 year ago

Why not just upgrade to the halosaur branch, where this was fixed almost two years ago?

cloudlakecho commented 1 year ago

@MurphyMc Thanks for your suggestion. I will switch the branch to "halosaur" and check the message during runtime.