Discussion:
[pox-dev] Create ICMP packets in POX
Sandesh Shrestha
2015-02-26 03:03:59 UTC
Permalink
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
Lucas Brasilino
2015-02-26 13:17:18 UTC
Permalink
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.
Post by Sandesh Shrestha
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)
Post by Sandesh Shrestha
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)
Post by Sandesh Shrestha
print eth
[aa:bb:cc:dd:ee:fe>aa:bb:cc:dd:ee:ff IP]
Post by Sandesh Shrestha
print eth.payload
[IP+ICMP 10.0.0.1>10.0.0.2 (cs:00 v:4 hl:5 l:20 t:64)]
Post by Sandesh Shrestha
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
Post by Sandesh Shrestha
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
Sandesh Shrestha
2015-02-27 19:15:13 UTC
Permalink
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()
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
Post by Lucas Brasilino
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.
Post by Sandesh Shrestha
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)
Post by Sandesh Shrestha
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)
Post by Sandesh Shrestha
print eth
[aa:bb:cc:dd:ee:fe>aa:bb:cc:dd:ee:ff IP]
Post by Sandesh Shrestha
print eth.payload
[IP+ICMP 10.0.0.1>10.0.0.2 (cs:00 v:4 hl:5 l:20 t:64)]
Post by Sandesh Shrestha
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
Dear All,
Post by Sandesh Shrestha
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
Murphy McCauley
2015-02-28 03:39:05 UTC
Permalink
Jumping in with a quick comment below...
Post by Sandesh Shrestha
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".
Post by Sandesh Shrestha
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
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
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
Sandesh Shrestha
2015-02-28 19:06:16 UTC
Permalink
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.

Thanks,
Sandesh Shrestha
Post by Murphy McCauley
Jumping 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 Brasilino
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.
Post by Sandesh Shrestha
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)
Post by Sandesh Shrestha
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)
Post by Sandesh Shrestha
print eth
[aa:bb:cc:dd:ee:fe>aa:bb:cc:dd:ee:ff IP]
Post by Sandesh Shrestha
print eth.payload
[IP+ICMP 10.0.0.1>10.0.0.2 (cs:00 v:4 hl:5 l:20 t:64)]
Post by Sandesh Shrestha
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
Dear All,
Post by Sandesh Shrestha
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
Murphy McCauley
2015-03-01 00:16:19 UTC
Permalink
Use Wireshark to examine the destination host's interface. Do you see the packet? Is it as you expect it?

-- Murphy
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.
Thanks,
Sandesh Shrestha
Jumping in with a quick comment below...
Post by Sandesh Shrestha
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".
Post by Sandesh Shrestha
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
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
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
Lucas Brasilino
2015-03-01 01:26:34 UTC
Permalink
Hi Sandesh,
Post by Sandesh Shrestha
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.
If mininet's destination host is connected to the same switch of your
source host or it is connected to other switch controlled by Pox (or
another OF controller) as well, the ICMP reply must be issued by the OF
component too. Isn't that the case ?
--
Att
Lucas Brasilino
Post by Sandesh Shrestha
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.
Thanks,
Sandesh Shrestha
On Fri, Feb 27, 2015 at 8:39 PM, Murphy McCauley <
Post by Murphy McCauley
Jumping 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 Brasilino
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.
Post by Sandesh Shrestha
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)
Post by Sandesh Shrestha
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)
Post by Sandesh Shrestha
print eth
[aa:bb:cc:dd:ee:fe>aa:bb:cc:dd:ee:ff IP]
Post by Sandesh Shrestha
print eth.payload
[IP+ICMP 10.0.0.1>10.0.0.2 (cs:00 v:4 hl:5 l:20 t:64)]
Post by Sandesh Shrestha
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
Dear All,
Post by Sandesh Shrestha
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
Sandesh Shrestha
2015-03-01 07:23:36 UTC
Permalink
Hello All,

I got it. Thanks for your support.

I got arp request in POX which is enough for my need. I just had to
calculate the round trip time.

Thanks,
Sandesh Shrestha
Post by Lucas Brasilino
Hi Sandesh,
Post by Sandesh Shrestha
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.
If mininet's destination host is connected to the same switch of your
source host or it is connected to other switch controlled by Pox (or
another OF controller) as well, the ICMP reply must be issued by the OF
component too. Isn't that the case ?
--
Att
Lucas Brasilino
Thank you very much for pointing that out Murphy. However, I am still not
Post by Sandesh Shrestha
able to get the response ping. Please share if you have any idea.
Thanks,
Sandesh Shrestha
On Fri, Feb 27, 2015 at 8:39 PM, Murphy McCauley <
Post by Murphy McCauley
Jumping 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 Brasilino
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.
Post by Sandesh Shrestha
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)
Post by Sandesh Shrestha
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)
Post by Sandesh Shrestha
print eth
[aa:bb:cc:dd:ee:fe>aa:bb:cc:dd:ee:ff IP]
Post by Sandesh Shrestha
print eth.payload
[IP+ICMP 10.0.0.1>10.0.0.2 (cs:00 v:4 hl:5 l:20 t:64)]
Post by Sandesh Shrestha
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
Dear All,
Post by Sandesh Shrestha
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
Loading...