# TE Tunnel with Conditional Attributes

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

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

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

<figure><img src="https://3072390383-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FkUz2C3GqnZcWhoVL6jfk%2Fuploads%2F2Y8YLgRovuICngh8xmfG%2Fimage.png?alt=media&#x26;token=75fcc60a-2a88-439b-9188-3fb5edcc326f" alt=""><figcaption></figcaption></figure>



Configure a bidirectional tunnel between CSR8 and XR11 that achieves the following:

* Uses signalled bandwidth of 100M and only BLUE links
* If 100M isn’t available, then the path should attempt to come up with 0 bandwidth
* If BLUE links aren’t available, the path should attempt to come up with 0 bandwidth and no affinity constraints















































## Answer <a href="#e88bdcef-abf3-4311-b7cc-b432c1b24bb9" id="e88bdcef-abf3-4311-b7cc-b432c1b24bb9"></a>

```
#CSR8
mpls traffic-eng lsp attributes NO_AFFINITY_NO_BW
 affinity 0x0 mask 0x0
 bandwidth 0
!
interface Tunnel0
 ip unnumbered Loopback0
 tunnel mode mpls traffic-eng
 tunnel destination 11.11.11.11
 tunnel mpls traffic-eng priority 7 7
 tunnel mpls traffic-eng bandwidth 100000
 tunnel mpls traffic-eng affinity 0x4 mask 0x4
 tunnel mpls traffic-eng path-option 1 dynamic
 tunnel mpls traffic-eng path-option 2 dynamic bandwidth  0
 tunnel mpls traffic-eng path-option 3 dynamic attributes NO_AFFINITY_NO_BW

#XR11
mpls traffic-eng
 attribute-set path-option NO_BW
  signalled-bandwidth 0
 !
 attribute-set path-option NO_AFFINITY_NO_BW
  signalled-bandwidth 0
  affinity 0x0 mask 0x0
 !
 exit
 exit
!
int tunnel-te 0
 ip unn lo0
 dest 8.8.8.8
 signalled-bandwidth 100000
 affinity 0x4 mask 0x4
 path-option 1 dynamic
 path-option 2 dynamic attribute-set NO_BW
 path-option 3 dynamic attribute-set NO_AFFINITY_NO_BW
```



## Explanation <a href="#id-63747220-43bc-42f1-b253-b1e456cffbe5" id="id-63747220-43bc-42f1-b253-b1e456cffbe5"></a>

The LSP attribute set feature allows you to apply attributes to individual path-options instead of to the TE tunnel as a whole. This allows you to do complex logic such as “if the previous path-option is not valid, try with affinity set to \<value>.” You can have the router try to remove constraints as previous path-options fail. This can allow the TE tunnel to always be up, even if, for example, someone accidentally removes affinity values from a router in the network.



On IOS-XE, this is accomplised using the following configuration:

```
#IOS-XE
mpls traffic-eng lsp attributes name
 affinity ...
 bandwidth ...
 priority ...
!
interface Tunnel0
 tunnel mpls traffic-eng path-option num dynamic|explicit attributes name
```



IOS-XE also allows you to specify only the bandwidth attribute without needing a separate attribute set. Note that when you use this, if the associated path-option is active, the router will attempt to reoptimize the tunnel every 30 seconds to try to satisfy the original bandwidth constraint. This allows for the tunnel to at least be up in case bandwidth cannot be satisfied, but to actually reserve the bandwidth as soon as possible when it becomes available again.

```
#IOS-XE
interface Tunnel0
 tunnel mpls traffic-eng path-option num dynamic|explicit bandwidth value
```



On IOS-XR, this is accomplished similarly using an attribute-set. Note that IOS-XR doesn’t support as many features with the attribute-set. The major ones are just signalled-bandwidth and affinity.

```
#IOS-XR
mpls traffic-eng
 attribute-set path-option name
  signalled-bandwidth ...
  affinity ...
!
int tunnel-te 0
 path-option num dynamic|explicit attribute-set name
```



To meet the task requirements, we set the affinity and bandwidth for the tunnel to 0x4/0x4 and 100M. Path-option 1 attempts to calculate a dynamic path. Path-option 2 uses zero bandwidth. Path-option 3 uses 0x0/0x0 affinity and zero bandwidth.

```
#CSR8
mpls traffic-eng lsp attributes NO_AFFINITY_NO_BW
 affinity 0x0 mask 0x0
 bandwidth 0
!
interface Tunnel0
 tunnel mpls traffic-eng bandwidth 100000
 tunnel mpls traffic-eng affinity 0x4 mask 0x4
 tunnel mpls traffic-eng path-option 1 dynamic
 tunnel mpls traffic-eng path-option 2 dynamic bandwidth  0
 tunnel mpls traffic-eng path-option 3 dynamic attributes NO_AFFINITY_NO_BW

#XR11
mpls traffic-eng
 attribute-set path-option NO_BW
  signalled-bandwidth 0
 !
 attribute-set path-option NO_AFFINITY_NO_BW
  signalled-bandwidth 0
  affinity 0x0 mask 0x0
 !
 exit
 exit
!
int tunnel-te 0
 signalled-bandwidth 100000
 affinity 0x4 mask 0x4
 path-option 1 dynamic
 path-option 2 dynamic attribute-set NO_BW
 path-option 3 dynamic attribute-set NO_AFFINITY_NO_BW
```



## Verification <a href="#id-52fe1bca-7dc9-46ba-b2f8-7b21a889cac2" id="id-52fe1bca-7dc9-46ba-b2f8-7b21a889cac2"></a>

When all links are up, CSR8 should be able to use the first 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%2F0kyECDizKUyC3bMchoUz%2Fimage.png?alt=media&#x26;token=81bf9753-e458-4167-bc95-80c6146ce80f" alt=""><figcaption></figcaption></figure></div>



If we change all of CSR8’s interfaces to only have 50M available bandwidth, path-option 1 should fail, and path-option 2 should succeed. Notice below that the requested bandwidth on the tunnel when path-option 2 is used is now zero.

```
#CSR8
int GigabitEthernet2.518 
 ip rsvp bandwidth 50000
int GigabitEthernet2.568 
 ip rsvp bandwidth 50000
int GigabitEthernet2.589
 ip rsvp bandwidth 50000
```

<div align="left"><figure><img src="https://3072390383-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FkUz2C3GqnZcWhoVL6jfk%2Fuploads%2FbW7rjjv0vTRJdofj8y3L%2Fimage.png?alt=media&#x26;token=ded8b923-f61e-4ad3-9223-604afcb47677" alt=""><figcaption></figcaption></figure></div>



Lastly, we can change CSR8’s local interfaces no not belong to affinity “BLUE” (0x4). This should cause path-option 2 to fail and path-option 3 should be used. Notice below that the affinity has changed to 0x0/0x0.

```
#CSR8
int GigabitEthernet2.518 
 no mpls traffic-eng attribute-flags
int GigabitEthernet2.568 
 mpls traffic-eng attribute-flags 0x2
```

<div align="left"><figure><img src="https://3072390383-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FkUz2C3GqnZcWhoVL6jfk%2Fuploads%2F8PM7qnT8BjwvPToMmnvV%2Fimage.png?alt=media&#x26;token=15983bb8-eb68-47aa-846b-27bdef1758e1" alt=""><figcaption></figcaption></figure></div>



We can also test this on XR11. By default, path-option 1 is used.

<div align="left"><figure><img src="https://3072390383-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FkUz2C3GqnZcWhoVL6jfk%2Fuploads%2F5cKHyZsomGlglRaHsg2a%2Fimage.png?alt=media&#x26;token=4b4cf5ec-7c25-4152-b586-94e1d24c68b5" alt=""><figcaption></figcaption></figure></div>



If we change XR11’s available bandwidth on all local interfaces to less than 100M, path-option 1 should fail.

```
#XR11
rsvp
 interface GigabitEthernet0/0/0/0.501
  bandwidth 10000
 !
 interface GigabitEthernet0/0/0/0.512
  bandwidth 10000
 !
 interface GigabitEthernet0/0/0/0.551
  bandwidth 10000
```

<div align="left"><figure><img src="https://3072390383-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FkUz2C3GqnZcWhoVL6jfk%2Fuploads%2FHoeL24yaP5BbxBEr7B1v%2Fimage.png?alt=media&#x26;token=2b9e508b-5642-4465-92eb-0025d5105ea6" alt=""><figcaption></figcaption></figure></div>



If we remove XR11’s BLUE affinity from local links, path-option 2 should fail and path-option 3 should be used.

```
#XR11
mpls traffic-eng
 interface GigabitEthernet0/0/0/0.512
  no attribute-names BLUE
 interface GigabitEthernet0/0/0/0.551
  no attribute-names BLUE
```

<div align="left"><figure><img src="https://3072390383-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FkUz2C3GqnZcWhoVL6jfk%2Fuploads%2FwGFJ91yTlCcgJCinsHI0%2Fimage.png?alt=media&#x26;token=c6aeb9b3-fd3c-49a7-8f4a-18658ea36d3c" alt=""><figcaption></figcaption></figure></div>
