无线网络直接和"正常"无线网络 - 不同的MAC?无线网络、正常、直接、不同

2023-09-07 08:38:20 作者:浪迹天涯只为你

目前,我正在试图连接两部手机哪知道通过WiFi直接对方的MAC地址,偶然发现了以下问题: MAC地址,我接受来自

  WifiManager wifiMan =(WifiManager)本
            .getSystemService(Context.WIFI_SERVICE);
    WifiInfo wifiInf = wifiMan.getConnectionInfo();
    MAC_ADDRESS = wifiInf.getMacAddress();
 

略有不同,那么一个来自WifiP2pManager发现和请求同行当我收到。举例:A0:XX:XX:...变成A2:XX:XX .... 有谁知道,为什么呢?我没有找到任何办法让无线网络直接MAC地址,并作为我认为的MAC地址应该是唯一的,它同样支持WiFi模块,可以同时处理(正常wifi和P2P /直),这是非常奇怪的.. 我该怎么办?对于两个设备(Galaxy Nexus的)我所得到的,它总是只有不同的MAC地址的前两个字符 - 我应该干脆放弃呢?是遇到问题(两个设备只不同的MAC地址的第一部分)的概率太高了?

感谢。

解决方案

阅读有关 MAC地址在维基百科。

       

地址既可以统一管理的地址或本地管理的地址。

         

普遍施用和局部施用的地址被通过设置地址的最高显著字节的第二最低位显著区分。该位也被称为U / L位,短通用/本地,它标识地址是如何给药。如果该位为0,该地址是统一管理。如果它是1,则地址是本地管理

  

由于Wi-Fi直是另一个堆栈MAC之上,你也应该检查什么该位意味着它。我发现了一些邮件讨论脱落一些轻这一点。下面引用显然是从WFA规范。

       

而P2P设备应指定一个P2P接口地址,对应     在§7.1.3.3.1描述IEEE标准802.11-2007的 1 格式,哪     用于与P2P集团P2P内业主或客户进行沟通     组。 P2P接口地址不要求全局唯一,     可以局部给药。对于P2P接口地址可以是相同的     P2P的设备地址提供给P2P界面的要求     地址在本节中得到满足。

  

所以,我认为这个问题的答案是,你不应该从 WifiManager 取MAC地址,并使用它与的Wi-Fi无线P2P 连接。

I'm currently trying to connect two phones which know each other's MAC address via WiFi Direct, and stumbled upon the following problem: The MAC address, I receive from

    WifiManager wifiMan = (WifiManager) this
            .getSystemService(Context.WIFI_SERVICE);
    WifiInfo wifiInf = wifiMan.getConnectionInfo();
    MAC_ADDRESS = wifiInf.getMacAddress();
无线网络 已连接上,但是上不了网 办公室里其他电脑都能正常上网

is slightly different then the one I receive from the WifiP2pManager when discovering and requesting peers. Example: a0:xx:xx:... turns into a2:xx:xx.... Does anyone know, why? I did not find any way to get the "wifi direct mac address", and as I thought the mac address should be unique and it's the same wifi-module that handles both (normal wifi and p2p/direct) this is very weird.. What should I do? For the two devices (Galaxy Nexus) I've got, it's always only the first two characters that differ in the mac addresses - should I simply discard them? Is the probability to encounter problems (two devices which only differ in the first part of mac address) too high?

Thanks.

解决方案

Reading about the MAC address on wikipedia.

Addresses can either be universally administered addresses or locally administered addresses.

Universally administered and locally administered addresses are distinguished by setting the second-least-significant bit of the most significant byte of the address. This bit is also referred to as the U/L bit, short for Universal/Local, which identifies how the address is administered. If the bit is 0, the address is universally administered. If it is 1, the address is locally administered.

Since Wi-Fi Direct is just another stack on top of MAC, you should also check what that bit can mean for it. I've found some mail discussion shedding some light on this. Apparently quote below is from a WFA spec.

The P2P Device shall assign a P2P Interface Address, corresponding to the format as described in §7.1.3.3.1 of IEEE Std 802.11‑2007 1, which is used to communicate with the P2P Group Owner or Clients within a P2P Group. A P2P Interface Address is not required to be globally unique and may be locally administered. A P2P Interface Address may be the same as the P2P Device Address provided the requirements for P2P Interface Address in this clause are satisfied.

So I believe answer to this question is, you shouldn't take MAC address from WifiManager and use it with Wi-Fi P2P connections.