anishathalye / offix

"Who is in the office?" 👀
https://anishathalye.com/whos-in-the-office/
GNU General Public License v3.0
186 stars 27 forks source link

Investigate using wifi signal level to estimate distance / presence better #9

Closed anishathalye closed 3 years ago

anishathalye commented 8 years ago

WiFi range > size of the room, so we sometimes have false positives. I'm not sure if we can see the wifi signal level using our hardware, and I'm not sure if it's high enough quality information that we can accurately tell whether people are actually in the room, but this would be good to investigate at some point.

rdalverny commented 8 years ago

First, thank you for this project! About 2 years about, I tried to do something similar by tweaking an access point to which users connected, playing with the DHCP server and bridging with a web application. I didn't know about the probe request, that's way better!

I investigated a bit. You can get the received signal strength in the radiotap data structure, by using this in parse_packet:

struct radiotap_data_t {
    uint8_t  wr_flags;
    uint8_t  wr_rate;
    uint16_t wr_chan_freq;
    uint16_t wr_chan_flags;
    uint8_t  wr_antsignal;
    uint8_t  wr_antenna;
};
struct radiotap_data_t *data;

if (radio tap->it_present == 0x0000482E)
{
    data = (struct radiotap_data_t *) (packet + 8);
    printf("%u", 256 - data->wr_antsignal);
}

I can open a PR integrating this better if you'd like.

anishathalye commented 8 years ago

Yeah, my hypothesis was that it would depend a good amount on specific device / topology of the room, so I didn't know a good way of setting any thresholds on received signal strength. It would probably require some investigation / experimentation to figure out a good way to do it.

If you feel like experimenting and you come up with something interesting, I'd be happy to merge a PR.

Also, btw, there's a named constant for the magic number (see https://github.com/anishathalye/offix/blob/08583fa69d697663ac987a1dccf5de93cc658e5d/offix-sniffer/radiotap.h#L110), so you probably want something like:

if (data->it_present & (1 << IEEE80211_RADIOTAP_DBM_ANTNOISE))
{
    // grab the information
}
anishathalye commented 3 years ago

Closing due to age