# Reoptimization timer

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 bi-directional TE tunnels between CSR8 and XR11, and between CSR8 and CSR5.
  * Simply use a dynamic path option.
* Configure R8, R5, and XR11 to reoptimize all tunnels every 1 minute, and whenever a linkup event happens.
* Configure the R8-XR11 tunnels to never reoptimize.

## Answer <a href="#id-79bcdab3-c034-4787-a6d5-3839d77974ab" id="id-79bcdab3-c034-4787-a6d5-3839d77974ab"></a>

```
#R8
mpls traffic-eng reoptimize timers frequency 60
mpls traffic-eng reoptimize events link-up
!
int tun11
 description TO_XR11
 ip unn lo0
 tunnel dest 11.11.11.11
 tunnel mode mpls traffic-eng
 tunnel mpls traffic-eng path-option 1 dynamic lockdown
!
int tun5
 description TO_R5
 ip unn lo0
 tunnel dest 5.5.5.5
 tunnel mode mpls traffic-eng
 tunnel mpls traffic-eng path-option 1 dynamic

#R5
mpls traffic-eng reoptimize timers frequency 60
mpls traffic-eng reoptimize events link-up
!
int tun5
 description TO_R8
 ip unn lo0
 tunnel dest 8.8.8.8
 tunnel mode mpls traffic-eng
 tunnel mpls traffic-eng path-option 1 dynamic

#XR11
mpls traffic-eng
 reoptimize 60
 reoptimize events link-up
 exit
!
int tunnel-te8
 description TO_R8
 ip unn lo0
 dest 8.8.8.8
 path-option 1 dynamic lockdown
```

## Explanation <a href="#id-28053452-0df4-4360-8e1d-c37d1cd32850" id="id-28053452-0df4-4360-8e1d-c37d1cd32850"></a>

MPLS traffic-eng tunnels are re-calculated using CSPF at the reoptimization interval, or upon a link-up event (if configured). The default reoptimization interval on IOS-XE and IOS-XR is 60 minutes. To change this interval, we can use the following commands:

```
#IOS-XE
mpls traffic-eng reoptimize timers frequency sec

#IOS-XR
mpls traffic-eng
 reoptimize sec
```

We can also simply execute reoptimization from the CLI in exec mode on both platforms:

```
#IOS-XE
mpls traffic-eng reoptimize [Tunnel # [path-option #]]

#IOS-XR
mpls traffic-eng reoptimize all|tunnel#
```

Finally, we can configure the router to run CSPF upon a linkup event to reoptimize all tunnels immediately:

```
#IOS-XE
mpls traffic-eng reoptimize events link-up

#IOS-XR
mpls traffic-eng
 reoptimize events link-up
```

## Verification <a href="#id-34900019-b0fd-4c87-bdff-c6a6b650ddf4" id="id-34900019-b0fd-4c87-bdff-c6a6b650ddf4"></a>

On R8, we can verify that the tunnel to XR11 has **lockdown** enabled on the path-option. This means that the path-option should never be re-optimized. This is a way to completely prevent reoptimization for this particular path-option.

<div align="left"><figure><img src="https://3072390383-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FkUz2C3GqnZcWhoVL6jfk%2Fuploads%2FNd17fSOgrZ5MjFVUXlwq%2Fimage.png?alt=media&#x26;token=22e07c5b-2053-4cd9-ba9f-14f039828b5e" alt=""><figcaption></figcaption></figure></div>

We can see this on XR11 as well:

<div align="left"><figure><img src="https://3072390383-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FkUz2C3GqnZcWhoVL6jfk%2Fuploads%2F5r01abXxnlWgUb9zV1co%2Fimage.png?alt=media&#x26;token=f0172268-9438-4975-9c2e-1c36870f4b03" alt=""><figcaption></figcaption></figure></div>

On R8, we can run **debug mpls traffic-eng tunnels reoptimize detail** to watch reoptimization events. We’ll see that every one minute, the “should\_reopt” value is TRUE for Tun5. Additionally, only tun5’s path-option 1 seems to be activated for reoptimization. We never see Tun11 show “should\_reopt: TRUE”. This appears to be due to the **lockdown** command on the XR11 tunnel path-option.

<div align="left"><figure><img src="https://3072390383-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FkUz2C3GqnZcWhoVL6jfk%2Fuploads%2FS8pNbIg7BwvTt5HWBAIg%2Fimage.png?alt=media&#x26;token=0129863b-8486-4984-a280-32fe5ac2045d" alt=""><figcaption></figcaption></figure></div>

If we flap a link on R8, this should also cause immediate reoptimization upon the link-up event. We’ll increase the optimization timer to make sure the reoptimization happens due to the event, and not the periodic timer.

```
#R8
mpls traffic-eng reoptimize timers frequency 100000
```

Before we make any changes, notice that every 30 seconds the router appears to run a check for whether reoptimization should occur. Every 30 seconds it is always “FALSE” now, because the reoptimization timer is so high.

<div align="left"><figure><img src="https://3072390383-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FkUz2C3GqnZcWhoVL6jfk%2Fuploads%2FwwdOYNfPeO5nxZJ9wrxP%2Fimage.png?alt=media&#x26;token=f4709fcb-c46a-4c59-ba07-8de5feb74dbf" alt=""><figcaption></figcaption></figure></div>

Next we’ll flap a link on R8. Watch how reoptimization is triggered by the IGP adjacency coming up. Interestingly, the reoptimization process seems triggered at link-down, link-up, and IGP-up. But only IGP-up seems to actually cause reoptimization. Perhaps “link-up” means that link is up from the TED perspective, which only occurs once IGP is up.

<div align="left"><figure><img src="https://3072390383-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FkUz2C3GqnZcWhoVL6jfk%2Fuploads%2FPsV3TSN5jtxnq6Dg1Vsd%2Fimage.png?alt=media&#x26;token=63cbb63f-4dc0-4314-bcf8-2e2b649514ca" alt=""><figcaption></figcaption></figure></div>

We can use the same debug command on IOS-XR: **debug mpls traffic-eng tunnel reoptimization**. We see that reoptimization is running every 60 seconds.

<div align="left"><figure><img src="https://3072390383-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FkUz2C3GqnZcWhoVL6jfk%2Fuploads%2FMFaKDYgCBjTzlPuxJNxU%2Fimage.png?alt=media&#x26;token=a767f121-93fd-41ec-adb5-99be18faf77e" alt=""><figcaption></figcaption></figure></div>

If we flap a link on XR11, we should see reoptimization kick in due to the link-up event. This gives us much better output than on IOS-XE. We can also clearly see that the tunnel to R8 is not a reopt candidate because the path-option is locked down:

<div align="left"><figure><img src="https://3072390383-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FkUz2C3GqnZcWhoVL6jfk%2Fuploads%2F3rwL84bkhBJ9JExbj4PA%2Fimage.png?alt=media&#x26;token=21ba3022-ef49-4465-8b43-2431a1ba616c" alt=""><figcaption></figcaption></figure></div>
