Routing Table

Learn via video courses
Topics Covered

Overview

In a computer, when the data packet is transmitted from one network to another network, it is required to choose the best path for transmitting the packet. Hence, routing is the concept of the network layer of the OSI suite, which selects the best path for transmitting packets among the network. The router is a networking device that is used to receive, analyze, and transmit data packets between computer networks.

What are Routing Tables in Computer Networks?

  • Routing is the process of sending a packet from one network to another network
  • Routing is a concept of layer 3 (network layer).
  • Routing is the process of discovering the best path for one network to another.
  • The best path is selected based on metric and administrative distance.
  • Routers are used to perform routing.
  • The routing table consists of a list of all known network addresses and information about where to forward the data packet. These entries in the routing table are called route entries or routes. The router will forward the data packet by selecting the best matching route entry.
  • A routing table is a set of rules, which can also be viewed in a table format, and it is used to discover where data packets (i.e., traveling over an Internet Protocol network) will be directed

The router maintains routing tables that consist of the following information:

  • Destination network and subnet mask of destination network.
  • Next-hop router information to go to the destination network.
  • In the routing table, Routing metrics, and administrative distance are also stored.

Note:

So routing is performed by network layer devices to deliver the data packet by selecting the best optimal path from one network to another.

Entries of an IP Routing Table

A routing table stores the information required to forward the data packet along the best path toward its destination. Each data packet has a piece of information about its origin and its destination Each entry of the routing table contains entries:

Network ID: The network ID or destination that corresponds to the route.

Subnet Mask: The subnet mask is the mask required to match the destination IP address with the network ID address.

Next Hop: It is an IP address to which the data packet is to be forwarded and it specifies the next router which is closest/most optimal in its routing path.

Outgoing Interface: An outgoing interface is an interface through which the data packet should go out to reach the destination network.

Metric: The general use of the metric is to specify the count of the minimum number of hops (routers crossed) to the network ID.

The following types of routes can be stored in the routing table entries

  • Directly Attached Network IDs
  • Remote Network IDs
  • Host Routes
  • Default Route
  • Destination

How are Routing Tables Populated?

The routing table can be maintained in the following ways:

  • Directly connected networks are added automatically.
  • Using Static Routing.
  • Using Dynamic Routing. Routing tables can be managed dynamically or manually(static routing). In dynamic routing, devices create and manage their tables automatically with the help of routing protocols for exchanging the information of the surrounding network topology. The routing table of the static network device changes when the network administrator manually changes it.

Components of Routing Table Entries

DestinationSubnet maskInterface
128.75.43.0255.255.255.0Eth0
128.75.43.0255.255.255.128Eth1
192.12.17.5255.255.255.255Eth2
defaultEth3

In the routing table, 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 default route defined in the routing table is used when a more specific network ID or route cannot be found. When all other fails, the default route is utilized. The default route always has a subnet mask 255.255.255.255.

Types of Routing Table Routes

There are three types of routing:

  • Static Routing.
  • Default Routing.
  • Dynamic Routing.

Below is an image to show the types of routing

types-of-routing

Static Routing

Static routing is a routing in which we add the route to the routing table manually. This routing table is created, updated, and managed manually.

Advantages:

  • The Cheaper router can be used as there is no overhead on the router.
  • Only the administrator is allowed to route to particular networks, so it provides security.
  • No bandwidth is utilized between the routers.

Disadvantage:

  • For a large network, it becomes difficult for the administrator to manually add every route to the routing table at every router
  • The administrator must possess a good knowledge of topology as the administrator has to manually add each route.

Default Routing

In this routing technique, the router is configured to transmit all the data packets to a single router (next hop). It forwards the data packet to the router, which is configured for default routing, without considering to which network packet belongs. It is commonly used with stub routers. A stub router is a type of router that has only one route to reach all other networks.

Advantages

  • Default routing keeps the size of the routing table small.

Disadvantages

  • If the computer network is too complex, then the setup of default routing also becomes difficult.
  • It is not a reliable routing technique, since if the next hop(router) fails the packet transfer will fail

Dynamic Routing

In the dynamic routing technique, table routes are automatically adjusted according to the current state of the route in the routing table. Dynamic routing requires the protocols to find the destination of the network and routes to reach that destination. RIP(Routing Information Protocol) and OSPF(Open Shortest Path First) are some examples of dynamic routing protocols. If one route goes down, then the automatic adjustment will be made to reach the network destination.

Features of dynamic routing protocol are given below:

  • For exchanging, the router should have the same dynamic protocol.
  • When any router discovers any changes in the topology of the network, the router advertises it to all other routers in the routing table.

Advantages:

  • Dynamic routing is easy to configure.
  • Dynamic routing is an effective technique for choosing the best route to a destination remote network and for finding a remote network

Disadvantage:

  • Dynamic routing requires more bandwidth for communication with other neighbors.
  • Dynamic routing is less secure in comparison to static routing.

Routing Protocols

Routing protocols are used to build networks, topology, and information on the next hop in routing tables. All this information is created and updated dynamically. RIP, IGRP, OSPF, etc. are some of the examples of routing protocols. There are two types of routing protocols.

Distance vector: In such types of protocols shortest path is determined by metric hop count. Hop count depends on the number of a router between the source and the destination. RIP (Routing Information Protocol) is an example of a distance vector routing protocol.

Link state: In the link-state routing protocol shortest path is determined by the first algorithm. In this, the path which has the lowest cost will be chosen. OSPF( Open Shortest Path First) is an example of a link-state routing protocol.

Routing Table Entry Example

To understand the routing table with an example, let us consider a network that is divided into four subnets. Subnets are a logical segmentation of an IP network into multiple, smaller network segments.

The IP addresses of all four subnets are given below:

  • 200.1.2.0 (Subnet a)
  • 200.1.2.64 (Subnet b)
  • 200.1.2.128 (Subnet c)
  • 200.1.2.192 (Subnet d)

Below is an image to show the subnetting of the network

routing-table-entry-example

Then, the Routing table that is maintained by the internal router is just like the given below routing table:

DestinationSubnet MaskInterface
200.1.2.0255.255.255.192a
200.1.2.64255.255.255.192b
200.1.2.128255.255.255.192c
200.1.2.192255.255.255.192d
Default0.0.0.0e

To find the right subnet (subnet ID), the router finds the bitwise AND of the destination IP address and all the subnets one after another.

  • If there is only a match, then the router forwards the packet to the corresponding interface
  • If there is more than one match, then the router forwards the packet on the interface corresponding to the longest subnet mask in the network.
  • If there is a situation where no match occurs, then the router forwards the packet on the interface in the network corresponding to the default entry.

Conclusion

  • Routing is the process of choosing the best path for transmitting a data packet from one network to another network.
  • Routing Table consists of the Network ID, Subnet Mask, Next Hop, Outgoing Interface, and Metric.
  • Static Routing, Dynamic Routing, or Default routing is a type of routing table route.
  • Routing protocols are of two types: Link-State and Distance vector.