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
369 stars 87 forks source link
heatmap site-survey survey wifi wifi-heatmap wireless wireless-network

python-wifi-survey-heatmap

.. image:: https://www.repostatus.org/badges/latest/inactive.svg :alt: Project Status: Inactive – The project has reached a stable, usable state but is no longer being actively developed; support/maintenance will be provided as time allows. :target: https://www.repostatus.org/#inactive

.. image:: https://img.shields.io/docker/cloud/build/jantman/python-wifi-survey-heatmap.svg :alt: Docker Hub Build Status :target: https://hub.docker.com/r/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.

This is rather rough "beta" code. The heatmap generation code is roughly based on Beau Gunderson's MIT-licensed wifi-heatmap code <https://github.com/beaugunderson/wifi-heatmap>_.

Many thanks to DL6ER <https://github.com/DL6ER>__ who contributed a massive amount of improvements to this project.

Operating System support

As mentioned in the description, this project is for LINUX ONLY. That doesn't mean a Linux docker container on Windows or Mac, or running it on Mac. The WiFi features - the heart of this project - are built on libnl3 <https://pypi.org/project/libnl3/>__, a Python wrapper around the Netlink protocol-based Linux kernel interfaces. In short, the survey commands will only work on a system that's running Linux, and where the Linux kernel is directly managing the WiFi hardware.

For people not running Linux, I am aware of (but have no affiliation with, haven't used, and can't endorse) the following projects:

Quick start

Check out the Running In Docker steps below to get single-line commands that run without the need to install anything on your computer (thanks to using docker). Creating a heatmap using the software consists of the following three essential steps:

  1. Start an iperf3 server on any machine in your local network. This server is used for bandwidth measurements to be independent of your Internet connection. When omitting the --server option, this may be skipped, however, be aware that the performance heatmaps tpyically are the icing on the cake of your measurement and are very useful in determining the real performance of your WiFi.
  2. Use the wifi-survey tool to record a measurement. You can load a floorplan and click on your current location ot record signal strength and determine the achievable bandwidth.
  3. Once done with all the measurements, use the wifi-heatmap tool to compute a high-resolution heatmap from your recorded data. In case your data turns out to be too coarse, you can always go back to step 2 and delete or move old and also add new measurements at any time.

Installation and Dependencies

NOTE: These can all be ignored when using Docker. DOCKER IS THE RECOMMENDED INSTALLATION METHOD. See below.

Recommended installation is via python setup.py develop in a virtualenv setup with --system-site-packages (for the above dependencies).

Tested with Python 3.7.

Data Collection

At each survey location, data collection should take 45-60 seconds. The data collected is currently:

Hints:

Usage

Server Setup ++++++++++++

On the system you're using as the iperf3 server, run iperf3 -s to start iperf3 in server mode in the foreground. By default it will use TCP and UDP ports 5201 for communication, and these must be open in your firewall (at least from the client machine). Ideally, you should be running the same exact iperf3 version on both machines.

Performing a Survey +++++++++++++++++++

The survey tool (wifi-survey) must be run as root or via sudo in order to use iwconfig/iwlist (or via Docker; see below).

First connect to the network that you want to survey. Then, run sudo wifi-survey where:

Command-line options include:

If TITLE.json already exists, the data from it will be pre-loaded into the application; this can be used to resume a survey.

When the UI loads, you should see your PNG file displayed. The UI is really simple:

At the end of the process, you should end up with a JSON file in your current directory named after the title you provided to wifi-survey (Title.json) that's owned by root. Fix the permissions if you want.

Note: The actual survey methodology is largely up to you. In order to get accurate results, you likely want to manually handle AP associations yourself. Ideally, you lock your client to a single AP and single frequency/band for the survey.

Playing A Sound When Measurement Finishes ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

It's possible to have wifi-survey play a sound when each measurement is complete. This can be handy if you're reading or watching something in another window while waiting for the measurements.

To enable this, call wifi-survey with the --ding argument, passing it the path to an audio file to play. A short sound effect is included in this repository at wifi_survey_heatmap/complete.oga and can be used via --ding wifi_survey_heatmap/complete.oga. by default, this will call /usr/bin/paplay (the PulseAudio player) passing it the ding file path as the only argument. The command used can be overridden with --ding-command /path/to/command but it must be one that accepts the path to an audio file as its only argument.

Inside Docker, however, this becomes quite a bit more difficult. Currently PulseAudio systems are supported, and this can be set up and enabled with the following steps:

  1. Find your host computer's IP address on the docker0 network: ip addr show dev docker0 - mine (and most Linux machines) is 172.17.0.1
  2. Find the CIDR block of your docker0 network. I do this using ip route show dev docker0, which gives me a CIDR of 172.17.0.0/16
  3. Have PulseAudio listen on a TCP socket, allowing connections from your Docker network: pactl load-module module-native-protocol-tcp port=34567 auth-ip-acl=172.17.0.0/16
  4. If you have iptables restricting traffic, insert a rule allowing traffic on port 34567 from Docker before your DROP rule. For example, to insert a rule at position 5 in the INPUT chain: iptables -I INPUT 5 -s 172.17.0.0/16 -p tcp -m multiport --dports 34567 -m comment --comment "accept PulseAudio port 34567 tcp from Docker" -j ACCEPT
  5. When running the Docker container, add -e "PULSE_SERVER=tcp:172.17.0.1:34567" to the docker run command.
  6. When running wifi-survey, add the --ding argument as specified above. Note that the path to the file must be inside the container; you can put an audio file in your current directory and use it via --ding /pwd/audioFile or you can use the default file built-in to the container via --ding /app/wifi_survey_heatmap/complete.oga

Heatmap Generation ++++++++++++++++++

Once you've performed a survey with a given title and the results are saved in Title.json, run wifi-heatmap TITLE to generate heatmap files in the current directory. This process does not require (and shouldn't have) root/sudo and operates only on the JSON data file. For this, it will look better if you use a PNG without the measurement location marks.

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.

The end result of this process for a given survey (Title) should be some .png images in your current directory:

If you'd like to synchronize the colors/thresholds across multiple heatmaps, such as when comparing different AP placements, you can run wifi-heatmap-thresholds passing it each of the titles / output JSON filenames. This will generate a thresholds.json file in the current directory, suitable for passing to the wifi-heatmap -t / --thresholds option.

Add --show-points to see the measurement points in the generated maps. Typically, they aren't important when you have a sufficiently dense grid of points so they are hidden by default.

Running In Docker

Survey ++++++

Note the

.. code-block:: bash

docker run \ --net="host" \ --privileged \ --name survey \ -it \ --rm \ -v $(pwd):/pwd \ -w /pwd \ -e DISPLAY=$DISPLAY \ -v "$HOME/.Xauthority:/root/.Xauthority:ro" \ jantman/python-wifi-survey-heatmap \ wifi-survey -b -i -s -p -t </p> <p>Note that running with <code>--net="host"</code> and <code>--privileged</code> is required in order to manipulate the host's wireless interface.</p> <p>Heatmap +++++++</p> <p><code>docker run -it --rm -v $(pwd):/pwd -w /pwd jantman/python-wifi-survey-heatmap:23429a4 wifi-heatmap <TITLE></code></p> <p>iperf3 server +++++++++++++</p> <p>Server: <code>docker run -it --rm -p 5201:5201/tcp -p 5201:5201/udp jantman/python-wifi-survey-heatmap iperf3 -s</code></p> <h2>Examples</h2> <p>Floorplan +++++++++</p> <p>.. image:: examples/example_floorplan.png :alt: example floorplan image</p> <p>Floorplan with Measurement Marks ++++++++++++++++++++++++++++++++</p> <p>.. image:: examples/example_with_marks.png :alt: example floorplan image with measurement marks</p> <p>2.4 GHz Channels ++++++++++++++++</p> <p>.. image:: examples/channels24_WAP1.png :alt: example 2.4 GHz channel usage</p> <p>5 GHz Channels ++++++++++++++</p> <p>.. image:: examples/channels5_WAP1.png :alt: example 5 GHz channel usage</p> <p>Jitter ++++++</p> <p>.. image:: examples/jitter_WAP1.png :alt: example jitter heatmap</p> <p>Quality +++++++</p> <p>.. image:: examples/quality_WAP1.png :alt: example quality heatmap</p> <p>RSSI / Signal Strength ++++++++++++++++++++++</p> <p>.. image:: examples/rssi_WAP1.png :alt: example rssi heatmap</p> <p>TCP Download Speed (Mbps) +++++++++++++++++++++++++</p> <p>.. image:: examples/tcp_download_Mbps_WAP1.png :alt: example tcp download heatmap</p> <p>TCP Upload Speed (Mbps) +++++++++++++++++++++++</p> <p>.. image:: examples/tcp_upload_Mbps_WAP1.png :alt: example tcp upload heatmap</p> <p>UDP Upload Speed (Mbps) +++++++++++++++++++++++</p> <p>.. image:: examples/udp_Mbps_WAP1.png :alt: example udp upload heatmap</p> <h2>Issues</h2> <p>If you see:</p> <p>.. code-block:: bash</p> <pre><code>Couldn't connect to accessibility bus: Failed to connect to socket /run/user/1000/at-spi/bus_0: No such file or directory</code></pre> <p>when running in docker, mount the socket in docker explicitly by adding an additional <code>-v</code> switch:</p> <p>.. code-block:: bash</p> <p>docker run ... -v /run/user/1000/at-spi/bus_0:/run/user/1000/at-spi/bus_0 ...</p></div> </div> <div class="footer"> <ul class="body"> <li>© <script> document.write(new Date().getFullYear()) </script> Githubissues.</li> <li>Githubissues is a development platform for aggregating issues.</li> </ul> </div> <script src="https://cdn.jsdelivr.net/npm/jquery@3.5.1/dist/jquery.min.js"></script> <script src="/githubissues/assets/js.js"></script> <script src="/githubissues/assets/markdown.js"></script> <script src="https://cdn.jsdelivr.net/gh/highlightjs/cdn-release@11.4.0/build/highlight.min.js"></script> <script src="https://cdn.jsdelivr.net/gh/highlightjs/cdn-release@11.4.0/build/languages/go.min.js"></script> <script> hljs.highlightAll(); </script> </body> </html>