android - Wi-Fi Direct 和 "normal"Wi-Fi - 不同的 MAC?

标签 android wifi wifi-direct wifip2p

我目前正在尝试通过 Wi-Fi Direct 连接两部知道彼此 MAC 地址的手机,但偶然发现了以下问题: 我从

收到的 MAC 地址
    WifiManager wifiMan = (WifiManager) this
            .getSystemService(Context.WIFI_SERVICE);
    WifiInfo wifiInf = wifiMan.getConnectionInfo();
    MAC_ADDRESS = wifiInf.getMacAddress();

与我在发现和请求对等点时从 WifiP2pManager 收到的略有不同。示例:a0:xx:xx:... 变为 a2:xx:xx.... 有谁知道为什么?我没有找到任何方法来获取“Wi-Fi Direct MAC 地址”,而且我认为 MAC 地址应该是唯一的,并且它是处理两者(普通 Wi-Fi 和 P2P/Direct)的同一个 Wi-Fi 模块.这很奇怪.. 我应该怎么办?对于我得到的两个设备 (Galaxy Nexus),MAC 地址总是只有前两个字符不同——我应该简单地丢弃它们吗?遇到问题(两台设备仅 MAC 地址第一部分不同)的概率是否太高?

谢谢。

最佳答案

阅读 MAC address在维基百科上。

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.

MAC 48 Address

由于 Wi-Fi Direct 只是 MAC 之上的另一个堆栈,您还应该检查该位对它的含义。我找到了一些 mail discussion阐明这一点。显然下面的引用来自 WFA 规范。

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.

所以我认为这个问题的答案是,您不应该从 WifiManager 获取 MAC 地址并将其用于 Wi-Fi P2P 连接。

关于android - Wi-Fi Direct 和 "normal"Wi-Fi - 不同的 MAC?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10968951/

相关文章:

iphone - 我如何连接到名为 "A"的受密码保护的 wifi

android - 是否可以通过编程方式从 Android 中删除记住的 Wifi Direct 组?

bluetooth - 经典蓝牙、BLE 还是...Wifi Direct?

iphone - 从Wifi到3G —停止播放并且无法在iPhone开发中恢复

android - 如何为 Android 构建命令行应用程序?

android - Dialog 的键盘消失后,VideoView 未正确呈现

Android onPreviewFrame 未被调用

ios - 管理 wifi 可达性变化的正确方法?

android - 如何在 Android 和 Linux 之间设置 Wifi-Direct 连接

Android - ArrayAdapter 重复 ListView 项目