Single-Domain SR-TE その5(Link Color Constraints)

SR-TE & Link Color Constraints が理解できたので自分のメモ用にアウトプットします。

リンクを論理的に色分けし、色に応じた経路を動的に生成する SR-TE

2. Topology

3. Config

◆h_N1(Head-End:exclude-any:RED & GREEN / metric type:TE)

hostname h_N1
group CCIE-ISIS
 router isis '.*'
  is-type level-2-only
  address-family ipv4 unicast
   metric-style wide
   segment-routing mpls
  !
  interface 'Gi.*'
   point-to-point
   address-family ipv4 unicast
   !
  !
  interface 'Loopback .*'
   address-family ipv4 unicast
   !
  !
 !
end-group
!
interface Loopback0
 ipv4 address 1.1.1.1 255.255.255.255
!
interface MgmtEth0/RP0/CPU0/0
 shutdown
!
interface GigabitEthernet0/0/0/0
 ipv4 address 10.1.2.1 255.255.255.0
!
interface GigabitEthernet0/0/0/1
 shutdown
!
interface GigabitEthernet0/0/0/2
 ipv4 address 10.1.3.1 255.255.255.0
!
router isis 1
 apply-group CCIE-ISIS
 net 49.0001.0000.0000.0001.00
 distribute link-state level 2
 address-family ipv4 unicast
  mpls traffic-eng level-2-only
  mpls traffic-eng router-id Loopback0
 !
 interface Loopback0
  address-family ipv4 unicast
   prefix-sid index 1
  !
 !
 interface GigabitEthernet0/0/0/0
 !
 interface GigabitEthernet0/0/0/2
 !
!
mpls oam
!
segment-routing
 traffic-eng
  interface GigabitEthernet0/0/0/0
   affinity
    name BULE
   !
  !       
  interface GigabitEthernet0/0/0/2
   affinity
    name BLUE
    name GREEN
   !
  !
  policy LINK_COLOR_CONSTRAINS_POLICY
   binding-sid mpls 24365
   color 6666 end-point ipv4 6.6.6.6
   autoroute
    include ipv4 6.6.6.6/32
   !
   candidate-paths
    preference 100
     dynamic
      metric
       type te
      !
     !
     constraints
      affinity
       exclude-any
        name RED
        name GREEN
       !
      !
     !
    !
   !
  !
  affinity-map
   name RED bit-position 10
   name BULE bit-position 20
   name GREEN bit-position 30
  !
 !
!
end

◆h_N1(Head-End:exclude-any:RED & GREEN / metric type:IGP)

hostname h_N1
group CCIE-ISIS
 router isis '.*'
  is-type level-2-only
  address-family ipv4 unicast
   metric-style wide
   segment-routing mpls
  !
  interface 'Gi.*'
   point-to-point
   address-family ipv4 unicast
   !
  !
  interface 'Loopback .*'
   address-family ipv4 unicast
   !
  !
 !
end-group
!
interface Loopback0
 ipv4 address 1.1.1.1 255.255.255.255
!
interface MgmtEth0/RP0/CPU0/0
 shutdown
!
interface GigabitEthernet0/0/0/0
 ipv4 address 10.1.2.1 255.255.255.0
!
interface GigabitEthernet0/0/0/1
 shutdown
!
interface GigabitEthernet0/0/0/2
 ipv4 address 10.1.3.1 255.255.255.0
!
router isis 1
 apply-group CCIE-ISIS
 net 49.0001.0000.0000.0001.00
 distribute link-state level 2
 address-family ipv4 unicast
  mpls traffic-eng level-2-only
  mpls traffic-eng router-id Loopback0
 !
 interface Loopback0
  address-family ipv4 unicast
   prefix-sid index 1
  !
 !
 interface GigabitEthernet0/0/0/0
 !
 interface GigabitEthernet0/0/0/2
 !
!
mpls oam
!
segment-routing
 traffic-eng
  interface GigabitEthernet0/0/0/0
   affinity
    name BULE
   !
  !       
  interface GigabitEthernet0/0/0/2
   affinity
    name BLUE
    name GREEN
   !
  !
  policy LINK_COLOR_CONSTRAINS_POLICY
   binding-sid mpls 24365
   color 6666 end-point ipv4 6.6.6.6
   autoroute
    include ipv4 6.6.6.6/32
   !
   candidate-paths
    preference 100
     dynamic
      metric
       type igp
      !
     !
     constraints
      affinity
       exclude-any
        name RED
        name GREEN
       !
      !
     !
    !
   !
  !
  affinity-map
   name RED bit-position 10
   name BULE bit-position 20
   name GREEN bit-position 30
  !
 !
!
end

◆h_N1(Head-End:include-all:BLUE / metric type:IGP)

hostname h_N1
group CCIE-ISIS
 router isis '.*'
  is-type level-2-only
  address-family ipv4 unicast
   metric-style wide
   segment-routing mpls
  !
  interface 'Gi.*'
   point-to-point
   address-family ipv4 unicast
   !
  !
  interface 'Loopback .*'
   address-family ipv4 unicast
   !
  !
 !
end-group
!
interface Loopback0
 ipv4 address 1.1.1.1 255.255.255.255
!
interface MgmtEth0/RP0/CPU0/0
 shutdown
!
interface GigabitEthernet0/0/0/0
 ipv4 address 10.1.2.1 255.255.255.0
 no shut
!
interface GigabitEthernet0/0/0/1
 shutdown
!
interface GigabitEthernet0/0/0/2
 ipv4 address 10.1.3.1 255.255.255.0
 no shut
!
interface GigabitEthernet0/0/0/3
 shutdown
!
interface GigabitEthernet0/0/0/4
 shutdown
!
router isis 1
 apply-group CCIE-ISIS
 net 49.0001.0000.0000.0001.00
 distribute link-state level 2
 address-family ipv4 unicast
  mpls traffic-eng level-2-only
  mpls traffic-eng router-id Loopback0
 !
 interface Loopback0
  address-family ipv4 unicast
   prefix-sid index 1
  !
 !
 interface GigabitEthernet0/0/0/0
 !
 interface GigabitEthernet0/0/0/2
 !
!
mpls oam
!
segment-routing
 traffic-eng
  interface GigabitEthernet0/0/0/0
   affinity
    name BULE
   !
  !       
  interface GigabitEthernet0/0/0/2
   affinity
    name BLUE
    name GREEN
   !
  !
  policy LINK_COLOR_CONSTRAINS_POLICY
   binding-sid mpls 24365
   color 6666 end-point ipv4 6.6.6.6
   autoroute
    include ipv4 6.6.6.6/32
   !
   candidate-paths
    preference 100
     dynamic
      metric
       type igp
      !
     !
     constraints
      affinity
       include-all
        name BLUE
       !
      !
     !
    !
   !
  !
  affinity-map
   name RED bit-position 10
   name BULE bit-position 20
   name GREEN bit-position 30
  !
 !
!
end

◆h_N1(Head-End:include-any:BLUE & RED / metric type:TE)

hostname h_N1
group CCIE-ISIS
 router isis '.*'
  is-type level-2-only
  address-family ipv4 unicast
   metric-style wide
   segment-routing mpls
  !
  interface 'Gi.*'
   point-to-point
   address-family ipv4 unicast
   !
  !
  interface 'Loopback .*'
   address-family ipv4 unicast
   !
  !
 !
end-group
!
interface Loopback0
 ipv4 address 1.1.1.1 255.255.255.255
!
interface MgmtEth0/RP0/CPU0/0
 shutdown
!
interface GigabitEthernet0/0/0/0
 ipv4 address 10.1.2.1 255.255.255.0
!
interface GigabitEthernet0/0/0/1
 shutdown
!
interface GigabitEthernet0/0/0/2
 ipv4 address 10.1.3.1 255.255.255.0
!
router isis 1
 apply-group CCIE-ISIS
 net 49.0001.0000.0000.0001.00
 distribute link-state level 2
 address-family ipv4 unicast
  mpls traffic-eng level-2-only
  mpls traffic-eng router-id Loopback0
 !
 interface Loopback0
  address-family ipv4 unicast
   prefix-sid index 1
  !
 !
 interface GigabitEthernet0/0/0/0
 !
 interface GigabitEthernet0/0/0/2
 !
!
mpls oam
!
segment-routing
 traffic-eng
  interface GigabitEthernet0/0/0/0
   affinity
    name BULE
   !
  !       
  interface GigabitEthernet0/0/0/2
   affinity
    name BLUE
    name GREEN
   !
  !
  policy LINK_COLOR_CONSTRAINS_POLICY
   binding-sid mpls 24365
   color 6666 end-point ipv4 6.6.6.6
   autoroute
    include ipv4 6.6.6.6/32
   !
   candidate-paths
    preference 100
     dynamic
      metric
       type te
      !
     !
     constraints
      affinity
       include-any
        name RED
        name BLUE
       !
      !
     !
    !
   !
  !
  affinity-map
   name RED bit-position 10
   name BULE bit-position 20
   name GREEN bit-position 30
  !
 !
!
end

h_N2(metric変更)

hostname h_N2
group CCIE-ISIS
 router isis '.*'
  is-type level-2-only
  address-family ipv4 unicast
   metric-style wide
   segment-routing mpls
  !
  interface 'Gi.*'
   point-to-point
   address-family ipv4 unicast
   !
  !
  interface 'Loopback .*'
   address-family ipv4 unicast
   !
  !
 !
end-group
!
interface Loopback0
 ipv4 address 2.2.2.2 255.255.255.255
!
interface MgmtEth0/RP0/CPU0/0
 shutdown
!
interface GigabitEthernet0/0/0/0
 ipv4 address 10.1.2.2 255.255.255.0
!
interface GigabitEthernet0/0/0/1
 ipv4 address 10.2.3.2 255.255.255.0
!
interface GigabitEthernet0/0/0/2
 ipv4 address 10.2.4.2 255.255.255.0
!
router isis 1
 apply-group CCIE-ISIS
 net 49.0001.0000.0000.0002.00
 address-family ipv4 unicast
  mpls traffic-eng level-2-only
  mpls traffic-eng router-id Loopback0
 !
 interface Loopback0
  address-family ipv4 unicast
   prefix-sid index 2
  !
 !
 interface GigabitEthernet0/0/0/0
 !
 interface GigabitEthernet0/0/0/1
 !
 interface GigabitEthernet0/0/0/2
  address-family ipv4 unicast
   metric 200
  !
 !
!
mpls oam
!
segment-routing
 traffic-eng
  interface GigabitEthernet0/0/0/0
   affinity
    name BLUE
   !
  !
  interface GigabitEthernet0/0/0/1
   affinity
    name BLUE
   !
  !
  interface GigabitEthernet0/0/0/2
   affinity
    name BLUE
   !
   metric 1000
  !
  affinity-map
   name RED bit-position 10
   name BLUE bit-position 20
   name GREEN bit-position 30
  !
 !
!
end

h_N3(metric変更)

hostname h_N3
group CCIE-ISIS
 router isis '.*'
  is-type level-2-only
  address-family ipv4 unicast
   metric-style wide
   segment-routing mpls
  !
  interface 'Gi.*'
   point-to-point
   address-family ipv4 unicast
   !
  !
  interface 'Loopback .*'
   address-family ipv4 unicast
   !
  !
 !
end-group
!
interface Loopback0
 ipv4 address 3.3.3.3 255.255.255.255
!
interface MgmtEth0/RP0/CPU0/0
 shutdown
!
interface GigabitEthernet0/0/0/0
 ipv4 address 10.1.3.3 255.255.255.0
!
interface GigabitEthernet0/0/0/1
 ipv4 address 10.2.3.3 255.255.255.0
!
interface GigabitEthernet0/0/0/2
 ipv4 address 10.3.5.3 255.255.255.0
!
interface GigabitEthernet0/0/0/3
 ipv4 address 10.3.4.3 255.255.255.0
!
router isis 1
 apply-group CCIE-ISIS
 net 49.0001.0000.0000.0003.00
 address-family ipv4 unicast
  mpls traffic-eng level-2-only
  mpls traffic-eng router-id Loopback0
 !
 interface Loopback0
  address-family ipv4 unicast
   prefix-sid index 3
  !
 !
 interface GigabitEthernet0/0/0/0
 !
 interface GigabitEthernet0/0/0/1
 !
 interface GigabitEthernet0/0/0/2
 !
 interface GigabitEthernet0/0/0/3
  address-family ipv4 unicast
   metric 2000
  !
 !
!
mpls oam
!
segment-routing
 traffic-eng
  interface GigabitEthernet0/0/0/0
   affinity
    name BLUE
    name GREEN
   !
  !
  interface GigabitEthernet0/0/0/1
   affinity
    name BLUE
   !
  !
  interface GigabitEthernet0/0/0/2
   affinity
    name RED
   !
  !
  interface GigabitEthernet0/0/0/3
   affinity
    name BLUE
   !
   metric 100
  !
  affinity-map
   name RED bit-position 10
   name BLUE bit-position 20
   name GREEN bit-position 30
  !
 !
!
end

h_N4(metric変更)

hostname h_N4
group CCIE-ISIS
 router isis '.*'
  is-type level-2-only
  address-family ipv4 unicast
   metric-style wide
   segment-routing mpls
  !
  interface 'Gi.*'
   point-to-point
   address-family ipv4 unicast
   !
  !
  interface 'Loopback .*'
   address-family ipv4 unicast
   !
  !
 !
end-group
!
interface Loopback0
 ipv4 address 4.4.4.4 255.255.255.255
!
interface MgmtEth0/RP0/CPU0/0
 shutdown
!
interface GigabitEthernet0/0/0/0
 ipv4 address 10.2.4.4 255.255.255.0
!
interface GigabitEthernet0/0/0/1
 ipv4 address 10.4.5.4 255.255.255.0
!
interface GigabitEthernet0/0/0/2
 ipv4 address 10.4.6.4 255.255.255.0
!
interface GigabitEthernet0/0/0/3
 ipv4 address 10.3.4.4 255.255.255.0
!
router isis 1
 apply-group CCIE-ISIS
 net 49.0001.0000.0000.0004.00
 address-family ipv4 unicast
  mpls traffic-eng level-2-only
  mpls traffic-eng router-id Loopback0
 !
 interface Loopback0
  prefix-attributes anycast
  address-family ipv4 unicast
   prefix-sid index 4
  !
 !
 interface GigabitEthernet0/0/0/0
  address-family ipv4 unicast
   metric 200
  !
 !
 interface GigabitEthernet0/0/0/1
 !
 interface GigabitEthernet0/0/0/2
 !
 interface GigabitEthernet0/0/0/3
 !
!
mpls oam
!
segment-routing
 traffic-eng
  interface GigabitEthernet0/0/0/0
   affinity
    name BLUE
   !
   metric 1000
  !
  interface GigabitEthernet0/0/0/1
   affinity
    name BLUE
    name GREEN
   !
  !
  interface GigabitEthernet0/0/0/2
   affinity
    name BLUE
   !
  !
  interface GigabitEthernet0/0/0/3
   affinity
    name BLUE
   !
  !
  affinity-map
   name RED bit-position 10
   name BLUE bit-position 20
   name GREEN bit-position 30
  !
 !
!
end

h_N5

hostname h_N5
group CCIE-ISIS
 router isis '.*'
  is-type level-2-only
  address-family ipv4 unicast
   metric-style wide
   segment-routing mpls
  !
  interface 'Gi.*'
   point-to-point
   address-family ipv4 unicast
   !
  !
  interface 'Loopback .*'
   address-family ipv4 unicast
   !
  !
 !
end-group
!
interface Loopback0
 ipv4 address 5.5.5.5 255.255.255.255
!
interface MgmtEth0/RP0/CPU0/0
 shutdown
!
interface GigabitEthernet0/0/0/0
 ipv4 address 10.3.5.5 255.255.255.0
!
interface GigabitEthernet0/0/0/1
 ipv4 address 10.4.5.5 255.255.255.0
!
interface GigabitEthernet0/0/0/2
 ipv4 address 10.5.6.5 255.255.255.0
!
router isis 1
 apply-group CCIE-ISIS
 net 49.0001.0000.0000.0005.00
 address-family ipv4 unicast
  mpls traffic-eng level-2-only
  mpls traffic-eng router-id Loopback0
 !
 interface Loopback0
  prefix-attributes anycast
  address-family ipv4 unicast
   prefix-sid index 5
  !
 !
 interface GigabitEthernet0/0/0/0
 !
 interface GigabitEthernet0/0/0/1
 !
 interface GigabitEthernet0/0/0/2
 !
!
mpls oam
!
segment-routing
 traffic-eng
  interface GigabitEthernet0/0/0/0
   affinity
    name RED
   !
  !       
  interface GigabitEthernet0/0/0/1
   affinity
    name BLUE
    name GREEN
   !
  !
  interface GigabitEthernet0/0/0/2
   affinity
    name BLUE
   !
  !
  affinity-map
   name RED bit-position 10
   name BLUE bit-position 20
   name GREEN bit-position 30
  !
 !
!
end

h_N6

hostname h_N6
group CCIE-ISIS
 router isis '.*'
  is-type level-2-only
  address-family ipv4 unicast
   metric-style wide
   segment-routing mpls
  !
  interface 'Gi.*'
   point-to-point
   address-family ipv4 unicast
   !
  !
  interface 'Loopback .*'
   address-family ipv4 unicast
   !
  !
 !
end-group
!
interface Loopback0
 ipv4 address 6.6.6.6 255.255.255.255
!
interface MgmtEth0/RP0/CPU0/0
 shutdown
!
interface GigabitEthernet0/0/0/0
 ipv4 address 10.4.6.6 255.255.255.0
!
interface GigabitEthernet0/0/0/1
 shutdown
!
interface GigabitEthernet0/0/0/2
 ipv4 address 10.5.6.6 255.255.255.0
!
router isis 1
 apply-group CCIE-ISIS
 net 49.0001.0000.0000.0006.00
 address-family ipv4 unicast
  mpls traffic-eng level-2-only
  mpls traffic-eng router-id Loopback0
 !
 interface Loopback0
  address-family ipv4 unicast
   prefix-sid index 6
  !
 !
 interface GigabitEthernet0/0/0/0
 !
 interface GigabitEthernet0/0/0/2
 !
!
mpls oam
!
segment-routing
 traffic-eng
  interface GigabitEthernet0/0/0/0
   affinity
    name BLUE
   !
  !
  interface GigabitEthernet0/0/0/2
   affinity
    name BLUE
   !
  !
  affinity-map
   name RED bit-position 10
   name BLUE bit-position 20
   name GREEN bit-position 30
  !
 !
!
end

4.下準備(各種メトリックの仕込み)

4.1 IGP(Default 10)

IGP で interface を指定して定義します。
e.g. h_N2's GigabitEthernet0/0/0/2 で IGP(ISIS)のメトリックを定義

RP/0/RP0/CPU0:h_N2(config)#router isis 1
RP/0/RP0/CPU0:h_N2(config-isis)#interface gigabitEthernet 0/0/0/2
RP/0/RP0/CPU0:h_N2(config-isis-if)#address-family ipv4 unicast 
RP/0/RP0/CPU0:h_N2(config-isis-if-af)#metric 200
RP/0/RP0/CPU0:h_N2(config-isis-if-af)#
RP/0/RP0/CPU0:h_N2(config-isis-if-af)#commit

4.2 Traffic-engineering(TE:Default 10)

Segment Routing の Traffic-engineering で interface を指定して定義します。
e.g. h_N2's GigabitEthernet0/0/0/2 で TE のメトリックを定義

RP/0/RP0/CPU0:h_N2(config)#?  
  segment-routing            Segment Routing
RP/0/RP0/CPU0:h_N2(config)#segment-routing 
RP/0/RP0/CPU0:h_N2(config-sr)#?
  traffic-eng         Segment Routing Traffic Engineering
RP/0/RP0/CPU0:h_N2(config-sr)#traffic-eng 
RP/0/RP0/CPU0:h_N2(config-sr-te)#?
  interface           Enable SR-TE on an interface(cisco-support)
RP/0/RP0/CPU0:h_N2(config-sr-te)#interface gigabitEthernet 0/0/0/2
RP/0/RP0/CPU0:h_N2(config-sr-if)#?
  metric              Interface TE metric configuration
RP/0/RP0/CPU0:h_N2(config-sr-if)#metric 1000
RP/0/RP0/CPU0:h_N2(config-sr-if)#
RP/0/RP0/CPU0:h_N2(config-sr-if)#show
Sun Apr  2 09:15:48.466 UTC
segment-routing
 traffic-eng
  interface GigabitEthernet0/0/0/2
   metric 1000
  !
 !
!

RP/0/RP0/CPU0:h_N2(config-sr-if)#

残りのノードもトポロジ図で指定した通りに定義します。

5. SR-TE の実装

実装の流れは、①全ノードでSegment Routing の Traffic-engineering を有効にしてから ② Link Color を定義します。③ Head-End で LSDBの情報をSR-TE DBに投入します。 また、④Head-End で SR-TE のポリシーを定義します。 ⑤最後に経路(Candidate-paths)のメトリックを選択し、⑥どの色を通過許可するかの制約事項を定義します。

5.1 全ノード共通

5.1.1 SR-TE有効化

①IGPでSegment Routing を有効にします。
忘れずに Loopback0 で prefix-sid index X を有効化します。

 router isis '.*'
  net 49.0001.0000.0000.000X.00
  address-family ipv4 unicast
   metric-style wide
   segment-routing mpls
  !
  interface Loopback 0
   address-family ipv4 unicast
    prefix-sid index X
   !
  !
 !

②IGP で Traffic-engineering 有効にします。 ISIS の場合、IGP のレベルと TE のレベルを合わせます。今回の場合は、level-2-only です。

RP/0/RP0/CPU0:h_N2(config)#router isis 1 
RP/0/RP0/CPU0:h_N2(config-isis)#address-family ipv4 unicast 
RP/0/RP0/CPU0:h_N2(config-isis-af)#?
  mpls                            Configure MPLS routing protocol parameters
RP/0/RP0/CPU0:h_N2(config-isis-af)#mpls ?
  traffic-eng  Routing protocol commands for MPLS Traffic Engineering
RP/0/RP0/CPU0:h_N2(config-isis-af)#mpls traffic-eng ?
  level-2-only      Enable mpls traffic-eng at level 2
RP/0/RP0/CPU0:h_N2(config-isis-af)#mpls traffic-eng level-2-only 
RP/0/RP0/CPU0:h_N2(config-isis-af)#mpls ?
  traffic-eng  Routing protocol commands for MPLS Traffic Engineering
RP/0/RP0/CPU0:h_N2(config-isis-af)#mpls traffic-eng ?
  router-id         Traffic Engineering stable IP address for system
RP/0/RP0/CPU0:h_N2(config-isis-af)#mpls traffic-eng router-id ?
  Loopback         Loopback interface(s) | short name is Lo
RP/0/RP0/CPU0:h_N2(config-isis-af)#mpls traffic-eng router-id Loopback 0
RP/0/RP0/CPU0:h_N2(config-isis-af)#show
Sat Mar 25 12:43:39.055 UTC
router isis 1
 address-family ipv4 unicast
  mpls traffic-eng level-2-only
  mpls traffic-eng router-id Loopback0
 !
!

RP/0/RP0/CPU0:h_N2(config-isis-af)#

③ グローバルで Segment Routing の Traffic-engineering 有効にします。

RP/0/RP0/CPU0:h_N2(config)#?
  segment-routing            Segment Routing
RP/0/RP0/CPU0:h_N2(config)#segment-routing ?
  traffic-eng     Segment Routing Traffic Engineering
RP/0/RP0/CPU0:h_N2(config)#segment-routing traffic-eng 
RP/0/RP0/CPU0:h_N2(config-sr-te)#
RP/0/RP0/CPU0:h_N2(config-sr-te)#show 
Sat Mar 25 12:50:31.803 UTC
segment-routing
 traffic-eng
 !
!

RP/0/RP0/CPU0:h_N2(config-sr-te)#

①先ずリンクの論理カラーを定義します。bit-position は任意の数字で良いですが、ドメインの全ノードで統一する必要があります。

RP/0/RP0/CPU0:h_N1(config)#segment-routing traffic-eng 
RP/0/RP0/CPU0:h_N1(config-sr-te)#?
  affinity-map        Affinity map configuration
RP/0/RP0/CPU0:h_N1(config-sr-te)#affinity-map 
RP/0/RP0/CPU0:h_N1(config-sr-te-affinity-map)#?
  name                Affinity name
RP/0/RP0/CPU0:h_N1(config-sr-te-affinity-map)#name ?
  WORD  Affinity color name
RP/0/RP0/CPU0:h_N1(config-sr-te-affinity-map)#name RED ?
  bit-position  Bit Position for the mapped affinity
RP/0/RP0/CPU0:h_N1(config-sr-te-affinity-map)#name RED bit-position ?
  <0-255>  Affinity attribute bit position
RP/0/RP0/CPU0:h_N1(config-sr-te-affinity-map)#name RED bit-position 10 ?
  <cr>  
RP/0/RP0/CPU0:h_N1(config-sr-te-affinity-map)#name RED bit-position 10 
RP/0/RP0/CPU0:h_N1(config-sr-te-affinity-map)#name BULE bit-position 20
RP/0/RP0/CPU0:h_N1(config-sr-te-affinity-map)#name GREEN bit-position 30
RP/0/RP0/CPU0:h_N1(config-sr-te-affinity-map)#    
RP/0/RP0/CPU0:h_N1(config-sr-te-affinity-map)#show
Sun Apr  2 09:22:11.691 UTC
segment-routing
 traffic-eng
  affinity-map
   name RED bit-position 10
   name BULE bit-position 20
   name GREEN bit-position 30
  !
 !
!

RP/0/RP0/CPU0:h_N1(config-sr-te-affinity-map)#

②それぞれのリンクに論理カラーを定義します。1リンクに複数のカラーを定義することも可能です。

RP/0/RP0/CPU0:h_N1(config)#segment-routing traffic-eng 
RP/0/RP0/CPU0:h_N1(config-sr-te)#interface gigabitEthernet 0/0/0/0
RP/0/RP0/CPU0:h_N1(config-sr-if)#?        
  affinity            Interface affinity configuration
RP/0/RP0/CPU0:h_N1(config-sr-if)#affinity 
RP/0/RP0/CPU0:h_N1(config-sr-if-affinity)#?
  name                Affinity name
RP/0/RP0/CPU0:h_N1(config-sr-if-affinity)#name ?
  RED    Affinity color name
  BULE   Affinity color name
  GREEN  Affinity color name
  WORD   Affinity color name
RP/0/RP0/CPU0:h_N1(config-sr-if-affinity)#name BULE ?
  <cr>  
RP/0/RP0/CPU0:h_N1(config-sr-if-affinity)#name BULE 
RP/0/RP0/CPU0:h_N1(config-sr-if-affinity)#interface gigabitEthernet 0/0/0/2
RP/0/RP0/CPU0:h_N1(config-sr-if)#affinity name BLUE
RP/0/RP0/CPU0:h_N1(config-sr-if)#affinity name GREEN
RP/0/RP0/CPU0:h_N1(config-sr-if)#
RP/0/RP0/CPU0:h_N1(config-sr-if)#show
Sun Apr  2 09:25:27.084 UTC
segment-routing
 traffic-eng
  interface GigabitEthernet0/0/0/2
   affinity
    name BLUE
    name GREEN
   !
  !
 !
!

RP/0/RP0/CPU0:h_N1(config-sr-if)#

残りのノードもトポロジ図で指定した通りに定義します。

5.2 Head-End(h_N1)

5.2.1 LSDBの情報をSR-TE DBに投入

IGP で以下のコマンドを定義します。ISIS のインターフェースレベルに合わせます。

RP/0/RP0/CPU0:h_N1(config)#router isis 1
RP/0/RP0/CPU0:h_N1(config-isis)#?
  distribute            Distribute routing information to external services
RP/0/RP0/CPU0:h_N1(config-isis)#distribute ?
  link-state  Distribute the link-state database to external services
RP/0/RP0/CPU0:h_N1(config-isis)#distribute link-state ?
  level        Set distribution for one level only
RP/0/RP0/CPU0:h_N1(config-isis)#distribute link-state level ?     
  <1-2>  Level
RP/0/RP0/CPU0:h_N1(config-isis)#distribute link-state level 2 
RP/0/RP0/CPU0:h_N1(config-isis)#

5.2.2 SR-TE Policy の定義

SR-TE Policy を以下のように定義します。
a) ポリシー名 :LINK_COLOR_CONSTRAINS_POLICY
b) B-SID(任意):24365
c) color :6666
d) Tail-End :6.6.6.6(h_N6)

SR-TEは、a)ポリシー名 と c)カラー、d)Tail-Endの指定が必須です。

① 先ずはポリシー名を定義します。

RP/0/RP0/CPU0:h_N1(config-sr-te)#policy ?
  WORD  Identifying name for policy with max 59 characters
RP/0/RP0/CPU0:h_N1(config-sr-te)#policy LINK_COLOR_CONSTRAINS_POLICY

② B-SID(binding-sid)は任意設定です。 ※ SR-TE Policy自体に割り当てられたSIDをB-SID(binding-sid)と呼びます。

RP/0/RP0/CPU0:h_N1(config-sr-te-policy)#?
  binding-sid              Binding Segment Identifier
RP/0/RP0/CPU0:h_N1(config-sr-te-policy)#binding-sid ?
  mpls  MPLS label
RP/0/RP0/CPU0:h_N1(config-sr-te-policy)#binding-sid mpls ?
  <16-1048575>  MPLS label
RP/0/RP0/CPU0:h_N1(config-sr-te-policy)#binding-sid mpls 24365 ?
  <cr>  

③ 次にカラーとTail-Endを指定します。

RP/0/RP0/CPU0:h_N1(config-sr-te-policy)#?
  color                    Specify color for policy
RP/0/RP0/CPU0:h_N1(config-sr-te-policy)#color ?
  <1-4294967295>  Color value
RP/0/RP0/CPU0:h_N1(config-sr-te-policy)#color 6666 ?
  end-point  Policy endpoint
RP/0/RP0/CPU0:h_N1(config-sr-te-policy)#color 6666 end-point ?
  ipv4  IPv4 address
RP/0/RP0/CPU0:h_N1(config-sr-te-policy)#color 6666 end-point ipv4 ?
  A.B.C.D  IPv4 endpoint address
RP/0/RP0/CPU0:h_N1(config-sr-te-policy)#color 6666 end-point ipv4 6.6.6.6 ?
  <cr>  

④ SR-TEポリシーで作成したLSP経由でパケットを転送させるため、autorouteを定義します。
端的に言うと、For traffic steering toward h_N6 ってことです。

RP/0/RP0/CPU0:h_N1(config-sr-te-policy)#?
  autoroute                Autoroute configuration
RP/0/RP0/CPU0:h_N1(config-sr-te-policy)#autoroute 
RP/0/RP0/CPU0:h_N1(config-sr-te-policy-autoroute)#?
  include             Prefixes for which IGP routes will be installed
RP/0/RP0/CPU0:h_N1(config-sr-te-policy-autoroute)#include ?
  all   Include all eligible prefixes
  ipv4  IPv4 address family
RP/0/RP0/CPU0:h_N1(config-sr-te-policy-autoroute)#include ipv4 ?
  A.B.C.D/length  IP prefix route to include
RP/0/RP0/CPU0:h_N1(config-sr-te-policy-autoroute)#include ipv4 6.6.6.6/32

5.2.3 Candidate-paths の定義

Candidate-paths を以下のように定義します。
a) preference :100(大きい方が優先されます!)
b) type :IGP(後の検証で他のタイプも確認します。)

RP/0/RP0/CPU0:h_N1(config-sr-te-policy)#?
  candidate-paths          Candidate-paths configuration
RP/0/RP0/CPU0:h_N1(config-sr-te-policy)#candidate-paths 
RP/0/RP0/CPU0:h_N1(config-sr-te-policy-path)#?
  preference          Policy path-option preference entry
RP/0/RP0/CPU0:h_N1(config-sr-te-policy-path)#preference ?
  <1-65535>  Path-option preference
RP/0/RP0/CPU0:h_N1(config-sr-te-policy-path)#preference 100 
RP/0/RP0/CPU0:h_N1(config-sr-te-policy-path-pref)#?
  dynamic             Dynamically allocated path
RP/0/RP0/CPU0:h_N1(config-sr-te-policy-path-pref)#dynamic ?
  metric                 Path metric configuration
RP/0/RP0/CPU0:h_N1(config-sr-te-policy-path-pref)#dynamic 
RP/0/RP0/CPU0:h_N1(config-sr-te-pp-info)#?
  metric                 Path metric configuration
RP/0/RP0/CPU0:h_N1(config-sr-te-pp-info)#metric 
RP/0/RP0/CPU0:h_N1(config-sr-te-path-metric)#type ?
  te        TE metric type
RP/0/RP0/CPU0:h_N1(config-sr-te-path-metric)#type te
RP/0/RP0/CPU0:h_N1(config-sr-te-path-metric)#
RP/0/RP0/CPU0:h_N1(config-sr-te-path-metric)#show
Sat Mar 25 13:10:29.595 UTC
segment-routing
 traffic-eng
  policy LINK_COLOR_CONSTRAINS_POLICY
   binding-sid mpls 24365
   color 6666 end-point ipv4 6.6.6.6
   autoroute
    include ipv4 6.6.6.6/32
   !
   candidate-paths
    preference 100
     dynamic
      metric
       type igp
      !
     !
    !
   !
  !
 !
!
RP/0/RP0/CPU0:h_N1(config-sr-te-path-metric)#

① SR-TE でトラフィックがリンクを通過する際、どの色を通過するのを許可するかの制約事項を定義します。

RP/0/RP0/CPU0:h_N1(config)#seg tra po LINK_COLOR_CONSTRAINS_POLICY can pref 100
RP/0/RP0/CPU0:h_N1(config-sr-te-policy-path-pref)#?
  constraints         Candidate path constraints
RP/0/RP0/CPU0:h_N1(config-sr-te-policy-path-pref)#constraints 
RP/0/RP0/CPU0:h_N1(config-sr-te-path-pref-const)#?
  affinity            Assign affinities to path
RP/0/RP0/CPU0:h_N1(config-sr-te-path-pref-const)#affinity ?
  exclude-any  Affinity attributes to exclude - presence of at least one excludes link
  include-all  Affinity attributes - all must be included
  include-any  Affinity attributes - at least one must be included
  <cr>         
RP/0/RP0/CPU0:h_N1(config-sr-te-path-pref-const)#   

② 3つ選択肢があります。
a) exclude-any Affinity attributes to exclude - presence of at least one excludes link
→ 指定した1つ以上のカラーを除いたものを許可します。
b) include-all Affinity attributes - all must be included
→ 指定したカラーがすべて一致する必要があります。
c) include-any Affinity attributes - at least one must be included
→ 指定した1つ以上のカラーが一致している必要があります。

詳しくは後で検証します。ここでは、a) exclude-any を選択します。

RP/0/RP0/CPU0:h_N1(config-sr-te-path-pref-const)#affinity 
RP/0/RP0/CPU0:h_N1(config-sr-te-path-pref-const-aff)#exclude-any      
RP/0/RP0/CPU0:(config-sr-te-path-pref-const-aff-rule)#?
  name                Affinity name
RP/0/RP0/CPU0:(config-sr-te-path-pref-const-aff-rule)#name ?
  RED    Affinity color name
  BULE   Affinity color name
  GREEN  Affinity color name
  WORD   Affinity color name
RP/0/RP0/CPU0:(config-sr-te-path-pref-const-aff-rule)#name RED ?
  <cr>  
RP/0/RP0/CPU0:(config-sr-te-path-pref-const-aff-rule)#name RED 
RP/0/RP0/CPU0:(config-sr-te-path-pref-const-aff-rule)#name GREEN

③ 最初に検証する条件としては、論理カラーが RED と GREEN のリンクを除外して Dynamic SR-TE が生成される様を確認します。

  policy LINK_COLOR_CONSTRAINS_POLICY
   binding-sid mpls 24365
   color 6666 end-point ipv4 6.6.6.6
   autoroute
    include ipv4 6.6.6.6/32
   !
   candidate-paths
    preference 100
     dynamic
      metric
       type igp
      !
     !
     constraints
      affinity
       exclude-any
        name RED
        name GREEN
       !
      !
     !
    !
   !
  !
 !
!

6. 検証

6.1 SR-TE 基本確認

SR-TEを定義すると新しいインターフェース(SR-TE用のLSP)が出現します。

  RP/0/RP0/CPU0:h_N1#show ip interface brief | exclude una
  Sun Apr  2 09:50:50.758 UTC
  
  Interface                      IP-Address      Status          Protocol Vrf-Name
★srte_c_6666_ep_6.6.6.6         1.1.1.1         Up              Up       default 
  Loopback0                      1.1.1.1         Up              Up       default 
  GigabitEthernet0/0/0/0         10.1.2.1        Up              Up       default 
  GigabitEthernet0/0/0/2         10.1.3.1        Up              Up       default 
  RP/0/RP0/CPU0:h_N1#

今回定義したSR-TEポリシーは、Head-End:1.1.1.1(h_N1)、color:6000、Tail-End:6.6.6.6(h_N6)です。 ルーティングにその変化が現れています。

  RP/0/RP0/CPU0:h_N1#show route 6.6.6.6/32 detail 
  Sun Apr  2 09:52:02.957 UTC
  
  Routing entry for 6.6.6.6/32
    Known via "isis 1", distance 115, metric 40, labeled SR, label redist non FIB, type level-2
    Installed Apr  2 09:30:31.882 for 00:21:31
    Routing Descriptor Blocks
★    6.6.6.6, from 6.6.6.6, via srte_c_6666_ep_6.6.6.6
        Route metric is 40
        Label: 0x3 (3)
        Tunnel ID: None
        Binding Label: 0x5f2d (24365)
        Extended communities count: 0
        Path id:1       Path ref count:0
        NHID:0x0(Ref:0)
    Route version is 0x95 (149)
    Local Label: 0x3e86 (16006)
    IP Precedence: Not Set
    QoS Group ID: Not Set
    Flow-tag: Not Set
    Fwd-class: Not Set
    Route Priority: RIB_PRIORITY_NON_RECURSIVE_MEDIUM (7) SVD Type RIB_SVD_TYPE_LOCAL
    Download Priority 1, Download Version 1079
    No advertising protos. 
  RP/0/RP0/CPU0:h_N1#

Head-End:1.1.1.1(h_N1)の LFIB を確認すると、 SR-TEの NEXT_HOP やTail-End、B-SID(任意):24365も確認できます。
SR-TE(LINK_COLOR_CONSTRAINS_POLICY)
・Head-End:1.1.1.1(h_N1)
・NEXT_HOP:10.1.2.2(Gi0/0/0/0)
・B-SID :24365

  RP/0/RP0/CPU0:h_N1#show mpls forwarding 
  Sun Apr  2 09:52:59.620 UTC
  Local  Outgoing    Prefix             Outgoing     Next Hop        Bytes       
  Label  Label       or ID              Interface                    Switched    
  ------ ----------- ------------------ ------------ --------------- ------------
  16002  Pop         SR Pfx (idx 2)     Gi0/0/0/0    10.1.2.2        0           
  16003  Pop         SR Pfx (idx 3)     Gi0/0/0/2    10.1.3.3        0           
  16004  16004       SR Pfx (idx 4)     Gi0/0/0/2    10.1.3.3        0           
  16005  16005       SR Pfx (idx 5)     Gi0/0/0/2    10.1.3.3        0           
  16006  16006       SR Pfx (idx 6)     Gi0/0/0/2    10.1.3.3        0           
  24000  Pop         SR Adj (idx 1)     Gi0/0/0/2    10.1.3.3        0           
  24001  Pop         SR Adj (idx 3)     Gi0/0/0/2    10.1.3.3        0           
  24002  Pop         SR Adj (idx 1)     Gi0/0/0/0    10.1.2.2        0           
  24003  Pop         SR Adj (idx 3)     Gi0/0/0/0    10.1.2.2        0           
★24005  Pop         6.6.6.6/32         srte_c_6666_ 6.6.6.6         0           
  24006  Pop         No ID              Gi0/0/0/0    10.1.2.2        0           
★24007  16003       SR TE: 4 [TE-INT]  Gi0/0/0/0    10.1.2.2        364         
  24008  Pop         No ID              Gi0/0/0/2    10.1.3.3        0           
★24365  Pop         No ID              srte_c_6666_ point2point     0           
  RP/0/RP0/CPU0:h_N1# 

CEFを確認するとSR-TEで定義した内容が反映されています。他のLoopbackアドレスと見比べると分かりやすいかと思います。
SR-TEのautorouteが効いています。他のLoopbackアドレスだとNEXT_HOPがインターフェース名ですが、Head-End宛だけがSR-TEになっています。

  RP/0/RP0/CPU0:h_N1#show cef 
  Sun Apr  2 09:54:33.596 UTC
  
  Prefix              Next Hop            Interface
  ------------------- ------------------- ------------------
  0.0.0.0/0           drop                default handler 
  0.0.0.0/32          broadcast
  1.1.1.1/32          receive             Loopback0
  2.2.2.2/32          10.1.2.2/32         GigabitEthernet0/0/0/0
  3.3.3.3/32          10.1.3.3/32         GigabitEthernet0/0/0/2
  4.4.4.4/32          10.1.3.3/32         GigabitEthernet0/0/0/2
  5.5.5.5/32          10.1.3.3/32         GigabitEthernet0/0/0/2
★6.6.6.6/32          6.6.6.6/32          srte_c_6666_ep_6.6.6.6
  10.1.2.0/24         attached            GigabitEthernet0/0/0/0
  10.1.2.0/32         broadcast           GigabitEthernet0/0/0/0
  10.1.2.1/32         receive             GigabitEthernet0/0/0/0
  10.1.2.255/32       broadcast           GigabitEthernet0/0/0/0
  10.1.3.0/24         attached            GigabitEthernet0/0/0/2
  10.1.3.0/32         broadcast           GigabitEthernet0/0/0/2
  10.1.3.1/32         receive             GigabitEthernet0/0/0/2
  10.1.3.255/32       broadcast           GigabitEthernet0/0/0/2
  10.2.3.0/24         10.1.2.2/32         GigabitEthernet0/0/0/0
                      10.1.3.3/32         GigabitEthernet0/0/0/2
  10.2.4.0/24         10.1.2.2/32         GigabitEthernet0/0/0/0
  10.3.4.0/24         10.1.3.3/32         GigabitEthernet0/0/0/2
  10.3.5.0/24         10.1.3.3/32         GigabitEthernet0/0/0/2
  10.4.5.0/24         10.1.3.3/32         GigabitEthernet0/0/0/2
  10.4.6.0/24         10.1.3.3/32         GigabitEthernet0/0/0/2
  10.5.6.0/24         10.1.3.3/32         GigabitEthernet0/0/0/2
  127.0.0.0/8         receive
  224.0.0.0/4         0.0.0.0/32          
  224.0.0.0/24        receive
  255.255.255.255/32  broadcast
  RP/0/RP0/CPU0:h_N1#

SR-TE ポリシーの情報はコマンドで確認することができます。

   RP/0/RP0/CPU0:h_N1#show segment-routing traffic-eng policy 
   Sun Apr  2 09:55:27.281 UTC
   
   SR-TE policy database
   ---------------------
   
   Color: 6666, End-point: 6.6.6.6
★1  Name: srte_c_6666_ep_6.6.6.6
     Status:
★2    Admin: up  Operational: up for 00:24:55 (since Apr  2 09:30:31.714)
     Candidate-paths:
       Preference: 100 (configuration) (active)
★3      Name: LINK_COLOR_CONSTRAINS_POLICY
★4      Requested BSID: 24365
         Constraints:
           Protection Type: protected-preferred
★5        Affinity:
★5          exclude-any:
★5          GREEN
★5          RED
           Maximum SID Depth: 10 
★6      Dynamic (valid)
★7        Metric Type: TE,   Path Accumulated Metric: 130 
★8          16002 [Prefix-SID, 2.2.2.2]
★8          16003 [Prefix-SID, 3.3.3.3]
★8          24003 [Adjacency-SID, 10.3.4.3 - 10.3.4.4]
★8          16006 [Prefix-SID, 6.6.6.6]
     Attributes:
       Binding SID: 24365
       Forward Class: Not Configured
       Steering labeled-services disabled: no
       Steering BGP disabled: no
       IPv6 caps enable: yes
       Invalidation drop enabled: no
   
   RP/0/RP0/CPU0:h_N1#

★1:Color と End-point(Head-End) が自動的にLSP名に反映されるのが特徴です。
SR-TE LSP名(Name: srte_c_6_ep_6.6.6.6)から、Color: 6000, End-point: 6.6.6.6であることが分かります。
★2:SR-TEが有効な状態を示しています。(Admin: up Operational: up)
★3:SR-TE ポリシーは、LINK_COLOR_CONSTRAINS_POLICY であることが分かります。
★4:このSR-TEに紐づけられているBinding SIDは、 24365 であることが分かります。
★5:論理リンクの GREEN と RED を通過しないTEであることが分かります。
★6:有効な Dynamic SR-TE であることが分かります。
★7:Dynamic SR-TE は TE のメトリックで計算して 最短経路が 130 であることが分かります。
★8:SID-list(今回は4つのSID)が確認できます。

tracerouteを実行すると、SR-TE の経路が分かります。

RP/0/RP0/CPU0:h_N1#traceroute 6.6.6.6 source 1.1.1.1       
Sun Apr  2 10:07:46.695 UTC

Type escape sequence to abort.
Tracing the route to 6.6.6.6

 1  10.1.2.2 [MPLS: Labels 16003/24003/16006 Exp 0] 11 msec  3 msec  3 msec 
 2  10.2.3.3 [MPLS: Labels 24003/16006 Exp 0] 6 msec  4 msec  3 msec 
 3  10.3.4.4 [MPLS: Label 16006 Exp 0] 7 msec  3 msec  3 msec 
 4  10.4.6.6 16 msec  *  16 msec 
RP/0/RP0/CPU0:h_N1#


除外リンク(RED & GREEN)を経由しない、かつ TE のメトリックが最小となる経路の SR-TE が動的に生成されていることが分かります。

次のコマンドで、SR-TE の転送状況が確認できます。

RP/0/RP0/CPU0:h_N1#show segment-routing traffic-eng forwarding policy 
Sun Apr  2 10:15:43.883 UTC

SR-TE Policy Forwarding database
--------------------------------

Color: 6666, End-point: 6.6.6.6
  Name: srte_c_6666_ep_6.6.6.6
  Binding SID: 24365
  Active LSP:
    Candidate path:
      Preference: 100 (configuration)
      Name: LINK_COLOR_CONSTRAINS_POLICY
    Local label: 24007
    Segment lists:
      SL[0]:
        Name: dynamic
        Switched Packets/Bytes: 25/700
          [MPLS -> MPLS]: 25/700
        Paths:
          Path[0]:
            Outgoing Label: 16003
            Outgoing Interfaces: GigabitEthernet0/0/0/0
            Next Hop: 10.1.2.2
            Switched Packets/Bytes: 25/700
              [MPLS -> MPLS]: 25/700
            FRR Pure Backup: No
            ECMP/LFA Backup: No
            Internal Recursive Label: Unlabelled (recursive)
            Label Stack (Top -> Bottom): { 16003, 24003, 16006 }

  Policy Packets/Bytes Switched: 51/1428

RP/0/RP0/CPU0:h_N1#

6.2 metric type:igp(exclude-any: RED and GREEN )

ここで、metric type:igp に変更します。

RP/0/RP0/CPU0:h_N1(config)#
RP/0/RP0/CPU0:h_N1(config)#seg tr policy LINK_COLOR_CONSTRAINS_POLICY can pref$
RP/0/RP0/CPU0:h_N1(config-sr-te-path-metric)#type igp
RP/0/RP0/CPU0:h_N1(config-sr-te-path-metric)#show
Sun Apr  2 10:17:55.796 UTC
segment-routing
 traffic-eng
  policy LINK_COLOR_CONSTRAINS_POLICY
   candidate-paths
    preference 100
     dynamic
      metric
       type igp
      !
     !
    !
   !
  !
 !
!

RP/0/RP0/CPU0:h_N1(config-sr-te-path-metric)#

インターフェースの状態、ルーティングテーブル、CEFは変化がありませんが、LFIBに変化が現れます。

   RP/0/RP0/CPU0:h_N1#show mpls forwarding 
   Sun Apr  2 10:19:45.505 UTC
   Local  Outgoing    Prefix             Outgoing     Next Hop        Bytes       
   Label  Label       or ID              Interface                    Switched    
   ------ ----------- ------------------ ------------ --------------- ------------
   16002  Pop         SR Pfx (idx 2)     Gi0/0/0/0    10.1.2.2        0           
   16003  Pop         SR Pfx (idx 3)     Gi0/0/0/2    10.1.3.3        0           
   16004  16004       SR Pfx (idx 4)     Gi0/0/0/2    10.1.3.3        0           
   16005  16005       SR Pfx (idx 5)     Gi0/0/0/2    10.1.3.3        0           
   16006  16006       SR Pfx (idx 6)     Gi0/0/0/2    10.1.3.3        0           
   24000  Pop         SR Adj (idx 1)     Gi0/0/0/2    10.1.3.3        0           
   24001  Pop         SR Adj (idx 3)     Gi0/0/0/2    10.1.3.3        0           
   24002  Pop         SR Adj (idx 1)     Gi0/0/0/0    10.1.2.2        0           
   24003  Pop         SR Adj (idx 3)     Gi0/0/0/0    10.1.2.2        0           
   24005  Pop         6.6.6.6/32         srte_c_6666_ 6.6.6.6         0           
   24006  Pop         No ID              Gi0/0/0/0    10.1.2.2        0           
   24008  Pop         No ID              Gi0/0/0/2    10.1.3.3        0           
★ 24009  24003       SR TE: 4 [TE-INT]  Gi0/0/0/0    10.1.2.2        252         
   24365  Pop         No ID              srte_c_6666_ point2point     0           
   RP/0/RP0/CPU0:h_N1#

IGP のメトリック合計が最も小さい経路のみに SR-TE が動的に変化します。
SR-TE ポリシーにもその変化は現れます。

   RP/0/RP0/CPU0:h_N1#show segment-routing traffic-eng policy 
   Sun Apr  2 10:21:28.895 UTC
   
   SR-TE policy database
   ---------------------
   
   Color: 6666, End-point: 6.6.6.6
     Name: srte_c_6666_ep_6.6.6.6
     Status:
       Admin: up  Operational: up for 00:50:57 (since Apr  2 09:30:31.714)
     Candidate-paths:
       Preference: 100 (configuration) (active)
         Name: LINK_COLOR_CONSTRAINS_POLICY
         Requested BSID: 24365
         Constraints:
           Protection Type: protected-preferred
           Affinity:
             exclude-any:
             GREEN
             RED
           Maximum SID Depth: 10 
         Dynamic (valid)
★1        Metric Type: IGP,   Path Accumulated Metric: 220 
★2          16002 [Prefix-SID, 2.2.2.2]
★2          24003 [Adjacency-SID, 10.2.4.2 - 10.2.4.4]
★2          16006 [Prefix-SID, 6.6.6.6]
     Attributes:
       Binding SID: 24365
       Forward Class: Not Configured
       Steering labeled-services disabled: no
       Steering BGP disabled: no
       IPv6 caps enable: yes
       Invalidation drop enabled: no
   
   RP/0/RP0/CPU0:h_N1#

★1:Dynamic SR-TE は IGP のメトリックで計算して 最短経路が 220 であることが分かります。
★2:SID-list(今回は3つのSID)が確認できます。

RP/0/RP0/CPU0:h_N1#traceroute 6.6.6.6 source 1.1.1.1       
Sun Apr  2 10:23:30.644 UTC

Type escape sequence to abort.
Tracing the route to 6.6.6.6

 1  10.1.2.2 [MPLS: Labels 24003/16006 Exp 0] 10 msec  3 msec  3 msec 
 2  10.2.4.4 [MPLS: Label 16006 Exp 0] 5 msec  3 msec  3 msec 
 3  10.4.6.6 13 msec  *  5 msec 
RP/0/RP0/CPU0:h_N1#


除外リンク(RED & GREEN)を経由しない、かつ IGP のメトリックが最小となる経路の SR-TE が動的に生成されていることが分かります。

次のコマンドで、SR-TE の転送状況が確認できます。

RP/0/RP0/CPU0:h_N1#show segment-routing traffic-eng forwarding policy detail 
Sun Apr  2 10:24:47.843 UTC

SR-TE Policy Forwarding database
--------------------------------

Color: 6666, End-point: 6.6.6.6
  Name: srte_c_6666_ep_6.6.6.6
  Binding SID: 24365
  Active LSP:
    Candidate path:
      Preference: 100 (configuration)
      Name: LINK_COLOR_CONSTRAINS_POLICY
    Local label: 24009
    Segment lists:
      SL[0]:
        Name: dynamic
        Switched Packets/Bytes: 18/504
          [MPLS -> MPLS]: 18/504
        Paths:
          Path[0]:
            Outgoing Label: 24003
            Outgoing Interfaces: GigabitEthernet0/0/0/0
            Next Hop: 10.1.2.2
            Switched Packets/Bytes: 18/504
              [MPLS -> MPLS]: 18/504
            FRR Pure Backup: No
            ECMP/LFA Backup: No
            Internal Recursive Label: Unlabelled (recursive)
            Label Stack (Top -> Bottom): { 24003, 16006 }
            Path-id: 1, Weight: 64

  Policy Packets/Bytes Switched: 69/1932

RP/0/RP0/CPU0:h_N1#

”exclude-any”の使い方が分かったので、次の選択肢を検証します。

6.3 include-all:BLUE / metric type:IGP

指定したカラーがすべて一致するという制約条件に変更します。 h_N1 から h_N6 の経路で”include-all”として指定できるカラーは BLUE しかありません。

RP/0/RP0/CPU0:h_N1(config-sr-te-path-pref-const)#affinity ?
  exclude-any  Affinity attributes to exclude - presence of at least one excludes link
  include-all  Affinity attributes - all must be included
  include-any  Affinity attributes - at least one must be included
  <cr>         
RP/0/RP0/CPU0:h_N1(config-sr-te-path-pref-const)#   

ということで、”include-all:BLUE ”に変更します。

RP/0/RP0/CPU0:h_N1(config)#seg tr po LINK_COLOR_CONSTRAINS_POLICY can pref 100
RP/0/RP0/CPU0:h_N1(config-sr-te-policy-path-pref)#constraints affinity 
RP/0/RP0/CPU0:h_N1(config-sr-te-path-pref-const-aff)#no exclude-any 
RP/0/RP0/CPU0:h_N1(config-sr-te-path-pref-const-aff)#include-all
RP/0/RP0/CPU0:(config-sr-te-path-pref-const-aff-rule)#name BLUE
RP/0/RP0/CPU0:(config-sr-te-path-pref-const-aff-rule)#show
Sun Apr  2 10:38:43.268 UTC
segment-routing
 traffic-eng
  policy LINK_COLOR_CONSTRAINS_POLICY
   candidate-paths
    preference 100
     constraints
      affinity
       include-all
        name BLUE
       !
      !
     !
    !
   !
  !
 !
!

RP/0/RP0/CPU0:(config-sr-te-path-pref-const-aff-rule)#

traceroute を実行してみます。

RP/0/RP0/CPU0:h_N1#traceroute 6.6.6.6 source 1.1.1.1
Sun Apr  2 12:06:11.386 UTC

Type escape sequence to abort.
Tracing the route to 6.6.6.6

 1  10.1.3.3 [MPLS: Label 16006 Exp 0] 10 msec  4 msec  3 msec 
 2  10.3.5.5 [MPLS: Label 16006 Exp 0] 5 msec  3 msec  3 msec 
 3  10.5.6.6 8 msec  *  9 msec 
RP/0/RP0/CPU0:h_N1#

(。´・ω・)ん? おかしい! RED のリンクを通過しています。以下のようになることを想定していました。


許可リンク(BLUE のみ)を経由する、かつ IGP のメトリックが最小となる経路の SR-TE が動的に生成されることを想定していました。

RP/0/RP0/CPU0:h_N1#show segment-routing traffic-eng policy 
Sun Apr  2 14:09:14.130 UTC

SR-TE policy database
---------------------

Color: 6666, End-point: 6.6.6.6
  Name: srte_c_6666_ep_6.6.6.6
  Status:
    Admin: up  Operational: up for 02:15:18 (since Apr  2 11:53:56.135)
  Candidate-paths:
    Preference: 100 (configuration) (active)
      Name: LINK_COLOR_CONSTRAINS_POLICY
      Requested BSID: 24365
        Protection Type: protected-preferred
        Maximum SID Depth: 10 
      Dynamic (valid)
        Metric Type: IGP,   Path Accumulated Metric: 30 
          16006 [Prefix-SID, 6.6.6.6]
  Attributes:
    Binding SID: 24365
    Forward Class: Not Configured
    Steering labeled-services disabled: no
    Steering BGP disabled: no
    IPv6 caps enable: yes
    Invalidation drop enabled: no

RP/0/RP0/CPU0:h_N1#

Affinity: が何故か反映されない。 include-all:BLUE / metric type:TE にしても同じ結果でした。 何か bug を踏んだ予感がします。

6.4 include-any:BLUE and RED / metric type:TE

指定した1つ以上のカラーが一致するという制約条件に変更します。

RP/0/RP0/CPU0:h_N1(config-sr-te-path-pref-const)#affinity ?
  exclude-any  Affinity attributes to exclude - presence of at least one excludes link
  include-all  Affinity attributes - all must be included
  include-any  Affinity attributes - at least one must be included
  <cr>         
RP/0/RP0/CPU0:h_N1(config-sr-te-path-pref-const)#   

ということで、”include-any:RED & BLUE ”に変更します。

RP/0/RP0/CPU0:h_N1(config)#seg tr po LINK_COLOR_CONSTRAINS_POLICY can pref 100$
RP/0/RP0/CPU0:h_N1(config-sr-te-path-pref-const-aff)#no include-all 
RP/0/RP0/CPU0:h_N1(config-sr-te-path-pref-const-aff)#include-any
RP/0/RP0/CPU0:(config-sr-te-path-pref-const-aff-rule)#name RED
RP/0/RP0/CPU0:(config-sr-te-path-pref-const-aff-rule)#name BLUE
RP/0/RP0/CPU0:(config-sr-te-path-pref-const-aff-rule)#show
Sun Apr  2 14:29:20.521 UTC
segment-routing
 traffic-eng
  policy LINK_COLOR_CONSTRAINS_POLICY
   candidate-paths
    preference 100
     constraints
      affinity
       include-any
        name RED
        name BLUE
       !
      !
     !
    !
   !
  !
 !
!

RP/0/RP0/CPU0:(config-sr-te-path-pref-const-aff-rule)#

traceroute を確認するとぱっと見は想定通りですが、SID-listが妙です。

RP/0/RP0/CPU0:h_N1#traceroute 6.6.6.6 source 1.1.1.1
Sun Apr  2 14:30:51.761 UTC

Type escape sequence to abort.
Tracing the route to 6.6.6.6

 1  10.1.3.3 [MPLS: Label 16006 Exp 0] 19 msec  5 msec  4 msec 
 2  10.3.5.5 [MPLS: Label 16006 Exp 0] 6 msec  4 msec  3 msec 
 3  10.5.6.6 10 msec  *  5 msec 
RP/0/RP0/CPU0:h_N1#


許可リンク(RED & BLUE)を経由する、かつ IGP のメトリックが最小となる経路の SR-TE が動的に生成されることを想定していました。
SR-TE ポリシーを確認するとやっぱりおかしい。down しているし affinity が足りないです。

RP/0/RP0/CPU0:h_N1#show segment-routing traffic-eng policy 
Sun Apr  2 14:33:39.609 UTC

SR-TE policy database
---------------------

Color: 6666, End-point: 6.6.6.6
  Name: srte_c_6666_ep_6.6.6.6
  Status:
★  Admin: up  Operational: down for 00:05:41 (since Apr  2 14:27:57.938)
  Candidate-paths:
    Preference: 100 (configuration)
      Name: LINK_COLOR_CONSTRAINS_POLICY
      Requested BSID: 24365
      Constraints:
        Protection Type: protected-preferred
★      Affinity:
★        include-any:
★        RED
        Maximum SID Depth: 10 
      Dynamic (invalid)
      Last error: No path found
        Metric Type: IGP,   Path Accumulated Metric: 30 
  Attributes:
    Forward Class: 0
    Steering labeled-services disabled: no
    Steering BGP disabled: no
    IPv6 caps enable: no
    Invalidation drop enabled: no

RP/0/RP0/CPU0:h_N1#

7. 検証から分かったこと

Link Color Constraints は意図した動作をするものとしないものがある。 IOS-XR 7.7.1 に変えても、”include-any ”と ”include-all ”は意図した動作をしませんでした。

8. 参考

① Constraints
www.cisco.com

② Segment Routing Traffic Engineering – Dynamic Candidate PathのLink Color
y-network.jp

次回は、SR & L3VPN について記事を書きます。
最後までお読みいただきありがとうございました!