# Module 7: Traffic Engineering

> **Course**: [ISP Backbone Lab Course](../README.md)
> **Previous**: [Module 6: Segment Routing](06-segment-routing.md)
> **Next**: [Module 8: Attack & Defense](08-attack-defense.md)

---

## Network Diagram

![SR-TE Explicit Path Steering](../diagrams/Module7_TrafficEngineering.png)
*SR-TE explicit path steering — default shortest path vs policy-driven SID stack path with Flex-Algo*

---

## Why TE?

By default, IS-IS picks the shortest path. But what if:
- The shortest path is congested?
- You want to send VoIP traffic on a low-latency path and bulk data on a high-bandwidth path?
- A fiber cut takes out the shortest path and you need a pre-computed backup?

**Traffic Engineering** lets you define explicit paths through the network.

## SR-TE (Segment Routing Traffic Engineering)

With SR, TE is just a **stack of SIDs**. Want traffic to go P1 → P2 → P-CORE → P4 instead of the direct path? Push labels `[16002, 16005, 16004]` onto the packet. Done. No RSVP tunnels, no signaling protocol, no state in the core.

## Lab 7 Config: SR-TE Policy

**PE-EDGE1 (force traffic to PE-EDGE4 via a specific path):**

```
segment-routing traffic-eng
 segment-list PATH-VIA-P2-PCORE
  index 10 mpls label 16002    ! P2
  index 20 mpls label 16005    ! P-CORE
  index 30 mpls label 16014    ! PE-EDGE4
 !
 policy STEER-TO-PE4
  color 100 end-point 10.0.0.14
  candidate-paths
   preference 200
    explicit segment-list PATH-VIA-P2-PCORE
```

## Flex-Algo (Advanced)

Flex-Algo lets you define **multiple topologies** on the same physical network. For example:
- **Algorithm 0** (default): Shortest path by metric
- **Algorithm 128**: Low-latency path (uses delay metric)
- **Algorithm 129**: High-bandwidth path (avoids congested links)

Each algorithm creates a separate set of SIDs, so you can steer traffic into different topologies without explicit path lists.

## Understanding Check

1. How does SR-TE compare to RSVP-TE? What makes it simpler?
2. What is a SID stack and how does it define a path?
3. What is Flex-Algo and when would you use it over explicit SR-TE?

---

> **Next Module**: [Module 8: Attack & Defense Labs →](08-attack-defense.md)
