Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

wrong RSSI value #9

Open
solsticedhiver opened this issue Oct 3, 2017 · 8 comments
Open

wrong RSSI value #9

solsticedhiver opened this issue Oct 3, 2017 · 8 comments

Comments

@solsticedhiver
Copy link

solsticedhiver commented Oct 3, 2017

When I use the -r or --rssi switch I got big negative value that are non sense.

I found out that I must replace the line 56 with this one:

rssi_val = -(256-ord(packet.notdecoded[-2:-1]))

to get the correct value

I don't know if it's universal.

@rpandey91
Copy link

Hi,
I am also getting the same value. Did you solve the issue?

@solsticedhiver
Copy link
Author

YES. I have shown the fix above. it's line 56

@solsticedhiver
Copy link
Author

A more general fix is to use the offical radiotap library to parse the RSSI value

Something like this:

from radiotap import radiotap_parse
offset, headers = radiotap_parse(str(packet))
rssi = headers['dbm_antsignal']

This adds a dependancy but it is a more robust fix.

@shepardac
Copy link

So before I make the fix I am unable to run Probemon. After I make:
rssi_val = -(256-ord(packet.notdecoded[-2:-1])) it works, but the rssi value is always -256. How do I fix?

@bmrquad
Copy link

bmrquad commented Jul 10, 2018

I am having the same issue. If we use the above where would this get placed in the coding?

@rub0t
Copy link

rub0t commented Oct 26, 2018

A more general fix is to use the offical radiotap library to parse the RSSI value

Something like this:

from radiotap import radiotap_parse
offset, headers = radiotap_parse(str(packet))
rssi = headers['dbm_antsignal']

This adds a dependancy but it is a more robust fix.

this worked for me.

@solsticedhiver
Copy link
Author

solsticedhiver commented Jan 15, 2019

So instead of importing a new dependancy with python-radiotap, one can use the following function (this is a stripped down version of the python-radiotap parsing module)

def parse_rssi(packet):
    # parse dbm_antsignal from radiotap header
    # borrowed from python-radiotap module
    radiotap_header_fmt = '<BBHI'
    radiotap_header_len = struct.calcsize(radiotap_header_fmt)
    version, pad, radiotap_len, present = struct.unpack_from(radiotap_header_fmt, packet)

    start = radiotap_header_len
    bits = [int(b) for b in bin(present)[2:].rjust(32, '0')]
    bits.reverse()
    if bits[5] == 0:
        return 0

    while present & (1 << 31):
        present, = struct.unpack_from('<I', packet, start)
        start += 4
    offset = start
    if bits[0] == 1:
        offset = (offset + 8 -1) & ~(8-1)
        offset += 8
    if bits[1] == 1:
        offset += 1
    if bits[2] == 1:
        offset += 1
    if bits[3] == 1:
        offset = (offset + 2 -1) & ~(2-1)
        offset += 4
    if bits[4] == 1:
        offset += 2
    dbm_antsignal, = struct.unpack_from('<b', packet, offset)
    return dbm_antsignal

So, for example replace line 56 with

    rssi_val = parse_rssi(buffer(str(packet)))

You will need to import struct module

@WolfspiritM
Copy link

With latest scapy you can just use:
rssi_val = packet.dBm_AntSignal

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants