What is a MAC address

(This has nothing to do with the address of your Mac Computer)

A MAC address also known as a media access control address is a unique 48 bit number identifier assigned to network interfaces.

Every piece of hardware with a ethernet, bluetooth or wireless interface has this unique 48 bit number to identify it. It is also used in other types of technologies but we are not going to cover them here. This number is normally stored in permanent memory on the device during manufacturing and would not be changed by the user.

The mac address is normally printed on a label attached to a device. Here is an example.

Sample of a MAC address on a network device

Decoding the MAC Address

The address structure is shown below

MAC address format

To decode the MAC address in the sample above (E8:FC:AF:B9:BE:A2) we split it in half which will give us the OUI and the network ID. The OUI is E8:FC:AF. We can lookup the OUI on this website and it will tell us it is assigned to Netgear Inc in San Jose California.

What is a MAC address for

MAC addresses operate at the lowest layer of the IP protocol. It what makes the ethernet network function. When we send a packet from one network device to another it is done using the MAC address. You are sending data packets from one MAC address to another MAC address. When a packet is sent across ethernet it will have the destination MAC address in the data packet. If the network device receiving the packet has the same MAC address as the destination address in the packet it will then accept the packet for further processing.. It the device MAC address and packet destination MAC address do not much it will be ignored.

No routing of packets is done be the MAC address. It is done at the IP layer. Low level ethernet and MAC addresses can only reach devices on the same network be it cabled or wireless.

Why do I need to supply a MAC address

Unlike some other development platforms the Arduino Ethernet Shield or Arduino boards with built in Ethernet do not come with a MAC address programmed into the board. Some Ethernet shields may have a sticker on it with an assigned MAC address that you can use. However many do not.

The Arduino YUN board comes with a MAC address. Other platforms such as Raspberry Pi are supplied with a MAC address.

To use the Arduino Ethernet Library we need to supply a MAC address for it to function.

Where can I get a MAC address

There are several methods of getting a MAC address:

  • Find an old piece of equipment such as a network card or device and use the MAC address from it. It will be on a label attached to the device.
  • Use the 48 bit number found in a Dallas DS18B20 temperature sensor. We use this in some of our projects.
  • Use a dedicated chip such as the Microchip MAC address chip. You would access this number via SPI or I2C.
  • If you were a manufacturer you would go through the official channels and get an official organisational identifier.

The first option is the easiest and guaranteed to be unique. The last two options would be if you are manufacturing a networked device and come at a cost.

Is the MAC address the same as the IP address

No. We have a IP Tutorial that explains what a IP address is.