# CSPF Tiebreakers

Load **mpls.te.base.config.with.ospf.cfg**

```
#IOS-XE
config replace flash:mpls.te.base.config.with.ospf.cfg

#IOS-XR
configure
load bootflash:mpls.te.base.config.with.ospf.cfg
commit replace
y
```



Configure two separate TE tunnels from R8 to XR11, and two separate TE tunnels from XR11 to R8.

* Each tunnel should reserve 200M of bandwidth.
* The only path-option should be dynamic.
* Find a way to ensure that the R8 → XR11 tunnels take the same path, and the XR11 → R8 tunnels take the same path. Do not manipulate TE/IGP cost in the network.



















































## Answer <a href="#fe98c550-4779-4838-b09a-52502c479c07" id="fe98c550-4779-4838-b09a-52502c479c07"></a>

```
#R8
mpls traffic-eng path-selection tiebreaker max-fill
!
int tun1
 description R8_TO_XR11_PATH1
 tun destination 11.11.11.11
 ip unn lo0
 tunnel mode mpls traffic-eng
 tunnel mpls traffic-eng path-option 1 dynamic
 tunnel mpls traffic-eng bandwidth 200000
!
int tun2
 description R8_TO_XR11_PATH2
 tun destination 11.11.11.11
 ip unn lo0
 tunnel mode mpls traffic-eng
 tunnel mpls traffic-eng path-option 1 dynamic
 tunnel mpls traffic-eng bandwidth 200000

#XR11
mpls traffic-eng
 path-selection
  tiebreaker max-fill
!
int tunnel-te1
 description XR11_TO_R8_PATH1
 destination 8.8.8.8
 ip unn lo0
 path-option 1 dynamic
 signalled-bandwidth 200000
!
int tunnel-te2
 description XR11_TO_R8_PATH2
 destination 8.8.8.8
 ip unn lo0
 path-option 1 dynamic
 signalled-bandwidth 200000
```



## Explanation <a href="#id-11acf9ce-df9c-45fa-b1ba-221214248e55" id="id-11acf9ce-df9c-45fa-b1ba-221214248e55"></a>

CSPF must always choose one single path. ECMP is never an option. When ECMP routes are found by CSPF, the following tiebreaker takes place:

* Choose the path that has the least used bandwidth. This will balance TE tunnels among paths as each new TE tunnel is setup.
* If there is still a tie, choose the path with the least number of hops.
* If there is still a tie, choose a path at random.



We can control the first tiebreaker with the following command:

```
#IOS-XE
mpls traffic-eng path-selection tiebreaker max-fill|min-fill|random
!
! OR
!
int tun1
 tunnel mpls traffic-eng path-selection tiebreaker max-fill|min-fill|random

#IOS-XR
mpls traffic-eng
 path-selection
  tiebreaker max-fill|min-fill|random
!
! OR
!
interface tunnel-te1
 path-selection
  tiebreaker max-fill|min-fill|random
```



The default is **min-fill**. By using **max-fill**, we instead choose the path that has the _most_ used bandwidth. This will end up filling up a path with TE tunnels first, loading one path completely until putting new TE tunnels on a second path.



By using **random**, we bypass the bandwidth evaluation completely, not caring about how much available bandwidth is on the ECMP paths, and instead just always choosing one path at random.



To solve this lab, we can set the path-selection to use **max-fill**. This will cause all LSPs to always take the same path, if that path has enough bandwidth, because the router is trying to load a single path as much as possible before using alternate ECMP paths.



## Verification <a href="#aaefb4ea-8129-4818-8954-72b126667ea2" id="aaefb4ea-8129-4818-8954-72b126667ea2"></a>

First, before changing the default path-selection, we setup the two TE tunnels one-by-one on R8. First tun1 is setup.

```
#R8
int tun1
 description R8_TO_XR11_PATH1
 tun destination 11.11.11.11
 ip unn lo0
 tunnel mode mpls traffic-eng
 tunnel mpls traffic-eng path-option 1 dynamic
 tunnel mpls traffic-eng bandwidth 200000
```



This tunnel was setup with the path: R8-R9-XR12-XR11

<div align="left"><figure><img src="https://3072390383-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FkUz2C3GqnZcWhoVL6jfk%2Fuploads%2FU7N0aR52Xpbi4Pcnfecv%2Fimage.png?alt=media&#x26;token=848bd9b1-5eef-4ee3-ad8f-f06bfea3e6b3" alt=""><figcaption></figcaption></figure></div>



We’ll now setup tunnel2. By default, it should use a path with the least-filled bandwidth, so it should not go over R9 and XR12.

```
#R8
int tun2
 description R8_TO_XR11_PATH2
 tun destination 11.11.11.11
 ip unn lo0
 tunnel mode mpls traffic-eng
 tunnel mpls traffic-eng path-option 1 dynamic
 tunnel mpls traffic-eng bandwidth 200000
```



This second tunnel is setup over the path: R8-R6-R10-XR11. The reason is that R8 has two ECMP paths to XR11. The R9-XR12 path already has reserved bandwidth (200M), so 800M is available. The R6-R10 has 1000M available, so that path has the min-fill bandwidth.

<div align="left"><figure><img src="https://3072390383-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FkUz2C3GqnZcWhoVL6jfk%2Fuploads%2FYxqMmcqm7qumV3dt00Ip%2Fimage.png?alt=media&#x26;token=5b22a46a-49aa-47ea-9af8-e47affec1c31" alt=""><figcaption></figcaption></figure></div>



We can change this by shutting down the tunnels, setting the tiebreaker to use **max-fill**, and re-signalling the tunnels.

<figure><img src="https://3072390383-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FkUz2C3GqnZcWhoVL6jfk%2Fuploads%2FWCTf9HDymX0WQIRu0eII%2Fimage.png?alt=media&#x26;token=7497c2d5-90b9-4649-9fd5-78c8e4eecc50" alt=""><figcaption></figcaption></figure>



Both tunnels now take the same path:

<div align="left"><figure><img src="https://3072390383-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FkUz2C3GqnZcWhoVL6jfk%2Fuploads%2FvvvOd66qpCIYBIjLbMEK%2Fimage.png?alt=media&#x26;token=875c6913-2574-4141-9245-2b63441a1c0b" alt=""><figcaption></figcaption></figure></div>



We’ll now do the same on XR11. Before changing the default tiebreaker, we’ll setup tun1 and then tun2. First, we have to bring down the R8 tunnels, because the R9-XR12 path has very high bandwidth load.

```
#R8
int tun1
 shut
int tun2
 shut

#XR11
int tunnel-te1
 description XR11_TO_R8_PATH1
 destination 8.8.8.8
 ip unn lo0
 path-option 1 dynamic
 signalled-bandwidth 200000
!
!
commit
!
!
int tunnel-te2
 description XR11_TO_R8_PATH2
 destination 8.8.8.8
 ip unn lo0
 path-option 1 dynamic
 signalled-bandwidth 200000
```



Notice that IOS-XR has the same default behavior (min-fill). The two TE tunnels are balanced between two paths. First R6-R8 is loaded by random. Then for tunnel-te2, the R6-R8 path has 800M available, while the XR12-R9 path has 1000M available, so the XR12-R9 path is choosen due to least-fill.

<div align="left"><figure><img src="https://3072390383-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FkUz2C3GqnZcWhoVL6jfk%2Fuploads%2Fyfhgj8wVonMreoFVsq6d%2Fimage.png?alt=media&#x26;token=64de7473-0d58-4e9c-a916-0fdc10408123" alt=""><figcaption></figcaption></figure></div>



We can change this behavior by bringing down the tunnels and re-calculating them using max-fill.

```
#XR11
no int tunnel-te1
no int tunnel-te2
commit
!
mpls traffic-eng
 path-selection
  tiebreaker max-fill
 exit
 exit
!
int tunnel-te1
 description XR11_TO_R8_PATH1
 destination 8.8.8.8
 ip unn lo0
 path-option 1 dynamic
 signalled-bandwidth 200000
!
!
commit
!
int tunnel-te2
 description XR11_TO_R8_PATH2
 destination 8.8.8.8
 ip unn lo0
 path-option 1 dynamic
 signalled-bandwidth 200000
```



Notice that the two TE tunnels now take the same path. First, R6-R10 is used by random. Then for tunnel-te2, R6-R10 has the most used bandwidth, so it is used again.

<div align="left"><figure><img src="https://3072390383-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FkUz2C3GqnZcWhoVL6jfk%2Fuploads%2FoEgznVhn3K8IJ9aKKlOm%2Fimage.png?alt=media&#x26;token=5fc4d43e-6fb5-4070-8d79-bac09da2e373" alt=""><figcaption></figcaption></figure></div>



### Shortest Hop Count <a href="#id-05ea9edd-3584-43a7-8aa0-46af1ae66dfb" id="id-05ea9edd-3584-43a7-8aa0-46af1ae66dfb"></a>

We can test the shortest hop count tiebreaker by artificially changing IGP metrics. The OSPF ref BW has been changed so that each link has a cost of 10. The link costs have then be manually manipulated to produce a 5 hop path from R8-R9-R2-R5-XR11 with cost 28, and a 4 hop path from R8-R6-R12-XR11 with cost 28.

<figure><img src="https://3072390383-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FkUz2C3GqnZcWhoVL6jfk%2Fuploads%2F5wrHq9pjI9zzNZD6VR7h%2Fimage.png?alt=media&#x26;token=fd94bdc2-754f-417a-9c04-924620bd14e2" alt=""><figcaption></figcaption></figure>



We have removed the max-fill tunnel-selection, so it is back to min-fill. When we signal the first path, it takes the R8-R6-XR12-XR11 path due to the shortest hop count.

<div align="left"><figure><img src="https://3072390383-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FkUz2C3GqnZcWhoVL6jfk%2Fuploads%2FxykebOYcQxecfEZ9hqI9%2Fimage.png?alt=media&#x26;token=1fda10be-25f2-4968-8990-f17e977618ee" alt=""><figcaption></figcaption></figure></div>



Next, we signal tunnel2. It uses the R8-R9-R2-R5-XR11 path, because it is now less filled. Notice that the router shows that the R8-R6-XR12-XR11 path is still the “shortest” path, even though tunnel2 was signaled through the longer hop path through R2.

<div align="left"><figure><img src="https://3072390383-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FkUz2C3GqnZcWhoVL6jfk%2Fuploads%2FtMd4xy1pkBCls2nswoTt%2Fimage.png?alt=media&#x26;token=71503fc5-007d-4339-9514-3b749658beb6" alt=""><figcaption></figcaption></figure></div>
