MAC Address vs IP Address – Why Both Are Necessary in Networking

arpipip addresslanmac address

I learnt that in ARP Protocol, to send a packet from one machine to another machine we need to know the MAC Address of the destination machine but since the destination has already been assigned a unique IP Address then isn't sending MAC Address redundant ?

Note-

  • I understand in TCP/IP there are various layers and among those is Data link layer whose its primary function is to check if the machines MAC Address matches the packets destination MAC Address.
    But since the packet already contains the Destination IP Address so why can't we send the packet further to the Network Layer to match the packets destination IP address with the machines IP address without making this check at the data link layer with MAC address.
    Please do not mark this question as dublicate because I've read previous Q&A on this topic but nothing explains the reason why this check isn't made at the network layer instead of data link layer.

    Kindly explain. Thank you.

Best Answer

Don't confuse the network layers. Each layer has a specific purpose. Also, don't assume that there is only one protocol for each layer. Layer-2 has many protocols, some of which use MAC addresses, and some which don't. Of those that use MAC addresses, some use 48-bit MAC addresses, and some use 64-bit MAC addresses. There are also multiple layer-3 protocols. IPv4, the most used, but not the only, layer-3 protocol, uses 32-bit addresses, but it is being replaced with IPv6, which uses 128-bit addresses. You don't want to replace or upgrade all your layer-2 devices each time you want to run a different layer-3 protocol.

MAC addresses are layer-2 addresses, and they are used to deliver layer-2 frames on a LAN. Switches are layer-2 devices, and they use MAC addresses to create a table of which host is connected to which switch interface. A switch will look at the source MAC address to build its MAC address table, and it will look at the destination MAC address, look it up in its MAC address table, and deliver the frame to the correct port. Absent a destination address in its MAC address table, the switch needs to flood the frame our every other interface, and that is pretty inefficient and wasteful of bandwidth on all the other interfaces. Switches do not look inside the frame to inspect the IP address. This allows layer-2 and switches to carry any layer-3 protocol (IPv4, IPX, IPv6, etc.).

IP addresses are layer-3 addresses, and they are only looked at by layer-3 devices, e.g. routers. A router receiving a layer-2 frame will strip the frame from the layer-3 packet, and it will look up the IP address in its routing table to see to which interface the packet should be switched. The router will build a new layer-2 frame for the new LAN connected to the destination interface.

Layer-2 (MAC address, etc.) is for devices connected to the same layer-2 domain, and layer-3 (IP address, etc.) allows you to send data to other layer-2 domains.

Related Topic