← Interview Prep

Segment Routing — Theory

Source routing for modern IP/MPLS backbones: SIDs, SR-MPLS vs SRv6, TI-LFA, and Flex-Algo — the parts worth explaining at a whiteboard.

Segment Routing (SR) rethinks how a packet is steered through a network. Instead of the control plane signaling and holding per-flow / per-LSP state in every core node (LDP, RSVP-TE), the ingress node encodes the entire path as an ordered list of segments in the packet header. The core just executes instructions and forwards.

SR is source routing: the head-end decides the path and writes it into the packet as an ordered segment list. Each segment is an instruction ("go to node X via the shortest path", "cross this specific link", "run this function"). The core keeps no per-flow state — it only needs to know the globally-agreed meaning of each segment, which the IGP already floods.

Core idea — source routing, stateless core

A segment is an identifier called a SID (Segment Identifier). The ingress imposes a stack/list of SIDs; each hop pops or reads the active segment, forwards toward it, and the next segment becomes active. The path lives in the packet, not in the routers.

Segment RoutingLDP / RSVP-TE
Path encodingOrdered SID list in the packet (source routing)Hop-by-hop state established by signaling
Core stateNone per-flow; only global SID→prefix mappings (from IGP)Per-LSP label state in every transit LSR
Signaling protocolNone extra — the IGP distributes SIDsLDP (label distribution) or RSVP-TE (per-LSP)
Traffic engineeringEncode the path at the head-end, no signalingRSVP-TE with reservations along the path
ScaleState ∝ number of nodes/links, not number of flowsState ∝ number of LSPs (N² mesh problem)

The practical payoff: a full-mesh TE topology that would need N² RSVP LSPs (and state in every hop) becomes a stateless SID list computed once at the edge.

SID types

Segments come in two broad flavors: global segments (meaningful network-wide, advertised by the IGP, everyone installs the same forwarding) and local segments (meaningful only on the node that allocated them).

SIDScopeMeaning / instruction
Prefix-SIDGlobal"Forward along the IGP shortest path to this prefix." Advertised by the IGP, drawn from the SRGB. ECMP-friendly (uses all equal-cost paths).
Node-SIDGlobalA Prefix-SID for a router's loopback — i.e. "get me to node X." The most common building block of a path.
Adjacency-SIDLocal"Send out this specific link/adjacency." Locally allocated by the router that owns the link; lets you pin an exact hop (e.g. force a non-shortest link).
Anycast-SIDGlobalSame Prefix-SID advertised by multiple nodes; the closest one wins — used for redundancy and to steer to "any member of a group" (e.g. a pair of border routers).
BGP Prefix-SIDGlobalPrefix-SID signaled by BGP (e.g. BGP-LU / EPE, SR in the DC) rather than the IGP.

The SRGB — Segment Routing Global Block

The SRGB is the range of label values (in SR-MPLS, e.g. 16000–23999) reserved on every node for global segments. A Prefix-SID is advertised as an index; each node computes the local label as SRGB_base + index.

Two data planes — SR-MPLS vs SRv6

SR is an architecture; it runs over two data planes. The control-plane concepts (SIDs, IGP flooding, TI-LFA, Flex-Algo) are shared — the difference is how the segment list is carried on the wire.

SR-MPLSSRv6
SID is…An MPLS labelAn IPv6 address (128-bit)
Segment list carried in…The MPLS label stackThe Segment Routing Header (SRH) — an IPv6 routing extension header (type 4)
DistributionIGP (IS-IS/OSPF) floods prefix-SIDs → no LDPIGP floods locators/SIDs; forwarding is native IPv6
Underlay requirementMPLS forwarding in the corePlain IPv6 forwarding (SRH-aware at SR nodes)
Header overhead4 bytes per label40-byte IPv6 + SRH (heavier; uSID compresses it)
ModelLabel stack = path"Network programming": locator:function:args

SR-MPLS — label stack = the path

The IGP (IS-IS or OSPF, with SR extensions) distributes prefix-SIDs, so LDP is no longer needed to build a transport LSP — one protocol (the IGP) both computes reachability and distributes labels. A TE path is just a stack of Node-SIDs (with Adjacency-SIDs where you must pin a link):

Ingress builds label stack to steer PE1 → PE2 via node R5:

   ┌──────────┐
   │  16005   │  ← Node-SID(R5)   (top: go to R5 shortest path)
   ├──────────┤
   │  16002   │  ← Node-SID(PE2)  (then to PE2)
   ├──────────┤
   │  payload │
   └──────────┘

Each core LSR: forward on shortest path to the top SID's prefix,
pop when it becomes the owner (PHP / next-segment), no per-LSP state.

SRv6 — IPv6 addresses as SIDs, "network programming"

In SRv6 each SID is a 128-bit IPv6 address structured as locator:function[:args]. The locator routes the packet to the node that owns the SID (it's just an IPv6 prefix in the IGP); the function is an instruction that node executes — this is SRv6 network programming.

SRv6 SID layout (locator : function):

   2001:db8:  aaaa :  0100  :: 0
   └─ locator (routes to the node) ─┘ └ function (End, End.DT4, …) ┘

uSID carrier (micro-program in one 128-bit address):

   2001:db8:  0001 0002 0005 0002  ::   ← visit nodes 1→2→5→2 in order
              └── micro-SIDs shifted left as each is consumed ──┘

IGP extensions distribute SIDs

SR reuses the link-state IGP you already run to flood SID information — no new distribution protocol:

Because reachability and label distribution collapse into one protocol, the failure/convergence story is the IGP's — one SPF, one set of timers — instead of coordinating IGP + LDP (and avoiding the classic LDP/IGP synchronization pitfalls).

TI-LFA — topology-independent fast reroute

TI-LFA (Topology-Independent Loop-Free Alternate) gives guaranteed, loop-free fast reroute with sub-50 ms protection against link, node, or SRLG failure — for essentially any topology. It leans on SR's key property: the ability to express an explicit repair path as a SID list.

LFA / rLFA (classic)TI-LFA (SR)
CoverageTopology-dependent — no backup exists for some topologies (esp. rings)~100%, topology-independent
Repair pathLimited to a directly usable loop-free neighbor (rLFA adds one remote node via a targeted LDP session)Any path, expressed as a repair SID list to the post-convergence point
Loops during repairPossible micro-loopsSteers onto the post-convergence path → avoids micro-loops
Extra protocol/staterLFA needs targeted LDPNone — SID list in the packet

Flex-Algo — custom IGP metrics

Flexible Algorithm (Flex-Algo) lets the IGP compute shortest paths against a custom optimization objective instead of only the default IGP metric — and binds that path to a prefix-SID. Steering onto a Flex-Algo path is then just "use that SID," no explicit SID list needed.

Flex-Algo vs explicit SR-TE

Flex-Algo is a distributed, IGP-computed intent bound to a single SID — cheap and simple, but the objective is coarse (one metric + constraints, computed by every node). Explicit SR-TE (head-end or PCE computed, arbitrary SID list) can express any path and per-flow constraints, at the cost of head-end/controller computation. Many designs use Flex-Algo for the common planes and SR-TE for the exceptions.

Benefits vs LDP / RSVP-TE

PropertySegment RoutingLDP / RSVP-TE
Protocols to runJust the IGP (SR extensions)IGP + LDP, and RSVP-TE for traffic engineering
Core per-flow stateNone — path is in the packetPer-LSP state in every transit node
TE without signalingYes — encode the SID list at the head-endNo — RSVP reservation along the whole path
ECMPNative / friendly (Prefix-SIDs follow all equal-cost paths)RSVP LSPs pin a single path; ECMP is awkward
Fast rerouteTI-LFA: ~100% coverage, loop-free, sub-50 msLFA (partial) or RSVP FRR (more state)
Scaling limit∝ nodes/links∝ number of LSPs (N² mesh)
Operational complexityLower — one protocol, predictable label plan (SRGB)Higher — IGP/LDP sync, RSVP soft-state refresh

The headline talking points: no LDP, no per-LSP core state, ECMP-friendly, TE without a signaling protocol, and a simpler overall control plane — plus TI-LFA and Flex-Algo as capabilities that are hard or impossible in the legacy stack.

Likely follow-up questions

Related: TCP — Theory & Mechanisms · Life of a Packet.