1. Introduction
Nowadays, multiple organizations produce, distribute, and sell network-related hardware, such as wireless or Ethernet cards. Eventually, such hardware will operate on a computer, enabling it to communicate over a network. So, once it happens, the question is: how to identify which hardware is involved in a particular networked communication?
Media Access Control (MAC) addresses are the key to answering the previous question. These addresses uniquely differentiate a network device in a network. However, MAC follows a specific protocol and considers several technical details to create an address: it is not so simple.
In this way, this tutorial explores MAC addresses. First, we’ll study basic concepts about MAC. Thus, we’ll understand the format of MAC addresses, investigating the meaning of each field of it. So, we’ll have some insights into the difference between MAC and IP addresses. Finally, we’ll have some final remarks.
2. The Basics of MAC
Media Access Control (MAC) is a resource that determines addresses for network hardware. These addresses are unique. In such a way, we can state that no two devices in the world share the same MAC address. It enables us to precisely determine which hardware component generated a frame traversing a network as well as which hardware component is supposed to receive it.
It is relevant to highlight that MAC refers to a physical address. In fact, it is a physical address in all meanings: besides setting it up logically in a hardware component, it is also burned in every Network Interface Card (NIC).
In modern networking, we use MAC addresses in the second layer of the OSI model (particularly in the MAC sublayer) and the first layer of the TCP/IP model. Thus, we can say that we’ll work with MAC addresses in the layer immediately before the network layer, regardless of the adopted model.
3. Deep Dive Into MAC Addresses
MAC addresses are formed by six bytes containing hexadecimal numbers. So, for each byte, we’ll have a two-digit number. Each digit, in turn, can have values from zero (0) to nine (9) and from A (10) to F (15).
Furthermore, there exist two major parts in MAC addresses: the manufacturer identification (first three bytes) and a unique number defined by the manufacturer that identifies a particular device in a network (last three bytes).
In the first byte of the first part of a MAC address, we have two special bits: the first and the second. The very first bit, called bit zero or I/G bit, determines if an address is unicast or multicast.
Computers define this bit when sending a frame through the network. If the I/G bit is zero (0), we have a unicast address, and the frame has a single destination. So, a NIC will accept the frame only if the destination MAC of it perfectly matches the NIC’s. Otherwise, if the I/G bit is one (1), we have a multicast address. Thus, a NIC can accept the frame based on another criterion, such as using a multicast address list.
The second bit, called bit one or U/L bit, defines if an address is universally or locally administered. A universally administered address is the one assigned by the NIC’s manufacturer. A locally administered address, in turn, consists of MAC addresses defined by software or operators of a system, overriding the address burnt in the physical hardware.
In this way, we can understand the MAC address formatting as depicted in the following figure:
Moreover, it is interesting to highlight that the way to format MAC addresses for human reading may vary according to which system shows it. For example, Windows-based systems format MAC addresses with double digits intercalated with dashes (xx-xx-xx-xx-xx-xx); Apple and Linux use colons to separate double digits (xx:xx:xx:xx:xx:xx), and CISCO show these addresses with sets of four digits separated by periods (xxxx.xxxx.xxxx).
4. MAC Addresses vs. IP Addresses
Until now, we know that MAC addresses identify a particular device in a network. So, we naturally can use MAC addresses to enable a device to communicate with other devices. It occurs indeed: the frame header carries a source and a destination MAC address.
But, if MAC addresses enable devices to communicate with each other and uniquely identify a network device, the question is: why do we also have IP addresses?
In the previously described conditions, an IP address has a similar purpose to a MAC address: identify a networked entity, enabling it to communicate with other networked entities. However, IP has two particular characteristics that differentiate it from MAC:
- An IP address identifies a networked entity, not a device (it is related to the location of a device, not the device itself)
- IP addresses can change over time
Let’s work with an analogy to understand better the differences and relations between IP and MAC: we are sending a letter to a friend. So, for both sender and recipient, we must include a name and an address. With the recipient’s address, the postman knows where to take the letter. However, the address does not define who lives there. Thus, the postman uses the recipient’s name to deliver the letter to the correct person at the provided address.
In the same scenario, our friends can sometimes move from one house to another, which will change the recipients’ addresses of our letters. But moving home does not implicate changing names. So, the recipients’ names of our letters are still the same.
In such an analogy, the MAC addresses are the recipients’ names (identify a particular device and never change), and the IP addresses are the recipients’ addresses (identify an entity and can change over time). These are the main differences and relations between MAC and IP.
4.1. How MAC and IP Technically Relate in Data Exchanging?
As we already saw, MAC and IP address messages from a source to a destination. However, only networked entities in the same local network (or group) know the MAC address of a particular device.
In such a way, a message must arrive at the destination’s network using IP. Then, it is addressed and forwarded to the final destination using MAC. Summarily, the destination MAC changes each hop in a router or computer a message does, but the destination IP never changes along the transmission.
Let’s consider a scenario in which a computer (#01) aims to communicate with another one (#02). These machines are in different networks, as shown in the following figure:
Thus, as the first machine does not know the MAC address of the second machine, it sets up the second machine’s IP address and sends the message to its default gateway, which will try to reach the proper network to forward the message.
The default gateway of the first machine does not know the MAC address of the second machine. However, they know how to reach a gateway of the destination network. So, it changes the destination MAC address to the destination network’s gateway one and forwards the message.
The gateway of the destination network receives the message. It knows the MAC address related to the destination IP address, setting it up in the MAC destination field and forwarding the message to the proper network device of the second machine.
5. Conclusion
In this tutorial, we explored MAC addresses. First, we briefly reviewed the basic concepts and characteristics of MAC. So, we studied the formatting of MAC addresses and the purpose of the main fields of it. Finally, we investigated the differences and relations between MAC and IP addresses.
We can conclude that MAC, with other protocols, bases modern networking. MAC addresses identify network devices, enabling them to communicate with each other in a local group or network by sending and receiving messages.