H3C 实现SR-MPLS TE

0 阅读8分钟

在现代网络中,流量工程(Traffic Engineering,简称 TE)作为确保网络资源合理分配与优化的关键技术,越来越得到重视。SR-MPLS TE(Segment Routing Traffic Engineering)在实现流量优化方面表现出了强大的优势。

SR-MPLS TE 的核心概念

Segment Routing (SR)是一种简化流量工程的技术,它不依赖于传统的 LDP(Label Distribution Protocol)来分发标签,而是通过预定义的 SID(Segment ID)来指导数据包的转发。在SR-MPLS TE中,路由器根据流量工程要求,使用一系列由控制器计算并下发的 SID 来进行流量引导。不同于传统的 LSP(Label Switched Path)机制,SR-MPLS TE 将控制平面与转发平面解耦,从而大大减少了网络中的状态信息。

配置拓扑如下:

图片

SR-MPLS TE 配置与工作流程

1. 配置网络节点(PE、P 路由器)

首先,在PE(Provider Edge)和P(Provider)路由器上启用 SR-MPLS 和流量工程功能。以PE1为例,配置步骤如下:

ospf 100
 segment-routing mpls
 segment-routing adjacency enable
 area 0.0.0.0

#
 mpls lsr-id 10.10.10.1
#
interface LoopBack0
 ip address 10.10.10.1 255.255.255.255
 ospf 100 prefix-sid index 10///配置前缀SR SID
 ospf 100 area 0.0.0.0
#
interface GigabitEthernet1/0
 ip address 10.10.11.1 255.255.255.0
 ospf 100 area 0.0.0.0
 mpls enable

2. 配置 MPLS VPN 和 BGP

为了支持 MPLS VPN 功能,PE 路由器需要配置 VPN 实例,并通过 BGP+VPNv4 与其他 PE 路由器交换路由信息。

PE1配置:

ip vpn-instance test
 route-distinguisher 1:1
 vpn-target 1:1 import-extcommunity
 vpn-target 1:1 export-extcommunity
#
ospf 1 vpn-instance test
 import-route bgp 100
 area 0.0.0.0
#
interface GigabitEthernet2/0
 ip binding vpn-instance test
 ip address 192.168.1.1 255.255.255.0
 ospf 1 area 0.0.0.0

bgp 100
 router-id 10.10.10.1
 peer 10.10.10.2 as-number 100
 peer 10.10.10.2 connect-interface LoopBack0
 #
 address-family ipv4 unicast
  peer 10.10.10.2 enable
 #
 address-family vpnv4
  peer 10.10.10.2 enable
 #
 ip vpn-instance test
 bgp 100
 router-id 10.10.10.1
 peer 10.10.10.2 as-number 100
 peer 10.10.10.2 connect-interface LoopBack0
 #
 address-family ipv4 unicast
  peer 10.10.10.2 enable
 #
 address-family vpnv4
  peer 10.10.10.2 enable
 #
 ip vpn-instance test
  #
  address-family ipv4 unicast
   import-route direct
   import-route ospf 1 allow-direct

PE2配置:

ip vpn-instance test
 route-distinguisher 1:1
 vpn-target 1:1 import-extcommunity
 vpn-target 1:1 export-extcommunity
#
ospf 1 vpn-instance test
 import-route bgp 100
 area 0.0.0.0
 #
interface GigabitEthernet2/0
 ip binding vpn-instance test
 ip address 192.168.2.1 255.255.255.0
 ospf 1 area 0.0.0.0
 #
 bgp 100
 router-id 10.10.10.2
 peer 10.10.10.1 as-number 100
 peer 10.10.10.1 connect-interface LoopBack0
 #
 address-family ipv4 unicast
  peer 10.10.10.1 enable
 #
 address-family vpnv4
  peer 10.10.10.1 enable
 #
 ip vpn-instance test
  #
  address-family ipv4 unicast
   import-route direct
   import-route ospf 1 allow-direct

查看VPNv4的信息

[PE1]display bgp routing-table ?
  dampened   Display dampened BGP routes
  flap-info  Display BGP route flap information
  ipv4       Specify the IPv4 address family
  ipv6       Specify the IPv6 address family
  vpnv4      Specify the VPNv4 address family
  vpnv6      Specify the VPNv6 address family

[PE1]display bgp routing-table vpn
[PE1]display bgp routing-table vpnv4

 BGP local router ID is 10.10.10.1 
 Status codes: * - valid, > - best, d - dampened, h - history,
               s - suppressed, S - stale, i - internal, e - external
               Origin: i - IGP, e - EGP, ? - incomplete

 Total number of routes from all PEs: 2

 Route distinguisher: 1:1(test)
 Total number of routes: 5

     Network            NextHop         MED        LocPrf     PrefVal Path/Ogn

* >  192.168.1.0        192.168.1.1     1                     32768   ?
* >  192.168.1.1/32     127.0.0.1       0                     32768   ?
* >i 192.168.2.0        10.10.10.2      1          100        0       ?
* >  192.168.100.100/32 192.168.1.2     2                     32768   ?
* >i 192.168.100.200/32 10.10.10.2      3          100        0       ?

3. 配置 TE 链路和显式路径

MPLS TE 路由器的配置要指定显式路径,即通过手动配置 SR SID 来指导流量转发,先查看相关节点对应的label。

图片

预设链路是PE1-P1-P2-P3-P4-PE2,静态配置链路:

mpls te
explicit-path sr-te
 nextsid index 1 label 16001 type prefix
 nextsid index 101 label 16002 type prefix
 nextsid index 201 label 16003 type prefix
 nextsid index 301 label 16004 type prefix
 nextsid index 401 label 16020 type prefix
#
interface Tunnel100 mode mpls-te
 ip address unnumbered interface LoopBack0
 mpls te signaling segment-routing
 mpls te path preference 1 explicit-path sr-te
 destination 10.10.10.2

4. 测试 TE 链路的连通性

一旦配置完成,可以通过以下命令测试 TE 隧道的连通性:

[PE1]ping mpls te Tunnel 100
MPLS ping TE tunnel Tunnel100 with 100 bytes of data:
100 bytes from 10.10.42.2: Sequence=1 time=12 ms
100 bytes from 10.10.42.2: Sequence=2 time=5 ms
100 bytes from 10.10.42.2: Sequence=3 time=5 ms
100 bytes from 10.10.42.2: Sequence=4 time=4 ms
100 bytes from 10.10.42.2: Sequence=5 time=5 ms

--- Ping statistics for TE tunnel Tunnel100 ---
5 packets transmitted, 5 packets received, 0.0% packet loss
Round-trip min/avg/max = 4/6/12 ms
[PE1]dis
[PE1]display mp
[PE1]display mpls te
[PE1]display mpls te ?
  ds-te             Differentiated Services-aware Traffic Engineering (DS-TE) 
                    information
  link-management   Link management information
  pce               Path Computation Element (PCE)
  tedb              Display MPLS TE database information
  tunnel-interface  Tunnel interface information

[PE1]display mpls te tun
[PE1]display mpls te tunnel-interface tun
[PE1]display mpls te tunnel-interface Tunnel 100
Tunnel Name            : Tunnel 100
Tunnel State           : Up (Main CRLSP up.
                             Main Shared-resource CRLSP down.
                             Backup CRLSP down.)
Tunnel Attributes      :  
  LSP ID               : 20277           Tunnel ID            : 100
  Admin State          : Normal         
  Ingress LSR ID       : 10.10.10.1      Egress LSR ID        : 10.10.10.2
  Signaling            : Segment-Routing Static CRLSP Name    : -
  Resv Style           : SE
  Tunnel mode          : -
  Reverse-LSP name     : -
  Reverse-LSP LSR ID   : -               Reverse-LSP Tunnel ID: -
  Class Type           : CT0             Tunnel Bandwidth     : 0 kbps
  Reserved Bandwidth   : 0 kbps
  Setup Priority       : -               Holding Priority     : -
  Affinity Attr/Mask   : 0/0
  Explicit Path        : sr-te
  Backup Explicit Path : -
  Metric Type          : TE
  Record Route         : Disabled        Record Label         : Disabled 
  FRR Flag             : Disabled        Bandwidth Protection : Disabled
  Backup Bandwidth Flag: Disabled        Backup Bandwidth Type: -
  Backup Bandwidth     : -
  Bypass Tunnel        : No              Auto Created         : No
  Route Pinning        : Disabled
  Retry Limit          : 3               Retry Interval       : 2 sec
  Reoptimization       : Disabled        Reoptimization Freq  : -
  Backup Type          : None            Backup LSP ID        : -
  Auto Bandwidth       : Disabled        Auto Bandwidth Freq  : -
  Min Bandwidth        : -               Max Bandwidth        : -
  Collected Bandwidth  : -               Service-Class        : -
  Path Setup Type      : EXPLICIT/-

5.抓包分析,SID的获取,SID是通过OSPF的扩展的属性协议,查看label

图片

[PE1]display ospf 100 routing verbose  | begin 10.10.10.1/32
 Destination: 10.10.10.1/32     
    Priority: Medium                  Type: Stub
   AdvRouter: 10.10.10.1              Area: 0.0.0.0 
  SubProtoID: 0x1               Preference: 10 
     NextHop: 0.0.0.0            BkNextHop: N/A 
      IfType: PTP                 BkIfType: N/A
   Interface: Loop0            BkInterface: N/A 
       NibID: 0x13000001            Status: Direct 
        Cost: 0              
     InLabel: 16010            Tunnel type: -
    OutLabel: 4294967295     OutLabel flag: -
  BkOutLabel: 4294967295   BkOutLabel flag: -
    LabelSrc: N/A               Delay Flag: -

 Destination: 10.10.10.2/32     
    Priority: Medium                  Type: Stub
   AdvRouter: 10.10.10.2              Area: 0.0.0.0 
  SubProtoID: 0x1               Preference: 10 
     NextHop: 10.10.15.5         BkNextHop: N/A 
      IfType: Broadcast           BkIfType: N/A
   Interface: GE3/0            BkInterface: N/A 
       NibID: 0x13000005            Status: Normal 
        Cost: 4              
     InLabel: 16020            Tunnel type: -
    OutLabel: 16020          OutLabel flag: N
  BkOutLabel: 4294967295   BkOutLabel flag: -
    LabelSrc: SR                Delay Flag: -

分析VPN通信过程,标签的交互PE1-P1,通过MPLS标签号规划好路线

图片

P1-P2

图片

以此类推。跟普通的MPLS VPN有很大的差别

目前是静态配置TE链路,如果动态配置,需要其他协议将路由器状态通告给控制器,由控制器计算再调整。

5.动态分配TE

在SR-MPLS TE(Segment Routing Traffic Engineering)中,动态分配 TE 路径时,路由器与控制器之间的通信主要依赖于PCEP(Path Computation Element Communication Protocol)和SDN(Software Defined Networking)等协议。控制器负责计算流量工程路径,并将计算出的路径信息下发到路由器。以下是具体的通信机制与过程:

(1) PCEP 协议概述

PCEP是一种专为路径计算和流量工程设计的协议,用于**控制器(Path Computation Element, PCE)**与路由器(Path Computation Client, PCC)之间的通信。其核心功能是让控制器计算路径,并通过 PCEP 将路径下发给路由器,路由器随后根据控制器计算的路径进行流量工程。

(2)控制器与路由器的通信方式

在 SR-MPLS TE 中,通常的控制器和路由器之间的通信步骤如下:

控制器与路由器之间建立 PCEP 会话

控制器(PCE)和路由器(PCC)之间通过 TCP(通常是 4168 端口)建立 PCEP 会话,用于传输路径计算请求和路径下发信息。

PCC 请求路径计算(PCReq)

路由器向控制器发起路径计算请求,通常包括:

PCE 计算路径并发送响应(PCUpd 或 PCRep)

控制器根据请求的约束条件计算最优路径,并通过 PCEP 将计算结果(即路径和 SID 信息)以PCUpd或PCRep消息下发给路由器。

路由器根据计算的路径进行流量工程

路由器收到计算的路径后,基于Segment Routing原理,将路径信息(即 SID 栈)添加到流量中,进行转发。



(3)SR-MPLS TE 与 SDN 控制器的集成

在 SR-MPLS TE 中,路由器与SDN 控制器的集成是必不可少的。SDN 控制器作为一个中央路径计算平台,通常会计算整网的流量工程路径,然后下发 SID 列表到每个节点。


6. 总结

SR-MPLS TE 和 PCEP 协议的结合,使得控制器能够动态计算流量工程路径,并将计算结果下发到路由器进行转发。与传统的 RSVP-TE 相比,SR-MPLS TE 的优势在于:

控制平面和转发平面的解耦,控制平面不再维护状态。

网络规模扩展性好,无需维持大量 LSP 会话。

与 SDN 控制器兼容,能够自动化地计算并调度流量。

通过 PCEP 协议,路由器与控制器之间能够快速交换路径信息,确保网络流量以最优路径转发。


如果你觉得这篇文章对你有帮助,欢迎点赞和分享!

下一篇,我将为你深入探讨SRv6 与 SR-MPLS TE 的差异与选择,敬请期待!