i wrote this program to sniff icmp packets in the network and print there source address. The code is as follows:
from scapy.all import *
def fun_callback(pkt):
print str(pkt.payload.src)
sniff(prn = fun_callback, filter = 'icmp', timeout =5)
After running this program, I am getting this error.
[root@localhost icmp]# python test.py
WARNING: Failed to execute tcpdump. Check it is installed and in the PATH
WARNING: No route found for IPv6 destination :: (no default route?)
192.168.134.131
192.168.134.131
192.168.134.2
192.168.134.2
fe80::20c:29ff:fee4:a130
134.160.38.1
192.168.134.131
Traceback (most recent call last):
File "test.py", line 5, in <module>
sniff(prn = fun_callback, filter = 'icmp', timeout =5)
File "/usr/lib/python2.7/site-packages/scapy/sendrecv.py", line 586, in sniff
r = prn(p)
File "test.py", line 4, in fun_callback
print str(pkt.payload.src)
File "/usr/lib/python2.7/site-packages/scapy/packet.py", line 176, in __getattr__
fld,v = self.getfield_and_val(attr)
File "/usr/lib/python2.7/site-packages/scapy/packet.py", line 172, in getfield_and_val
return self.payload.getfield_and_val(attr)
File "/usr/lib/python2.7/site-packages/scapy/packet.py", line 172, in getfield_and_val
return self.payload.getfield_and_val(attr)
File "/usr/lib/python2.7/site-packages/scapy/packet.py", line 1057, in getfield_and_val
raise AttributeError(attr)
AttributeError: src
[root@localhost icmp]#
Why this exception is occurring?