Wednesday, March 14, 2012

Load Balancing & CEF

How to verify the load balancing method you’re using. Very basic and simple, CEF is a huge topic.

Load balancing describes functionality in a router that distributes packets across multiple links based on layer 3 routing information. If a router discovers multiple paths to a destination, the routing table is updated with multiple entries for that destination.

1. Check the routing table to make sure your dynamic routing protocol has the same metric for the destination network via the different paths. In our case, it does.


Cisco-4900M#show ip route 192.168.179.193
Routing entry for 192.168.179.193/32
  Known via "ospf 4567", distance 110, metric 3, type inter area
  Last update from 192.168.222.93 on TenGigabitEthernet1/3, 2w5d ago
  Routing Descriptor Blocks:
 
* 192.168.222.109, from 192.168.179.112, 2w5d ago, via TenGigabitEthernet1/4
      Route metric is 3, traffic share count is 1
    192.168.222.93, from 192.168.179.111, 2w5d ago, via TenGigabitEthernet1/3
      Route metric is 3, traffic share count is 1

There is also an asterisk (*) next to one of the block entries. This corresponds to the active route that is used for new traffic. The term 'new traffic' corresponds to a single packet or an entire flow to a destination, depending on the type of switching configured.

Source: http://www.cisco.com/en/US/tech/tk365/technologies_tech_note09186a0080094820.shtml

2. Verify If CEF is enabled on the interfaces. It's enabled by default on all newer Cisco devices. In our case it’s enabled  and its indicated below in red.

Cisco-4900M#show cef interface tenGigabitEthernet 1/3
TenGigabitEthernet1/3 is up (if_number 64)
  Corresponding hwidb fast_if_number 64
  Corresponding hwidb firstsw->if_number 64
  Internet address is 192.168.222.92/31
  ICMP redirects are never sent
  IP unicast RPF check is disabled
  Inbound access list is not set
  Outbound access list is not set
  IP policy routing is disabled
  BGP based policy accounting on input is disabled
  BGP based policy accounting on output is disabled
  Hardware idb is TenGigabitEthernet1/3
  Fast switching type 1, interface type 155
  IP CEF switching enabled  IP CEF switching turbo vector
  IP Null turbo vector
  IP prefix lookup IPv4 mtrie 8-8-8-8 optimized
  Input fast flags 0x0, Output fast flags 0x0
  ifindex 63(63)
  Slot 1 Slot unit 3 VC -1
  Transmit limit accumulator 0x0 (0x0)
  IP MTU 9198

Cisco-4900M#show cef interface tenGigabitEthernet 1/4
TenGigabitEthernet1/4 is up (if_number 65)
  Corresponding hwidb fast_if_number 65
  Corresponding hwidb firstsw->if_number 65
  Internet address is 192.168.222.108/31
  ICMP redirects are never sent
  IP unicast RPF check is disabled
  Inbound access list is not set
  Outbound access list is not set
  IP policy routing is disabled
  BGP based policy accounting on input is disabled
  BGP based policy accounting on output is disabled
  Hardware idb is TenGigabitEthernet1/4
  Fast switching type 1, interface type 155
  IP CEF switching enabled  IP CEF switching turbo vector
  IP Null turbo vector
  IP prefix lookup IPv4 mtrie 8-8-8-8 optimized
  Input fast flags 0x0, Output fast flags 0x0
  ifindex 64(64)
  Slot 1 Slot unit 4 VC -1
  Transmit limit accumulator 0x0 (0x0)
  IP MTU 9198

Cisco-4900M#show ip cef 192.168.179.193
192.168.179.193/32
  nexthop 192.168.222.93 TenGigabitEthernet1/3
  nexthop 192.168.222.109 TenGigabitEthernet1/4

3. Verifying the load balancing method. In our scenario, we are using per-destination load balancing, indicated below in red.

Cisco-4900M#show ip cef 192.168.179.193 internal
192.168.179.193/32, epoch 1, RIB[I], refcount 6, per-destination sharing  sources: RIB
  feature space:
   Broker: linked
  ifnums:
   TenGigabitEthernet1/3(64): 192.168.222.93
   TenGigabitEthernet1/4(65): 192.168.222.109
  path 2031A37C, path list 20311034, share 1/1, type attached nexthop, for IPv4
  nexthop 192.168.222.93 TenGigabitEthernet1/3, adjacency IP adj out of TenGigabitEthernet1/3, addr 192.168.222.93 206DE9E0
  path 2031A3F0, path list 20311034, share 1/1, type attached nexthop, for IPv4
  nexthop 192.168.222.109 TenGigabitEthernet1/4, adjacency IP adj out of TenGigabitEthernet1/4, addr 192.168.222.109 206DE860
  output chain:
    loadinfo 202FD5C0, per-session, 2 choices, flags 0003, 34 locks
    flags: Per-session, for-rx-IPv4
    16 hash buckets (hardware has 8 hash buckets)
      < 0 > IP adj out of TenGigabitEthernet1/3, addr 192.168.222.93 206DE9E0
      < 1 > IP adj out of TenGigabitEthernet1/4, addr 192.168.222.109 206DE860
      < 2 > IP adj out of TenGigabitEthernet1/3, addr 192.168.222.93 206DE9E0
      < 3 > IP adj out of TenGigabitEthernet1/4, addr 192.168.222.109 206DE860
      < 4 > IP adj out of TenGigabitEthernet1/3, addr 192.168.222.93 206DE9E0
      < 5 > IP adj out of TenGigabitEthernet1/4, addr 192.168.222.109 206DE860
      < 6 > IP adj out of TenGigabitEthernet1/3, addr 192.168.222.93 206DE9E0
      < 7 > IP adj out of TenGigabitEthernet1/4, addr 192.168.222.109 206DE860
      < 8 > IP adj out of TenGigabitEthernet1/3, addr 192.168.222.93 206DE9E0
      < 9 > IP adj out of TenGigabitEthernet1/4, addr 192.168.222.109 206DE860
      <10 > IP adj out of TenGigabitEthernet1/3, addr 192.168.222.93 206DE9E0
      <11 > IP adj out of TenGigabitEthernet1/4, addr 192.168.222.109 206DE860
      <12 > IP adj out of TenGigabitEthernet1/3, addr 192.168.222.93 206DE9E0
      <13 > IP adj out of TenGigabitEthernet1/4, addr 192.168.222.109 206DE860
      <14 > IP adj out of TenGigabitEthernet1/3, addr 192.168.222.93 206DE9E0
      <15 > IP adj out of TenGigabitEthernet1/4, addr 192.168.222.109 206DE860
    Subblocks:
     None

You can also issue the below command if you don’t care about seeing the hashing algorithm currently in use and other misc details.

Cisco-4900M#show ip cef 192.168.179.193 detail
192.168.179.193/32, epoch 1, per-destination sharing
  nexthop 192.168.222.93 TenGigabitEthernet1/3
  nexthop 192.168.222.109 TenGigabitEthernet1/4

You can set load-balancing to work per-destination or per-packet. Per-destination load balancing means the router distributes the packets based on the destination address. Given two paths to the same network, all packets for destination1 on that network go over the first path, all packets for destination2 on that network go over the second path, and so on. This preserves packet order, with potential unequal usage of the links. If one host receives the majority of the traffic all packets use one link, which leaves bandwidth on other links unused. A larger number of destination addresses leads to more equally used links. To achieve more equally used links use IOS software to build a route-cache entry for every destination address, instead of every destination network, as is the case when only a single path exists. Therefore traffic for different hosts on the same destination network can use different paths. The downside of this approach is that for core backbone routers carrying traffic for thousands of destination hosts, memory and processing requirements for maintaining the cache become very demanding.


You want to avoid per-packet if you are using VOIP in your network as packets can arrive out of order. Per packet works good with there is only one server ont he other side of the link.

To change the load balancing method, under the interface issue the following commands.

ip load-sharing per-packet
ip load-sharing per-destination

Note, per packet is not always an option on some devices.


 If you want to learn more about load-balancing and cef, visit the below links.


No comments:

Post a Comment