# LDP and ECMP

Load **isis.cfg**

```
#IOS-XE
config replace flash:isis.cfg

#IOS-XR
configure
load bootflash:isis.cfg
commit replace
y
```

ISIS is already pre-configured. Configure LDP on all routers using LDP IGP autoconfig.

Notice that R2 has ECMP routes in its RIB. How will R2 treat traffic sourced from 1.1.1.1 destined for 19.19.19.19 by default?

## Answer <a href="#id-19bc9259-1d81-4a2a-9705-608912514783" id="id-19bc9259-1d81-4a2a-9705-608912514783"></a>

```
#R1-R6
router isis
 mpls ldp autoconfig

#XR1
router isis 1
 add ipv4
  mpls ldp auto-config
!
mpls ldp
```

## Explanation <a href="#id-7091f787-8a6b-4ae8-9458-c1a324f76062" id="id-7091f787-8a6b-4ae8-9458-c1a324f76062"></a>

LDP follows the IGP. So if there are ECMP paths in the IGP, both label bindings are installed in the LFIB.

We can check this by inspecting the LFIB entry for 19.19.19.19/32 on R2:

<div align="left"><figure><img src="https://3072390383-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FkUz2C3GqnZcWhoVL6jfk%2Fuploads%2FD5Ee7zu3zLUsJ2ErHWJI%2Fimage.png?alt=media&#x26;token=d251a8a5-79a5-4acd-bc82-76c2a3f2960e" alt=""><figcaption></figcaption></figure></div>

It just so happens that both R3 and R4 allocated the label 23 for 19.19.19.19/32.

We can verify which path will be used for traffic sourced from R1 using the following command:

<div align="left"><figure><img src="https://3072390383-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FkUz2C3GqnZcWhoVL6jfk%2Fuploads%2F5QbTHry4NECxlPGoaOCW%2Fimage.png?alt=media&#x26;token=91f624c7-bfc6-4528-bf75-b6ff6e5307bd" alt=""><figcaption></figcaption></figure></div>

By default, the CEF load-sharing algorithm is **universal**, which only uses L3 information, but uses a hash so that each router makes a different hashing calculation. So when we traceroute from R1, we should see that all traffic is forwarded out Gi2.23 only.

<div align="left"><figure><img src="https://3072390383-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FkUz2C3GqnZcWhoVL6jfk%2Fuploads%2FzS45evAavkueHAMvAooQ%2Fimage.png?alt=media&#x26;token=dadf3bc5-fdb2-40b4-9154-3a3923ce4dcb" alt=""><figcaption></figcaption></figure></div>

If we want, we can change the CEF load-sharing algorithm to include L4 flow information into the hash. This produces a different hop for each traceroute probe due to the different L4 port.

```
#R2
ip cef load-sharing algorithm include-ports source destination
```

<div align="left"><figure><img src="https://3072390383-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FkUz2C3GqnZcWhoVL6jfk%2Fuploads%2FIdDwQg7D0tW2qJzz3rDO%2Fimage.png?alt=media&#x26;token=1cd7789a-0f29-43a9-8ebd-34c0c4c6ddbd" alt=""><figcaption></figcaption></figure></div>
