Genie's Tech Blog

Where knowledge has no dimensions

MPLS TE Affinity

Hello Friends,

Today, i am going to have an interesting discussion on Coloring concept in MPLS TE which is actually implemented through Affinity value and mask. You must have already read in my previous posts as how MPLS TE works. Today, we will be seeing how Affinity works and what is it used for. Before we start off with Affinity, lets first discuss the MPLS TE property called Attribute-Flag. Its a 32-bit bitmap on a link that can indicate the existence of up to 32 separate properties on that link. The default value of this property is 0x0. The attributes can vary from 0x0 to 0xFFFFFFFF. The calculation for the attributes is all done using 0 and 1. Please remember that the attribute-flag is configured under the interface where as TE Affinity and Mask are configured under the tunnel interface on the headend router. MPLS TE Affinity is used to influence the path selection process of the MPLS TE Tunnels. It interacts with CSPF to decide upon which interface should be added to the path and which should be ignored. In order to better understand how the TE affinity and Mask works with attribute-flags, I will start with a simple equation.

(AFFINITY && MASK) == (ATTRIBUTE && MASK)

Now lets try to understand the tricky part here - the connection between the affinity value and the mask. In simple words, if a bit is set to 1 in the mask, you will care about the value in the affinity string. Lets try to understand this with the help of an example. Consider a TE tunnel with the affinity value of 0x1 which in binary is 0000 0001. Now say, you want to match a path which has 01 at the end. Thus you care about the last two bits which in binary becomes 0000 0011 (remember that 1 means you care about the value). So, now if you configure the interface with the attribute-flag value of 0x1 across the path you want to setup, the TE tunnel will come up. But if you try to configure the affinity-flag value of 0x3 which means the value is (0000 0011) which means its not matching with the affinity value, the TE tunnel will not come up. If you configure the Affinity-Flag as 0x5, then the TE tunnel should be again up as the binary is (0000 0101). If you do the AND operation with the Mask you match the last two bits which is 01. Hope this clarifies a bit. Lets now have a look at the live example. Consider the below topology.

 

In the above topology, XR1 is acting as the headend router and R5 is acting as the Tailend router. Lets now have a look at the configuration on XR1 router.

Config on XR1:
===========
router ospf 100
 router-id 1.1.1.1
 area 0
  mpls traffic-eng
  interface Loopback0
  !
  interface GigabitEthernet0/0/0/0
  !
  interface GigabitEthernet0/0/0/1
  !
  interface GigabitEthernet0/0/0/2
  !
 !
 mpls traffic-eng router-id Loopback0
!

mpls ldp
 router-id 1.1.1.1
 interface GigabitEthernet0/0/0/0
 !
 interface GigabitEthernet0/0/0/1
 !
 interface GigabitEthernet0/0/0/2
 !
!
mpls traffic-eng
 interface GigabitEthernet0/0/0/0
 !
 interface GigabitEthernet0/0/0/1
 !
 interface GigabitEthernet0/0/0/2
 !

interface tunnel-te15
 bandwidth 5000
 ipv4 unnumbered Loopback0
 autoroute announce
 destination 5.5.5.5
 path-option 1 dynamic
!

Similar configuration can be put in on other XR and IOS routers. Now the above config is without the TE Affinity and Attribute-Flag under the interfaces. The TE tunnel will come up dynamically choosing the shortest path.

Output on XR1:
===========
RP/0/0/CPU0:XR1#sh mpls traffic-eng tunnels 15
Tue Dec 31 15:18:53.912 SGT


Name: tunnel-te15  Destination: 5.5.5.5
  Status:
    Admin:    up Oper:   up   Path:  valid   Signalling: connected

    path option 1,  type dynamic  (Basis for Setup, path weight 2)
    G-PID: 0x0800 (derived from egress interface properties)
    Bandwidth Requested: 0 kbps  CT0
    Creation Time: Tue Dec 31 11:32:32 2013 (03:46:22 ago)
  Config Parameters:
    Bandwidth:        0 kbps (CT0) Priority:  7  7 Affinity: 0x0/0xffff
    Metric Type: TE (default)
    Hop-limit: disabled
    AutoRoute:  enabled  LockDown: disabled   Policy class: not set
    Forward class: 0 (default)
    Forwarding-Adjacency: disabled
    Loadshare:          0 equal loadshares
    Auto-bw: disabled
    Fast Reroute: Disabled, Protection Desired: None
    Path Protection: Not Enabled
    BFD Fast Detection: Disabled
    Soft Preemption: Disabled
  History:
    Tunnel has been up for: 03:46:22 (since Tue Dec 31 11:32:32 SGT 2013)
    Current LSP:
      Uptime: 03:46:22 (since Tue Dec 31 11:32:32 SGT 2013)
    Reopt. LSP:
      Last Failure:
        LSP not signalled, identical to the [CURRENT] LSP
        Date/Time: Tue Dec 31 11:52:31 SGT 2013 [03:26:23 ago]

  Path info (OSPF 100 area 0):
  Node hop count: 2
  Hop0: 14.14.14.4
  Hop1: 45.45.45.4
  Hop2: 45.45.45.5
  Hop3: 5.5.5.5
Displayed 1 (of 1) heads, 0 (of 0) midpoints, 0 (of 0) tails
Displayed 1 up, 0 down, 0 recovering, 0 recovered heads
RP/0/0/CPU0:XR1#

Now lets try to play around with the path. We configure the below command under the Tunne-TE 15 interface:

"affinity 0x1 mask 0x3"

In the above config, we are setting the affinity bit to 0x1 i.e. 0000 0001 and the mask value as 0x3 which means that we need to care about just the last two bits i.e. 0000 0011. Now we configure the attribute-flag value of 0x1 on the interfaces following the path : XR1 --- XR3 --- XR4 --- R5.

Config on XR1:
==========
mpls traffic-eng
 interface GigabitEthernet0/0/0/0
 !
 interface GigabitEthernet0/0/0/1
 !
 interface GigabitEthernet0/0/0/2
  attribute-flags 0x1
 !

We can now see that the path has been modified accordingly for the MPLS TE Tunnel.

Output on XR1:
===========
RP/0/0/CPU0:XR1#sh mpls tra tunnels 15
Fri Jan  3 01:32:28.340 SGT


Name: tunnel-te15  Destination: 5.5.5.5
  Status:
    Admin:    up Oper:   up   Path:  valid   Signalling: connected

    path option 1,  type dynamic  (Basis for Setup, path weight 3)
    G-PID: 0x0800 (derived from egress interface properties)
    Bandwidth Requested: 0 kbps  CT0
    Creation Time: Tue Dec 31 11:32:32 2013 (2d13h ago)
  Config Parameters:
    Bandwidth:        0 kbps (CT0) Priority:  7  7 Affinity: 0x1/0x3
    Metric Type: TE (default)
    Hop-limit: disabled
    AutoRoute:  enabled  LockDown: disabled   Policy class: not set
    Forward class: 0 (default)
    Forwarding-Adjacency: disabled
    Loadshare:          0 equal loadshares
    Auto-bw: disabled
    Fast Reroute: Disabled, Protection Desired: None
    Path Protection: Not Enabled
    BFD Fast Detection: Disabled
    Soft Preemption: Disabled
  History:
    Tunnel has been up for: 00:00:12 (since Fri Jan 03 01:32:16 SGT 2014)
    Current LSP:
      Uptime: 00:00:12 (since Fri Jan 03 01:32:16 SGT 2014)
    Reopt. LSP:
      Last Failure:
        LSP not signalled, identical to the [CURRENT] LSP
        Date/Time: Fri Jan 03 00:52:31 SGT 2014 [00:39:57 ago]
    Prior LSP:
      ID: 4 Path Option: 1
      Removal Trigger: path verification failed

  Path info (OSPF 100 area 0):
  Node hop count: 3
  Hop0: 13.13.13.3
  Hop1: 34.34.34.3
  Hop2: 34.34.34.4
  Hop3: 45.45.45.4
  Hop4: 45.45.45.5
  Hop5: 5.5.5.5
Displayed 1 (of 1) heads, 0 (of 0) midpoints, 0 (of 0) tails
Displayed 1 up, 0 down, 0 recovering, 0 recovered heads
RP/0/0/CPU0:XR1#

We can again main the headend choose a better path. If we configure the interface facing XR4 with the attribute-flag of 0x5, then it still matches the equation that we saw above.

Config on XR1:
==========
mpls traffic-eng
 interface GigabitEthernet0/0/0/0
  attribute-flags 0x5
 !
 interface GigabitEthernet0/0/0/1
 !
 interface GigabitEthernet0/0/0/2
  attribute-flags 0x1
 !

With this config, the TE "Affinity And Mask" value matches with the "Attribute-Flag And Mask". Lets have a look at the re-optimized path.

Output on XR1:
===========
RP/0/0/CPU0:XR1#sh mpls tr tunnels 15
Sat Jan  4 05:29:54.650 SGT


Name: tunnel-te15  Destination: 5.5.5.5
  Status:
    Admin:    up Oper:   up   Path:  valid   Signalling: connected

    path option 1,  type dynamic  (Basis for Setup, path weight 2)
    G-PID: 0x0800 (derived from egress interface properties)
    Bandwidth Requested: 0 kbps  CT0
    Creation Time: Tue Dec 31 11:32:32 2013 (3d17h ago)
  Config Parameters:
    Bandwidth:        0 kbps (CT0) Priority:  7  7 Affinity: 0x1/0x3
    Metric Type: TE (default)
    Hop-limit: disabled
    AutoRoute:  enabled  LockDown: disabled   Policy class: not set
    Forward class: 0 (default)
    Forwarding-Adjacency: disabled
    Loadshare:          0 equal loadshares
    Auto-bw: disabled
    Fast Reroute: Disabled, Protection Desired: None
    Path Protection: Not Enabled
    BFD Fast Detection: Disabled
    Soft Preemption: Disabled
  History:
    Tunnel has been up for: 02:10:14 (since Sat Jan 04 03:19:41 SGT 2014)
    Current LSP:
      Uptime: 02:10:14 (since Sat Jan 04 03:19:41 SGT 2014)
    Reopt. LSP:
      Last Failure:
        LSP not signalled, identical to the [CURRENT] LSP
        Date/Time: Sat Jan 04 03:24:31 SGT 2014 [02:05:24 ago]
    Prior LSP:
      ID: 6 Path Option: 1
      Removal Trigger: reoptimization completed

  Path info (OSPF 100 area 0):
  Node hop count: 2
  Hop0: 14.14.14.4
  Hop1: 45.45.45.4
  Hop2: 45.45.45.5
  Hop3: 5.5.5.5
Displayed 1 (of 1) heads, 0 (of 0) midpoints, 0 (of 0) tails
Displayed 1 up, 0 down, 0 recovering, 0 recovered heads
RP/0/0/CPU0:XR1#

From the above output we can see that the path has now been modified back to XR1 --- XR4 --- R5. Also, do not forget to look at the Affinity value in the above output. It displays what the tunnel is configured for. If you want to check out for path options for the TE tunnel based on their attribute-flag & affinity, you can check the command "show mpls traffic-eng tunnels affinity".

Output on XR1:
==========
RP/0/0/CPU0:XR1#sh mpls traffic-eng tunnels affinity
Sat Jan  4 06:25:46.855 SGT


Name: tunnel-te15  Destination: 5.5.5.5
  Status:
    Admin:    up Oper:   up   Path:  valid   Signalling: connected

    path option 1,  type dynamic  (Basis for Setup, path weight 2)
    G-PID: 0x0800 (derived from egress interface properties)
    Bandwidth Requested: 0 kbps  CT0
    Creation Time: Tue Dec 31 11:32:32 2013 (3d18h ago)
  Config Parameters:
    Bandwidth:        0 kbps (CT0) Priority:  7  7 Affinity: 0x1/0x3
    Metric Type: TE (default)
    Hop-limit: disabled
    AutoRoute:  enabled  LockDown: disabled   Policy class: not set
    Forward class: 0 (default)
    Forwarding-Adjacency: disabled
    Loadshare:          0 equal loadshares
    Auto-bw: disabled
    Fast Reroute: Disabled, Protection Desired: None
    Path Protection: Not Enabled
    BFD Fast Detection: Disabled
    Soft Preemption: Disabled
  History:
    Tunnel has been up for: 03:06:06 (since Sat Jan 04 03:19:41 SGT 2014)
    Current LSP:
      Uptime: 03:06:06 (since Sat Jan 04 03:19:41 SGT 2014)
    Reopt. LSP:
      Last Failure:
        LSP not signalled, identical to the [CURRENT] LSP
        Date/Time: Sat Jan 04 03:24:31 SGT 2014 [03:01:16 ago]
    Prior LSP:
      ID: 6 Path Option: 1
      Removal Trigger: reoptimization completed

  Path info (OSPF 100 area 0):
    Link 0: 14.14.14.1
      Attribute flags: 0x5
      Attribute names: Unknown Unknown
    Link 1: 45.45.45.4
      Attribute flags: 0x1
      Attribute names: Unknown

Displayed 1 (of 1) heads, 0 (of 0) midpoints, 0 (of 0) tails
Displayed 1 up, 0 down, 0 recovering, 0 recovered heads

If we see the above output, we notice that the output shows two attribute-flags 0x5 and 0x1. Do note that, if you try to configure the path with the attribute-flag of 0x3, the tunnel will not work.

Hope the above post was useful.

Cheers...!!!

Genie

Comments are closed