Scapy ping ICMP



sudo tcpdump -nn src 127.0.0.1 and dst 127.0.0.1 -i lo

In another terminal we send a single ping:


ping -c 1 localhost

This is what tcpdump captured:


10:42:23.016599 IP 127.0.0.1 > 127.0.0.1: ICMP echo request, id 11, seq 1, length 64
10:42:23.016608 IP 127.0.0.1 > 127.0.0.1: ICMP echo reply, id 11, seq 1, length 64

Then we run our scapy script:


examples/scapy/ping.py
import scapy.all as scapy
scapy.send(scapy.IP()/scapy.ICMP(id=1, seq=1))

sudo /opt/venv3/bin/python ping.py


10:43:48.081774 IP 127.0.0.1 > 127.0.0.1: ICMP echo request, id 0, seq 0, length 8