Wednesday, 7 March 2018

ETHERCHANNEL

How etherchannel algorithm actually works ?

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,
  1. Traffic is not distributed properly through each link in etherchannel across the network.
  2. 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?
  3. 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.

router receives packet

Router Packet explained

What happened, when router receives packet?


what_happen.jpg

Upon receiving the Packet, router has to follow three generic steps before its routes the packets:
-> Routing
-> Forwarding (Switching)
-> Encapsulation
Let’s discuss each one of them in detail
Routing Process: Routing process is nothing but routers control plane. Router records a routing table listing what route should be used to forward a data packet, and through which physical interface connection. Router learns your network routes information either by static configuration or by using dynamically configure routing protocol like IGP (OSPF, EIGRP, RIP, IS-IS) or though Exterior routing protocol like BGP.
When router receives any packet it has to remove Layer 2 header information present on packet(Example:In Ethernet, source and destination Mac address present on L2 header). Once router remove L2 information it looks for Layer 3 information available on packet that is source and destination IP address.
For moving L3 packet between interfaces, router checks destination address and finds longest-prefix match in IP routing table to find outgoing interface. In IPv4 router uses longest mask to identify best routing entry for forwarding packet.
Example: Let’s assume we have configured 3 different static routes with different subnet mask.
Sh ip route 1.1.1.1
ip route 1.1.1.0 255.255.255.0 fa0/2
ip route 1.1.0.0 255.255.0.0 fa0/1
ip route 1.0.0.0 255.0.0.0 fa0/0
In above example when router does route lookup for destination address 1.1.1.1 out of 3 entries router will choose longest-prefix length match entry i.e. 1.1.1.0/24 , because destination address has most common bits matches with selected route and will forward packet out fa0/2.
Destination prefixBinary Splitting
1.1.1.100000001 00000001 00000001 00000001
1St Entry 1.1.1.0/2400000001 00000001 00000001 00000000
2nd Entry 1.1.0.0/1600000001 00000001 00000000 00000000
3rd Entry 1.0.0.0/800000001 00000000 00000000 00000000


Now for any other destination prefix like 1.1.2.0 longest match is 1.1.0.0/16 and for 1.2.0.0 it would be 1.0.0.0/8
Longest match possible in IPv4 routing is /32 (255.255.255.255) and shortest match possible is default route i.e. 0.0.0.0
->If there are multiple routes with same subnet mask learned via same protocol by router then router chooses lowest metric between them.

For Example: Eigrp use composite “metric” and Ospf uses “Cost” for comparison.
->If there is multiple routes with same subnet mask learn via different protocol on router then router chooses lowest administrative distance (AD).
->Last and important point is recursive lookup: which states that whenever there is route lookup more than once it will be termed as recursive lookup. It has to be done by router till destination address point towards any physical or logical interface.
Example:


We have a network 1.1.1.1 connected somewhere and we are reaching it by interface fa0/0 having next-hop IP address 2.2.2.2.So we can configure static route in two different ways either we can define next-hop IP address i.e.2.2.2.2 or we can mention interface number fa0/0 as gateway shown below.

ip route 1.1.1.1 255.255.255.255 2.2.2.2
ip route 1.1.1.1 255.255.255.255 FastEthernet0/0
Both statements look same although both have different meaning.When you point destination address to next hop as exit interface you don’t need further route lookup as router assume destination address is directly connected to that interface. But when you point destination address to any next hop ip address, we need another route lookup also for next hop ip address is referring as recursive lookup.
To get more information on how static route work when you set gateway as Next-Hop IP address or to Next-Hop interface please refer this document
Forwarding process: It is also known as switching process. Once router finds outgoing interface, packet move between interfaces by switching process. This is done by process switching, fast switching or cef switching. Forwarding can be done by using adjacency tables reside on the route processor or on interface cards that support switching.
-> Process switching requires the device CPU to be involved for every forwarding decision.
-> Fast switching still uses the CPU for initially packets and to fill cache table in router. Once initial packet has been forwarded, the information about how to reach the destination is stored in a fast-switching cache’s .when another packet going to the same destination, the next hop information can be re-used from the cache and so the router processor doesn’t have to look into it, but if the information is not cached the CPU will have to process entire packets.
-> When CEF mode is enabled it build the CEF FIB and adjacency tables reside on the route processor, and the route processor performs the express forwarding.
In switching process device do actual packet link load balancing depending on the methodology we use.
Encapsulation process: L3 header will remain intact unchanged except for nating, vpn etc. layer 2 headers keep changing on hop by hop basis, depending on transmission media. For transmitting L3 packet on wire router need to find out l2 information for packets and it’s depending on the type of media we are using for transmission.

To explain encapsulation process in bit detail, I have created a small topology shown as below in diagram.

rou1.jpg
As discussed above, depending on the transmission media (In this example transmission media is Ethernet) MAC address in layer 2 headers will keep changing on hop by hop basis.
To generate some traffic, Lets ping from R3 to R2 interface address.As soon as R1 receives the packet from R3, It will remove the L2 information sent by R3 and check the L3 information that is source (20.1.1.2) and destination address (10.1.1.1) available on packet. Then it will look into its routing table to find out going interface i.e. fa0/0 in above example. Once router identify outgoing interface it will attach L2 header before putting the packet on the wire. So now R1 will attach its own interface Mac address as source and R2’s as destination mac address.

Banner MOTD Banner Exec Banner Login

Login:
banner login ^
******************************************************************************
* WARNING !!!                                                                *
* This system is for the use of authorized users only.                       *
*                                                                            *
* Individuals using this network without authority, or in excess of their    *
* authority, are subject to legal action.                                   *
*                                                                  
******************************************************************************
^
Exec:
banner exec ^
Current switch configuration is Version1, any changes to this version will need to be updated.
The '^' symbols are your pattern breaks. If you have a "^" in your message, IOS will think that you want to stop the message there, so you need to use something that's not in your message.