Jumping in with a quick comment below... On Feb 27, 2015, at 11:15 AM, Sandesh Shrestha <sande...@ualberta.ca> wrote:
> Hey Lucas, > > Thanks for the help. I was able to send icmp packets to mininet host using > the code below. > I used arbitrary source mac address and source ip. The destination ip and > destination mac address is the values of > the mininet host connected in port 1 of the switch. > > However I was not able to get the icmp reply from the host.Could you please > check what the probem is. > > from pox.core import core > import pox.openflow.libopenflow_01 as of > import pox.lib.packet as pkt > from pox.lib.addresses import EthAddr,IPAddr > > log= core.getLogger() > > class Icmp(object): > def __init__(self): > core.openflow.addListeners(self) > > def _handle_PacketIn(self,event): > packet=event.parsed > > > if packet.find("icmp"): > log.debug("Icmp message received") > > def _handle_ConnectionUp(self,event): > > #This part is the ping reply > icmp=pkt.icmp() > icmp.type=pkt.TYPE_ECHO_REQUEST > echo=pkt.ICMP.echo(payload="0123456789") > icmp.payload= echo > log.debug("This is the icmp payload %s"%icmp.payload) > > #Create IP payload > ipp = pkt.ipv4() > ipp.protocol=ipp.ICMP_PROTOCOL > ipp.srcip=IPAddr("10.0.0.10") > ipp.dstip=IPAddr("10.0.0.1") > ipp.payload=icmp > log.debug( "This is the ip payload %s"%ipp.payload) > > #Create Ethernet Payload > e= pkt.ethernet() > e.src=EthAddr("00:00:00:00:00:10") > e.dst=EthAddr("00:00:00:00:00:01") > e.type=e.IP_TYPE > e.payload=ipp > log.debug( "This is the ethernet payload %s"%e.payload) > > #Send it to first input port > msg = of.ofp_packet_out() > msg.actions.append(of.ofp_action_output(port=1)) > msg.date=e.pack() .. I don't know what other problems this code may have, but the above will certainly be enough to keep it from working. You mean "msg.data". > msg.in_port=of.OFPP_NONE > event.connection.send(msg) > > def launch(): > > def start_switch(event): > log.debug("Controlling %s"%(event.connection)) > Icmp() > core.openflow.addListenerByName("ConnectionUp",start_switch) > > > Thanks, > Sandesh Shrestha > www.sandeshshrestha.blogspot.com > > On Thu, Feb 26, 2015 at 6:17 AM, Lucas Brasilino <lr...@cin.ufpe.br> wrote: > Hi Sadesh, > > I think you can construct a ICMP request as below. I did use python > interactively just as example. > The ethernet packet object 'eth' must be sent by using openflow's > ofp_packet_out() (method) message along > with ofp_action_output() (method) action to inform switch which output port > the packet must be sent from. > python was started from pox installation directory. > > >>> import pox.lib.packet as pkt > >>> from pox.lib.addresses import IPAddr,EthAddr > >>> echo = pkt.ICMP.echo(payload="0123456789") > >>> icmp = pkt.icmp(type=pkt.ICMP.TYPE_ECHO_REQUEST,payload=echo) > >>> ip = > >>> pkt.ipv4(srcip=IPAddr("10.0.0.1"),dstip=("10.0.0.2"),protocol=pkt.ipv4.ICMP_PROTOCOL,payload=icmp) > >>> eth = > >>> pkt.ethernet(src=EthAddr("aa:bb:cc:dd:ee:fe"),dst=EthAddr("aa:bb:cc:dd:ee:ff"),type=pkt.ethernet.IP_TYPE,payload=ip) > >>> print eth > [aa:bb:cc:dd:ee:fe>aa:bb:cc:dd:ee:ff IP] > >>> print eth.payload > [IP+ICMP 10.0.0.1>10.0.0.2 (cs:00 v:4 hl:5 l:20 t:64)] > >>> print eth.payload.payload > [t:ECHO_REQUEST c:0 chk:0][ICMP id:25863 seq:0] > > > I didn't test myself now but it should work :) > Hope it helps > > -- > Att > Lucas Brasilino > MSc Student @ Federal University of Pernambuco (UFPE) / Brazil > twitter: @lucas_brasilino > > > 2015-02-26 0:03 GMT-03:00 Sandesh Shrestha <sande...@ualberta.ca>: > > Dear All, > > I want to create an ICMP request(not reply) packet in POX. How can I do > that?Especially what will be the icmp payload and source ip and mac address > so that I get reply from the mininet host. > > > Thanks, > Sandesh Shrestha > www.sandeshshrestha.blogspot.com > > > > > > >