Mainstream algorithms for dynamic routing

A router is a network device with multiple network cards. When an ingress network packet is sent to the router, it determines how to correctly forward the traffic based on a local forwarding information base. This base of forwarding information is often called a routing table.

There will be multiple routing rules in a routing table. Each rule contains at least these three pieces of information.

  • Destination network: Where does this packet want to go?
  • Exit equipment: From which port are the bags thrown out?
  • Next hop gateway: The address of the next router.

The routing policy on the gateway is configured according to these three configuration information. A core idea of ​​this configuration method is to configure routing based on the destination IP address.

1. Distance vector routing algorithm : It is based on the Bellman-Ford algorithm.

The basic idea of ​​this algorithm is that each router saves a routing table, which contains multiple rows. Each row corresponds to a router in the network. Each row contains two parts of information. One is to go to the target router and which line to go out. The other is the distance to the destination router.

It can be seen that each router knows the global information. How to update this information? Each router knows the distance between itself and its neighbors. Every few seconds, each router tells its neighbors the distances it knows to all routers. Each router can also get similar information from its neighbors.

Each router calculates the distance from other routers based on the newly collected information. For example, the distance between one of its neighbors and the target router is M, and its distance from its neighbor is x, then its distance from the target router is x+M.

The first problem is that good news travels quickly and bad news travels slowly. The second problem with this algorithm is that every time it is sent, the entire global routing table must be sent.

2. Link state routing algorithm : based on Dijkstra algorithm.

The basic idea of ​​this algorithm is: when a router starts up, it first discovers neighbors, says hello to the neighbors, and the neighbors reply. Then calculate the distance to the neighbor, send an echo, and request immediate return. Divide by two to get the distance. Then it broadcasts the link status packets between itself and its neighbors to every router in the entire network. In this way, each router can receive information about its relationship with its neighbors. Therefore, each router can build a complete graph locally, and then use Dijkstra's algorithm on this graph to find the shortest path between two points.

Unlike distance vector routing protocols, the entire routing table is sent when updating. Link state routing protocols only broadcast updated or changed network topology, which makes the update message smaller, saving bandwidth and CPU utilization. And once a router hangs up, its neighbors will broadcast the news, which can quickly converge the bad news.

OSPF (Open Shortest Path First) is such a link-state routing protocol that is widely used in data centers. Because it is mainly used inside the data center for routing decisions, it is called Interior Gateway Protocol (IGP).

The whole point of the interior gateway protocol is to find the shortest path. Within an organization, the shortest path is often the best. Of course, sometimes OSPF can find multiple shortest paths and can perform load balancing among these multiple paths. This is often called equal-cost routing.

External network routing protocol (Border Gateway Protocol, referred to as BGP). In the online world, each country becomes an Autonomous System (AS). There are several types of autonomous systems.

  • Stub AS: There is only one external connection. This type of AS will not transmit packets from other ASs. For example, a personal or small company network.
  • Multihomed AS: There may be multiple connections to other ASs, but most of them refuse to help other ASs transmit packets. For example, some large company networks.
  • Transit AS: has multiple connections to other ASs and can help other ASs transmit packets. For example, the backbone network.

The algorithm used by the BGP protocol is the path-vector protocol. It is an upgraded version of the distance vector routing protocol.

This article is a study note for Day 9 in September. The content comes from Geek Time's "Internet Protocol". This course is recommended.

Guess you like

Origin blog.csdn.net/key_3_feng/article/details/132783122