Hello everyone!
Routing technology is the key to the continuous operation of the Internet. Routing technology, which works at the third layer of the TCP/IP model, provides IP-based communication for devices on the network and implements the interconnection between devices on different network segments.
What is routing?
Routing is path information that can guide IP packet forwarding.
As shown in the following figure, router RTA has a packet that needs to be sent to target network N. Router RTN searches the routing table based on the destination address and finds that the outbound interface to the destination network N is GE0/0/0 and the next-hop router is RTB. Then, the packet is sent from GE0/0/0 to router RTB. Router RTB forwards the packet to router RTC in the same manner, and the last router RTC in the network sends the packet to the destination network N.

Packets are forwarded in the following path on the network: router RTA -> router RTB -> router RTC -> target network N.
From this example, we can see that Routers provide a mechanism for interconnecting heterogeneous networks to transmit packets from one network to another. The router selects an appropriate path (a network includes one or more routers) based on the destination address of the packet header, and then sends the packet to the next router, finally the packet will be sent to the destination host.
The following describes the IP routing process based on the routing information on RTA, RTB, and RTC.

As shown in the figure, the left of RTA is connected to network 10.3.1.0, and the right of RTC is connected to network 10.4.1.0. When the 10.3.1.0 network has a packet to be sent to the 10.4.1.0 network, the IP process involves the following three steps:
(1) The data packet of the 10.3.1.0 network is sent to the E1 port of the RTA directly connected to the network. After receiving the data packet, the E1 port searches its routing table and finds that the next hop to the destination address is 10.1.2.2 and the outbound interface is E0. Then the packet is sent out from the E0 interface and forwarded to the next 10.1.2.2.
(2) The IP address of the E0 interface on RTB is 10.1.2.2. After receiving the data packet, RTB searches its routing table based on the destination address of the data packet, finds that the next hop to the destination address is 10.2.1.2, and the outbound interface is E1. The packet is sent by RTB through the E1 interface and sent to the next-hop 10.2.1.2.
(3) The IP address of the E0 interface on RTC is 10.2.1.2. After receiving the data packet, RTC still searches its routing table based on the destination address of the data packet, finds that the destination address is its directly connected network segment, and the next hop to the destination address is 10.4.1.1, and the interface is E1. Finally, the packet is sent from the E1 interface to the destination address.
The IP routing process clearly demonstrates that routers rely on routing tables to forward packets. To implement the routing function well, a router needs to do the following tasks:
1. Examine the destination of the packet. This function is used to determine whether the router knows the destination information.
2. Identify information sources. Where does the router get the path to a given destination? Statically specified by the administrator or dynamically obtained from other routers?
3. Discover possible routes. What are the possible routes to the destination?
4. Select the best route. What is the best route to the destination? Should routers balance load across multiple paths?
5. Verify and maintain routing information. Is the path to the destination valid? Is it up-to-date? In addition to generating routing tables, routers periodically verify and maintain routing information to ensure that entries in the routing table are valid.
Route classification
There are many ways to classify routes. There are three sources of routing, Therefore, if classify routes according to the source, they can be divided into:
Direct routes: Small cost, simple configuration, routes belonging to local interfaces can only be found.
Static routes: No cost, simple configuration, manual maintenance. When topology changes, static routes won't change. Only for simple network topologies.
Dynamic routes: High cost, complex configuration, no manual maintenance. Can be applied to complex network topologies. When topology changes, dynamic routes can change.
Depending on the destination of the routing, it can be divided into:
Subnet Routing: the destination is a subnet
Host Routing: the destination is a host
According to whether the destination is directly connected to the router, it can be divided into:
Direct routing: the destination network is directly connected to the router.
Indirect Routing: the destination network is not directly connected to the router.
IP Routing-table
The key of a router to forward packets is the routing table. Each router has a routing table, and the route entries inside it will indicate which physical port should be used to send a packet to the network or the host, or which next router can reach the path. Packets with a destination that does not exist in the routing table will be discarded.

The following key items are included in the routing table:
Destination: identify the destination address or destination network of the IP packet.
Mask: together with the destination address, it identifies the address of a network segment where the destination host or router is located. The corresponding network segment information can be obtained after doing the "AND" operation to the destination address and the network mask. The mask is composed of a number of continuous "1", which can be expressed in dot-decimal notation or in the continuous number of "1" in the mask.
Interface: Indicate which interface will be used to forward the IP packet out of the router.
Next-Hop: Specify the interface address of the next router that the IP packet will go through.
We will introduce some other fields inside the routing table, such as priority, metric, and so on later.
Source of Routing (Protocol)
The Protocol field in the routing table specifies the origin of a route, that is, how a route is generated. There are three types of routes:
Routes discovered by link layer protocols (Direct)
Small cost, simple configuration, no manual maintenance. Only the routes on the network segment to which the interface belongs can be discovered. These routes are also called interface routes or direct routes.
Manual configuration static routing (Static)
No cost, simple configuration, manual maintenance. Static routes are manually configured by administrators. Static routes can be used to establish an interconnected network. However, when a network fault occurs, static routes cannot be automatically rectified and must be manually configured by the administrator.
Routing discovered by the dynamic routing protocol (RIP, OSPF, etc.)
When the network topology is complex, the manual configuration of static routes is time-consuming and error-prone. In this case, dynamic routing protocols can be used to automatically discover and modify routes without manual maintenance. However, dynamic routing protocols have high costs and complex configurations.
Thanks for reading!




