This question is aked in mostly all interviews related to Computer networks and almost everyone just gives the defination of MAC addresses and the interviwer keeps on grinding and at last you don’t have the correct answer.
MAC addresses are unique physical addresses used in LAN to identify a device. These were developed way before for IP addresses even existed as a part of Ethernet addressing.
Think of a situation when we have completly removed MAC addressing. Now this network would only ever support IPv4 (let).
But IP is just a protocol. There are also other layer-3 protocols like IPv6, IPvX etc each having different bit sizes of addressing. You don’t want to replace or upgrade all your devices each time you want to run a different protocol.
IP was not the only L3 protocol and Ethernet was not the only layer 2 protocol. That is why there are layers. You can isolate the function of one from the other. It made developing networking easier because you didn’t have to have a special version for every type of network. The price you pay for layering is that you have to “map” between a 32 bit IP address and a 48 bit MAC address (for Ethernet). That is the purpose of the ARP protocol — to map between layer 2 and layer 3.
IP protocol was invented mainly to tackle the problems of routing and introduce an abstraction layer from the physical layout.
Lets say there was no IP addressing . Then in a small network all the devices are directly addressable, so MAC addresses works fine.
But as networks got bigger and became interconnected, there was a need to know how to get from one network to another (Routing). We maintain a routing table in each router.
Now since there is no IP, routing table will have to maintain a list of all MAC addresses available in the network and then also have to search/match for the destination MAC through all the entries. This will consume lots of space and time. This will be a very inefficient approach as the size of a network can grow to millions of participants worldwide.
So we needed some better way to do this. This is where we needed some hierachial form of addressing which may help in grouping multiple addresses to decrease the size of routing table (Supernetting).
The concept :
IP-to-IP communication is really just a series of MAC-to-MAC communication taking place at each router hop.
The IP header of a packet leaving the source destined to an IP will always maintain the source IP and destination IP. When encapsulated, the Ethernet header contains your source MAC and the destination MAC of your default gateway. There’s no knowledge of the final destination MAC from source’s perspective. That first router will rewrite the source MAC to itself and the destination MAC to the next router hop, and so on, until the packet arrives at the last router that is directly connected to the destination subnet.
IP addresses are used to determine the next hop and the MAC address is used to physically identify the device serving as the next hop.
When a Packet arrives at router it will ask “I want to go to this DestinationIP. On which interface of yours I should go? “. Router will lookup in its Routing table and determines the next hop using the Destination IP address in the packet and IP entries in its routing table. Then the router will modify the source and destination MAC addressses in the frame. The source address will be that of the forwarding interface of the router and the receiving interface of the next hop will be the destination MAC address. This will continue from hop to hop until it reaches the final host, each time the MAC addresses will change, but the source and destination IP address will remain the same during the whole process.
So to sum up,
- Why IP addressing was developed?
To tackle the problems of routing and introduce an abstraction layer from the physical layout , a new hierachial form of addressing was developed. - Why do we still need MAC addresses?
Think of a situation when we have completly removed MAC addressing and now this network would only ever support IPv4.
What about other protocols?? There are also other layer-3 protocols like IPv6, IPvX etc each having different bit sizes of addressing. You don’t want to replace or upgrade all your devices each time you want to run a different protocol. That’s why we something completly seperated from L3. Ethernet addressing and IP addressing operate on different layers. - What is the need of MAC in routing?
IP-to-IP communication is really just a series of MAC-to-MAC communication taking place at each router hop.
What directs the packet from the “Source” to the “Destination” is the IP address. But what gets the packet from the Source to RouterA, and then from RouterA to RouterB, and then from RouterB to Destination is the MAC addresses.