Search
Home Search Center IP Encyclopedia Online Courses Intelligent Model Selection

What Is IP Routing?

IP routing is the process of selecting a path to efficiently transmit IP packets from a source address to a destination address on a network. It is the most basic element of a data communication network. Devices that implement IP routing are routers, which store routing tables for data packet forwarding. Routers maintain routing tables using IP routing protocols, such as BGP, IS-IS, and OSPF.

Why Is IP Routing Important?

IP routing is the process of selecting a path to efficiently transmit IP packets from a source address to a destination address on a network. It is the most basic element of a data communication network. Routes are classified into unicast routes and multicast routes by IP transmission mode. In this document, routes refer to unicast routes. Devices running IP routing are routers.

As a network expands in scale, there may be thousands of transmission paths to the same destination. To strike the best balance between the transmission speed, quality, and efficiency, route selection is especially important. In the following figure, to transmit data packets from computer A to computer B, two paths are available: one by way of networks 1, 3, and 5 and the other by way of networks 2 and 4. Although the first path is longer, it achieves a higher forwarding speed when the other path has a poor network connection. As a result, the first path is selected to transmit the data packets.

What Is a Routing Table? How Does It Work?

A routing table is a data table stored on each router. It is like a map, on which you can search for the path to a specific destination network address. A routing table has many entries, each indicating a route that corresponds to a destination on a network. The following figure shows a routing table.

When a router receives an IP packet, it checks the destination address in the packet header and searches its routing table for an entry matching the destination address. If a matching entry is found, the router forwards the packet based on the outbound interface and next hop specified in the entry. If no matching entry is found, the router checks whether a default route exists; if no default route exists, the router discards the IP packet. At the same time, the router sends an Internet Control Message Protocol (ICMP) error message to the source device of the packet, reporting that the destination address or network is unreachable.

Each router stores one local core routing table, which stores the routes discovered by various routing protocols. Among these routes, the optimal route is selected. The routing table may contain the following types of routes:

  • Direct route: indicates a route to the network segment where a local interface of the router resides. Such routes are automatically discovered and added to the routing table by the router.
  • Static route: indicates a route manually configured by the network administrator.
  • Dynamic route: indicates a route discovered by the router through a dynamic routing protocol, such as Border Gateway Protocol (BGP), Intermediate System to Intermediate System (IS-IS), Open Shortest Path First (OSPF), or Routing Information Protocol (RIP).

Routes can also be classified into the following two types by the destination address type:

  • Host route: indicates a route destined for a host address. Through this route, data packets are sent only to this host address.
  • Network segment route: indicates a route destined for a network segment address. Through this route, data packets are sent to all hosts on the network segment.

On NetEngine series routers, you can run the display ip routing-table command to view information about the routing table. For example:

<HUAWEI> display ip routing-table
Route Flags: R - relay, D - download to fib, T - to vpn-instance, B - black hole route
------------------------------------------------------------------------------
Routing Table: Public
         Destinations : 8        Routes : 8

Destination/Mask     Proto  Pre  Cost   Flags  NextHop        Interface

       0.0.0.0/0      Static 60   0      D     10.1.4.2       GigabitEthernet1/0/0
       10.1.4.0/30    OSPF   10   0      D     10.1.4.1       GigabitEthernet1/0/0
       10.1.4.1/32    Direct 0    0      D     127.0.0.1      InLoopBack0
       10.1.4.2/32    OSPF   10   0      D     10.1.4.2       GigabitEthernet1/0/0
     127.0.0.0/8      Direct 0    0      D     127.0.0.1      InLoopBack0
     127.0.0.1/32     Direct 0    0      D     127.0.0.1      InLoopBack0
127.255.255.255/32    Direct 0    0      D     127.0.0.1      InLoopBack0
255.255.255.255/32    Direct 0    0      D     127.0.0.1      InLoopBack0

The routing table contains the following key information:

  • Destination: indicates the destination address or destination network segment of the route.
  • Mask: indicates the network mask. It is used together with the destination address (through an AND operation) to identify the address of the network segment where a destination host or router resides. For example, if the destination address is 1.1.1.1 and the mask is 255.255.255.0, the address of the network segment where the host or router resides is 1.1.1.0.
  • Proto: indicates the method by which the route is obtained. For example, Direct indicates a direct route, and Static indicates a static route.
  • Pre: indicates the preference of the route in the IP routing table. Multiple routes to the same destination may exist and have different next hops or outbound interfaces. These routes may be discovered by different routing protocols or manually configured static routes. Among these routes, the one with the highest priority (smallest preference value) is selected as the optimal route.
  • Cost: indicates the cost of the route. When multiple routes to the same destination have the same preference, the route with the smallest cost is selected as the optimal route. The route cost is a value used to evaluate the quality of a route path. It is also called the route metric and indicates the cost of the route path from the source node to the destination node. The cost depends on multiple factors such as the network topology, bandwidth, delay, reliability, and security.
  • Flags: indicates the source and destination of a data packet and how the router processes the packet.
  • Nexthop: indicates the IP address of the next hop.
  • Interface: indicates the outbound interface through which IP packets are forwarded.

In addition to the local core routing table, there are protocol routing tables, each of which is maintained by the corresponding routing protocol and stores the routing information discovered by this protocol. A protocol routing table allows a routing protocol to import and advertise routes generated by other routing protocols. For example, if a router that runs OSPF needs to use OSPF to advertise direct routes, static routes, or IS-IS routes, the router needs to import these routes into its OSPF routing table.

The following is an example of the OSPF routing table (for details about fields in the command output, see Description of the display ospf routing command output):

<HUAWEI> display ospf routing
OSPF Process 1 with Router ID 4.4.4.4

          Routing Tables

 Routing for Network  
 Destination        Cost      Type           NextHop         AdvRouter       Area  
 172.16.1.0/24      4         Inter-area     192.168.2.1     2.2.2.2         0.0.0.2
                    4         Inter-area     192.168.2.3     2.2.2.2         0.0.0.2  
 192.168.0.0/24     2         Inter-area     192.168.2.1     2.2.2.2         0.0.0.2 

 Routing for ASEs  
 Destination        Cost      Type       Tag      NextHop         AdvRouter  
 10.0.0.0/8        1         Type2      1        192.168.2.1     1.1.1.1 

 Total Nets: 4  
 Intra Area: 1  Inter Area: 2  ASE: 1  NSSA: 0

What Are the Rules for Selecting IP Routes?

Route Preference

Routing protocols (including static routing) may discover different routes to the same destination, but not all the routes are optimal. In this case, the one discovered by the routing protocol with the highest priority (smallest preference value) is selected as the optimal route.

The following table lists the default preference of each routing protocol or route type on Huawei routers. Value 0 indicates a direct route, and value 255 indicates any route learned from an unreliable source. A smaller preference value indicates a higher priority. Except for direct routes, the preferences of all routing protocols or route types can be manually configured. In addition, the preferences of static routes can vary.

On Huawei products, such as the NE40E, both external and internal preferences are defined. An external preference refers to the preference manually configured for a routing protocol. The preceding table lists the default external preferences of routing protocols. If different routing protocols are configured with the same external preference, the system selects the optimal route by internal preference. The following table lists the internal preferences of different routing protocols.

For example, if an OSPF route and a static route are both destined for 10.1.1.0/24 and their external preferences are both set to 5, the system selects the optimal route by internal preference. The internal preference of OSPF is 10, whereas the internal preference of the static route is 60. As such, the OSPF route takes precedence over the static route in route selection.

Longest match rule

The prefix of each IP route is defined by an IP address and mask length. When receiving an IP packet, a router matches the destination IP address of the packet against all entries in its local routing table bit by bit until the entry with the longest prefix match is found. The router then forwards the packet based on the next hop in this entry. The longest match rule is the most fundamental part of route selection. It improves the route selection efficiency and prevents routing loops.

Assume that there are three routing entries 172.16.2.0/24, 172.16.1.0/24, and 172.16.0.0/16 (1, 2, and 3 for short) in the routing table, and the corresponding outbound interfaces are S1, S2, and S3, respectively. To forward a data packet destined for 172.16.2.1, the router selects routing entry 1 according to the longest match rule because its prefix is longer and more accurate than the prefix of routing entry 3 and routing entry 2 does not match the destination address.

Default Route

Default routes are special routes. If the destination address of a packet does not match any destination address in the routing table, the router forwards the packet using a default route. If no default route is available and the destination address of the packet does not exist in the routing table, the router discards the packet. Default routes can be manually configured or generated by dynamic routing protocols, such as OSPF and IS-IS. In the routing table, a default route is presented with the destination address 0.0.0.0/0. You can run the display ip routing-table command to check whether a default route is available.

The IP route selection process is as follows:

  1. After receiving a data packet, a router searches for a route that best matches the destination address of the packet according to a route selection rule (such as the longest match rule). If such a route is found, the router forwards the packet based on the outbound interface and next hop of the route.
  2. If no matching route is found, the device checks whether a default route exists. If no default route exists, the device discards the packet and sends an ICMP message to the source device.

What Are the Commonly Used Routing Protocols?

Depending on how they are generated, routes are classified into direct routes, static routes, and dynamic routes (discovered by dynamic routing protocols).

Direct Routes

A direct route is automatically discovered by the link layer protocol of an interface. As long as the interface is active, the router adds the route destined for the corresponding network segment to the routing table.

Static Routes

Static routes are manually configured by administrators. On a simple network, static routes alone can ensure the network operates properly. If the device cannot use dynamic routing protocols or cannot establish a route to the destination network, static routes can be used to help accurately control route selection. Properly configuring and using static routes can improve network performance and guarantee the required bandwidth for important applications. However, if a fault occurs on the network or the topology changes, static routes do not automatically change. Instead, they must be changed manually by the administrator. As such, static routes are inflexible.

Dynamic Routing Protocols

Different from direct and static routes, dynamic routing protocols have their own routing algorithms and can automatically adapt to network topology changes. Dynamic routing protocols are applicable to networks with a large number of Layer 3 devices. However, dynamic routing protocols require complex configuration, pose higher requirements on the system than static routes do, and consume more network resources. Dynamic routing protocols can be classified into the following types based on their application scopes:

  • Interior Gateway Protocols (IGPs): run within an autonomous system (AS). Common IGPs include RIP, OSPF, and IS-IS.
  • Exterior Gateway Protocols (EGPs): run between ASs. At present, BGP is the most widely used EGP.

The following table lists the common dynamic routing protocols and their comparisons.

About This Topic
  • Author: Sun Yuling
  • Updated on: 2024-11-12
  • Views: 3130
  • Average rating:
Share link to