On the Internet, network connection devices control network traffic and ensure data transmission quality on networks. Common network connection devices include hubs, bridges, switches, and routers.
As a standard network connection device, a router is used to select routes and forward packets. Based on the destination address in the received packet, a router selects a path to send the packet to the next router. The last router is responsible for sending the packet to the destination host. In addition, a router can select an optimal path for data transmission.
For example, in Figure 1, traffic from Host A to Host C needs to pass through three networks and two routers. The hop count from a router to its directly connected network is zero. The hop count from a router to a network that the router can reach through another router is one. The rest can be deduced by analogy. If a router is connected to another router through a network, a network segment exists between the two routers, and they are considered adjacent on the Internet. In Figure 1, the bold arrows indicate network segments. The routers do not need to know about the physical link composition of each network segment.
Network sizes may vary greatly, and the actual lengths of network segments vary as well. Therefore, you can set a weighted coefficient for the network segments of each network and then measure the cost of a route based on the number of network segments.
A route with the minimal network segments is not necessarily optimal. For example, a route passing through three high-speed Local Area Network (LAN) network segments may be a better choice than one passing through two low-speed Wide Area Network (WAN) network segments.