[pox-dev] Errors when sending new created packets

Murphy McCauley murphy.mccauley at gmail.com
Thu Oct 11 15:56:53 PDT 2012


dstip and srcip should be IPAddrs, not strings.

-- Murphy

On Oct 11, 2012, at 3:53 PM, Weiyang Mo wrote:

> Hi,All
>  
> I plan to send a packet from the controller out the port whenever I receiver packet_in on that port. That's what I already did in NOX.
>  
> here's my following code:
> def _handle_PacketIn (event):
>           udp_packet = udp()
>            payload = "123456890"
>           udp_packet.srcport = 11118
>           udp_packet.dstport = 18888
>           udp_packet.len = udp.MIN_LEN + len(payload)
>           udp_packet.set_payload(payload)
>           ipv4_packet = ipv4()
>           ipv4_packet.iplen = ipv4.MIN_LEN + udp_packet.len
>           ipv4_packet.protocol = ipv4.UDP_PROTOCOL
>           ipv4_packet.dstip = "10.0.0.4"
>           ipv4_packet.srcip = "192.168.1.101"
>           ipv4_packet.set_payload(udp_packet)
>           eth_packet = ethernet()
>           eth_packet.set_payload(ipv4_packet)
>           eth_packet.src = EthAddr("00:00:00:00:00:11")
>           eth_packet.dst = EthAddr("00:00:00:00:00:22")
>           eth_packet.type = ethernet.IP_TYPE
> #          udp_packet.csum = udp_packet.checksum()
>           msg = of.ofp_packet_out(data = eth_packet)
>           msg.actions.append(of.ofp_action_output(port = event.port))
>           log.debug ("the configuration command is successully sent")
>  
> However I get the following errors:
>  msg = of.ofp_packet_out(data = eth_packet)
>   File "/home/openflow/pox/pox/openflow/libopenflow_01.py", line 2905, in __init__
>     initHelper(self, kw)
>   File "/home/openflow/pox/pox/lib/util.py", line 220, in initHelper
>     setattr(obj, k, v)
>   File "/home/openflow/pox/pox/openflow/libopenflow_01.py", line 2916, in _set_data
>     self._data = data.pack()
>   File "/home/openflow/pox/pox/lib/packet/packet_base.py", line 168, in pack
>     rest = self.next.pack()
>   File "/home/openflow/pox/pox/lib/packet/packet_base.py", line 168, in pack
>     rest = self.next.pack()
>   File "/home/openflow/pox/pox/lib/packet/packet_base.py", line 172, in pack
>     return self.hdr(rest) + rest
>   File "/home/openflow/pox/pox/lib/packet/udp.py", line 108, in hdr
>     self.csum = self.checksum()
>   File "/home/openflow/pox/pox/lib/packet/udp.py", line 135, in checksum
>     ippacket = struct.pack('!IIBBH', self.prev.srcip.toUnsigned(),
> AttributeError: 'str' object has no attribute 'toUnsigned'
>  
>  
> Any advice?
>  
> Thanks very much.
>  
> Weiyang
> 
>  




More information about the pox-dev mailing list