Routing Tables in Computer Network - GeeksforGeeks

03 Sep, 2019
Routers:A Router is a networking device that forwards data packets between computer network. This device is usually connected to two or more different networks. When a data packet comes to a router port, the router reads address information in packet to determine out which port the packet will be sent. For example, a router provides you with the internet access by connecting your LAN with the Internet.
When a packet arrives at a Router, it examines destination IP address of a received packet and make routing decisions accordingly. Routers use Routing Tables to determine out which interface the packet will be sent. A routing table lists all networks for which routes are known. Each router’s routing table is unique and stored in the RAM of the device.
Routing Table:A routing table is a set of rules, often viewed in table format, that is used to determine where data packets traveling over an Internet Protocol (IP) network will be directed. All IP-enabled devices, including routers and switches, use routing tables. See below a Routing Table:
 Destination      Subnet mask         Interface
 128.75.43.0      255.255.255.0       Eth0
 128.75.43.0      255.255.255.128     Eth1
 192.12.17.5      255.255.255.255     Eth3
 default                              Eth2
The entry corresponding to the default gateway configuration is a network destination of 0.0.0.0 with a network mask (netmask) of 0.0.0.0. The Subnet Mask of default route is always 255.255.255.255 .
Entries of an IP Routing Table:A routing table contains the information necessary to forward a packet along the best path toward its destination. Each packet contains information about its origin and destination. Routing Table provides the device with instructions for sending the packet to the next hop on its route across the network.
Each entry in the routing table consists of the following entries:
Network ID:The network ID or destination corresponding to the route.Subnet Mask:The mask that is used to match a destination IP address to the network ID.Next Hop:The IP address to which the packet is forwardedOutgoing Interface:Outgoing interface the packet should go out to reach the destination network.Metric:A common use of the metric is to indicate the minimum number of hops (routers crossed) to the network ID.
Network ID:The network ID or destination corresponding to the route.
Subnet Mask:The mask that is used to match a destination IP address to the network ID.
Next Hop:The IP address to which the packet is forwarded
Outgoing Interface:Outgoing interface the packet should go out to reach the destination network.
Metric:A common use of the metric is to indicate the minimum number of hops (routers crossed) to the network ID.
Routing table entries can be used to store the following types of routes:
Directly Attached Network IDs
Remote Network IDs
Host Routes
Default Route
Destination
When a router receives a packet, it examines the destination IP address, and looks up into its Routing Table to figure out which interface packet will be sent out.
How are Routing Tables populated?There are ways to maintain Routing Table:
Directly connected networks are added automatically.
Using Static Routing.
Using Dynamic Routing.
These Routing tables can be maintained manually or dynamically. In dynamic routing, devices build and maintain their routing tables automatically by using routing protocols to exchange information about the surrounding network topology. Dynamic routing tables allow devices to “listen” to the network and respond to occurrences like device failures and network congestion. Tables for static network devices do not change unless a network administrator manually changes them.
Route Determination Process (finding Subnet ID using Routing Table):Consider a network is subnetted into 4 subnets as shown in the above picture. The IP Address of the 4 subnets are:
200.1.2.0 (Subnet a)
200.1.2.64 (Subnet b)
200.1.2.128 (Subnet c)
200.1.2.192 (Subnet d) 
Then, Routing table maintained by the internal router looks like:
To find its right subnet (subnet ID), router performs the bitwise ANDing of destination IP Address mentioned on the data packet and all the subnet masks one by one.
If there occurs only one match, router forwards the data packet on the corresponding interface.
If there occurs more than one match, router forwards the data packet on the interface corresponding to the longest subnet mask.
If there occurs no match, router forwards the data packet on the interface corresponding to the default entry.
Example-1: GATE-CS-2004 | Question 55
Example-2: GATE IT 2006 | Question 63
Note that the routing tables are not specific for Cisco devices. Even your Windows operating system has a routing table that can be displayed using the route print command
Computer Networks-Network Layer
Network Layer
Computer Networks
GATE CS
Computer Networks
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
RSA Algorithm in Cryptography
TCP Server-Client implementation in C
Data encryption standard (DES) | Set 1
Socket Programming in Python
Types of Network Topology
ACID Properties in DBMS
Types of Operating Systems
Normal Forms in DBMS
Page Replacement Algorithms in Operating Systems
Cache Memory in Computer Organization