Think that we need to go to USA, from Sri Lanka. But assume there is no direct flight to USA. So what we will do…? If there are direct flights from Sri Lanka to Singapore and from Singapore to USA, we can go to USA. In such a scenario we have two types of destinations. One is a long destination (LD) which is from Sri Lanka to USA and the other is short destinations (SD) which are Sri Lanka to Singapore and Singapore to USA. If we can achieve all the short destinations in a correct order, ultimately we can reach to our long destination. So, when we are in Sri Lanka LD is SL-USA but SD is SL-SIN. Then we travel to Singapore. In Singapore LD is SL-USA but SD is SIN-USA. Now we are in USA. Note that when we reach to Singapore we change the SD but we haven’t change the LD, because our ultimate goal is to go to USA.
|Click on the image to maximize|
A collection of interconnected devices are called as a network. When the number of devises gets bigger and bigger, the single network will divide into manageable sub networks. In a network all devices are recognized by its MAC (Media Access Control) address. IP address is a logical address that assigned to device in a way that human can remember, but it’s limited to a single network. The network is identified by the subnet mask. Default gateway is used as an access point to go to another network.
Think you are using the C1 Computer. You need to copy a file in S1 (18.104.22.168) server. So how C1 will communicate with S1? To do a copy you need to specify an IP address of the server. In this scenario it is 22.214.171.124. When you enter that IP address your machine will tally it with its IP address and the subnet mask. C1s subnet mask is 255.255.255.0, so its network address is 192.168.1.0. The requested IP 126.96.36.199 is not in the range of 192.168.1.0 – 192.168.1.255, or else its no in the same network. Then your computer will try to move the request to the default gateway which is specified as 192.168.1.1.
Computer will broadcast a ARP message to the network and only the corresponding interface will reply for that. Now the computer knows the MAC address of the default gateway. So it will create a packet with Source IP (S-IP) 192.168.1.1, Destination IP (D-IP) as 188.8.131.52. Source MAC address (S-MAC) is aaaa:aaaa:aaaa . But C1 doesn’t know the MAC address of the S1, and its now decided to forward the packet to the default gateway. Therefore, destination MAC address (D-MAC) will be bbbb:bbbb:bbbb.
Now the packet is in the R1 router. It will check the packets D-MAC address and feel it’s for the router R1. When it checks the D-IP address router realize that it’s not for the router but it need to go through the router to some were else. Now the router checks its routing table and realizes that the required network is not connected to it. But the router is capable of knowing neighbor route; therefore R1 will try to move the packet to the next best router. To do that R1 modify the packets S-MAC to cccc:cccc:cccc and D-MAC dddd:dddd:dddd. But it wont change the S-IP (but NAT will do a small change) and D-IP.
So this is like we travelling form SL to SIN in the example. This process will happen in all the routers which are in the path for the network 184.108.40.206.
When the packet comes to R3, it also checks the D-MAC and D-IP. When R3 checks the D-IP, it knows that it has connected to that requested network. So it moves the packet to the switch which will map D-IP to its MAC and forward it to the S1. So in this whole process MAC works as a temporary address, but IP works as the permanent address. So that’s why we need two addresses to communicate over a network.