Address mapping is a process of determining a logical address knowing the physical address of the device and determining the physical address by knowing the logical address of the device. Address mapping is required when a packet is routed from source host to destination host in the same or different network.
Why Address Mapping?
We know that the Internet is a collection of several physical networks that are interconnected using routers. Now when in an Internet, a source node sends a packet to the destination node the packet has to travel through different physical networks before it is delivered to the destination node.
At the network level, any device connected to the network can be identified by its logical address (IP address). However, the device at the physical level is identified by its physical address.
The physical address is unique to the local network but not in the universal network such as the Internet. However, the logical address is unique universally. Now why do we require both addresses, we can use only one type of address to identify a host or router in the network.
The physical address and the logical address both are different identifiers and we require both of them as the physical address defines the physical connection between source host to destination host whereas the logical address defines routable connection from source host to the destination host and from network to network.
So as both physical and logical addresses are essential to route a packet from the source host to the destination host, we require an address mapping mechanism to relate a physical address of the device to its logical address and vice versa.
Types of Address Mapping
There are two kinds of address mapping, static address mapping, and dynamic address mapping. In the section ahead we will discuss both of them in detail.
1. Static Mapping
In static mapping, each device connected to the network maintains a table i.e., routing table which has a list of all the routes from that device to a particular network or hosts. It maintains the network/next hop association i.e., the logical address of next-hop and its corresponding physical address.
A source host knows the logical address of the host to which it wants to deliver the packet so it can refer to the routing table to recognize the physical address of the destined host. But the static address mapping has some constraint over the physical address of the device as it changes in certain conditions such as:
- If a device changes its Network Interface Card (NIC), the physical address of the device also changes. As the physical address is hardcoded on the NIC card at the time of its manufacturing.
- Some local networks such as LocalTalk compel the connected device to change its physical address each time the device turns on.
- Nowadays there are some third-party apps through which users can change their physical address.
Even the logical address of the device also changes under some circumstances such as:
- If the host switches the network, this changes the logical address of the host.
- If you reset your modem, it also results in a change of logical address.
- If the host gets connected to the network via VPN (Virtual Private Network) then it appears that you
In such a scenario, if we use static address mapping, more time will be wasted in updating the routing table at each connected device and this will generate overhead on the connected devices which will also affect the performance of the network. A solution to this is dynamic mapping.
2. Dynamic Mapping
In dynamic mapping usually, the source host knows the logical address of the destination host but to deliver the packet to the destined host its physical address is required as at the physical level the device is identified by its physical address.
So, the source host uses the protocols to identify the physical address of the destination host. Two protocols are designed for dynamic mapping ARP (Address Resolution Protocol) and RARP (Reverse Address Resolution Protocol).
ARP protocol determines the physical address of a device knowing its logical address. RARP protocol determines the logical address of a device knowing its physical address. We will discuss how this mapping is done.
1. Mapping Logical Address to Physical Address
When a source host wants to send a packet to the destination host it obtains the logical address of the destination host from the DNS (Domain Name Server). If the packet is at any intermediatory router in the network the logical address of the next-hop router is obtained using the routing table.
Now the packet to be sent is encapsulated in the frame at the data link layer as it has to travel through the physical network and at the physical level the sender would require the physical address of the receiver. So, the source host broadcasts the ARP query packet to all the hosts in the network.
The ARP query packet contains the source’s physical logical address and the destination’s logical address. All the hosts present in the network receive this query packet and but only the target host (destination host) recognize its logical address and prepares an ARP reply packet. Other hosts discard the ARP query packet.
The ARP reply packet contains the physical address of the destination host and in this way, the ARP protocol retrieves the physical address for the corresponding logical address. I have described the ARP protocol in brief in our previous content.
2. Mapping Physical Address to Logical Address
To map a physical address of a device to its logical address there are protocols such as RARP, BOOT, DHCP. This RARP protocol is used in the certain scenario such as:
- A diskless station is just turned on, it can retrieve its physical address by referring to the NIC interface, but to get its logical address it can RARP protocol.
- If an enterprise has a limited IP address, then it assigns an IP address to its hosts on demand for that the host has to IP address for a short time lease.
RARP’s working is similar to the working of RARP. The host can get its physical address by reading its NIC card. And to get its logical address the host broadcasts the RARP request packet to its local network. The machine which knows all the IP addresses will respond with the logical address for the host requesting for logical address.
So, this is address mapping which is important for routing a packet on the Internet. We have seen both kinds of mapping static and dynamic. Among which dynamic mapping is the convenient one.