The MAC address, also called IEEE address, long address, or extended address, is a 64bit number that uniquely identifies this board from all other ZigBee boards in the world. This number is large enough to allow for about 4 billion ZigBee boards for every square meter of land on earth. ZigBee believes that will be a large enough address space for the foreseeable future.
The top 24 bits of this address consist of the Organizational Unique Identifier (OUI). The lower 40 bits are managed by the OEM producing the boards. For example, all Freescale development boards use the OUI 0x0050c2. The rest of the bits 0x37b001xxxx define the specific ZigBee development board (see Figure 4.16).
Figure 4.16: MAC Addresses
The 64-bit MAC addresses have no direct relationship to the 16-bit NwkAddr. If a node leaves one ZigBee network and joins another, its MAC address will remain the same, but the NwkAddr will likely change.
ZigBee radios do not contain a MAC address. It is up to the OEM producing boards to procure these and place them in flash memory into the board's MCU. The OUI is obtained from IEEE (http://www.IEEE.org). At the time of this writing, an OUI costs a one-time fee of around $1,600 US. If your company already ships networking products (WiFi, Ethernet, etc.) it probably already has an OUI and manages these numbers.
It's interesting to note that no standards body truly polices MAC addresses. If your company places duplicate MAC addresses into nodes that go out in the field, it will confuse the networks and your products won't work, but IEEE won't come after your company. So I guess, in a way, this is self-policing.
In the Freescale solution, for ease of development in the labs, the MAC address is set to a random value by default (address 0x0000000000000000 means to pick a random MAC address). Do not continue to use random MAC addresses in shipping products, or even in field trials.
MAC addresses are used in a number of ZigBee calls, most conspicuously in binding. The reason MAC addresses are used for binding is in case a node is mobile in the network, and it changes its short address. An example of this would be a handheld remote control that moves throughout the house. If the remote moves out of radio range of its parent, it must pick a new parent so that any node which wants to send data to the remote can find where the remote polls for its messages. When a ZED picks a new parent like this, it sends out a device to indicate its new NwkAddr, along with its unique MAC address. Any other node in the network that cares updates its internal tables to reflect this new NwkAddr for the node.
MAC addresses are also used by ZigBee in every secure packet as part of the nonce (the unique number that identifies the packet from all others for authentication reasons).
In the Freescale solution, the MAC address is located in flash memory in the structure gHardwareParametersInit. In the Freescale MC13213 (MCU + radio), this structure is at a fixed location at 0xFF72 which places the MAC address at 0xff81. The function which retrieves the MAC address, BUtl_CreateExtendedAddress(), which is found in BeeUtil.c, can also be overridden to get or to create the MAC address in any way you wish.
Remember that the MAC address, like all over-the-air entities, is little endian. So the MAC address 0x0050c237b0011234 would be represented as the following sequence of bytes in flash memory:
0x34 0x12 0x01 0xb0 0x37 0xc2 0x50 0x00
At compile-time, the MAC address can be set through Freescale BeeKit or directly in ApplicationConf.h:
When going to production, you'll need a way to manage the MAC address numbers if your company does not already have such a system. A simple spreadsheet with production run ranges will do.
The production boards must be programmed with these unique MAC addresses, in addition to any other serial numbers, model identifiers, or anything else that should be in flash memory. If you outsource your production, most production facilities offer this "serialization " service.
MAC addresses can be obtained from http://www.IEEE.org.
Every board must have a 64-bit MAC address.