While transmitting packets in an IP or internet protocol network, it is essential to find the most efficient way of delivering a data packet to its destination. This function is performed by using routing tables. A routing table is a small database which contains information about the IP network, next hop and paths in that network. All IP nodes, inclusive of routers and network switches, present on the network have IP routing table in the form of small database. The database (routing table) is managed by the device’s firmware. When a packet arrives at a node, it extracts the destination IP address, look up the routing table for possible paths and decide on the next hop based on the cost of the route. A hop is a path joining two routers.
What does an IP routing table contain?
Routing tables consist of a list of IP addresses. Each IP address corresponds to either a remote router or a network gateway. The local router is configured to recognise these devices on the network.
In addition to the IP address, the routing table also stores a network mask along with some more information, which specifies the range of IP addresses that the remote router can accept.
The size of the routing tables depends on the type of network. For instance, for a home network, routing tables are small. This is because all the traffic is sent to the gateway of your ISP (Internet Service Provider) which, in turn, carry out the process of routing. A reasonable estimate for a home network routing table would be ten entries.
On the other hand, some routing tables contain several thousand entries. The routers, containing these routing tables, form the backbone of the Internet.
Entries in a routing table
This field contains the network ID or destination of the packet to be routed. A very common ID used in this field is the IP address of the destination.
A network mask or netmask is a 32-bit number used to divide an IP address into subnets. Utilizing a network mask, one can specify the range of available hosts in the network.
The network mask is stored in the routing table to check if the destination IP address is within the IP range of the network ID.
This field contains the IP address of the next node in the path of the packet.
A packet can reach its destination via many routes, but for ensuring optimal and efficient routing, cost of the path or route is computed and stored in this field.
A commonly used metric would be a total number of hops required for the packet to reach its destination. A lower number of hops decides the efficiency of the path.
This entry contains information about the type of interface which will be used to forward the data packet. The interface could be a physical node or a logical computer program.
In most of the case, this field will contain the IP address of the network interface card (NIC) that forwards the packet to the next hop.
Types of routing
Routing of a data packet can be done in either of two ways – automatically or manually. Routers can set up their routing tables automatically on connecting to the ISP’s (Internet Service Provider) gateway.
This process is called dynamic routing. Consider the case of a router in a home network. The router will add one entry each for the ISP’s primary and secondary DNS (Domain Name System) servers.
The rest of the table will be populated with entries for the computers on the home network. Some of these routers may even restrict the user from manually changing an entry in the router table. However, the case is different for business routers.
In business routers, only network administrators have the option to update or change routing table entries manually. The provision to manually alter routing tables is called static routing.
To ensure full connectivity in static routing, network administrators configure a static route to every network on every router. The primary purpose of this is to optimise the network regarding performance.
However, static routing is not fault-tolerant. If the network undergoes any change such as a link goes down or a new network is added, manual intervention is essential. In case a node in the network becomes unavailable, routers cannot choose a new route (i.e. update routing tables ) automatically.
Static routing is a good option for networks that do not change.
Viewing contents of Routing tables
To view the routing table on a Linux/Unix machine, open a terminal and enter the following command: “netstat -rn”. Entries of the routing table would look something like given below:
Open a command prompt on your system and then type the following: “route print”. Among a large amount of data printed, find the following five columns.