Prerequisite
Assuming the interface is in monitor mode, and correct channel assigned.
Following example configures iface=wlan0
to monitor mode
and listens to channel=6
$ sudo ip link set wlan0 down
$ sudo iw dev wlan0 set type monitor
$ sudo ip link set wlan0 up
$ sudo iw dev wlan0 set channel 6
Python3
RSSI from a packet can be earned by dBm_AntSignal
if RadioTap
header is correctly sniffed together.
from scapy.all import RadioTap
from scapy.all import sniff
# sniff a packet from the interface
pkt = sniff(iface="wlan0", count=1)
pkt = pkt[0]
# getting the RSSI
radiotap = pkt.getlayer(RadioTap)
rssi = radiotap.dBm_AntSignal
print("RSSI={}".format(rssi)) # RSSI=-84
Python2
Seems like dBm_AntSignal
is not working on python2 scapy, following example will work.
extra = pkt.notdecoded
rssi = -(256-ord(extra[-4:-3]))
Hope this helps.