scapy icmp samles
Send a simple Echo Request and wait for the answer and display it.  
# set target ip and icmp-data
ip_target = ""
data = "Space for Rent!"
# define ip and icmp
ip = IP()
icmp = ICMP()
# creat ip + icmp parameters
ip.dst = ip_target
icmp.type = 8
icmp.code = 0

a = sr1(ip/icmp/data)
and the new Scapy Ping Command (function)  
def ping(host, count=3):
  packet = IP(dst=host)/ICMP()
  for x in range(count):
     ans = sr1(packet)

ping ("",4)
for sending all types and codes of icmp, simply build 2 for loops and send the packet. On the Taget side, you can sniff, what packet's are recived.  
# set target ip 
ip_target = ""
# define ip and icmp 
ip = IP()
icmp = ICMP()
# set the destinaion IP to the target
ip.dst = ip_target
# create 2 casade loops for sending the icmp packet
for i_type in range(0,256):
  for i_code in range(0,256):
    icmp.type = i_type
    icmp.code = i_code
    print i_type,i_code


scapy special icmp
send icmp type 3 and code 4 packtes back to the a sender for reduce the MTU -> manipulate the MTU size -> create routing entrys on a Windows XP System

(c) 2009 by / last update: 07.11.2009