ECMP – Example of ECMP Using Hashing Technique

ciscoecmpospfrouterrouting

Can someone provide me an example of how Equal-cost multi-path routing uses hashing to decided which packet goes to which? I apologize for that but all I found online are just a definition of ECMP.

Best Answer

ECMP takes place when multiple output (equal-cost) paths are available for forwarding packets to the same network destination.

The hash function must map information from the incoming packet to the output interface.

For example, let me make up an illustrative overly simple hashing function for this:

1) Picture every output interface with an ifIndex like this:

  • Fa0: ifIndex 1
  • Fa1: ifIndex 2
  • Fa2: ifIndex 3

Number of interfaces: 3

2) Given the destination IP address A.B.C.D, take the least significant byte D.

Example: IP = 1.0.0.5, D = 5

3) Divide the value of D by the number of interfaces, take the remainder, then and add one to it.

D = 5
Number of interfaces = 3
Remainder plus 1: 5 % 3 + 1 = 3

4) Use the result as ifIndex and throw the packet at its interface.

Example: For IP 1.0.0.5, write the packet to output interface Fa2 (ifIndex=3).