In this section I would like to highlight on very basic topic "How etherchannel hash algorithm works". In day-to-day networking life some common issues that we face with etherchannel is,
- Traffic is not distributed properly through each link in etherchannel across the network.
- One port mostly, like an example, gi8/11 is being selected mostly for every traffic during peak hours. Why Gi8/11 is highly utilized and others have normal utilization?
- How to change algorithm so that it select ports based on traffic pattern?
Let me start with basic fundamental: How etherchannel algorithm actually works ?
On most of the CISCO switches platform, default ether-channel load-balance algorithm is "XOR source and destination IP " to do the load-balance. The load-balancing is purely based on hashing provided by the hardware, which is in turn based on flows. You can essentially end up with a load balance setup that never changes links depending on your configured flows. You can choose whether to hash on Source or Destination Layer2 (MAC), Layer3(IP Address), or Layer4(Ports) flow information, but hash algorithm cannot be configured or changed to load balance the traffic among the ports in an Etherchannel.
Typically, you will need to play with your Source and Destination settings to find which settings used with your traffic flows creates the best load balance.
The Cisco-proprietary hash algorithm computes a value in the 0-7 range. With this value as a basis, a particular port in the Etherchannel is chosen. The port setup includes a mask which indicates which values the port accepts for transmission. With the maximum number of eight ports in a single Etherchannel, each port accepts only one value. If the Etherchannel has four ports, each port accepts two values, and so on.
Note: The hash algorithm cannot be configured or changed to load balance the traffic among the ports in an Etherchannel.
Assuming the default configuration, a flow is the source IP destination IP pair. Regardless of what the traffic is, that source destination pair will always use the same physical path. As an example,
If you have “http and ftp to/from the same source/destination IP, it will always use the same physical link. If a source destination pair is idle for a time, it will still use the same physical path since it always hashes with the same result. For instance, there is a very high value of replication traffic between several servers. You have 3 flows generating 50 mbps and 10 flows generating 1mbps. From what, it's entirely possible that the 3 largeflows could end up on the same physical link which means that you will have one circuit running at 50mbps and the other at 1mpbs.
So if in traffic capture, if it shows the traffic patterns are mainly in UDP with some of identical source and destination IP address pairs. Since most of traffic patterns are UDP with different port number during the peak hour, the better way to load balance the traffic is either to use source-port or destination-port hash algorithm depends on the traffic path. Again, this will not guarantee the traffic load balance to 50/50.
EXAMPLE :
----------------
Let's take a live example,
I have 4 port etherchannel configured on my switch,
Gi7/11
Gi7/12
Gi8/11
Gi8/12
Sw1#sh ether summ
Flags: D - down P - bundled in port-channel
------+-------------+-----------+-----------------------------------------------
1 Po1(SU) LACP Gi7/11(P) Gi7/12(P) Gi8/11(P) Gi8/12(P)
Let's pick up some traffic flow for particular Source and Destination IP and have a look which link it selects ,
SW1#test etherchannel load-balance interface port-channel 1 ip 203.116.22.16 203.116.42.149
Computed RBH: 0x6
Would select Gi8/11 of Po1
SW1#test etherchannel load-balance interface port-channel 1 ip 203.116.22.90 203.116.42.149
Computed RBH: 0x6
Would select Gi8/11 of Po1
SW1#test etherchannel load-balance interface port-channel 1 ip 203.116.22.17 203.116.42.149
Computed RBH: 0x7
Would select Gi8/12 of Po1
SW1#test etherchannel load-balance interface port-channel 1 ip 203.116.22.91 203.116.42.149
Computed RBH: 0x7
Would select Gi8/12 of Po1
SW1#test etherchannel load-balance interface port-channel 1 ip 203.116.22.18 203.116.42.149
Computed RBH: 0x4
Would select Gi7/11 of Po1
SW1#test etherchannel load-balance interface port-channel 1 ip 203.116.22.19 203.116.42.149
Computed RBH: 0x5
Would select Gi7/12 of Po1
SW1#test etherchannel load-balance interface port-channel 1 ip 203.116.22.92 203.116.42.149
Computed RBH: 0x0
Would select Gi7/11 of Po1
SW1#test etherchannel load-balance interface port-channel 1 ip 203.116.22.93 203.116.42.149
Computed RBH: 0x1
Would select Gi7/12 of Po1
SW1#test etherchannel load-balance interface port-channel 1 ip 203.116.22.20 203.116.42.149
Computed RBH: 0x2
Would select Gi8/11 of Po1
SW1#test etherchannel load-balance interface port-channel 1 ip 203.116.22.94 203.116.42.149
Computed RBH: 0x2
Would select Gi8/11 of Po1
SW1#test etherchannel load-balance interface port-channel 1 ip 203.116.22.21 203.116.42.149
Computed RBH: 0x3
Would select Gi8/12 of Po1
SW1#test etherchannel load-balance interface port-channel 1 ip 203.116.22.95 203.116.42.149
Computed RBH: 0x3
Would select Gi8/12 of Po1
SW1#test etherchannel load-balance interface port-channel 1 ip 203.116.22.22 203.116.42.149
Computed RBH: 0x0
Would select Gi7/11 of Po1
SW1#test etherchannel load-balance interface port-channel 1 ip 203.116.22.96 203.116.42.149
Computed RBH: 0x5
Would select Gi7/12 of Po1
SW1#test etherchannel load-balance interface port-channel 1 ip 203.116.22.23 203.116.42.149
Computed RBH: 0x1
Would select Gi7/12 of Po1
SW1#test etherchannel load-balance interface port-channel 1 ip 203.116.22.97 203.116.42.149
Computed RBH: 0x4
Would select Gi7/11 of Po1
Here we do see the traffic is going with round robin which was expected. However, we do see the links of G7/11 and G8/11 were utilized more than the other 2 links. This is highly likely caused by same pair of IP address, source and destination. Same pair of source and destination IP will always use the same link since the load balance hash algorithm calculation will always be the same.
Computed RBH: 0x0 Would select G7/11 of Po 1
Computed RBH: 0x1 Would select G7/12 of Po 1
Computed RBH: 0x2 Would select G8/11 of Po 1
Computed RBH: 0x3 Would select G8/12 of Po 1
Computed RBH: 0x4 Would select G7/11 of Po 1
Computed RBH: 0x5 Would select G7/12 of Po 1
Computed RBH: 0x6 Would select G8/11 of Po 1
Computed RBH: 0x7 Would select G8/12 of Po 1
BEST PRACTICES :
---------------------------
We should follow below steps to ensure that etherchannel works best in all conditions,
1. Try to put even number of links in ether-channel and monitor the throughput of link.
Explanation:
If the number of physical port is not equal to power of 2 (not 2, 4 or 8), you will have unequal load-balance as well. For example, pick a case,
Under port-channel X, we have 3 interfaces being bundled gi8/8, gi9/8 and gi9/12. The load balance algorithm will need to use two bits from the hash.
Two bit will give 4 different patterns (00, 01, 10, and 11) and the patterns are assigned to the physical port. Therefore, the overall traffic is not 33% on each channel. It will be 50% on one and 25% on the other two links.
2. Please monitor the link utility during peak hours and note down the data. Based on traffic pattern in your network , you can change ether-channel load-balance algorithm to "src-dst mac" or "srd-dst ip" or “src-dst port” etc. "src-dst mac" works best in most of the cases in network
I hope it could help a bit in your understanding of operation of ether-channel.
Enjoy browsing CSC blogs folks