How to calculate the distance of devices over WI-FI using force and signal frequency?

Asked

Viewed 167 times

2

How can I calculate the distance of a device by wifi, using the strength of the signal of the same?

I’m using tshark (wireshark) to perform this 802.11 scan, capturing only Prob requests (the moment the device searches for Aps). Then filter the fields that interest me as MAC address of the emitter, Signal Strength and among others.

Shell command (With MAC filter):

tshark -l -i wlxe894f617588c -Y "wlan.fc.type_subtype == 4 && wlan.sa == xx:xx:xx:xx:xx:xx" -T fields -e wlan_radio.timestamp -e _ws.col.Source -e _ws.col.Destination -e wlan_radio.signal_dbm  -e wlan_radio.frequency

Output

1614649110  xx:xx:xx:XX:XX:XX   Broadcast   -34 2412
1614751459  xx:xx:xx:XX:XX:XX   Broadcast   -40 2412
1615400027  xx:xx:xx:XX:XX:XX   Broadcast   -74 2412
1615514449  xx:xx:xx:XX:XX:XX   Broadcast   -74 2412
1615672377  xx:xx:xx:XX:XX:XX   Broadcast   -86 2412

From the above columns I use only the last two which are signal strength and frequency. To perform the following calculation:

Distance = 10 ((27.55 - (20 * log10(Frequency)) + signalLevel)/20)

Described as response How to calculate Distance from Wifi router using Signal Strength? He further informs:

Example: Frequency = 2412MHz, signalLevel = -57dbm, result = 7.000397427391188m

But when I perform the calculation with these values the result is totally different:

#include <stdio.h>
#include <math.h>

int main(){
    float r = pow(10.0,((27.55 - (20 * log10(2414))+ -57)/20.0));
    printf("%d\n",r); // resultado 0.000014
    return 0;
}

There are other answers that involve the calculation FSPL (Free Space Path Lost), but it requires variables that I do not have, such as sensitivity of antenna reception or its gain.

It is obviously not easy to get the exact distance of the device, since the signal strength is sensitive to any physical barrier and interference of the same frequency. The very goal is to know how many Vices are next to my antenna in a radius of 5 meters or more if necessary being connected or not.

  • 2

    That would be a math problem, regardless of being in a code, right? I don’t think that brings the problem to the site scope. Anyway, it would be closed by typing error, if you were to consider in the scope, pq is a mistake when copying the formula forgetting the ABS. Links to better understand how Sopt works: [Tour], [Ask], Manual on how NOT to ask questions and [Help]. Remembering that your points already allow access to the network chat, more suitable for this type of thing (especially the Stack Burst room)

  • 1

    Really. Now I realize that it’s a question back more to physics/electronics

1 answer

3


I tested it here on Matlab:

Frequency in 2412

signallevel in -57

inserir a descrição da imagem aqui

Your code is missing one abs look there in the image formula:

abs(-57)

Correct equation for the above data:

10 ^ ((27.55 - (20 * log10(2412)) + abs(-57))/20)

Browser other questions tagged

You are not signed in. Login or sign up in order to post.