Hi, 

I followed pong.py from POX to create an ICMP reply using NOX, the packet 
captured by wireshark says “Malformed Packet: IP”. I looked into the packet, 
the ethernet header seems fine.

Here is my codes, could you help me to check where I did wrong? 
Is it because icmp has no payload?
Or, ethernet_header.tostring() is the wrong argument when calling 
send_openflow_packet?

Thank you very much.

Weiyun

from nox.lib.packet.ethernet import ethernet
from nox.lib.packet.ipv4 import ipv4
from nox.lib.packet.icmp import icmp

# ICMP reply
icmp_header = icmp()
# icmp.TYPE_ECHO_REPLY = 0
icmp_header.type = 0 
#icmp_header.payload = packet.find("icmp").payload
#Controller print:  AttributeError: icmp instance has no attribute 'payload'

ip_header = ipv4()
ip_header.protocol = ipv4.ICMP_PROTOCOL
ip_header.srcip = packet.next.dstip
ip_header.dstip = packet.next.srcip

ethernet_header = ethernet()
ethernet_header.src = packet.dst
ethernet_header.dst = packet.src
ethernet_header.type = ethernet.IP_TYPE

ip_header.payload = icmp_header
ethernet_header.payload = ip_header

actions = [[openflow.OFPAT_OUTPUT, [0, inport]]]
# call send_openflow_packet(self, dp_id, packet, actions, 
inport=openflow.OFPP_CONTROLLER)
inst.send_openflow_packet(dpid, ethernet_header.tostring(), actions, 
openflow.OFPP_CONTROLLER)



From: Murphy McCauley 
Sent: Tuesday, July 10, 2012 3:39 PM
To: Weiyun 
Cc: [email protected] 
Subject: Re: [nox-dev] How to generate ICMP packet?

On Jul 10, 2012, at 12:24 PM, Weiyun wrote:


  Could you give me an example how to generate a ICMP reply message?

  I suppose that first create packet_base instance, then add ipv4 header, and 
then icmp header?

More like an *ethernet* and then ipv4 and then icmp.


  Is there a way to copy necessary information from ICMP request to reply 
message, and then modify some attributes?

Sure.  Just copy it.

The pong.py sample in POX does exactly this.  It won't quite work with NOX's 
version of the packet library, but it may be useful as an example.

  How about ICMP unreachable message?


Well, you can read the RFC and set the fields appropriately.

Also, POX's l2_multi.py has an example of generating destination unreachable 
messages.  Again, it won't be directly usable in NOX, but it might be helpful.


Hope that helps.

-- Murphy

Reply via email to