Load Balancing in CEF
CEF allows for load balancing or load sharing of traffic among multiple outgoing links. CEF needs multiple outgoing links as next hops in the routing table to perform load balancing. The command maximum-paths specifies how many paths or next hops are allowed per prefix in the routing table for the specific routing protocol. For instance, if you configure maximum-path 2 under the routing protocol Open Shortest Path First (OSPF), only two OSPF paths per prefix are allowed in the routing table. Those two paths are then shown in the CEF table as outgoing paths.
In CEF, the two main load balancing schemes are per-packet or per-destination. If you configure the per-packet load balancing scheme, the load balancing of all packets is round-robin packet per packet on the outgoing links. The per-packet load balancing is configured with the interface command ip load-sharing per-packet. You need to configure this command on all the outbound interfaces if you want to configure per-packet CEF load balancing.
The default CEF load balancing scheme is per-destination. This terminology is a bit misleading, though, because the CEF per-destination load balancing is done by hashing the destination and source IP address. In contrast, the per-destination load balancing that fast switching does is strictly by looking at the destination IP address. Per-destination load sharing is the default load sharing scheme for CEF. It is the default load sharing method for CEF because the per-packet load sharing scheme can send consecutive packets of the same flow (this means the same source/destination IP address pair) across different paths and hence might lead to a reordering problem of the IP packets at the destination. This can lead to problems for traffic such as VoIP because a performance hit or quality degradation can occur if the packets arrive out of sequence, as packets might be considered lost. In addition, it adds jitter.
Per-packet load sharing, however, gives a perfect load sharing distribution on the outgoing paths, whereas the per-destination load sharing is only a statistical method of distributing flows per pairs of (source IP address, destination IP address). Therefore, the load sharing of traffic with the perdestination method can only give a good result (a good distribution among all possible outgoing links) if enough different pairs of source and destination addresses make up the traffic toward the different destinations that are outbound on the outgoing links. Even then, if some flows are present, with considerably more traffic on than some others, which are on one path, the distribution might still be uneven. Look at Example 6-6 to see how to change the CEF load balancing scheme.
Example 6-6 Per-Destination Versus Per-Packet CEF Load Sharing Example paris#show cef interface ethernet 1/2 Ethernet1/2 is up (if_number 5)
Corresponding hwidb fast_if_number 5 Corresponding hwidb firstsw->if_number 5 Internet address is 10.200.201.1/24 ICMP redirects are always sent Per packet load-sharing is disabled IP unicast RPF check is disabled paris#conf t
Enter configuration commands, one per line. End with CNTL/Z.
paris(config)#int et 1/2
paris(config-if)#ip load-sharing per-packet paris(config-if)#~Z
paris#
paris#show cef interface ethernet 1/2
Ethernet1/2 is up (if_number 5)
Corresponding hwidb fast_if_number 5 Corresponding hwidb firstsw->if_number 5 Internet address is 10.200.201.1/24 ICMP redirects are always sent Per packet load-sharing is enabled IP unicast RPF check is disabled
NOTE To restore the CEF default load balancing mode (per-destination load balancing), configure the command ip load-sharing per-destination.
Cisco IOS can load-balance in CEF by hashing the source and destination IP address and pointing the result of that hash to a load sharing table. This table holds 16 hash buckets. Each of the 16 hash buckets points to one adjacency, and multiple buckets can point to the same adjacency. Example 6-7 shows that you can verify the hash buckets for the per-destination load sharing scheme with the show ip cef [network [mask]] internal command.
Example 6-7 CEF Load Balancing Example paris#show ip cef 10.200.254.4 detail
10.200.254.4/32, epoch 0, per-destination sharing nexthop 10.200.201.2 Ethernet1/2 nexthop 10.200.203.2 Ethernet1/3
paris#show ip cef 10.200.254.4 internal
10.200.254.4/32, version 26, epoch 0, RIB, refcount 5, per-destination sharing sources: RIB
output chain:
loadinfo 6327D930, per-session, flags 0003, 6 locks flags: Per-session, for-rx-IPv4
|
16 hash |
buckets |
|||||||||||
|
<0 |
> |
IP |
adj |
out |
of |
Ethernet1/2, |
addr |
10 |
.200 |
201 |
2 |
6346B8C0 |
|
<1 |
> |
IP |
adj |
out |
of |
Ethernet1/3, |
addr |
10 |
.200 |
203 |
2 |
6346C640 |
|
<2 |
> |
IP |
adj |
out |
of |
Ethernet1/2, |
addr |
10 |
.200 |
201 |
2 |
6346B8C0 |
|
<3 |
> |
IP |
adj |
out |
of |
Ethernet1/3, |
addr |
10 |
.200 |
203 |
2 |
6346C640 |
|
<4 |
> |
IP |
adj |
out |
of |
Ethernet1/2, |
addr |
10 |
.200 |
201 |
2 |
6346B8C0 |
|
<5 |
> |
IP |
adj |
out |
of |
Ethernet1/3, |
addr |
10 |
.200 |
203 |
2 |
6346C640 |
|
<6 |
> |
IP |
adj |
out |
of |
Ethernet1/2, |
addr |
10 |
.200 |
201 |
2 |
6346B8C0 |
|
<7 |
> |
IP |
adj |
out |
of |
Ethernet1/3, |
addr |
10 |
.200 |
203 |
2 |
6346C640 |
|
<8 |
> |
IP |
adj |
out |
of |
Ethernet1/2, |
addr |
10 |
.200 |
201 |
2 |
6346B8C0 |
|
<9 |
> |
IP |
adj |
out |
of |
Ethernet1/3, |
addr |
10 |
.200 |
203 |
2 |
6346C640 |
|
<10 |
> |
IP |
adj |
out |
of |
Ethernet1/2, |
addr |
10 |
.200 |
201 |
2 |
6346B8C0 |
|
<11 |
> |
IP |
adj |
out |
of |
Ethernet1/3, |
addr |
10 |
.200 |
203 |
2 |
6346C640 |
|
<12 |
> |
IP |
adj |
out |
of |
Ethernet1/2, |
addr |
10 |
.200 |
201 |
2 |
6346B8C0 |
|
<13 |
> |
IP |
adj |
out |
of |
Ethernet1/3, |
addr |
10 |
.200 |
203 |
2 |
6346C640 |
|
<14 |
> |
IP |
adj |
out |
of |
Ethernet1/2, |
addr |
10 |
.200 |
201 |
2 |
6346B8C0 |
|
<15 |
> |
IP |
adj |
out |
of |
Ethernet1/3, |
addr |
10 |
.200 |
203 |
2 |
6346C640 |
Unequal Cost Load Balancing 159
To verify which outgoing interface a particular flow of traffic is taking in the case of perdestination load sharing, use the command show ip cef exact-route source-address destination-address. Example 6-7 shows that prefix 10.200.254.4/32 has two outgoing interfaces in the CEF table: Ethernet 1/2 and Ethernet1/3. Example 6-8 shows that the outgoing interface is Ethernet 1/ 2 for traffic destined for that IP address 10.200.254.4 and with a source IP address of 10.200.254.1.
Example 6-8 show ip cef exact-route Example paris#show ip cef exact-route 10.200.254.1 10.200.254.4
10.200.254.1 -> 10.200.254.4 => IP adj out of Ethernet1/2, addr 10.200.201.2 paris#show ip cef exact-route 10.200.1.2 10.200.254.4
10.200.1.2 -> 10.200.254.4 => IP adj out of Ethernet1/3, addr 10.200.203.2
As you can see in Example 6-8, the traffic that is destined to the same destination IP address can take a different output interface if the source IP address is different.
Sixteen hash buckets exist. These hash buckets distribute the load of traffic among all possible outgoing paths in the best possible way. For example, in the case of two outgoing paths, eight hash buckets are assigned to each outgoing path. In the case of three outgoing paths, five hash buckets are assigned to each outgoing path, and one hash bucket is unassigned. In short, if 16 is not divisible by the number of paths, the remainder hash buckets are not used and are disabled.
Continue reading here: Troubleshooting CEF
Was this article helpful?