Thank you very much for pointing that out Murphy. However, I am still not
able to get the response ping. Please share if you have any idea.
Post by Murphy McCauleyJumping in with a quick comment below...
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()
core.openflow.addListeners(self)
packet=event.parsed
log.debug("Icmp message received")
#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)
log.debug("Controlling %s"%(event.connection))
Icmp()
core.openflow.addListenerByName("ConnectionUp",start_switch)
Thanks,
Sandesh Shrestha
www.sandeshshrestha.blogspot.com
Post by Lucas BrasilinoHi 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.
Post by Sandesh Shresthaimport 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)
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)
[aa:bb:cc:dd:ee:fe>aa:bb:cc:dd:ee:ff IP]
[IP+ICMP 10.0.0.1>10.0.0.2 (cs:00 v:4 hl:5 l:20 t:64)]
Post by Sandesh Shresthaprint 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
Dear All,
Post by Sandesh ShresthaI 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