注册 | 登录 忘记密码? 51cto首页 | 博客 | 论坛 | 招聘
热点文章 用了十年的QQ号,第二次被..
 帮助

MPLS基本概念、设置和效验


2007-12-08 23:37:41
 标签:网络 标签 MPLS 设置   [推送到技术圈]

    关于MPLS原理的文章在网上有很多,在这里就不在详细论述,只做一下简单的回顾
一、MPLS概述
MPLS是一种2.5层技术,最初产生的目的是在网络骨干上提高数据的转发速度,减少延迟。MPLS数据转发只需检查入口标签,在根据事先建立的LFIB就可决定输出接口立即转发,解决了传统IP网络递归搜索,最长匹配造成的转发效率低、延迟及延迟抖动大的问题,而MPLS VPNMPLS TE更加引起网络界对MPLS的关注。
二、部分基本概念回顾
1、包模式下的标签及标签结构
标签是一种定长的(20比特)插入在二层和三层包头之间的数据头,在MPLS网络中使用标签来决定数据的转发,在包模式下标签结构如下:
 
20比特LABEL字段用来表示标签值。由于标签是定长的,因此可用硬件来实现数据转发,这种硬件转发方式与传统使用软件路由最长匹配的转发方式相比具有速度快、时延低的优点。
   特别注意在标签结构中使用的S值的目的是用来表示标签是否到底,这样可以使用多层标签,也就是我们经常说的标签栈。在以后的实验中我们会看到MPLS VPNMPLS TE就使用了两个以上的标签。
 
    2、标记交换路由器(LSR---lable switch routers)
  支持并使用了MPLS协议的路由器我们称为LSR
3FEC(转发等价类)
  MPLS实际上是一种分类转发的技术,它将具有相同转发处理方式(目的地相同、使用的转发路径相同、具有相同的服务等级等)的分组归为一类,这种类别就称为转发等价类FEC属于相同转发等价类的分组在MPLS网络中将获得完全相同的处理。在LDP(后面讲到)过程中,各种等价类对应于不同的标记,在MPLS网络中,各个节点将通过分组的标记来识别分组所属的转发等价类。
  
4、标记交换路径(LSP
  使用MPLS协议建立起来的分组转发路径,我们称作LSP,它是由标记分组源LSR与目的LSR之间的一系列LSR以及它们之间的链路构成。
5LDP标记分发协议
LDP与传统的IP网络的路由协议的作用类似,负责FEC的分类,
分配和分布标签和路由的绑定信息及LSP的建立和维护等。只要经LDP学到的路由与IGP学到的路由相同,就会在LSR上的LFIB中创建一个进程。

 
  6LFIB
类似于路由表,包含目标网络prefix以及对应的如和出标签以及出口信息等。其中的local tag是告诉上游LSR使用这个标签到达本地;而outging tag是下游LSR告诉本地LSR要到达某个目标网络应该使用这个标签到达下游LSR
7、上游和下游
源网络被称为上游;目标网络被成为下游。
8、下游分发标签及数据转发
MPLS网络中,标签是由靠近目标网络的下游LSR逐级向上游LSR分发,标签仅具有局部意义。
9POP tag倒数第二跳标签弹出
由于连接目标网络的LSR直接连接到客户网络,为了减轻倒数第一跳LSR的负担,CISCOMPLS网络中采用POP tag倒数第二跳标签弹出机制。也就是在连接目标网络的倒数第二跳LSR上就将标签弹出直接将数据转发到倒数第一跳LSR上。
三、标签的分发及数据转发的基本过程
以下图为例,我们来看一下标签的分发和数据转发构成,图中R2R3R4R5R8MPLS网络中的LSR路由器,而R1R11为客户
ROUTER
在这个例子中我们以192.168.5.0/24网络为目标网络为例,这样R2R3R4相对于R8就为上游LSR,而R8R4R3相对于R2就为下游LSR。对于目标网络192.168.5.0/24标签的分发是由R8---R4---R3---R2方向,采用下游分发方式分发的;而数据转发是根据实现实现分配的标签由R2---R3---R4R8方向转发的。具体见下图所示:
注意:local tag是本地ROUTER告知上游LSR应该使用这个标记到达某个目标网络;而out tag是由下游LSR接收到的标签,本地LSR根据这个标签向下游转发数据。
四、实验拓扑
五、设置指导
1、在所有路由器上启动routing protocol,考虑到MPLS VPNMPLS TE正常情况下,在MPLS骨干网络中主要采用两种IGP协议:OSPFIS-IS,并保证路由畅通,在这个实验中我们以OSPF为例。
2、在MPLS骨干网络上所有路由器上启动CEFdistribute CEF.
  Router(config)# ip cef
  Router(config)# ip cef distributed
3、在所有LSR连接MPLS 骨干的接口上起用MPLS
Router(config--f)#mpls ip
Router(config--f)# tag-switching ip
具体采用那个命令要根据IOS版本。
4、指定使用那种标签分发协议,默认为TDP,当与其他厂家设备相连时要指定使用LDP
Router(config)#mpls label protocol <tdp/ldp>
六、部分效验命令
1show ip route---效正路由
2show ip protocol---检查routing protocol是否正常启动。
3show ip cef---检查CEF是否正常启动。
4show mpls interface---检查MPLS骨干的接口是否起用了MPLS,同时检查使用的是那种标签分发协议。
5show mpls forwarding-tableshow tag-switching forwarding-table检查是否正确建立了MPLS forwarding tableLFIB),使用这个命令可以看到针对某个目标网络在本地LSR上的输入和输出标签,以及输出接口等信息。
6show mpls forwarding-table < Destination prefix> 〈MASK detail可以查看某个目标网络的详细的mpls forwarding table.
7show mpls ldp binding < Destination prefix> 〈MASK〉或
Show tag-switching tdp binding < Destination prefix> MASK效验针对某个具体的目标网络的标签关联信息。应该注意的是针对某个目标网络具有多个途径时,会有多个remote bingding标签,这种
情况下LSR将选择具有shortest path的标签。
8show ip cef < Destination prefix> detail不但可以效验CEF是否工作正常同时也可以效验标签是否正确置换。
9show mpls ldp neighborshow tag-switching tdp neighbor效验LSR之间是否正确建立了ldp neighbortdp neighbor关系。
 
七、所有ROUTER设置
r1设置
enable
config t
no ip domain lookup
host r1
ip cef
enable password ccsr
inter lo 0
ip address 1.1.1.1 255.255.255.255
no shut
exit
inter fa 2/0
full-duplex
ip address 192.168.1.1 255.255.255.0
no shut
exit
router ospf 1
network 192.168.1.0 0.0.0.255 area 1
exit
line vty 0 4
login
password ccsr
end
 
 
 
r2设置
enable
config t
no ip domain lookup
host r2
ip cef
enable password ccsr
inter lo 0
ip address 2.2.2.2 255.255.255.255
no shut
exit
inter fa 2/0
full-duplex
ip address 192.168.1.2 255.255.255.0
no shut
exit
 
inter fa 0/0
full-duplex
ip address 192.168.2.1 255.255.255.0
mpls ip
no shut
exit
 
router ospf 1
network 2.2.2.2 0.0.0.0 area 0
network 192.168.1.0 0.0.0.255 area 1
network 192.168.2.0 0.0.0.255 area 0
exit
line vty 0 4
login
password ccsr
end
 
 
r3设置
enable
config t
no ip domain lookup
host r3
ip cef
enable password ccsr
inter lo 0
ip address 3.3.3.3 255.255.255.255
no shut
exit
 
inter fa 2/0
full-duplex
ip address 192.168.3.1 255.255.255.0
mpls ip
no shut
exit
inter fa 0/0
full-duplex
ip address 192.168.2.2 255.255.255.0
mpls ip
no shut
exit
 
router ospf 1
network 3.3.3.3 0.0.0.0 area 0
network 192.168.3.0 0.0.0.255 area 0
network 192.168.2.0 0.0.0.255 area 0
exit
line vty 0 4
login
password ccsr
end
 
 
 
r4设置
enable
config t
no ip domain lookup
host r4
ip cef
enable password ccsr
inter lo 0
ip address 4.4.4.4 255.255.255.255
no shut
exit
 
inter fa 2/0
full-duplex
ip address 192.168.3.2 255.255.255.0
mpls ip
no shut
exit
 
inter fa 3/0
full-duplex
ip address 192.168.4.1 255.255.255.0
mpls ip
no shut
exit
router ospf 1
network 4.4.4.4 0.0.0.0 area 0
network 192.168.3.0 0.0.0.255 area 0
network 192.168.4.0 0.0.0.255 area 0
exit
line vty 0 4
login
password ccsr
end
 
 
 
 
r8设置
enable
config t
no ip domain lookup
host r8
ip cef
enable password ccsr
inter lo 0
ip address 8.8.8.8 255.255.255.255
no shut
exit
 
 
inter fa 3/0
full-duplex
ip address 192.168.4.2 255.255.255.0
mpls ip
no shut
exit
inter fa 2/0
full-duplex
ip address 192.168.5.1 255.255.255.0
no shut
exit
router ospf 1
network 8.8.8.8 0.0.0.0 area 0
network 192.168.4.0 0.0.0.255 area 0
network 192.168.5.0 0.0.0.255 area 2
exit
login
password ccsr
end
 
 
r11设置
enable
config t
no ip domain lookup
host r11
ip cef
enable password ccsr
inter lo 0
ip address 11.11.11.11 255.255.255.255
no shut
exit
 
 
inter fa 2/0
full-duplex
ip address 192.168.5.2 255.255.255.0
no shut
line vty 0 4
 
exit
router ospf 1
network 192.168.5.0 0.0.0.255 area 2
exit
line vty 0 4
login
password ccsr
end
八、部分效验
1、路由器正常设置后,我们会从路由器上的显示中判断LSR的工作情况,我们这里以R4的显示为例:
r4#
*Sep 20 12:32:59.635: %SYS-5-CONFIG_I: Configured from console by console
*Sep 20 12:33:01.519: %LINK-3-UPDOWN: Interface FastEthernet2/0, changed state to up
*Sep 20 12:33:01.563: %LINK-3-UPDOWN: Interface FastEthernet3/0, changed state to up
*Sep 20 12:33:02.519: %LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet2/0, changed state to up
*Sep 20 12:33:02.563: %LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet3/0, changed state to up
*Sep 20 12:33:40.371: %OSPF-5-ADJCHG: Process 1, Nbr 3.3.3.3 on FastEthernet2/0 from LOADING to FULL, Loading Done
*Sep 20 12:33:42.295: %OSPF-5-ADJCHG: Process 1, Nbr 8.8.8.8 on FastEthernet3/0 from LOADING to FULL, Loading Done
*Sep 20 12:33:55.427: %LDP-5-NBRCHG: TDP Neighbor 3.3.3.3:0 is UP
*Sep 20 12:34:01.623: %LDP-5-NBRCHG: TDP Neighbor 8.8.8.8:0 is UP
我们从R4启动时的显示可以看出:
 1、相应的接口启动
 2ospf neighbor建立
3ldp neighbor建立
2show mpls ldp neighbor效验LSR之间是否正确建立了ldp neighbor关系。我们这里以R4的显示为例:
r4#show mpls ldp neighbor
    Peer TDP Ident: 3.3.3.3:0; Local TDP Ident 4.4.4.4:0
        TCP connection: 3.3.3.3.711 - 4.4.4.4.11013
        State: Oper; PIEs sent/rcvd: 7/7; Downstream
        Up time: 00:03:24
        TDP discovery sources:
          FastEthernet2/0, Src IP addr: 192.168.3.1
        Addresses bound to peer TDP Ident:
          192.168.3.1     3.3.3.3         192.168.2.2    
    Peer TDP Ident: 8.8.8.8:0; Local TDP Ident 4.4.4.4:0
        TCP connection: 8.8.8.8.11012 - 4.4.4.4.711
        State: Oper; PIEs sent/rcvd: 7/7; Downstream
        Up time: 00:03:18
        TDP discovery sources:
          FastEthernet3/0, Src IP addr: 192.168.4.2
        Addresses bound to peer TDP Ident:
          192.168.4.2     8.8.8.8         192.168.5.1    
r4#
从上面的显示可以看出R4R3R8建立了正确的ldp neighbor.
3、检查mpls forwarding-table, R4的显示为例
r4#show mpls forwarding-table
Local  Outgoing    Prefix            Bytes tag  Outgoing   Next Hop   
tag    tag or VC   or Tunnel Id      switched   interface             
16     Pop tag     192.168.2.0/24    896        Fa2/0      192.168.3.1 
17     16          2.2.2.2/32        0          Fa2/0      192.168.3.1 
18     Pop tag     3.3.3.3/32        0          Fa2/0      192.168.3.1 
19     Pop tag     8.8.8.8/32        0          Fa3/0      192.168.4.2 
20     17          192.168.1.0/24    1518       Fa2/0      192.168.3.1 
21     Pop tag     192.168.5.0/24    2166       Fa3/0      192.168.4.2 
r4#
从上面显示可以看出由于R4对于192.168.5.0/24网络来说是倒数第二跳LSR,因此进行了标签弹出(Pop tag
  下面我们在来看一下R3mpls forwarding-table
r3#show mpls forwarding-table
Local  Outgoing    Prefix            Bytes tag  Outgoing   Next Hop   
tag    tag or VC   or Tunnel Id      switched   interface             
16     Pop tag     2.2.2.2/32        0          Fa0/0      192.168.2.1 
17     Pop tag     192.168.1.0/24    2012       Fa0/0      192.168.2.1 
18     Pop tag     192.168.4.0/24    0          Fa2/0      192.168.3.2 
19     Pop tag     4.4.4.4/32        0          Fa2/0      192.168.3.2 
20     19          8.8.8.8/32        0          Fa2/0      192.168.3.2 
21     21          192.168.5.0/24    1544       Fa2/0      192.168.3.2 
r3#
我们可以看到由于R3不是倒数第二跳LSR,它针对目标网络192.168.5.0/24同时具有local tagoutgoing tag
 
4、效验CEF是否正常工作以及标签是否正确置换
R3为例:
r3#show ip cef 192.168.5.2 detail
192.168.5.0/24, version 22, epoch 0, cached adjacency 192.168.3.2
0 packets, 0 bytes
  tag information set
    local tag: 21
    fast tag rewrite with Fa2/0, 192.168.3.2, tags imposed: {21}
  via 192.168.3.2, FastEthernet2/0, 0 dependencies
    next hop 192.168.3.2, FastEthernet2/0
    valid cached adjacency
    tag rewrite with Fa2/0, 192.168.3.2, tags imposed: {21}
r3#