The EtherChannel load-balancing method uses a Cisco-proprietary hashing algorithm. The algorithm computes values in the range of 0-7 that it assings to ports in the EtherChannel and uses these values as a basis to determine which port is used to forward particular traffic. The table below demonstrates how many values will be designated to each port, depending on the number of links in the EtherChannel:
The XOR operation is done on the last 3 bits of the source and destination address which would then correspond to a value of 0 – 7, which is in turn assigned to one of the ports in the channel. If you have 8 ports in the channel, then you get a 1 to 1 ratio of values assigned to ports. If you have less than 8 ports in the channel then you start to get ports with multiple values assigned.
For instance, if you have 4 ports in the channel, each port would be assigned 2 values. If you have 3 ports in the channel, you would get a 3-3-2 ratio.
I can give a brief explanation of the XOR operation. With XOR or exclusive-or, you take two binary numbers, perform a XOR, and get either a 1 or 0 depending on the binary values. Basically XOR will only give a 1 when you have binary values of 1 and 0 that the operation is being performed on.
So when comparing bit streams, in this case, last 3 of source and destination, when you have two 1s you get a 0, two 0s you get a 0, and 1 and 0 you get a 1.
Here is an example:
Source IP: 192.168.1.1
Dest IP : 192.168.1.2
Source last 3 in binary: 001
Dest last 3 in binary: 010
The switch does a bit-by-bit comparison, which corresponds, from left to right, to: 011. For a port value of 3.
Now lets say we have 2 ports in the channel, this would correspond to 4 values being assigned to each port. The first port would have values of 0,2,4,6 and the second port values of 1,3,5,7.
So with our value calculated above of 3, this traffic would flow over the 2nd port in the channel.
So the number of ports in the channel will determine the ratio of values assigned to each port. So with a 2 port channel, we will have 4 values assigned to each port, for a 4-4 ratio.
So lets call the 2 ports A and B. The values are assigned in order from port A to B, and then to A and B again. ( I don’t recall how Cisco chooses which port is A and B at the moment.) So A will be assigned 0, then B will be assigned 1, then A 2, and B 3, and so on and so forth, until no more values are remaining.
With a 3 port channel, you will have a 3-3-2 ratio of values assigned. So lets say we have ports A, B, and C. A will be assigned 0, B assigned 1, and C assigned 2, then A 3, B 4, C 5, A 6, B 7.
Here is a table:
The balancing is done based on flows, not based on packets. We will go back to this later on.
Etherchannel can have up to 8 ports, so number of links like 3, 5, 6 and 7 would never have equal distribution. Here is why and this is point where we are not able to influence:
#“test etherchannel load-balance interface port-channel 5 ip 126.96.36.199 188.8.131.52”
Computed RBH: 0x3
Would select Te2/2 of Po5
#show interfaces port-channel 5 etherchannel
Ports in the Port-channel:
Index Load Port EC state No of bits
0 55 Te2/1 Active 4
1 AA Te2/2 Active 4
We need to look at the bolded values (55 or AA). It is time for math. 55 is 0101 0101 in binary. It means that for interface te2/1 bits 0, 2, 4 and 6 are set. So RBH value of 0, 2, 4, and 6 belongs to te2/1. Our RBH value is 0x3, so the chosen port would be te2/2. Let’s check it out. AA is 1010 1010 in binary, so for te2/2 bits 1, 3, 5 and 7 are set, than RBH value of 1, 3, 5, and 7 belongs to port te2/2.
Note: That other platform has different has size. In Nexus line card,
M1 – 3bit and F1 – 8bit.
We have a maximum of 8 ports configured in a ether-channel / port-channel. for load balacing scenario you can refer the below mentioned table.
We can create multiple channel on different platform, Maximum channel will depend on the platform you’re using/
Etherchannel Loadbalancing on Catalyst Switches