问题描述:

I use AR9271 chipset usb WiFi device on Debian 7 on kernel 3.12.rc5. I use ath9k_htc and nl80211 drivers.

I create an ad-hoc WLAN via wpa_supplicant 2.0 and I would like to obtain received signal strength of the neighboring device in a C program.

What function or API can I use to obtain that information?

网友答案:

Edit: Did not notice the ad-hoc part the first time.. For ad-hoc, I don't really know.

For what it's worth and for infrastructure connections:

If you have wpa_supplicant, you should also have wpa_cli.

The command:

wpa_cli signal_poll

should give you screen scrapeable output.

You can (also) interface with wpa_supplicant via C, using wpa_ctrl_open() and wpa_ctrl_request():

Something in the line of:

#include "wpa_ctrl.h"
<needed declarations and definitions>
ctrl = wpa_ctrl_open(path);
wpa_ctrl_request(ctrl, "SIGNAL_POLL", 11, buf, &len, NULL);
网友答案:

This is eminently doable with libpcap, monitoring the wireless lan for the raw packets, including the 802.11 header, which contains the RSSI, as well as the origin MAC address. See this question for a couple of hints and tips as to the decoding the underlying packet structure.

The easiest thing to do is listen for packets from the neighboring devices so that you can read their RSSI. Raw traffic from the wlan device tends to be insanely noisy - you'll have to filter it for only the devices that you're interested in.

The information is only available by reading it yourself, though, there's nothing gathering the data for you; and if there is a quiet device on your network you'll have to figure out some way to get it to talk so you can read the RSSI from it.

相关阅读:
Top