SR-TE Pt. 6 (Flex Algo)
Flex Algo stands for Flexible Algorithm. Every prefix SID is associated with an algorithm, with the default being algorithm 0. By using different algorithms, paths to prefix SIDs can be calculated based on other metrics and constraints besides using lowest cost.
Have you noticed in the previous articles that the Prefix-SID IGP advertisements contain an algorithm associated with them?
RP/0/RP0/CPU0:R1#show ospf database opaque-area 7.0.0.1 self-originate
Wed Sep 7 19:11:59.534 UTC
OSPF Router with ID (1.1.1.1) (Process ID 2)
Type-10 Opaque Link Area Link States (Area 0)
LS age: 303
Options: (No TOS-capability, DC)
LS Type: Opaque Area Link
Link State ID: 7.0.0.1
Opaque Type: 7
Opaque ID: 1
Advertising Router: 1.1.1.1
LS Seq Number: 80000029
Checksum: 0x95d8
Length: 44
Extended Prefix TLV: Length: 20
Route-type: 1
AF : 0
Flags : 0x40
Prefix : 1.1.1.1/32
SID sub-TLV: Length: 8
Flags : 0x0
MTID : 0
Algo : 0
SID Index : 1Algorithm 0 is the default IGP best path calculation algorithm. A prefix SID is an instruction to steer traffic towards the prefix using the IGP ECMP-aware best path. However, this is only because it is associated with algorithm 0 by default. We can use different algorithms to steer traffic towards a prefix SID using a completely different calculation. We can use lowest delay or include/exclude link colors just like with SR-TE policies.
Algorithms 0-127 are reserved, and 128-255 are available for you, the operator, to define and use. For example, you can choose for flex algo 128 to be the lowest delay. A router can advertise a prefix with multiple SID indexes, one for each algorithm.
One benefit of using flex algo is that the SID list can be reduced compared to using an SR-TE policy. An SR-TE policy may need to generate a SID list of length 3 or 4 to steer traffic along a TE path. However if all routers agree that flex algo #130 defines the set of constraints, then only a single SID is needed. All routers collectively calculate the best path using flex algo 130, instead of the headend calculating the path and preprogramming a list of SIDs.
Lab
On R1 let’s define flex algo #128 to mean “steer traffic along RED links only.” We’ll advertise the loopback with a prefix sid index of 1000 + R# on each router.
You can see SID index 1001 for flex algo 128 in R1’s Extended Prefix Opaque LSA.
Additionally, the Router Information Opaque LSA includes Flex Algo 128 now:
Algorithm 0 is SPF, and algorithm 1 is strict SPF
You can see the Flex Algo definition at the bottom
Let’s repeat this on each router in the topology:
Examine R2’s LFIB. Notice that the outgoing interface for R6’s algo 0 prefix SID is the ECMP path via Gi0/0/0/1 and Gi0/0/0/3. The outgoing interface for R6’s algo 128 prefix SID is Gi0/0/0/2.
Unlike algo 0 prefix SIDs, there are no IP-to-MPLS forwarding entries in CEF for these algo 128 prefix SIDs. The only situation in which these labels will be used is when using SR-TE policies.
On R2 we’ll create the CUSTOMER_A VRF and observe the path that traffic towards the prefix 10.1.2.0/24 takes. We’ll create the same ODN definition as on R1, but instead of specifying the link affinity colors that must be included, we’ll specify that the path must use sid-algorithm 128.
Traffic flows via the RED path, using the prefix SID for algo 128. Only a single prefix SID needs to be imposed at R2.
Traffic originated at R1 still uses the prefix SIDs, as the ODN definition uses a link-affinity constraint instead of flex algo constraint.
If we change the ODN definition on R1 to use flex algo 128 we will see the flex algo 128 prefix SID used.
R1 does not have 17006 in its LFIB, because R1 is in a different IGP domain compared to R6. However the PCE, R2, calculated the path and passed it onto R1.
Conclusion
You’ve now gained a deeper understanding of Prefix SIDs. The introductory definition is that a prefix SID represents the ECMP-aware IGP lowest cost path to a given prefix. The new definition is that a prefix SID represents the ECMP-aware path to a given prefix based on the algorithm for that prefix SID. Algorithm 0 is the default, which means to use basic SPF to find the shortest path based on lowest metric. The operator can define any other algorithms in the range 128-255 to create new shortest path calculations based on lowest delay or constraints. Additional algorithms are advertised in the IGP, and a given prefix can have multiple prefix SIDs associated with it, one per algorithm.
Further Reading
https://www.youtube.com/watch?v=I0_-fTmcxZU&ab_channel=SegmentRouting
Last updated