Wi-Fi Direct and "normal" Wi-Fi - Different MAC?

damian picture damian · Jun 10, 2012 · Viewed 7.5k times · Source

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

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

is slightly different than 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 "Wi-Fi Direct MAC address", and as I thought the MAC address should be unique, and it's the same Wi-Fi module that handles both (normal Wi-Fi 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.

Answer

auselen picture auselen · Jan 23, 2013

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.

MAC 48 Address

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.