Thursday, 29 August 2019

networking - Why can't routers use MAC addresses instead of private/local IP addresses?


I understand the reason public IP addresses are necessary to be that if we only had MAC to move data between one host and another, the entire Internet would be one massively flat network. But what is the need for private IP addresses? Why can't routers just connect to local clients using their MAC address?



Answer



The answer is your software applications and operating system are designed to communicate using TCP/IP, not directly with Ethernet MAC addressing.


So regardless of whether the remote computer/node you wish to communicate with is in your local network or in some other network halfway round the globe, that logical link is established with TCP/IP. That way applications just define the destination IP address in the IP packet, fill it with data (which is actually packed into a TCP/UDP segment), and send it along the way without having to worry how the underlying layers deal with the actual transmission.


It is the operating system's networking stack that determines if the IP address is local or remote:



  1. If local network, look for MAC address corresponding to that IP address and send the IP packet direct, which is in an Ethernet frame.

  2. If remote network, look for MAC address of default gateway router to send the IP packet, also within an Ethernet frame. The router retrieves the IP packet from the frame, looks at the address and determines the next node (and its MAC address) to pass it along, and sends it that direction in another Ethernet frame.


Note: it is totally possible for IP packets to be delivered in another data link protocol other than Ethernet (guess what, your dial-up or DSL modem is not connected to your ISP via an Ethernet cable). And applications should not have to care so as long as the destination IP address is reachable. It is also totally possible to wrap other networking protocol data (that is not an IP packet) in an Ethernet frame for transmission.


No comments:

Post a Comment

How can I VLOOKUP in multiple Excel documents?

I am trying to VLOOKUP reference data with around 400 seperate Excel files. Is it possible to do this in a quick way rather than doing it m...