How Segment Routing Works?

The below figure explains an MPLS network with 8 routers using Segment Routing, IGP IS-IS, a label range of 1000 to 1999 for node IDs, and 2000 and higher for adjacency IDs. ISIS will use sub-TLV extensions to distribute IP prefix reachability alongside segment ID (the MPLS label) across the network.

Kindly note that we are taking the simple label ranges just to understand the concept, however, in real config environment, the label ranges are allocated on the based of Segment Routing Global Block (SRGB) for Prefix or Node SIDs. SRGB is explicitly explained in an another article of this Blog.



Router R8 advertises its loopback0 ipv4 prefix 8.8.8.8/32 with attached prefix-SID (or Node SID) 1008 through IGP (OSPF or ISIS) sub-TLV extensions. A Node SID is bound to the SPF like algorithm.

All remote nodes install the Node Segment to  R8 in their forwarding plane.

One Segment is equal to one Label.
Segment List = Label Stack.

As per picture below, for the traffic destined from Router R1 to Router R8 (via shortest path R1-R2-R3-R4-R8 - Segment shown with blue arrow), R1 pushes label 1008 over the packet and send it to R2. Routers R2 and R3 in the path will lookup their forwarding tables and perform Swap operation with same label 1008. PHP Router R4 will perform Pop operation and send packet to R8.

Commands (IOS-XR):

To check label pushed on R1 for an IPv4 prefix - show cef 8.8.8.8/32
To check label pushed on R1 for an IPv6 Prefix - show cef ipv6 2001::0001:1008/128
To check forwarding plane on other routers (say R2) - show mpls forwarding labels 1008

Another way, Segment identifiers can also be combined as an ordered list (stack of labels) to perform traffic engineering. A segment list can contain several adjacency segments, several node segments, or a combination of both depending on the forwarding requirements. As shown in picture below, Router R1 could alternatively push label stack (1004, 2019) to reach Router R8 using the shortest path (say R1-R2-R3-R4-R7-R8) and all applicable ECMPs to Router D and then through an explicit interface onto the destination. Router R1 does not need to signal the new path, and the state information remains constant in the network. Router R1 ultimately enforces a forwarding policy that determines which flows destined to router R8 are switched through a particular path.  Label 2019 is R7 to R8 Adjacency SID.