Home »
Computer Network
Computer Network Routing and Viewing Routing Table
In this tutorial, we will learn about computer network routing, the basics of routing tables, and how to view routing tables.
By Mahima Rao Last updated : April 26, 2023
What is Computer Network Routing?
The process of sending packets from one network to another is called routing. Routing is of two types of static and dynamic. Routes are based on the destination network. Routing is to find the best path for the network from one network to another. The best path is chosen on the basis of metric and administrative distance. Routing is performed by routers. For this routers make routing tables. Now let's understand about routing tables.
Routers make routing tables that contain the following information's:
- Destination network and its subnet mask.
- There is information about the next hop router to go to Destination network.
- Routing metrics and administrative distance are stored.
Routing Tables - Types of Protocols
Routing tables are related to 2 types of protocols:
1. Routed Protocols
These are network layer protocols. Routed protocols attach to logical addresses with devices. These protocols are responsible for sending data from one network to another. For example, IP (Internet Protocol) and IPX etc.
2. Routing Protocols
These protocols build networks, topology and next hop information in routing tables. All these information is created dynamically (automatic). For example, RIP, IGRP, and OSPF etc. Routing protocols are of 2 types.
- Distance vector
Such protocols are determined by metric hop count (number of routers between sources and destination). The route which is the lowest in the route is chosen by the same route. Example of this type of protocol is RIP.
- Link state
Metric shortest path in such protocols is determined by the first algorithm. The cost of the cost of all the routes, which is the lowest cost, is route is chosen. The example of such protocols is OSPF.
How to determine the best route to destination network?
To determine the best route to Destination network, the router uses the following 3 elements:
- Prefix-Length
This is the number of bits to identify the network. From this, the most accurate route is determined. The longer the prefix length, the more precise the path is. For example, suppose a packet is going to 10.1.5.0/24 host and the router's routing table has 2 networks given.
10.1.5.0/24
10.0.0.0/8
So the first network will be selected on this because its prefix length is high. It does not matter what the metric or administrative distance is.
- Metric
The metric router gives the ability to find the best routes under the routing protocol. Distance vector uses the protocols distance as metric and link state protocols use the shortest path first algorithm as the metric used to calculate. The routes which are best metric are added to the routing tables. Even if a routing protocol has 4 routes to go to the same network, even if the metric is the best, it will only be added to the routing table. If more than one route of equal metric is available then correct metric will be selected by loading balance.
- Administrative Distance
If more than one routing protocol is running on the router, then which protocol is to trust most, it is determined by the administrative distance. The administrative distance at the bottom is the lowest, the same protocol is chosen. Administrative distance is a numerical value that is assigned to dynamic protocols. It is fixed. The protocol whose administrative distance is unknown is never taken in the routing table.
Viewing Routing Table
The routing table can be viewed on any router. For this, you need to run show IP route command. You can see it from the user execution mode.
#Router1 show ip route
When you execute this command, the list of all routers is displayed to you. A label along with all these routers is also shown which is how it is connected to all the current router. The list of all these labels is being given below.
- C - This label means that the given router is directly connected to the current router.
- S - This label indicates that the given router has been statically managed.
- S * - This is the default route between the router given by the current router.
- D - This label means that the given router is using the EIGRP protocol.
- I - This label states that given the router IGRP protocol is being used.
- R - It says that the given router is using RIP protocol.
- O - this label means that the given router is using OSPF protocol.
Clearing Routing Table
If you want to clear all routes from the routing table, you can use the clear command for this. By clearing the Routing table, you can force routing protocols to populate the routing table again.
#Router clear ip route
Choosing Best Route
You can follow the procedure given below to choose the best route to any destination router.
- First of all you will have to match the prefix length of the route with the destination route. You will choose the routes that are most accurate in the prefix length.
- Now you have to choose the route from which route is the lowest metric.
- If the same metric has more than one route then you will choose the route with the lowest administrative distance and this will be your best route.