jantman / python-wifi-survey-heatmap

A Python application for Linux machines to perform WiFi site surveys and present the results as a heatmap overlayed on a floorplan
GNU Affero General Public License v3.0
375 stars 88 forks source link

wifi-heatmap --ap-names seems not working #22

Closed ggruening closed 2 years ago

ggruening commented 2 years ago

Hello everyone,

Thanks for all the work!

I'm trying to use the -a / --ap-names option. Unfortunately I can't find any documentation about the structure of the json file. I tried something like this:

{
    "aa:bb:cc:dd:ee:01": "AP1 5",  
    "aa:bb:cc:dd:ee:02": "AP1 24",  
    "aa:bb:cc:dd:ee:03": "AP2 5",   
    "aa:bb:cc:dd:ee:04": "AP2 24",  
    "aa:bb:cc:dd:ee:05": "AP3 24", 
    "aa:bb:cc:dd:ee:06": "AP3 5"     
}

A wifi-heatmap --ap-names ap-mapping.json [TITLE] does not change the images at all. Is this a bug or am I doing something wrong?

Best regards, Gregor

jantman commented 2 years ago

Gregor,

I don't actually use that option myself. I just looked through the code and it looks like, while this is not documented, --ap-names only works if wifi-heatmap is run with --show-points. Could you please give that a try and let me know if that causes the AP names to show up?

Thanks, Jason

ggruening commented 2 years ago

Thanks for the hint.

The measurement points are displayed with --show-points, but their labeling is in the form <SSID> (<frequency>). The name of the access points is still missing.

There is actually no difference between wifi-heatmap --show-points [TITLE] and wifi-heatmap --show-points --ap-names ap-mapping.json [TITLE].

Are there any further ideas?

jantman commented 2 years ago

Hmmm... I'll need to take a look after work today. I don't use the ap names feature myself, so it could just be broken in a way that I haven't noticed yet.

Is there any chance that you could upload one of the resulting heatmaps, and also the output of running that command with -vv for debug-level output?

ggruening commented 2 years ago

You're welcome :-)

heatmap.log

tcp_download_Mbps_example json

jantman commented 2 years ago

Looking at the code, I think the JSON file expects SSID keys, not BSSID.

In wifi-heatmap, the contents of ap-mapping.json is [loaded(https://github.com/jantman/python-wifi-survey-heatmap/blob/master/wifi_survey_heatmap/heatmap.py#L151-L156) into self._ap_names, with the keys converted to upper-case. When processing the survey data (survey_points list in the JSON file, i.e. example.json), for each item in survey_points, we look at the ssid value in the result dictionary. If there's a matching key (upper case to upper case) in the AP names, we display that value. If not, we display the SSID.

ggruening commented 2 years ago

Maybe I'm confused, but I do not see the point. A network that is broadcast from several access points has the same SSID everywhere, and the information that would be helpful is which access point I am actually connected to despite the same SSID. What am I missing?

jantman commented 2 years ago

You're not confused. It appears that this is a bug.

Looking back in the git history, it originally used BSSIDs like you'd expect. The README even has a line about that:

You can optionally pass the path to a JSON file mapping the access point MAC addresses (BSSIDs) to friendly names via the -a / --ap-names argument. If specified, this will annotate each measurement dot on the heatmap with the name (mapping value) and frequency band of the AP that was connected when the measurement was taken. This can be useful in multi-AP roaming environments.

However, v1.0.0 / #4 was a PR that included a massive rewrite of the wireless-handling code to move from iwlist to nl80211. It appears that a commit in that PR switched these labels from BSSID to SSID.

jantman commented 2 years ago

I have a fix for this currently in a branch: https://github.com/jantman/python-wifi-survey-heatmap/tree/issues/22

I'll try to get that released in the next few days.

ggruening commented 2 years ago

Just checked out the new branch... it works! Thank you very much. It makes this great software even more great :-) I'll stay tuned for the new release.

jantman commented 2 years ago

This has been released as 1.1.0 and should be live on Docker Hub as well. Thank you so much for taking the time to report the issue and help with troubleshooting!