Internet consists of meshing together millions of individual networks, and also allowing communication between them. Hence using the internet from almost anywhere in the world it is now possible to access data from anywhere else, often just within a fraction of a second. The way communication happen across all this network is through routing.
Routing | Basic Concept
Routing is one of those thing which is both very simple and very complex. At very high level it is very simple but underneath the hood routing is very complex and technologically advanced topic. Today the largest company and ISP exclusively handle the most intensive routing issue.From very basic stand point A Router is a network device that forwards traffic depending on the destination address of the traffic. A router also a device that has at least two network interfaces. Because it needs to connect two network to do its job.
There are few simple steps of basic-routing:
- Receive the data packet to one of its interfaces.
- Router examines the destination address of that packet.
- and then router looks up the destination network of that IP in its routing-table.
- Finally router forwards the traffic to the interface that is closest to the remote network as determined by additional info in the routing table.
These steps repeating itself as often as needed until the traffic reaches its destination.
Let consider a router connected two networks, A and B. Address space of network A is 192.168.1.0/24 and for network B 10.20.30.0/24. The router has an interface on each network. On network A router has an IP 192.168.1.1. Also on network B it has an IP 10.20.30.1. These IPs specifically belong to individual network not to particular node on the network. A computer on network with an IP address 192.168.1.95 sends a packet to the address 10.20.30.65. The computer already knows that this IP address isn’t on its local subnet. So it sends that packet to the mac address of its gateway, the router. The router’s interface on network A receives the packet. Because it sees that destination mac address belongs to it.
The router then stripped away the DataLink_Layer encapsulation leaving the Network_Layer content, the IP_Datagram. Now the router can directly inspect the IP_Datagram Header for the destination IP field. It finds the destination IP 10.20.30.65. The router looks at its routing table and sees that the network B or 10.20.30.0/24 is the correct network of the destination IP. It also sees that this network is only one hop away, in fact, since the network is directly connected, it even has the MAC_address for this IP_address in its ARP table.
Forming NEW Packet
Now to forward the received packet to Network B router needs to form a new packet. Therefore it duplicates all of the data from the first IP_Datagram. Then it decrements the TTL by one and also calculate the new checksum. Finally it encapsulates the new IP_datagram inside of a new Ethernet_Frame. This time the router sets its own MAC_address on the interface of network B as source MAC_address. Since it has the MAC_address of 10.20.30.65 in it ARP-table, it sets that as destination MAC_address. Lastly it sends the packet at network B and the data finally reaches to the node at 10.20.30.65.
Routing at Broader Image
Let we have another Network C which has an address space of 172.16.1.0/24. So we have initiated a second router (Router B) that connects Network B and Network C. Router B has interface at network B has an IP: 10.10.0.1. Also its interface at Network C has an IP: 172.16.1.1
Computer at Network A has an IP: 192.168.1.0 wants to send some data to the computer at network C has an IP: 172.16.1.220. So computer at 192.168.1.0/24 knows that 172.16.1.220 is not on it’s local network. Therefore it sends the packet to its gateway 192.168.1.1, router between A and B. The Router A then inspects the contents of that packet. It sees the destination address 172.16.1.220 and look up its routing table. So it knows the quickest way to reach to 172.16.1.0/24 via another router with an IP 10.10.0.1. Hence Router A decrements the TTL field and sends the packet along to the Router B, 10.10.0.1. Router B knows it directly connect to 172.16.1.220 and sends the packet to the destination.
This is the basic of routing, but in real life routers usually connected with many more than just two networks. Very often packets may have to cross dozens of routers before reaching its final destination. Finally, in order to protect against breakages core internet routers typically connected in a mash. Which means there might be many different paths for a packet to take.
Next we will discuss about Routing Table and Routing Protocol in Networking Fundamentals