使用 Cisco 快速转发排除并行链路上的负载均衡故障

来源:互联网 发布:六孔陶笛淘宝 编辑:程序博客网 时间:2024/05/17 01:02

http://www.cisco.com/cisco/web/support/CN/107/1078/1078908_loadbal_cef.html


目录

简介
先决条件
要求
使用的组件
规则
背景信息
什么是负载平衡?
在 Cisco 快速转发之前 - 收集多条路径或路由
配置 Cisco 快速转发负载分担
Cisco 快速转发负载平衡内部机制
Cisco 快速转发负载平衡的验证
链路改变后的负载分担
即将删除的负载分担信息
已知问题
Cisco 快速转发负载平衡的硬件支持
相关的思科支持社区讨论
相关信息

简介

本文澄清Cisco IOS 软件如何实现在多条并行链路间的第3层负载均衡,当曾经Cisco快速转发时。

先决条件

要求

本文档假设读者对 Cisco 快速转发的两个数据结构已有所了解。

  • 转发信息库 (FIB)

  • 邻接表

有关 Cisco 快速转发功能的操作概述,请参阅本文档的相关信息部分。

使用的组件

本文档不限于特定的软件和硬件版本。

本文档中的信息都是基于特定实验室环境中的设备创建的。本文档中使用的所有设备最初均采用原始(默认)配置。如果您是在真实网络上操作,请确保您在使用任何命令前已经了解其潜在影响。

规则

有关文档规则的详细信息,请参阅 Cisco 技术提示规则。

背景信息

IP 交换是 Cisco IOS 用于通过路由器转发数据包的内部机制。可用机制包括进程交换、快速交换和 Cisco 快速转发。整个系统性能和负载平衡受到的影响取决于交换多数信息包采用三种机制的哪种机制。

IP 交换机制支持两种常规模式,基于数据包和基于目标。下表概述了这两种模式的优点和缺点。

 基于目标基于数据包IP 交换机制基于目标的快速交换和 Cisco 快速转发。基于数据包的进程交换和 Cisco 快速转发。优点使用快速交换功能,可以保证指定目的地的信息包采用同一条路径,即使有多条路径可以使用。具备 Cisco 快速转发交换功能后,给定源-目的地主机对的数据包可以保证采取同一条路径,即使有多条路径可以使用时也是如此。不同主机对的流量倾向于选择不同路径。具有每数据包负载均衡的路径使用率情况良好,因为每数据包负载均衡允许路由器在路径发送连续数据包,无论是单个主机还是用户会话。它使用循环方法,确定每个数据包采用哪条路径到达目的地。缺点具备快速交换功能后,由于到达目的地的数据包总是跟随同一条路径,所以每个目的地交换可能导致负载共享不等同。当源-目标对的数量较少时,Cisco 快速转发交换可能会导致分布不均。基于目标的负载均衡取决于流量的统计分布;随着源-目标对的数量增加,负载共享将更有效。特定源-目的地主机对的数据包可能采用不同路径,这可能导致数据包重新排队。建议不要对 IP 语音 (VoIP) 和其他要求依序提供的流采取此方式。

什么是负载平衡?

负载均衡描述路由器通过多条路径将数据包传输到目的地 IP 地址(亦称 IP 前缀)的功能。

当探讨负载均衡时,我们首先需要定义以下术语。

期限定义前缀描述目标 IP 网络,例如 192.16.10.0/24。使用从交换信息获取的信息、使用动态路由协议,或者手动配置静态路由,思科IOS可将目的地IP前缀添加到路由表。路径描述到达目标前缀的有效路由。Cisco IOS 会为每条路径指定一个代价。指向目标前缀的一组活动路径的代价可能相等,也可能不等。会话描述两个 IP 节点之间的一个单向通信流。会话中的所有数据包都使用相同的源和目标 IP 地址。

有关详细信息,请参阅负载均衡如何工作?

在 Cisco 快速转发之前 - 收集多条路径或路由

Cisco 快速转发使用 IP 路由表中的路径信息来平衡多条链路上的流量。为此,要确认适当的 Cisco 快速转发负载均衡,首先要确认 IP 路由表的内容。

在下列拓朴图中,两个路由器(路由器A和路由器B)在三个串行接口上背对背地连接,同时提供高级数据链路控制(HDLC)封装。

路由器 A路由器 B
interface Ethernet 0  ip address  192.168.20.1 255.255.255.0 ! interface Serial1  ip address 10.10.10.1 255.255.255.0  ! interface Serial2  ip address 20.20.20.1 255.255.255.0 ! interface Serial3  ip address 30.30.30.1 255.255.255.0  ip ospf cost 100 ! router ospf 1  network 10.10.10.0 0.0.0.255 area 0  network 20.20.20.0 0.0.0.255 area 0  network 30.30.30.0 0.0.0.255 area 0 network 192.168.20.0 0.0.0.255 area 0
interface Serial1  ip address 10.10.10.2 255.255.255.0  clockrate 2000000 ! interface Serial2  ip address 20.20.20.2 255.255.255.0  clockrate 148000 ! interface Serial3  ip address 30.30.30.2 255.255.255.0  ip ospf cost 100  clockrate 148000 router ospf 1  network 10.10.10.0 0.0.0.255 area 0  network 20.20.20.0 0.0.0.255 area 0  network 30.30.30.0 0.0.0.255 area 0maximum-paths 1

我们看一下路由器 B 如何选择一条或多条路径以抵达路由器 A 的以太网接口 IP 网络 192.168.20.0。

  • 默认情况下,开放最短路径优先(OSPF)支持四等价路径对目的地。在此方案中路由器 B 将配置为最大路径数为 1。因此路由器 B 根据它首先接收的路径,只从相等路径中选择其中之一。路由器 B 首先选择串口 2 作为指向 192.168.20.0 网络的单一路径。使用 show ip cef 和 show ip route 命令可以查看当前路径集。

    RouterB#show ip cef  192.168.20.0 192.168.20.0/24, version 59, cached adjacency to Serial2 0 packets, 0 bytes   via 20.20.20.1, Serial2, 0 dependencies     next hop 20.20.20.1, Serial2     valid cached adjacency RouterB#show ip route  192.168.20.0 Routing entry for  192.168.20.0/24   Known via "ospf 1", distance 110, metric 74, type intra area   Redistributing via ospf 1   Last update from 20.20.20.1 on Serial2, 00:03:58 ago   Routing Descriptor Blocks:   * 20.20.20.1, from 204.204.204.1, 00:03:58 ago, via Serial2       Route metric is 74, traffic share count is 1
  • 在 OSPF 之下使用 maximum-paths 命令,允许路由表超过一条路径。OSPF 只允许进行等价负载均衡。如果要配置不同开销的负载共享,请将增强 的 内部 网关 路由 协议和 内部 网关 路由协议(EIGRP/IGRP)配置为内部网关协议(IGP)。请参阅不等价(可变)路径负载均衡在 IGRP 和 EIGRP 中如何工作?以了解更多信息。

    RouterB(config)#router ospf 1RouterB(config-router)#maximum-paths ?   <1-6>  Number of paths   RouterB(config-router)#maximum-paths 3 
  • 使用 show ip route 命令确认路由表包含两个指向 192.168.20.0 的路径。

    RouterB#show ip route  192.168.20.0Routing entry for  192.168.20.0/24   Known via "ospf 1", distance 110, metric 74, type intra area   Redistributing via ospf 1   Last update from 10.10.10.1 on Serial1, 00:00:11 ago   Routing Descriptor Blocks:   * 20.20.20.1, from 204.204.204.1, 00:00:11 ago, via Serial2       Route metric is 74, traffic share count is 1          10.10.10.1, from 204.204.204.1, 00:00:11 ago, via Serial1       Route metric is 74, traffic share count is 1       !--- The route metric is 74 for both paths.
  • 虽然我们配置 OSPF 支持三个等价路径,但只有二个活动路径显示在 show ip route 输出中。我们可以使用 show ip ospf interface 命令确定原因。因此 Serial3 比 Serial1 和 Serial2 有一更高成本,因此它们不对等。

    RouterB#show ip ospf interface s1Serial1 is up, line protocol is up   Internet Address 10.10.10.4/24, Area 0   Process ID 1, Router ID 100.100.100.1, Network Type POINT_TO_POINT, Cost: 64   RouterB#show ip ospf interface s2Serial2 is up, line protocol is up   Internet Address 20.20.20.2/24, Area 0   Process ID 1, Router ID 100.100.100.1, Network Type POINT_TO_POINT, Cost: 64   RouterB#show ip ospf interface s3Serial3 is up, line protocol is up   Internet Address 30.30.30.2/24, Area 0   Process ID 1, Router ID 100.100.100.1, Network Type POINT_TO_POINT, Cost: 100
  • 使用 show run 命令确认是否用 ip ospf cost 100 命令配置了串口 3。使用 no ip ospf cost 100 sub-interface 命令从配置上取消它,并使三个串行链路的成本相等。

    RouterB#show run interface s3 Building configuration... Current configuration: ! interface Serial3  ip address 30.30.30.2 255.255.255.0  no ip directed-broadcast  ip ospf cost 100  ip ospf interface-retry 0
  • 现在 show ip route 命令将显示指向 192.168.20.0 网络的三个等价路径。

    RouterB#show ip route  192.168.20.0 Routing entry for  192.168.20.0/24   Known via "ospf 1", distance 110, metric 74, type intra area   Redistributing via ospf 1   Last update from 10.10.10.1 on Serial1, 00:00:01 ago   Routing Descriptor Blocks:   * 20.20.20.1, from 204.204.204.1, 00:00:01 ago, via Serial2       Route metric is 74, traffic share count is 1     30.30.30.1, from 204.204.204.1, 00:00:01 ago, via Serial3       Route metric is 74, traffic share count is 1     10.10.10.1, from 204.204.204.1, 00:00:01 ago, via Serial1       Route metric is 74, traffic share count is

现在让我们看看 Cisco 快速转发负载平衡如何使用路由表中的信息来转发数据包。

配置 Cisco 快速转发负载分担

Cisco 快速转发功能通过使用负载共享表来完成负载均衡。在 Cisco 路由器上使用所有其他负载平衡解决方案,便可以在出局接口上做出负载均衡决策。不同于其他交换方法,Cisco 快速转发根据该路径的起源和目的地址,追踪路径。要简化该过程,您可以说该路径是 IP 会话,并且每个会话在逻辑上都被识别为唯一的源-目标地址对。

为了了解负载平衡如何发生,您必须首先知道这些表如何关连。Cisco 快速转发表指向 16 个哈希桶(负载共享表),16 个哈希又指向并行路径的邻接表。有关详细信息,请参阅 Cisco 快速转发负载均衡内部机制部分。将被交换的每个数据包被分为源地址和目的地址对,并根据加载共享表进行检查。

注意: Cisco 快速转发交换有两种主要类型,基于目标和基于数据包。如果两种类型都在路由器上使用,那么每种类型都有它自己的加载共享表。

基于目标的负载均衡允许路由器使用多条路径进行负载共享。当您启用 Cisco 快速转发时,按照目的地进行的负载均衡是默认启用的,这是大多数情况下选择的负载均衡方式。由于按目的地进行负载均衡取决于数据流的统计分配,随着源-目的地对的数量增加,负载共享开始变得更加有效。

基于数据包的负载均衡允许路由器通过路径发送连续数据包而不考虑单个主机或用户会话。它使用循环方法,确定每个数据包采用哪条路径到达目的地。基于数据包的负载均衡可确保在多条链路上实现均衡。具有每信息包负载均衡的路径使用率情况良好,但使用于特定源-目的地主机对的信息包可能采用不同的路径,从而引起信息包重排序。为此,每个数据包负载均衡对于特定类型的数据流量并不适合,例如 VoIP,它取决于数据包到达目的地的次序。使用每个数据包负载平衡,有助于确保单一来源--目的地对的路径不会超载。

使用 ip load-sharing 命令可以在基于数据包和基于目标的方法之间进行切换。

7200-1.3(config)#interface fast 0/0   7200-1.3(config-if)#ip load-sharing ?   per-destination  Deterministic distribution   per-packet       Random distribution   7200-1.3(config-if)#ip load-sharing per-packet

使用 show cef interface 命令可以确认所做的更改。

7200-1.3#show cef interface fast 0/0 FastEthernet0/0 is up (if_number 3)   Corresponding hwidb fast_if_number 3   Corresponding hwidb firstsw->if_number 3   Internet address is 172.16.81.13/24   ICMP redirects are always sent   Per packet load-sharing is enabled   IP unicast RPF check is disabled   Inbound access list is not set   Outbound access list is not set   IP policy routing is disabled   Hardware idb is FastEthernet0/0   Fast switching type 1, interface type 18   IP CEF switching enabled   IP Feature Fast switching turbo vector   IP Feature CEF switching turbo vector   Input fast flags 0x0, Output fast flags 0x0   ifindex 1(1)   Slot 0 Slot unit 0 VC -1   Transmit limit accumulator 0x0 (0x0)   IP MTU 1500

Cisco 快速转发负载平衡内部机制

首先我们先来了解一下 Cisco 快速转发负载均衡背后的内部机制。

  • 为每个会话(请参阅上表)分配一个活动路径。

  • 会话到路径的分配使用源 IP 地址和目的地 IP 地址的散列功能,使用 Cisco IOS 的最新版本,独特的散列 ID 将在端到端路径上随机分配。

  • 将活动路径内部分配给 16 个 Hash Bucket 中的若干 Hash Bucket。路径到 Hash Bucket 的分配随负载均衡类型和活动路径数而变化。

  • 散列函数的结果被用来选择启用时段,因而在会话中使用哪个路径。

  • 对于路由器转发的所有会话,每个活动路径都传输相同数量的会话。

下面我们通过示例来查看一下这些 Cisco 快速转发的内部过程。

  1. 使用 maximum-paths 命令将目标前缀的活动路径数减少到 2。

    RouterB(config)#router ospf 1RouterB(config-router)#maximum-paths 2
  2. 使用 show ip cef {prefix} internal 命令查看路径到 Hash Bucket 的分配。

    RouterB#show ip cef  192.168.20.0 internal  192.168.20.0/24, version 66, per-destination sharing 0 packets, 0 bytes   via 20.20.20.1, Serial2, 0 dependencies     traffic share 1     next hop 20.20.20.1, Serial2     valid adjacency   via 30.30.30.1, Serial3, 0 dependencies     traffic share 1     next hop 30.30.30.1, Serial3     valid adjacency   0 packets, 0 bytes switched through the prefix   Load distribution: 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 (refcount 1)   !--- The load distribution line summarizes how each path is !--- assigned to the hash buckets.    Hash  OK  Interface                 Address         Packets   1     Y   Serial2                   point2point           0   2     Y   Serial3                   point2point           0   3     Y   Serial2                   point2point           0   4     Y   Serial3                   point2point           0   5     Y   Serial2                   point2point           0   6     Y   Serial3                   point2point           0   7     Y   Serial2                   point2point           0   8     Y   Serial3                   point2point           0   9     Y   Serial2                   point2point           0   10    Y   Serial3                   point2point           0   11    Y   Serial2                   point2point           0   12    Y   Serial3                   point2point           0   13    Y   Serial2                   point2point           0   14    Y   Serial3                   point2point           0   15    Y   Serial2                   point2point           0   16    Y   Serial3                   point2point 

    16 个 Hash Bucket 的设置取决于负载均衡类型和活动路径数。比较简单的情况是路径数为偶数。活动路径将均匀分布在 16 个 Hash Bucket 中。如果 16 不能按照激活路径数目划分,那么代表其余的最后几个时段失效。下表显示了两条和三条活动路径在 Hash Bucket 中的分布情况。

    Bucket/路径0123456789101112131415201010101010101013012012012012012x

    在下面的示例中,有三条路径指向目标。请注意 Cisco 快速转发如何取消 hash bucket 16,三个串行链路如何均匀分配 hash bucket 1 至 15 的。

    RouterB#show ip cef  192.168.20.0 interface  192.168.20.0/24, version 64, per-destination sharing 0 packets, 0 bytes   via 20.20.20.1, Serial2, 0 dependencies     traffic share 1     next hop 20.20.20.1, Serial2     valid adjacency   via 30.30.30.1, Serial3, 0 dependencies     traffic share 1     next hop 30.30.30.1, Serial3     valid adjacency   via 10.10.10.1, Serial1, 0 dependencies     traffic share 1     next hop 10.10.10.1, Serial1     valid adjacency   0 packets, 0 bytes switched through the prefix   Load distribution: 0 1 2 0 1 2 0 1 2 0 1 2 0 1 2 (refcount 1)   !--- The active paths are assigned to hash buckets in a !--- round-robin pattern.     Hash  OK  Interface                 Address         Packets   1     Y   Serial2                   point2point           0   2     Y   Serial3                   point2point           0   3     Y   Serial1                   point2point           0   4     Y   Serial2                   point2point           0   5     Y   Serial3                   point2point           0   6     Y   Serial1                   point2point           0   7     Y   Serial2                   point2point           0   8     Y   Serial3                   point2point           0   9     Y   Serial1                   point2point           0   10    Y   Serial2                   point2point           0   11    Y   Serial3                   point2point           0   12    Y   Serial1                   point2point           0   13    Y   Serial2                   point2point           0   14    Y   Serial3                   point2point           0   15    Y   Serial1                   point2point           0   !--- Hash bucket 16 has been removed. 

    注意: 虽然他们为目的地选择单个路径,但 Cisco 快速转发预定目的地和快速交换机制会随着他们选择该路径的方式的不同而不同。Cisco 快速转发会同时考虑源和目标 IP 地址,而快速交换只考虑目标 IP 地址。

Cisco 快速转发负载平衡的验证

使用以下步骤验证路由器上的 Cisco 快速转发负载均衡。

  1. 确认路由器上全局启用了 Cisco 快速转发。

    S3-4K-2#show ip cef %CEF not running Prefix                      Next Hop                     Interface !--- This output shows Cisco Express Forwarding is not enabled. !--- Use ip cef command in global configuration to enable it.
  2. 确认特定出站接口上启用了基于数据包或基于目标的交换。默认设置为基于目标。

    RouterA#show cef interface s1 Serial1 is up (if_number 3)  Internet address is 10.10.10.1/24   ICMP redirects are always sent   Per packet loadbalancing is disabled   IP unicast RPF check is disabled   Inbound access list is not set   Outbound access list is not set   Interface is marked as point to point interface   Hardware idb is Serial1   Fast switching type 4, interface type 40   IP CEF switching enabled   !--- Cisco Express Forwarding is enabled on the interface.   IP CEF Fast switching turbo vector   Input fast flags 0x0, Output fast flags 0x0   ifindex 5(5)  Slot 0 Slot unit 1 VC -1     Transmit limit accumulator 0x0 (0x0)   IP MTU 1500 
  3. 使用 show ip route 命令确认路由表和 Cisco 快速转发表包含所有并行路径。

    RouterB#show ip route 192.168.20.0 Routing entry for 192.168.20.0/32, 1 known subnets  O       192.168.20.1 [110/65] via 20.20.20.1, 00:06:54, Serial1                      [110/65] via 10.10.10.1, 00:06:54, Serial2                      [110/65] via 30.30.30.1, 00:06:54, Serial3 
  4. 使用 show ip cef 命令检查 Cisco 快速转发 FIB。

    RouterB#show ip cef 192.168.20.0192.168.20.0/24, version 18, per-destination sharing0 packets, 0 bytes  via 30.30.30.1, Serial3,   0 dependencies    traffic share 1    next hop 30.30.30.1, Serial3    valid adjacency  via 20.20.20.1, Serial2, 0 dependencies    traffic share 1    next hop 20.20.20.1, Serial2    valid adjacency  via 10.10.10.1, Serial1, 0 dependencies    traffic share 1    next hop 10.10.10.1, Serial1    valid adjacency  0 packets, 0 bytes switched through the prefix  tmstats: external 0 packets, 0 bytes           internal 0 packets, 0 bytesRouterB#show ip cef 192.168.20.0 internal192.168.20.0/24, version 18, per-destination sharing0 packets, 0 bytes  via 30.30.30.1, Serial3, 0 dependencies    traffic share 1    next hop 30.30.30.1, Serial3    valid adjacency  via 20.20.20.1, Serial2, 0 dependencies    traffic share 1    next hop 20.20.20.1, Serial2    valid adjacency  via 10.10.10.1, Serial1, 0 dependencies    traffic share 1    next hop 10.10.10.1, Serial1    valid adjacency  0 packets, 0 bytes switched through the prefix  tmstats: external 0 packets, 0 bytes           internal 0 packets, 0 bytes  Load distribution: 0 1 2 0 1 2 0 1 2 0 1 2 0 1 2 (refcount 1)  Hash  OK  Interface                 Address         Packets  1     Y   Serial3                   point2point           0  2     Y   Serial2                   point2point           0  3     Y   Serial1                   point2point           0  4     Y   Serial3                   point2point           0  5     Y   Serial2                   point2point           0  6     Y   Serial1                   point2point           0  7     Y   Serial3                   point2point           0  8     Y   Serial2                   point2point           0  9     Y   Serial1                   point2point           0  10    Y   Serial3                   point2point           0  11    Y   Serial2                   point2point           0  12    Y   Serial1                   point2point           0  13    Y   Serial3                   point2point           0  14    Y   Serial2                   point2point           0  15    Y   Serial1                   point2point           0

    注意: 上面的负载共享表显示负载分布为 0 1 2 0 1 2...每个路由的流量分担为 1。这意味着三个等价路由分担了等价的基于目标负载。

  5. 检查 Cisco 快速转发的邻接关系。

    RouterB#show adjacency detailProtocol Interface                 AddressIP       Serial1                   point2point(11)                                   0 packets, 0 bytes                                   0F000800                                   CEF   expires: 00:02:31                                         refresh: 00:00:31IP       Serial2                   point2point(11)                                   0 packets, 0 bytes                                   0F000800                                   CEF   expires: 00:02:31                                         refresh: 00:00:31IP       Serial3                   point2point(11)                                   0 packets, 0 bytes                                   0F000800                                   CEF   expires: 00:02:31                                         refresh: 00:00:31
  6. 确认所有出站接口上都配置了预期的 Cisco 快速转发负载均衡机制。

    RouterB#show ip cef  192.168.20.0 192.168.20.0/24, version 89, per-destination sharing 0 packets, 0 bytes   via 10.10.10.1, Serial1, 0 dependencies     traffic share 1     next hop 10.10.10.1, Serial1     valid adjacency   [output omitted]
  7. 启用无用数据时段记帐,收集统计数据,以便更好了解您网络中的 Cisco 快速转发模式。例如,您也许想要收集信息,如转换到目的地的数据包和字节的数量,或者通过目的地转换的数据包的数量。请使用以下命令:

    router(config)# ip cef accounting load-balance-hash

    通过观察 Packet 字段下的值验证数据包流。

    RouterB#show ip cef 192.168.20.0 internal[...]  Load distribution: 0 1 2 0 1 2 0 1 2 0 1 2 0 1 2 (refcount 1)  Hash  OK  Interface                 Address         Packets  1     Y   Serial                    point2point           0  2     Y   Serial2                   point2point           0  3     Y   Serial1                   point2point           0  4     Y   Serial3                   point2point           0  5     Y   Serial2                   point2point          35  6     Y   Serial1                   point2point           0  7     Y   Serial3                   point2point           0  8     Y   Serial2                   point2point          60  9     Y   Serial1                   point2point           0  10    Y   Serial3                   point2point           0  11    Y   Serial2                   point2point           0  12    Y   Serial1                   point2point           0  13    Y   Serial3                   point2point           0  14    Y   Serial2                   point2point          30  15    Y   Serial1                   point2point           0

    125 个数据包流经 Serial2。如果您使用 ping,生成数据流,请确保 ping 数据包必须传输通过 Cisco 快速转发交换的路由器。换句话说,ping 数据包必须从一个 Cisco 快速转发交换接口进入,进行 Cisco 快速转发交换,然后从另一个 Cisco 快速转发交换接口离开。

    注意: 随着源-目标对的数量增加,基于目标的负载共享将更有效。

  8. 将流量发送到前缀时,捕获 show interface 命令的若干输出。分析“txload”和“rxload”值。(某些接口会显示一个“load”值,其中同时考虑了传送和接收)。虽然每个数据包负载平衡按数据包数量进行均衡分配,但由于数据包大小不同,并行链路显示出的速率可能稍微有些不均衡。

    Serial1/0:0 is up, line protocol is upreliability 255/255, txload 10/255, rxload 3/255 Serial1/1:0 is up, line protocol is upreliability 255/255, txload 18/255, rxload 3/255
  9. 具备每个目的地负载均衡的 Cisco 快速转发功能后,您可以确定带有下列命令会话分配到哪条路径。添加关键字 internal 以显示所使用的 Hash Bucket。

    show ip cef exact-route {source-ip-address} {dest-ip-address} [internal] RouterB# show ip cef exact-route 50.50.50.2 192.168.20.1  internal50.50.50.2      -> 192.168.20.1   : Serial9/0 (next hop 20.20.20.1)                                    Bucket 4 from 15, total 3 pathsRouterB# show ip cef exact-route 5.5.5.1 192.168.20.1  internal   5.5.5.1         ->192.168.20.1   : Serial9/0 (next hop 20.20.20.1)                                    Bucket 7 from 15, total 3 pathsRouterB# show ip cef exact-route 6.6.6.1 192.168.20.1  internal6.6.6.1         -> 192.168.20.1   : Serial9/0 (next hop 20.20.20.1)                                    Bucket 7 from 15, total 3 pathsRouterB# show ip cef exact-route 8.8.8.1 192.168.20.1  internal8.8.8.1         -> 192.168.20.1   : Serial9/0 (next hop 20.20.20.1)                                    Bucket 13 from 15, total 3 paths
  10. 如果输出不均匀,请考虑以下事项:

    • 穿过并行链路的唯一源和目标地址对或会话的数量。

    • 每个会话中的数据包的大小和数量。其中一个会话是否具有大量数据包?按目的地进行负载平衡取决于数据流的统计分布,并且随着源目的地对的增加,它变得更加有效。

链路改变后的负载分担

当路由表更改将激活路径的数目调整到目的地时,Cisco 快速转发对在 show ip cef {prefix} internal 命令输出中看到负载平衡结构进行更新。然后,Cisco 快速转发会将新到达的数据包与邻接的对应 Hash Bucket 进行匹配。所选时段可能与以前使用的时段相同或不相同。

以下步骤描述了到目的地前缀的活动的路径数目更改之后,Cisco Express Forwarding 负载均衡信息如何更新。

  1. 假设目标前缀可通过两条路径到达。路径 1 处于非活动状态,路径 2 处于活动状态并承载所有流量。

  2. 当路径 1 重新变为可用时,会提示 Ip 路由再收敛进程。

  3. 现在,Cisco 快速转发将在这两条路径上均衡负荷而不会将现有流量保持在路径 2 上。否则将不会使用路径 1。换句话说,Cisco 快速转发不考虑在有效路径上为一次会话转发数据包,并且可以根据据它所选择的哈希桶,为数据流选择新的路径。

即将删除的负载分担信息

在更改路由表后,Cisco快速转发功能删除并重建向哈希桶分配有效路径的负载平衡结构。在重建进程期间,一些信息包可能丢失,show ip cef {prefix}内部命令则因为这个删除而显示负载共享信息。

router#show ip cef 10.10.128.0 int  10.10.128.0/28, version 63, per-destination sharing  0 packets, 0 bytes    via 10.8.0.31, 0 dependencies, recursive      next hop 10.8.2.49, POS0/0/0      valid adjacency    Load sharing information due for deletion 

当默认 0.0.0.0 路由的活动路径的数目发生改变时,通过 Cisco Bug ID CSCdm87127 实施的更改最大程度地减少数据包丢失。特别是,Cisco 快速转发现在可以为 FIB 条目分配最大空间的活动路径。

已知问题

Cisco 快速转发负载均衡在四条路径上并不相等。有关详细信息,请参阅 CSCdm87756 (仅限注册用户)。

在早于Cisco IOS12.0(16)S的版本中,输入show ip cef exact-route命令可能导致Cisco 12000系列互联网路由器或Cisco 7500/rsp系列路由器中的路由处理器(RP)重新加载。当目的地前缀递归,并且路由器开始共享下一跳的负载时,会发生这种情况。有关详细信息,请参阅 CSCdt80914 (仅限注册用户),其中解决了这一问题。

在 6500 系列平台 CEF 中,不支持基于数据包的负载均衡。这是由于硬件限制,目前只能使用基于目标的负载均衡。因此,唯一的选择就是使用分布式多链路点对点协议 (dMLPPP) 或第 4 层流负载共享。

Cisco 快速转发负载平衡的硬件支持

最初是使用基于软件的转发的平台支持 Cisco 快速转发的基于数据包的负载均衡。这类平台包括 2600、3600 和 7200 系列。在带 NSE-1 的 7200 系列和 10000 系列中,现在每个数据包负载平衡都由使用 PXF(Parallel Express Forwarding) 的硬件所支持。使用 Catalyst 6000 系列,MSFC2 上的 Cisco IOS Cisco 快速转发的 ip load-sharing per-packet、ip cef accounting per-prefix 和 ip cef accounting non-recursive 命令仅适用于 Cisco 快速转发在 MSFC2 上以软件交换的流量。命令不影响 PFC2 进行硬件第 3 层交换的数据流或者配备 DFC 的交换模块的数据流。有关详细信息,请参阅在 Supervisor 引擎 2 上配置 IP 单播第 3 层交换。

注意: 带有 NSE-100 处理器卡的 Cisco 7300 路由器不支持 PXF 中的 CEF 基于数据包的负载均衡。PXF 只支持基于目标的负载均衡。但看起来它们有技术支持,因为配置命令可以在路由器的 CLI 中提供。这个问题记录在 Cisco Bug ID CSCdx63389 中并进行了纠正。

在 12000 系列上,每个数据包负载平衡都可以提供给第三层的所有转发引擎(引擎 3 和 4 除外)使用。每个板卡都会做出独立的转发决定。要查看每个 IP 流的确切路由,请在使用基于硬件的 Cisco 快速转发表的线路卡上使用 exec slot X show ip hardware-cef exact-route src dst 命令。

0 0