# SRv6 uSID w/ SR-TE

Load **top1.vpnv4v6.srv6.usid.configured.cfg**

```
#IOS-XR
configure
load top1.vpnv4v6.srv6.usid.configured.cfg
commit replace
y

#IOS-XE
config replace flash:top1.vpnv4v6.srv6.usid.configured.cfg
```

L3VPN for IPv4 and IPv6 is currently functional using SRv6 uSID in the core.

* Configure XR9 and XR10 as PCEs and XR5, XR6, XR7 and XR8 as PCE clients.
  * The PCEP session should use IPv6.
  * Configure XR9 as the primary PCE.
* Configure the XR1-XR3 link with high latency.
* Color BGP routes received from CSR3 for low-latency ODN SR-TE.
  * The policy should be calculated via PCEP.
* Traffic from CSR1 to CSR3 should take the path CSR1-XR5-XR1-XR2-XR4-XR7-CSR3

## Answer <a href="#cc8fb17f-ebb0-4ee0-9e32-7fe68819e9a2" id="cc8fb17f-ebb0-4ee0-9e32-7fe68819e9a2"></a>

```
#XR9
pce
 address ipv6 2001:db8:200::9
!
router isis 1
 distribute link-state

#XR10
pce
 address ipv6 2001:db8:200::a
!
router isis 1
 distribute link-state

#XR5, XR6, XR7, XR8
segment-routing
 traffic-eng
  on-demand color 10
   srv6
    locator CCIE binding-sid dynamic behavior ub6-insert-reduced
   !
   dynamic
    pcep
    !
    metric
     type latency
  !
  pcc
   source-address ipv6 2001:db8:200::<R#>
   pce address ipv6 2001:db8:200::9
    precedence 100
   !
   pce address ipv6 2001:db8:200::a
    precedence 200

#XR1, XR3
performance-measurement
 interface GigabitEthernet0/0/0/0.3013
  delay-measurement
   advertise-delay 1000000

#XR7
extcommunity-set opaque COLOR_10
  10
end-set
!
route-policy SET_COLOR
  set extcommunity color COLOR_10
end-policy
!
router bgp 100
 vrf CUSTOMER
  address-family ipv4 unicast
   redistribute ospf CUSTOMER route-policy SET_COLOR
  !
  address-family ipv6 unicast
   redistribute ospfv3 CUSTOMER route-policy SET_COLOR
```

## Explanation <a href="#id-43d99181-a28f-4e0e-a1e3-33f0ab62b34f" id="id-43d99181-a28f-4e0e-a1e3-33f0ab62b34f"></a>

Using SRv6 with uSID allows us to use SR-TE which we are already familiar with. Everything works very similarly to using SR-TE with SR-MPLS. The main difference is that you must define the locator for the policy, and specify that the router will allocate a SID with behavior uB6-insert-reduced SRH.

```
segment-routing
 traffic-eng
  on-demand color 10
   srv6
    locator CCIE binding-sid dynamic behavior ub6-insert-reduced
```

Otherwise, everything else should already be familiar. First we configure PCEP. R9 will be primary PCE by giving it a lower precedence value.

```
#PCC
segment-routing
 traffic-eng
  pcc
   source-address ipv6 2001:db8:200::<R#>
   pce address ipv6 2001:db8:200::9
    precedence 100
   !
   pce address ipv6 2001:db8:200::a
    precedence 200

#PCE
pce
 address ipv6 2001:db8:200::<R#>
!
router isis 1
 distribute link-state
```

If we forget whether a higher or lower value is best, we can use the below show command to verify which PCE is being preferred:

<div align="left"><figure><img src="https://3072390383-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FkUz2C3GqnZcWhoVL6jfk%2Fuploads%2FtJ4e6VxVoYddSEp4tFEB%2Fimage.png?alt=media&#x26;token=6ad3f0cd-7be8-4693-b7bc-a7be70950c2e" alt=""><figcaption></figcaption></figure></div>

On the egress PE, we set the color on the VPN routes. CSR3 is running OSPF as the PE-CE protocol, so XR7 sets the color as the routes are redistributed from OSPF into BGP.

```
#XR7
extcommunity-set opaque COLOR_10
  10
end-set
!
route-policy SET_COLOR
  set extcommunity color COLOR_10
end-policy
!
router bgp 100
 vrf CUSTOMER
  address-family ipv4 unicast
   redistribute ospf CUSTOMER route-policy SET_COLOR
  !
  address-family ipv6 unicast
   redistribute ospfv3 CUSTOMER route-policy SET_COLOR
```

We also set the latency value on the XR1-XR3 link to be high. Even though no other links have latency configured, the TE metric appears to be substituted for the latency value, so the policy will still be able to be calculated.

```
#XR1, XR3
performance-measurement
 interface GigabitEthernet0/0/0/0.3013
  delay-measurement
   advertise-delay 1000000
```

Finally, we set the ODN policy on the ingress PEs.

```
segment-routing
 traffic-eng
  on-demand color 10
   srv6
    locator CCIE binding-sid dynamic behavior ub6-insert-reduced
   !
   dynamic
    pcep
    !
    metric
     type latency
```

XR5, upon receiving the colored route, asks the PCE to calculate an associated policy. This is successful, as we see on R9:

<div align="left"><figure><img src="https://3072390383-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FkUz2C3GqnZcWhoVL6jfk%2Fuploads%2Fras0cOSKnwokDthWVpPN%2Fimage.png?alt=media&#x26;token=1ab9b012-e4cd-43ab-88cb-dd48ac9b2f53" alt=""><figcaption></figcaption></figure></div>

The details show us that the first SID is R2, and last is R7:

<div align="left"><figure><img src="https://3072390383-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FkUz2C3GqnZcWhoVL6jfk%2Fuploads%2FVDkgZTT5V8flHpM0TXnD%2Fimage.png?alt=media&#x26;token=a77b783a-efc7-4d11-8628-70a7a281de9f" alt=""><figcaption></figcaption></figure></div>

XR5 allocates a Binding SID for the policy, and reports it to both XR9 and XR10 (for redundancy).

There does not appear to be a way to verify the actual carrier SID that will be produced by this policy. In the CEF table we can see that the ultimate encapsulation uses fd00:0:7:e003, with the SRv6 SID fd00:0:2:: being inserted:

<div align="left"><figure><img src="https://3072390383-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FkUz2C3GqnZcWhoVL6jfk%2Fuploads%2FutjWneDpk0D5OwmYeIvp%2Fimage.png?alt=media&#x26;token=cc09892e-ecae-4b13-821c-61d43f236ef4" alt=""><figcaption></figcaption></figure></div>

By taking a pcap, we can see that the destination address is the correct compressed CSID:

<figure><img src="https://3072390383-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FkUz2C3GqnZcWhoVL6jfk%2Fuploads%2FL6ow0QWv061j8dE4C0uI%2Fimage.png?alt=media&#x26;token=5f6abbc0-722b-4e62-8a29-d232f1f541bd" alt=""><figcaption></figcaption></figure>

### Further exploring the ODN policy <a href="#c524c29d-8f47-40d6-8613-3146ac37f247" id="c524c29d-8f47-40d6-8613-3146ac37f247"></a>

I found that the following config does not work.

```
segment-routing
 traffic-eng
  srv6
   locator CCIE binding-sid dynamic behavior ub6-insert-reduced
  !
  on-demand color 10
   dynamic
    pcep
    !
    metric
     type latency
```

The ODN policy does not come up until I specify **srv6** under the ODN policy. It appears that without **srv6** under the ODN policy, there is no way for the router to know that it is not an SR-MPLS policy.

```
segment-routing
 traffic-eng
  srv6
   locator CCIE binding-sid dynamic behavior ub6-insert-reduced
  !
  on-demand color 10
   srv6
   !
   dynamic
    pcep
    !
    metric
     type latency
```

Alternatively, I can just define the locator directly under the ODN policy itself.

```
segment-routing
 traffic-eng
  on-demand color 10
   srv6
    locator CCIE binding-sid dynamic behavior ub6-insert-reduced
   !
   dynamic
    pcep
    !
    metric
     type latency
```
