开发者

How can I get nearby phone 's RSSI and Mac address under the same Ad-Hoc mode?

开发者 https://www.devze.com 2023-03-20 03:07 出处:网络
I have changed the some android phones to ad-hoc mode and let them have the same essid (by using command on each phone:\"iwconfig .. essid XXX\").In this way they merged in one ad-hoc network and can

I have changed the some android phones to ad-hoc mode and let them have the same essid (by using command on each phone:"iwconfig .. essid XXX").In this way they merged in one ad-hoc network and can successfully send udp packets among them.

Next, I want to get nearby phones's RSSI and Mac address in the same ad-hoc network.I try to start wpa_supplicant process and intent to get rssi by scaning(not through android system so android API such as getRssi(), getScanResult() could not be used), but I only get one essid "XXX" which stand for this adhoc network(BSSID) and a fake Mac address .

then I try to modify the command "iwlist" to recompile it on android, I got the same results above..I don't know whether this phenomenon is determined by linux system or wireless driver..

then I try to catch the beacon packets of the phone, I get the correc开发者_如何学Got mac and rssi, but the beacon receiver is under moniter mode not in the ad-hoc mode,thus could not send udp packets to nearby phones..

so what can I do to get each phone's RSSI and Mac address in the same Ad-Hoc network?

thanks a lot!!


I am not sure I completely understand your question but I think you have a bit of a misunderstanding about WiFi.

First, RSSI stands for "Received Signal Strength Indication", which means the strength of the signal from the receiver's perspective. In your situation, the only way one phone can know the RSSI of another phone is if data about RSSI is communicated at a higher (i.e. application) layer.

For example:

  1. Phone A sends radio message XYZ to Phone B.
  2. Phone B can hear message XYZ from Phone A at -75dBm.
  3. Phone B could then send a message to Phone A to tell Phone A that it is hearing Phone A at -75dBm.
  4. (Phone A can now to the same thing as Phone B, by using the RSSI of the messages it is receiving from Phone B)

Second, I'm not completely aware of how ad-hoc networks handle BSSIDs etc, but I'm fairly sure you will face a similar problem to the RSSI one above. I.e. The ad-hoc mode probably chooses which BSSID to use for the establishment of the WiFi network. This does not have to be the MAC address of any of the devices (e.g. it can be a fake MAC). If you want to communicate a phone's own MAC to another phone you will have to put it in a message at the application layer and send it to a receiving application on another phone.

For example:

  1. Phone A interrogates its own OS/Network interfaces and finds its own MAC address (NB: it could find more than one!)
  2. Phone A puts this in an application message (i.e. your own UDP packet) and sends it to Phone B.
  3. Phone B receives the message, unpacks the message and finds out what MAC Phone A has told it.

So in short, the answer is: Collect and share the information at the application layer, you can't "sniffer/overhear" the information you are after from the wifi stack.

0

精彩评论

暂无评论...
验证码 换一张
取 消