网络协议分析(MPLS工作机制分析)

来源:互联网 发布:linux vim 复制命令 编辑:程序博客网 时间:2024/06/05 11:34

一、内容


1.按照课堂常用地址分配规则,配置各路由器的接口ip地址,以及路由器的环回地址。

2.配置mpls域中路由器的mpls协议,标签协议采用ldp协议。

3.说明mpls协议的标签交换过程,抓包说明。

4.R1 ping通R6的环回接口,说明数据通信过程,抓包说明。

5.R1 ping通R5的环回接口,说明通信过程,抓包说明和R1 ping通R6的环回接口的区别。

二、实现方法

(1)  按照课堂常用地址分配规则,配置各路由器的接口ip地址,以及路由器的环回地址。

1)配置各路由器的接口ip地址,以及路由器的环回地址。

1、R1

R1#conf t

Enter configuration commands, one perline.  End with CNTL/Z.

R1(config)#int s0/0

R1(config-if)#ip add 12.12.12.1255.255.255.0

R1(config-if)#no shut

*Mar  1 00:01:44.495: %LINK-3-UPDOWN: InterfaceSerial0/0, changed state to up

*Mar  1 00:01:45.499: %LINEPROTO-5-UPDOWN: Lineprotocol on Interface Serial0/0, changed state to up

R1(config-if)#int loopback 0

*Mar  1 00:01:58.735: %LINEPROTO-5-UPDOWN: Lineprotocol on Interface Loopback0, changed state to up

*Mar  1 00:02:12.771: %LINEPROTO-5-UPDOWN: Lineprotocol on Interface Serial0/0, changed state to down

R1(config-if)#ip add 1.1.1.1255.255.255.255

R1(config-if)#no shut

2、R2

R2#conf t

Enter configuration commands, one perline.  End with CNTL/Z.

R2(config)#int s0/0

R2(config-if)#ip add 12.12.12.2255.255.255.0

R2(config-if)#no shut

*Mar  1 00:05:02.495: %LINK-3-UPDOWN: InterfaceSerial0/0, changed state to up

*Mar  1 00:05:03.499: %LINEPROTO-5-UPDOWN: Lineprotocol on Interface Serial0/0, changed state to up

R2(config-if)#int s0/1

R2(config-if)#ip add 23.23.23.2255.255.255.0

R2(config-if)#no shut

*Mar  1 00:05:29.119: %LINK-3-UPDOWN: InterfaceSerial0/1, changed state to up

*Mar  1 00:05:30.119: %LINEPROTO-5-UPDOWN: Lineprotocol on Interface Serial0/1, changed state to up

R2(config-if)#int loopback 0

*Mar  1 00:05:43.063: %LINEPROTO-5-UPDOWN: Lineprotocol on Interface Loopback0, changed state to up

*Mar  1 00:05:52.339: %LINEPROTO-5-UPDOWN: Lineprotocol on Interface Serial0/1, changed state to down

R2(config-if)#ip add 2.2.2.2255.255.255.255

R2(config-if)#no shut

R2(config-if)#exit

3、R3

R3#conf t

Enter configuration commands, one perline.  End with CNTL/Z.

R3(config)#int s0/1

R3(config-if)#ip add 23.23.23.3255.255.255.0

R3(config-if)#no shut

*Mar  1 00:09:20.507: %LINK-3-UPDOWN: InterfaceSerial0/1, changed state to up

*Mar  1 00:09:21.511: %LINEPROTO-5-UPDOWN: Lineprotocol on Interface Serial0/1, changed state to up

R3(config-if)#int s0/2

R3(config-if)#ip add 34.34.34.3255.255.255.0

R3(config-if)#no shut

*Mar  1 00:09:48.919: %LINK-3-UPDOWN: InterfaceSerial0/2, changed state to up

*Mar  1 00:09:49.923: %LINEPROTO-5-UPDOWN: Lineprotocol on Interface Serial0/2, changed state to up

R3(config-if)#int loopback 0

*Mar  1 00:10:00.319: %LINEPROTO-5-UPDOWN: Lineprotocol on Interface Loopback0, changed state to up

R3(config-if)#ip add 3.3.3.3255.255.255.255

*Mar  1 00:10:12.831: %LINEPROTO-5-UPDOWN: Lineprotocol on Interface Serial0/2, changed state to down

R3(config-if)#no shut

R3(config-if)#exit

4、R4

R4#conf t

Enter configuration commands, one perline.  End with CNTL/Z.

R4(config)#int s0/2

R4(config-if)#ip add 34.34.34.4255.255.255.0

R4(config-if)#no shut

*Mar  1 00:13:01.143: %LINK-3-UPDOWN: InterfaceSerial0/2, changed state to up

*Mar  1 00:13:02.143: %LINEPROTO-5-UPDOWN: Lineprotocol on Interface Serial0/2, changed state to up

R4(config-if)#int s0/3

R4(config-if)#ip add 45.45.45.4255.255.255.0

R4(config-if)#no shut

*Mar  1 00:13:33.759: %LINK-3-UPDOWN: InterfaceSerial0/3, changed state to up

*Mar  1 00:13:34.763: %LINEPROTO-5-UPDOWN: Lineprotocol on Interface Serial0/3, changed state to up

R4(config-if)#int loopback 0

*Mar  1 00:13:43.359: %LINEPROTO-5-UPDOWN: Lineprotocol on Interface Loopback0, changed state to up

*Mar  1 00:14:03.091: %LINEPROTO-5-UPDOWN: Lineprotocol on Interface Serial0/3, changed state to down

R4(config-if)#ip add 4.4.4.4255.255.255.255

R4(config-if)#no shut

R4(config-if)#exit

5、R5

R5#conf t

Enter configuration commands, one perline.  End with CNTL/Z.

R5(config)#int s0/3

R5(config-if)#ip add 45.45.45.5255.255.255.0

R5(config-if)#no shut

*Mar  1 00:15:47.791: %LINK-3-UPDOWN: InterfaceSerial0/3, changed state to up

*Mar  1 00:15:48.791: %LINEPROTO-5-UPDOWN: Lineprotocol on Interface Serial0/3, changed state to up

R5(config-if)#int s0/0

R5(config-if)#ip add 56.56.56.5255.255.255.0

R5(config-if)#no shut

*Mar  1 00:16:12.347: %LINK-3-UPDOWN: InterfaceSerial0/0, changed state to up

*Mar  1 00:16:13.351: %LINEPROTO-5-UPDOWN: Lineprotocol on Interface Serial0/0, changed state to up

R5(config-if)#int loopback 0

*Mar  1 00:16:26.775: %LINEPROTO-5-UPDOWN: Lineprotocol on Interface Loopback0, changed state to up

R5(config-if)#ip add 5.5.5.5255.255.255.255

R5(config-if)#no shut

R5(config-if)#exit

6、R6

R6#conf t

Enter configuration commands, one perline.  End with CNTL/Z.

R6(config)#int s0/0

R6(config-if)#ip add 56.56.56.6255.255.255.0

R6(config-if)#no shut

*Mar  1 00:19:03.799: %LINK-3-UPDOWN: InterfaceSerial0/0, changed state to up

*Mar  1 00:19:04.803: %LINEPROTO-5-UPDOWN: Lineprotocol on Interface Serial0/0, changed state to up

R6(config-if)#int loopback 0

*Mar  1 00:19:15.711: %LINEPROTO-5-UPDOWN: Lineprotocol on Interface Loopback0, changed state to up

R6(config-if)#ip add 6.6.6.6255.255.255.255

R6(config-if)#no shut

R6(config-if)#exit

2)配置各路由器的动态路由协议(rip)。

1、R1

R1(config)#router rip

R1(config-router)#v 2

R1(config-router)#no au

R1(config-router)#net 0.0.0.0

R1(config-router)#exit

2、R2

R2(config)#router rip

R2(config-router)#v 2

R2(config-router)#no au

R2(config-router)#net 0.0.0.0

R2(config-router)#exit

3、R3

R3(config)#router rip

R3(config-router)#v 2

R3(config-router)#no au

R3(config-router)#net 0.0.0.0

R3(config-router)#exit

4、R4

R4(config)#router rip

R4(config-router)#v 2

R4(config-router)#no au

R4(config-router)#net 0.0.0.0

R4(config-router)#exit

5、R5

R5(config)#router rip

R5(config-router)#v 2

R5(config-router)#no au

R5(config-router)#net 0.0.0.0

R5(config-router)#exit

6、R6

R6(config)#router rip

R6(config-router)#v 2

R6(config-router)#no au

R6(config-router)#net 0.0.0.0

R6(config-router)#exit

(2)  配置mpls域中路由器的mpls协议,标签协议采用ldp协议。

1)R2

R2(config)#int s0/1

R2(config-if)#mpls label protocol ldp

R2(config-if)#mpls ip

R2(config-if)#exit

2)R3

R3(config)#mpls label protocol ldp

R3(config)#int s0/1

R3(config-if)#mpls ip

R3(config-if)#int s0/2

*Mar  1 00:46:36.135: %LDP-5-NBRCHG: LDP Neighbor2.2.2.2:0 (1) is UP

R3(config-if)#mpls ip

R3(config-if)#exit

3)R4

R4(config)#mpls label protocol ldp

R4(config)#int s0/2

R4(config-if)#mpls ip

R4(config-if)#int s0/3

*Mar  1 00:48:20.707: %LDP-5-NBRCHG: LDP Neighbor3.3.3.3:0 (1) is UP

R4(config-if)#mpls ip

R4(config-if)#exit

4)R5

R5(config)#int s0/3

R5(config-if)#mpls label protocol ldp

R5(config-if)#mpls ip

R5(config-if)#exit

(3)  说明mpls协议的标签交换(LDP)过程,抓包说明。

1)LDP邻居发现:通过互发Hello报文(UDP/prot:646/IP:224.0.0.2)。

2)建立TCP连接:由地址大的一方主动发起(TCP/port:646)。

会话初始化:由Master发出初始化消息,并携带协商参数。

3)由slave检查参数能否接受,如果能则发送初始化消息,并携带协商参数,并随后发送keepalive消息。

4)master检查参数能否接受,如果能则发送keepalive消息。

5)相互收到keepalive消息,会话建立。期间收到任何差错消息,均关闭会话,断开TCP连接。

每个路由器都将每个网段看为一个FEC,并为每个FEC都分配一个本地标签,然后将本地标签与这个网段关联起来,形成一个映射关系,用来指导自己接收到去这个网段的数据包时的操作(入口边缘路由器是打上下游发给自己的标签;LSR是将自己的本地标签交换为下游发给自己的标签;出口边缘路由器是移除标签)。相互发送映射关系给邻居,若一个邻居收到两份同一网段的映射关系,它会选择路由表中下一跳的路由器发来的映射关系。以此类推,建立LSP。

6)LDP邻居在通信过程中会相互发送保活包,以确保邻居还在。

(4)  R1ping通R6的环回接口,说明数据通信过程,抓包说明。

1)从R1发出的ping包,在进入MPLS域之前,request数据包只有IP层,没有MPLS层,且IP层中的TTL为255。

2)IP层TTL减一,request数据包从R2出去后,被添加了标签,有MPLS层,标签号为19。MPLS层的TTL直接与IP层的TTL相等,均为254。

通过show mpls forwarding-table命令,可以查看R2的mpls转发表LFIB,当目标地址为6.6.6.6时,R2会给数据包打上编号为19的标签。

3)request数据包进入R3后标签交换,交换后的标签号为18。数据包从R3出去,有MPLS层,MPLS层的TTL减一为253,而IP层的TTL保持为254。

通过show mpls forwarding-table命令,可以查看R3的mpls转发表LFIB,当目标地址为6.6.6.6时,R3会给数据包交换打上编号为18的标签。

4)request数据包进入R4后标签交换,交换后的标签号为18。数据包从R4出去,有MPLS层,MPLS层的TTL减一为252,而IP层的TTL保持为254。

通过show mpls forwarding-table命令,可以查看R4的mpls转发表LFIB,当目标地址为6.6.6.6时,R4会给数据包交换打上编号为18的标签。

5)request数据包进入R5后,MPLS层的TTL减一为251,赋给IP层的TTL,去除标签。数据包从R5出去,没有MPLS层,只有IP层,IP层的TTL为251。

通过show mpls forwarding-table命令,可以查看R5的mpls转发表LFIB,当目标地址为6.6.6.6时,R5会给数据包去除标签。

6)从R6发回的回包,在进入MPLS域之前,reply数据包只有IP层,没有MPLS层,且IP层中的TTL为255。

7)IP层TTL减一,reply数据包从R5出去后,被添加了标签,有MPLS层,标签号为22。MPLS层的TTL直接与IP层的TTL相等,均为254。

通过show mpls forwarding-table命令,可以查看R5的mpls转发表LFIB,当目标地址为12.12.12.0时,R5会给数据包打上编号为22的标签。

8)reply数据包进入R4后标签交换,交换后的标签号为18。数据包从R4出去,有MPLS层,MPLS层的TTL减一为253,而IP层的TTL保持为254。

通过show mpls forwarding-table命令,可以查看R4的mpls转发表LFIB,当目标地址为12.12.12.0时,R4会给数据包交换打上编号为18的标签。

9)reply数据包进入R3后,MPLS层的TTL减一为252,赋给IP层的TTL,倒数第二跳弹出,去除标签(因为12.12.12.0网段是R2的直连网段,R3为倒数第二跳,倒数第一跳是R2)。数据包从R3出去,没有MPLS层,只有IP层,IP层的TTL为252。

通过show mpls forwarding-table命令,可以查看R3的mpls转发表LFIB,当目标地址为12.12.12.0时,R3会倒数第二跳弹出,去除标签。

10)  reply数据包只有IP层,没有MPLS层,且IP层中的TTL减一为251。

(5)  R1ping通R5的环回接口,说明通信过程,抓包说明和(4)的区别。

1)从R1发出的ping包,在进入MPLS域之前,request数据包只有IP层,没有MPLS层,且IP层中的TTL为255。

2)IP层TTL减一,request数据包从R2出去后,被添加了标签,有MPLS层,标签号为21。MPLS层的TTL直接与IP层的TTL相等,均为254。

通过show mpls forwarding-table命令,可以查看R2的mpls转发表LFIB,当目标地址为5.5.5.5时,R2会给数据包打上编号为21的标签。

3)request数据包进入R3后标签交换,交换后的标签号为16。数据包从R3出去,有MPLS层,MPLS层的TTL减一为253,而IP层的TTL保持为254。

通过show mpls forwarding-table命令,可以查看R3的mpls转发表LFIB,当目标地址为5.5.5.5时,R3会给数据包交换打上编号为16的标签。

4)request数据包进入R4后,MPLS层的TTL减一为252,赋给IP层的TTL,倒数第二跳弹出,去除标签(因为5.5.5.5是R5的环回,直连,R4为倒数第二跳,倒数第一跳是R5)。数据包从R4出去,没有MPLS层,只有IP层,IP层的TTL为252。

通过show mpls forwarding-table命令,可以查看R4的mpls转发表LFIB,当目标地址为5.5.5.5时,R4会倒数第二跳弹出,去除标签。

5)IP层TTL减一,reply数据包从R5出去后,被添加了标签,有MPLS层,标签号为22。MPLS层的TTL直接与IP层的TTL相等,均为255。

通过show mpls forwarding-table命令,可以查看R5的mpls转发表LFIB,当目标地址为12.12.12.0时,R5会给数据包打上编号为22的标签。

6)reply数据包进入R4后标签交换,交换后的标签号为18。数据包从R4出去,有MPLS层,MPLS层的TTL减一为254,而IP层的TTL保持为255。

通过show mpls forwarding-table命令,可以查看R4的mpls转发表LFIB,当目标地址为12.12.12.0时,R4会给数据包交换打上编号为18的标签。

7)reply数据包进入R3后,MPLS层的TTL减一为253,赋给IP层的TTL,倒数第二跳弹出,去除标签(因为12.12.12.0网段是R2的直连网段,R3为倒数第二跳,倒数第一跳是R2)。数据包从R3出去,没有MPLS层,只有IP层,IP层的TTL为253。

通过show mpls forwarding-table命令,可以查看R3的mpls转发表LFIB,当目标地址为12.12.12.0时,R3会倒数第二跳弹出,去除标签。

8)reply数据包只有IP层,没有MPLS层,且IP层中的TTL减一为252。

差别:

1、request包

R1 ping R6的环回接口时,由于6.6.6.6是R6环回,倒数第二跳是R5(即6.6.6.6不是R5的直连网段),而R5又是MPLS的边界(到边界就要去标签),所以在R5上去标签。

R1 ping R5的环回接口时,由于5.5.5.5是R5的环回(直连),倒数第二跳是R4,R4不是MPLS的边界,所以标签在倒数第二跳R4上弹出,完成去标签的操作。

2、reply包

由R6(6.6.6.6)和R5(5.5.5.5)返回的回包,目地地址都是R1的s0/0(12.12.12.1),由于12.12.12.0网段是R2的直连网段,倒数第二跳是R3,R3不是MPLS的边界,所以标签在倒数第二跳R3上弹出,完成去标签的操作。