# Module 6: Segment Routing

> **Course**: [ISP Backbone Lab Course](../README.md)
> **Previous**: [Module 5: eBGP](05-ebgp.md)
> **Next**: [Module 7: Traffic Engineering](07-traffic-engineering.md)

---

## Network Diagram

![Segment Routing SID Assignments](../diagrams/Module6_SegmentRouting.png)
*Segment Routing SID assignments (SRGB 16000+) with Prefix SIDs and Adjacency SIDs on all nodes*

---

## The Evolution: LDP → SR

Remember how LDP assigns labels? It works, but it has problems:
- LDP creates a **full mesh of label bindings** — every router gets a label for every prefix
- LDP is a **separate protocol** that must stay in sync with IS-IS (if they disagree, traffic blackholes)
- No built-in traffic engineering

**Segment Routing (SR)** fixes all of this by embedding labels directly into IS-IS (or OSPF). No more LDP. No more synchronization issues.

## How SR Works

Instead of LDP negotiating labels between neighbors, each router advertises a **Segment ID (SID)** via IS-IS:

- **Prefix SID** = A label for reaching a specific router's loopback (replaces what LDP does)
- **Adjacency SID** = A label for a specific link (used for traffic engineering)

The SID is an **index** added to a globally configured **SRGB (Segment Routing Global Block)**. Default SRGB: 16000–23999.

Example: If P1's Prefix SID index is 1, its label is **16001** everywhere in the network. No negotiation needed.

## Lab 6 Config: Enable Segment Routing

**On every router (replace LDP):**

```
! Remove LDP (optional — SR and LDP can coexist, but pure SR is cleaner)
no mpls ldp router-id Loopback0 force
!
! Enable SR in IS-IS
router isis YOURSP
 segment-routing mpls
 segment-routing prefix-sid-map advertise-local
!
interface Loopback0
 ip router isis YOURSP
 isis prefix-sid index <UNIQUE_NUMBER>
```

**SID Index Assignments:**

| Router | Loopback | Prefix SID Index | Resulting Label |
|--------|----------|-----------------|----------------|
| P1 | 10.0.0.1 | 1 | 16001 |
| P2 | 10.0.0.2 | 2 | 16002 |
| P3 | 10.0.0.3 | 3 | 16003 |
| P4 | 10.0.0.4 | 4 | 16004 |
| P-CORE | 10.0.0.5 | 5 | 16005 |
| PE-EDGE1 | 10.0.0.11 | 11 | 16011 |
| PE-EDGE2 | 10.0.0.12 | 12 | 16012 |
| PE-EDGE3 | 10.0.0.13 | 13 | 16013 |
| PE-EDGE4 | 10.0.0.14 | 14 | 16014 |

## Verification

```
show isis segment-routing prefix-sid-map
show mpls forwarding-table          ! Labels should now be 16xxx
show isis database detail           ! Look for SR TLVs in the LSPs
show segment-routing mpls state
```

## Understanding Check

1. Why is SR simpler than LDP? What failure mode does it eliminate?
2. What's the SRGB and why does it need to be the same on every router?
3. What's the difference between a Prefix SID and an Adjacency SID?
4. Can SR and LDP coexist? When would you want that?

---

> **Next Module**: [Module 7: Traffic Engineering →](07-traffic-engineering.md)
