CCNP SWITCH Etherchannel Course: Choosing The Link
In the first two installments of this free CCNP SWITCH course on Etherchannels, we covered the fundamentals of Etherchannel success and the correct commands to negotiate an Etherchannel with PaGP and LACP.
Right now, we’re going to take a very detailed look at how a Cisco switch decides which link of an Etherchannel to use for a particular traffic flow. We’re using the same two-switch network with four trunks between the two, using Fast 0/21, 0/22, 0/23, and 0/24 on each.
Etherchannels give us load balancing, but not pure load balancing. In our lab, we have four parallel links in the EC, but that doesn’t mean each link is carrying 25% of the load. Basically, a Cisco-proprietary hash algorithm is run that will deliver a value of 0 – 7, and those values are assigned to links in the EC. It’s these values that are used to determine which link will handle which traffic flow. (We’re dealing with per-flow balancing here, not per-packet or per-frame balancing.) That algorithm can use any of the following:
- Source IP address
- Destination IP address
- Both source and destination IP address
- Both source and destination MAC address
- TCP / UDP port numbers
The switch may use the hash of the last low-order bits to choose the link that will carry the traffic flow, or it may get the exclusive-OR operation (“XOR”) involved. The only time the XOR operation is used is when one of the combination load-balancing methods are used – the source and destination IP address, source and destination port number, or the source and destination MAC address. (You get the point.) For every method involving only one value, the hash of the bits reveals the port that will handle traffic for that particular flow.
The XOR operation’s name might look scary, but it’s one of the easiest math operations you’ll ever carry out. It’s a bit-by-bit comparison, with only two possible answers:
- If the compared bits are the same, the result is 0.
- If the compared bits are different, the result is 1.
That’s it! The number of bits needed for the XOR depends on how many links we have in the EC:
|Number of links in EC||# of lowest-order bits to XOR||Possible results|
Using our four-link EC, let’s figure out which link traffic would use that was sourced from 126.96.36.199 and destined for 188.8.131.52. If you want to break down the entire address for practice (ahem), that’s a great idea, but with a 4-link EC we only need the last two bits. The last octet of each address, with the two lowest-order bits highlighted:
11 = 00001011
22 = 00010110
We perform the XOR on a bit-by-bit basis, from left to right, so we’ll first XOR the 7th bit of each octet, 1 and 1. That gives us a “0” for the first bit of the XOR result. When we XOR the 8th bit of each octet, “1” and “0”, the return is a “1” for the XOR’s second and final bit. “01” converts to the decimal 1, so the switch will use the port assigned value “01” to send the data.
Let’s walk through another example, using a source IP address of 184.108.40.206 and a destination of 220.127.116.11. With our four-path EC, we need the last two bits of each address for our XOR.
11 = 00001011
15 = 00001111
Since both bits in the 7th position and both bits in the 8th position match up, we know our XOR return is “00”, resulting in the link assigned value 0 as the winner!
To change the load-balancing method for your switch, use port-channel load-balance and verify with show etherchannel load-balance. This is a global command – you can’t change the load balancing method on a per-port or per-EC level.
SW3(config)#port-channel load-balance ? dst-ip Dst IP Addr dst-mac Dst Mac Addr src-dst-ip Src XOR Dst IP Addr src-dst-mac Src XOR Dst Mac Addr src-ip Src IP Addr src-mac Src Mac Addr
The “XOR” choices balance on source and destination IP or source and destination MAC. Verify with show etherchannel load-balance.
SW3#show etherchannel load-balance EtherChannel Load-Balancing Configuration: dst-ip EtherChannel Load-Balancing Addresses Used Per-Protocol: Non-IP: Destination MAC address IPv4: Destination IP address IPv6: Destination IP address
Etherchannels are relatively easy to configure and verify, but can be a little tricky to troubleshoot. Coming up next, I’ll give you a comprehensive list of things to look for when you’re troubleshooting an Etherchannel.