Data Communication Computer Network 简明教程
Network Layer Routing
当设备访问目标时具有多路径时,会优先选择一条路径。这个选择过程称为路由。路由由特殊网络设备(路由器)完成,也可以通过软件流程完成。基于软件的路由器功能有限,适用范围较小。
When a device has multiple paths to reach a destination, it always selects one path by preferring it over others. This selection process is termed as Routing. Routing is done by special network devices called routers or it can be done by means of software processes.The software based routers have limited functionality and limited scope.
路由器始终配置一些默认路由。默认路由告诉路由器如果没有找到通往特定目的地的路由,则将数据包转发到何处。如果有多条路径可以到达同一目的地,路由器可以根据以下信息做出决策:
A router is always configured with some default route. A default route tells the router where to forward a packet if there is no route found for specific destination. In case there are multiple path existing to reach the same destination, router can make decision based on the following information:
-
Hop Count
-
Bandwidth
-
Metric
-
Prefix-length
-
Delay
路由可以通过静态配置或动态学习。可以配置一条路由优先于其他路由。
Routes can be statically configured or dynamically learnt. One route can be configured to be preferred over others.
Unicast routing
互联网和内联网上大多数流量(称为单播数据或单播流量)都使用指定目的地发送。通过互联网路由单播数据称为单播路由。这是最简单的路由形式,因为目的地已知。因此,路由器只需查找路由表并将数据包转发到下一跳即可。
Most of the traffic on the internet and intranets known as unicast data or unicast traffic is sent with specified destination. Routing unicast data over the internet is called unicast routing. It is the simplest form of routing because the destination is already known. Hence the router just has to look up the routing table and forward the packet to next hop.

Broadcast routing
默认情况下,广播数据包不会在任何网络上的路由器路由和转发。路由器创建广播域。但是,可以在某些特殊情况下对其进行配置以转发广播。广播消息会发送给网络中的所有设备。
By default, the broadcast packets are not routed and forwarded by the routers on any network. Routers create broadcast domains. But it can be configured to forward broadcasts in some special cases. A broadcast message is destined to all network devices.
广播路由可以通过两种方式(算法)进行:
Broadcast routing can be done in two ways (algorithm):
-
A router creates a data packet and then sends it to each host one by one. In this case, the router creates multiple copies of single data packet with different destination addresses. All packets are sent as unicast but because they are sent to all, it simulates as if router is broadcasting. This method consumes lots of bandwidth and router must destination address of each node.
-
Secondly, when router receives a packet that is to be broadcasted, it simply floods those packets out of all interfaces. All routers are configured in the same way. This method is easy on router’s CPU but may cause the problem of duplicate packets received from peer routers. Reverse path forwarding is a technique, in which router knows in advance about its predecessor from where it should receive broadcast. This technique is used to detect and discard duplicates.
Multicast Routing
多播路由是广播路由的一种特殊情况,具有重要的差异和挑战。在广播路由中,数据包会发送到所有节点,即使它们不需要。但在多播路由中,数据只会发送到希望接收数据包的节点。
Multicast routing is special case of broadcast routing with significance difference and challenges. In broadcast routing, packets are sent to all nodes even if they do not want it. But in Multicast routing, the data is sent to only nodes which wants to receive the packets.

路由器必须知道希望接收多播数据包(或流)的节点,然后才能进行转发。多播路由使用生成树协议来避免循环。
The router must know that there are nodes, which wish to receive multicast packets (or stream) then only it should forward. Multicast routing works spanning tree protocol to avoid looping.
多播路由还使用反向路径转发技术来检测和丢弃重复项和循环。
Multicast routing also uses reverse path Forwarding technique, to detect and discard duplicates and loops.
Anycast Routing
Anycast 数据包转发是一种机制,其中多个主机可以具有相同的逻辑地址。当收到发往此逻辑地址的数据包时,它会发送到在路由拓扑中最近的主机。
Anycast packet forwarding is a mechanism where multiple hosts can have same logical address. When a packet destined to this logical address is received, it is sent to the host which is nearest in routing topology.

Anycast 路由是借助 DNS 服务器完成的。每当收到 Anycast 数据包时,会询问 DNS 将其发送到何处。DNS 提供的是其上配置的最近的 IP 地址。
Anycast routing is done with help of DNS server. Whenever an Anycast packet is received it is enquired with DNS to where to send it. DNS provides the IP address which is the nearest IP configured on it.
Unicast Routing Protocols
有两种类型的路由协议可用于路由单播数据包:
There are two kinds of routing protocols available to route unicast packets:
. Distance Vector Routing Protocol Distance Vector is simple routing protocol which takes routing decision on the number of hops between source and destination. A route with less number of hops is considered as the best route. Every router advertises its set best routes to other routers. Ultimately, all routers build up their network topology based on the advertisements of their peer routers, For example Routing Information Protocol (RIP).
. Link State Routing Protocol Link State protocol is slightly complicated protocol than Distance Vector. It takes into account the states of links of all the routers in a network. This technique helps routes build a common graph of the entire network. All routers then calculate their best path for routing purposes.for example, Open Shortest Path First (OSPF) and Intermediate System to Intermediate System (ISIS).
Multicast Routing Protocols
单播路由协议使用图形,而多播路由协议使用树,即生成树来避免循环。最佳树称为最短路径生成树。
Unicast routing protocols use graphs while Multicast routing protocols use trees, i.e. spanning tree to avoid loops. The optimal tree is called shortest path spanning tree.
-
DVMRP - Distance Vector Multicast Routing Protocol
-
MOSPF - Multicast Open Shortest Path First
-
CBT - Core Based Tree
-
PIM - Protocol independent Multicast
跨协议组播现在普遍使用。它有两种方式:
Protocol Independent Multicast is commonly used now. It has two flavors:
-
PIM Dense Mode This mode uses source-based trees. It is used in dense environment such as LAN.
-
PIM Sparse Mode This mode uses shared trees. It is used in sparse environment such as WAN.
Routing Algorithms
路由算法如下:
The routing algorithms are as follows:
Flooding
泛洪是最简单的分组转发方法。当收到一个数据包时,路由器会将其发送到除收到数据包的接口以外的所有接口。这给网络造成了过大的负担,并且大量重复的数据包在网络中游荡。
Flooding is simplest method packet forwarding. When a packet is received, the routers send it to all the interfaces except the one on which it was received. This creates too much burden on the network and lots of duplicate packets wandering in the network.
使用生存时间 (TTL) 可以避免数据包的无限循环。另一种泛洪方法被称为选择性泛洪,它可以减少网络开销。在此方法中,路由器不会泛洪到所有接口,而是选择性地泛洪。
Time to Live (TTL) can be used to avoid infinite looping of packets. There exists another approach for flooding, which is called Selective Flooding to reduce the overhead on the network. In this method, the router does not flood out on all the interfaces, but selective ones.
Shortest Path
网络中的路由决策主要基于源和目标之间的成本。跳数在这里起着主要作用。最短路径是一种使用各种算法来决定具有最少跳数的路径的技术。
Routing decision in networks, are mostly taken on the basis of cost between source and destination. Hop count plays major role here. Shortest path is a technique which uses various algorithms to decide a path with minimum number of hops.
常见的最短路径算法有:
Common shortest path algorithms are:
-
Dijkstra’s algorithm
-
Bellman Ford algorithm
-
Floyd Warshall algorithm