Skip to main content

What is a MAC Address and How It Works

Understanding MAC Addresses​

A MAC (Media Access Control) address is a unique identifier assigned to network interfaces for communication at the data link layer of a network. Every device that connects to a network—such as computers, smartphones, routers—has a network interface card (NIC) with a unique MAC address. This address is crucial for enabling devices to communicate over a local area network (LAN).

  • Format: A MAC address is a 48-bit (6-byte) hexadecimal number, usually written in formats like 00:1A:2B:3C:4D:5E or 00-1A-2B-3C-4D-5E.

  • Components:

    1. OUI (Organizationally Unique Identifier): The first 24 bits (3 bytes) of a MAC address represent the manufacturer of the NIC. For example:

      • Apple Inc. has OUI 00:1C:B3, which might lead to a MAC address like 00:1C:B3:4F:56:8A.

      • Google Inc. has OUI 3C:5A:B4, leading to a MAC address such as 3C:5A:B4:2D:3F:77.

    2. NIC-Specific: The remaining 24 bits (3 bytes) are unique to the specific NIC, ensuring that no two devices will have the same MAC address.

How MAC Addresses Facilitate Communication​

Flow of Data

Visual Representation of Data Flow in a Network Using MAC Addresses

Scenario 1: Communication Within the Same Network​

When two devices are on the same network (subnet), communication is straightforward because they share the same network address range. Here's how it works using specific IP and MAC addresses:

  1. Source and Destination Information:

    • Source IP: 172.168.1.3

    • Destination IP: 172.168.1.4

    • Subnet Mask: /24

  2. Network Recognition:

    The source device determines that the destination IP is on the same network based on the subnet mask.

  3. ARP Request:

    If the source device does not already know the MAC address of the destination, it broadcasts an ARP (Address Resolution Protocol) request: "Who has IP address 172.168.1.4? Tell 172.168.1.3."

    Note

    Although devices know each other's IP addresses within the same network, MAC addresses are still necessary because IP addresses can change frequently, while MAC addresses are fixed.

  4. ARP Reply:

    The destination device with IP 172.168.1.4 responds with its MAC address.

  5. Frame Creation:

    The source device creates a data frame, including:

    • Source MAC: MAC address of 172.168.1.3

    • Destination MAC: MAC address of 172.168.1.4

    • Payload: Actual message data

  6. Frame Transmission:

    The source device sends the frame to a network switch, which directs it to the destination device using its MAC address.

Scenario 2: Communication Across Different Networks​

When a device sends data to another device in a different network, routers and switches are involved to handle the routing of data:

  1. Identifying the Network:

    • Source IP: 172.168.1.3 (MAC: aaa)

    • Destination IP: 192.140.1.4 (MAC: hhh)

    • Subnet Mask: /24

  2. Default Gateway:

    The source device recognizes that the destination is on a different network and must route traffic through its default gateway (router).

  3. ARP Request for Gateway:

    If the source device doesn't know the MAC address of its gateway, it sends an ARP request for the gateway's IP address (172.168.1.1).

  4. Router Interaction:

    • Frame Creation: The source device sends a frame to the router with its MAC address as the source and the router's MAC address as the destination.

    • Routing Table Lookup: The router uses its routing table to find the path to the destination network.

  5. Packet Forwarding:

    The router encapsulates the packet in a new frame:

    • Source MAC: Router's MAC (ddd)

    • Destination MAC: Destination router's MAC (eee)

    Note

    This step highlights the hop-to-hop nature of the Data Link Layer. Each frame's destination MAC is only for the next directly connected device, not the final destination.

  6. Final Delivery:

    Upon reaching the destination network, the router sends another ARP request to find the destination device's MAC address. It then forwards the frame, ensuring it reaches the correct device.

Common Questions About MAC Addresses​

Why Don't We Use Only MAC Addresses Instead of Both MAC and IP?

If every device used only MAC addresses, each device would need to maintain a comprehensive list of MAC addresses for all other devices worldwide. This scenario is impractical due to storage and processing limitations. Using IP addresses allows each router and switch to maintain a manageable routing table, optimized for space and speed, facilitating efficient global communication.