WOLF-LAB沃尔夫网络实验室中国网络精英的发源地!
24小时咨询热线:173-1636-2402

新闻资讯

News

您当前位置: 新闻资讯 > 华为技术 > 详情

MPLS LDP会话的建立过程- HCIE Datacom技术文档

发布日期:2022-04-28 浏览次数:2891 来源:崔志鹏

MPLS LDP会话的建立过程- HCIE Datacom技术文档

WOLF-LAB沃尔夫网络实验室

HCIE培训针对0基础入门学员开设,

LDP协议规定了标签分发过程中的各种消息以及相关的处理过程。通过LDP,LSR可以把网络层的路由信息映射到数据链路层的交换路径上,进而建立起LSP。

 

LDP会话的建立过程

两台LSR之间交换Hello消息触发LDP会话的建立。

LDP会话的建立过程如图1所示:

1651144090348761.png

  1. 两个LSR之间互相发送Hello消息。
    Hello消息中携带传输地址(即设备的IP地址),双方使用传输地址建立LDP会话。

  2. 传输地址较大的一方作为主动方,发起建立TCP连接。
    图1所示,LSR_1作为主动方发起建立TCP连接,LSR_2作为被动方等待对方发起连接。

  3. TCP连接建立成功后,由主动方LSR_1发送初始化消息,协商建立LDP会话的相关参数。
    LDP会话的相关参数包括LDP协议版本、标签分发方式、Keepalive保持定时器的值、最大PDU长度和标签空间等。

  4. 被动方LSR_2收到初始化消息后,LSR_2接受相关参数,则发送初始化消息,同时发送Keepalive消息给主动方LSR_1。
    如果被动方LSR_2不能接受相关参数,则发送Notification消息终止LDP会话的建立。
    初始化消息中包括LDP协议版本、标签分发方式、Keepalive保持定时器的值、最大PDU长度和标签空间等。

  5. 主动方LSR_1收到初始化消息后,接受相关参数,则发送Keepalive消息给被动方LSR_2。
    如果主动方LSR_1不能接受相关参数,则发送Notification消息给被动方LSR_2终止LDP会话的建立。

当双方都收到对端的Keepalive消息后,LDP会话建立成功。

LDP邻居的发现:

1651144122479498.png

@两台路由器会先进行邻居的发现,当启用了LDP协议,两台路由器会周期性发送hello报文,进行邻居的发现,在hello报文中携带一个传输地址,默认情况下用的是lsr-id;

@接着由传输地址大的一方,以自己传输地址作为源地址,DIP地址是传输地址小的发起TCP的连接完成三次握手,用于建立LDP的会话;

@hello用于LDP的发现,TCP连接用于建立LDP的会话,端口号是TCP的646。hello报文5s发一次,DIP:224.0.0.2,端口号UDP的646;

 

LDP邻居的建立:

1651144150125347.png

dis:通过hello包进行对等体的发现;

tcp:建立LDP的会话;

session:发起方发送init报文,携带协商参数,对端收到后也会发送init报文,要是协商参数没问题就互相发送keeplive报文作为确认;

advertisement:

@两台路由器会发送address,就是把启用了mpls和mpls ldp的接口地址+自己的LSR-ID携带出去;

@lable mapping标签映射消息,路由器为自己路由表中的路由分配的标签,彼此进行标签信息的交换;

@notification:如果在整个过程中出现问题就发送nof报文

注意:

@传输地址必须可达;

@ldp中因为默认使用LSR-ID充当传输地址,LSR-ID必须可达;

@但是可以修改传输地址,此时只要保证修改后的传输地址可达就行,这时候LSR-ID就跟router-id一样,无需设备上必须有一个接口地址属于LSR-ID;

@假设将下图的AR1的LSR-ID改成3.3.3.3,传输地址改成g0/0/0接口地址,LDP的邻居关系和会话都是可以正常建立的;

 

LDP配置:

1651144277702853.png

R1:

mpls lsr-id 1.1.1.1

mpls

mpls ldp

interface GigabitEthernet0/0/0

 mpls

 mpls ldp

 

R1/R2互相发送的hello报文:

Frame 10: 76 bytes on wire (608 bits), 76 bytes captured (608 bits) on interface -, id 0

Ethernet II, Src: HuaweiTe_ba:13:f8 (00:e0:fc:ba:13:f8), Dst: IPv4mcast_02 (01:00:5e:00:00:02)

Internet Protocol Version 4, Src: 1.1.12.1, Dst: 224.0.0.2

User Datagram Protocol, Src Port: 646, Dst Port: 646

Label Distribution Protocol

    Version: 1

    PDU Length: 30

    LSR ID: 1.1.1.1    //自己的LSR-ID

    Label Space ID: 0    //标签空间

    Hello Message

        0... .... = U bit: Unknown bit not set

        Message Type: Hello Message (0x100)

        Message Length: 20

        Message ID: 0x00000008

        Common Hello Parameters

            00.. .... = TLV Unknown bits: Known TLV, do not Forward (0x0)

            TLV Type: Common Hello Parameters (0x400)

            TLV Length: 4

            Hold Time: 15    //LDP邻居失效时间是15s

            0... .... .... .... = Targeted Hello: Link Hello

            .0.. .... .... .... = Hello Requested: Source does not request periodic hellos

            ..0. .... .... .... = GTSM Flag: Not set

                [Expert Info (Chat/Protocol): GTSM is not supported by the source]

                    [GTSM is not supported by the source]

                    [Severity level: Chat]

                    [Group: Protocol]

            ...0 0000 0000 0000 = Reserved: 0x0000

        IPv4 Transport Address

            00.. .... = TLV Unknown bits: Known TLV, do not Forward (0x0)

            TLV Type: IPv4 Transport Address (0x401)

            TLV Length: 4

            IPv4 Transport Address: 1.1.1.1   //传输地址

注意:

@hello包是基于UDP 646的,每隔5s发送一次,LDP邻居的失效时间是15s;

LDP邻居的失效时间是15s,224.0.0.2来维护的;

LDP会话失效的时间是45s,keepalive每隔15s发送一次;

LDP邻居的失效时间和LDP会话的失效时间是两回事

@携带了传输地址:默认LSR-ID

int g0/0/0

mpls ldp transport-address interface //把这个接口的地址作为传输地址,此时在hello包中就看不到传输地址的字段了,看不到就是SIP地址和传输地址一样;

@lable space id:标签空间id,等于0就是基于设备的。

image.png

1、基于接口的标签空间:一般用于信源模式下,ATM很少使用了已经。就是不同的FEC可以分配相同的标签,转发报文的时候不能单纯的根据标签,而是根据接口+标签。接口上分配的标签必须唯一,在同一个接口上给两个不同的FEC分配的标签不能相同,但是在不同的接口上可以为不同的FEC分配相同的标签。

2、基于设备的标签空间:现在用的都是基于帧模式的MPLS,长度不固定。就是LSRA来说给不同的邻居为FEC分配的是同一个标签,LSRA给自身设备上1000条路由分配的标签都是唯一的。

 

@两台路由器彼此发送hello包,就能彼此知道传输地址了;

@完成三次握手,传输地址大的一方发起;

 

R2首先发送init,因为R2的传输地址大:

Frame 16: 90 bytes on wire (720 bits), 90 bytes captured (720 bits) on interface -, id 0

Ethernet II, Src: HuaweiTe_a8:76:56 (00:e0:fc:a8:76:56), Dst: HuaweiTe_ba:13:f8 (00:e0:fc:ba:13:f8)

Internet Protocol Version 4, Src: 2.2.2.2, Dst: 1.1.1.1

Transmission Control Protocol, Src Port: 49178, Dst Port: 646, Seq: 1, Ack: 1, Len: 36

Label Distribution Protocol

    Version: 1

    PDU Length: 32

    LSR ID: 2.2.2.2      

    Label Space ID: 0

    Initialization Message

        0... .... = U bit: Unknown bit not set

        Message Type: Initialization Message (0x200)

        Message Length: 22

        Message ID: 0x00000006

        Common Session Parameters

            00.. .... = TLV Unknown bits: Known TLV, do not Forward (0x0)

            TLV Type: Common Session Parameters (0x500)

            TLV Length: 14

            Parameters

                Session Protocol Version: 1

                Session KeepAlive Time: 45    //keepalive每隔15s发送一次,会话失效时间为45s。

                0... .... = Session Label Advertisement Discipline: Downstream Unsolicited proposed   //标签通告的方式DU

                .0.. .... = Session Loop Detection: Loop Detection Disabled      //环路检测的方式:没有disable

                Session Path Vector Limit: 0

                Session Max PDU Length: 4096

                Session Receiver LSR Identifier: 1.1.1.1

                Session Receiver Label Space Identifier: 0

 

R1回复的init+keepalive:

Frame 18: 98 bytes on wire (784 bits), 98 bytes captured (784 bits) on interface -, id 0

Ethernet II, Src: HuaweiTe_ba:13:f8 (00:e0:fc:ba:13:f8), Dst: HuaweiTe_a8:76:56 (00:e0:fc:a8:76:56)

Internet Protocol Version 4, Src: 1.1.1.1, Dst: 2.2.2.2

Transmission Control Protocol, Src Port: 646, Dst Port: 49178, Seq: 1, Ack: 37, Len: 44

Label Distribution Protocol

    Version: 1

    PDU Length: 40

    LSR ID: 1.1.1.1

    Label Space ID: 0

    Initialization Message

        0... .... = U bit: Unknown bit not set

        Message Type: Initialization Message (0x200)

        Message Length: 22

        Message ID: 0x0000000a

        Common Session Parameters

            00.. .... = TLV Unknown bits: Known TLV, do not Forward (0x0)

            TLV Type: Common Session Parameters (0x500)

            TLV Length: 14

            Parameters

                Session Protocol Version: 1

                Session KeepAlive Time: 45

                0... .... = Session Label Advertisement Discipline: Downstream Unsolicited proposed

                .0.. .... = Session Loop Detection: Loop Detection Disabled

                Session Path Vector Limit: 0

                Session Max PDU Length: 4096

                Session Receiver LSR Identifier: 2.2.2.2

                Session Receiver Label Space Identifier: 0

    Keep Alive Message

        0... .... = U bit: Unknown bit not set

        Message Type: Keep Alive Message (0x201)

        Message Length: 4

        Message ID: 0x0000000b

 

R2回复keepalive+address:

Frame 19: 94 bytes on wire (752 bits), 94 bytes captured (752 bits) on interface -, id 0

Ethernet II, Src: HuaweiTe_a8:76:56 (00:e0:fc:a8:76:56), Dst: HuaweiTe_ba:13:f8 (00:e0:fc:ba:13:f8)

Internet Protocol Version 4, Src: 2.2.2.2, Dst: 1.1.1.1

Transmission Control Protocol, Src Port: 49178, Dst Port: 646, Seq: 37, Ack: 45, Len: 40

Label Distribution Protocol

    Version: 1

    PDU Length: 36

    LSR ID: 2.2.2.2

    Label Space ID: 0

    Keep Alive Message

        0... .... = U bit: Unknown bit not set

        Message Type: Keep Alive Message (0x201)

        Message Length: 4

        Message ID: 0x00000007

    Address Message

        0... .... = U bit: Unknown bit not set

        Message Type: Address Message (0x300)

        Message Length: 18

        Message ID: 0x00000008

        Address List

            00.. .... = TLV Unknown bits: Known TLV, do not Forward (0x0)

            TLV Type: Address List (0x101)

            TLV Length: 10

            Address Family: IPv4 (1)

            Addresses

                Address 1: 1.1.12.2    //携带了自己的LSR-ID和所有启用了ldp的接口地址

                Address 2: 2.2.2.2

假设R2右边连接着R3,R2的g0/0/1接口也启用了MPLS MPLS LDP,如果将此接口上敲undo mpls ldp,此时R2会发送地址撤销报文:

1651144330266722.png

Frame 1866: 82 bytes on wire (656 bits), 82 bytes captured (656 bits) on interface -, id 0

Ethernet II, Src: HuaweiTe_a8:76:56 (00:e0:fc:a8:76:56), Dst: HuaweiTe_ba:13:f8 (00:e0:fc:ba:13:f8)

Internet Protocol Version 4, Src: 2.2.2.2, Dst: 1.1.1.1

Transmission Control Protocol, Src Port: 49178, Dst Port: 646, Seq: 2977, Ack: 2939, Len: 28

Label Distribution Protocol

    Version: 1

    PDU Length: 24

    LSR ID: 2.2.2.2

    Label Space ID: 0

    Address Withdrawal Message

        0... .... = U bit: Unknown bit not set

        Message Type: Address Withdrawal Message (0x301)

        Message Length: 14

        Message ID: 0x00000263

        Address List

            00.. .... = TLV Unknown bits: Known TLV, do not Forward (0x0)

            TLV Type: Address List (0x101)

            TLV Length: 6

            Address Family: IPv4 (1)

            Addresses

                Address 1: 1.1.23.2

 

R1也会发送address消息:

Frame 20: 86 bytes on wire (688 bits), 86 bytes captured (688 bits) on interface -, id 0

Ethernet II, Src: HuaweiTe_ba:13:f8 (00:e0:fc:ba:13:f8), Dst: HuaweiTe_a8:76:56 (00:e0:fc:a8:76:56)

Internet Protocol Version 4, Src: 1.1.1.1, Dst: 2.2.2.2

Transmission Control Protocol, Src Port: 646, Dst Port: 49178, Seq: 45, Ack: 77, Len: 32

Label Distribution Protocol

    Version: 1

    PDU Length: 28

    LSR ID: 1.1.1.1

    Label Space ID: 0

    Address Message

        0... .... = U bit: Unknown bit not set

        Message Type: Address Message (0x300)

        Message Length: 18

        Message ID: 0x0000000c

        Address List

            00.. .... = TLV Unknown bits: Known TLV, do not Forward (0x0)

            TLV Type: Address List (0x101)

            TLV Length: 10

            Address Family: IPv4 (1)

            Addresses

                Address 1: 1.1.12.1

                Address 2: 1.1.1.1

 

R1和R2彼此交换标签映射消息:

注意:R1和R2都会发送两个标签映射消息

R1发送的两个:

Frame 22: 98 bytes on wire (784 bits), 98 bytes captured (784 bits) on interface -, id 0

Ethernet II, Src: HuaweiTe_ba:13:f8 (00:e0:fc:ba:13:f8), Dst: HuaweiTe_a8:76:56 (00:e0:fc:a8:76:56)

Internet Protocol Version 4, Src: 1.1.1.1, Dst: 2.2.2.2

Transmission Control Protocol, Src Port: 646, Dst Port: 49178, Seq: 77, Ack: 77, Len: 44

Label Distribution Protocol

    Version: 1

    PDU Length: 40

    LSR ID: 1.1.1.1

    Label Space ID: 0

    Label Mapping Message

        0... .... = U bit: Unknown bit not set

        Message Type: Label Mapping Message (0x400)

        Message Length: 30

        Message ID: 0x0000000d

        FEC

            00.. .... = TLV Unknown bits: Known TLV, do not Forward (0x0)

            TLV Type: FEC (0x100)

            TLV Length: 8

            FEC Elements

                FEC Element 1

                    FEC Element Type: Prefix FEC (2)         //根据什么分类的,根据路由的前缀

                    FEC Element Address Type: IPv4 (1)     //根据IPV4路由的前缀,进行路由分类的

                    FEC Element Length: 32                    //路由表有一条1.1.1.1/32的路由          

                    Prefix: 1.1.1.1

        Generic Label

            00.. .... = TLV Unknown bits: Known TLV, do not Forward (0x0)

            TLV Type: Generic Label (0x200)

            TLV Length: 4

            .... .... .... 0000 0000 0000 0000 0011 = Generic Label: 3 (0x00003)      //分配的标签是3,告诉别人我是倒数第一跳

        Unknown TLV type (0x0900)

            11.. .... = TLV Unknown bits: Unknown TLV, do Forward (0x3)

            TLV Type: Unknown TLV type (0x900)

            TLV Length: 2

            TLV Value: ffff

-------------------------------------------------------------------------------------------------------------------------------------

Frame 26: 98 bytes on wire (784 bits), 98 bytes captured (784 bits) on interface -, id 0

Ethernet II, Src: HuaweiTe_ba:13:f8 (00:e0:fc:ba:13:f8), Dst: HuaweiTe_a8:76:56 (00:e0:fc:a8:76:56)

Internet Protocol Version 4, Src: 1.1.1.1, Dst: 2.2.2.2

Transmission Control Protocol, Src Port: 646, Dst Port: 49178, Seq: 121, Ack: 165, Len: 44

Label Distribution Protocol

    Version: 1

    PDU Length: 40

    LSR ID: 1.1.1.1

    Label Space ID: 0

    Label Mapping Message

        0... .... = U bit: Unknown bit not set

        Message Type: Label Mapping Message (0x400)

        Message Length: 30

        Message ID: 0x0000000e

        FEC

            00.. .... = TLV Unknown bits: Known TLV, do not Forward (0x0)

            TLV Type: FEC (0x100)

            TLV Length: 8

            FEC Elements

                FEC Element 1

                    FEC Element Type: Prefix FEC (2)

                    FEC Element Address Type: IPv4 (1)

                    FEC Element Length: 32

                    Prefix: 2.2.2.2

        Generic Label

            00.. .... = TLV Unknown bits: Known TLV, do not Forward (0x0)

            TLV Type: Generic Label (0x200)

            TLV Length: 4

            .... .... .... 0000 0000 0100 0000 0000 = Generic Label: 1024 (0x00400)   //R1也会给2.2.2.2/32的路由分配标签1024

        Unknown TLV type (0x0900)

            11.. .... = TLV Unknown bits: Unknown TLV, do Forward (0x3)

            TLV Type: Unknown TLV type (0x900)

            TLV Length: 2

            TLV Value: 05dc

 

R2发送的两个:

Frame 23: 98 bytes on wire (784 bits), 98 bytes captured (784 bits) on interface -, id 0

Ethernet II, Src: HuaweiTe_a8:76:56 (00:e0:fc:a8:76:56), Dst: HuaweiTe_ba:13:f8 (00:e0:fc:ba:13:f8)

Internet Protocol Version 4, Src: 2.2.2.2, Dst: 1.1.1.1

Transmission Control Protocol, Src Port: 49178, Dst Port: 646, Seq: 77, Ack: 121, Len: 44

Label Distribution Protocol

    Version: 1

    PDU Length: 40

    LSR ID: 2.2.2.2

    Label Space ID: 0

    Label Mapping Message

        0... .... = U bit: Unknown bit not set

        Message Type: Label Mapping Message (0x400)

        Message Length: 30

        Message ID: 0x00000009

        FEC

            00.. .... = TLV Unknown bits: Known TLV, do not Forward (0x0)

            TLV Type: FEC (0x100)

            TLV Length: 8

            FEC Elements

                FEC Element 1

                    FEC Element Type: Prefix FEC (2)

                    FEC Element Address Type: IPv4 (1)

                    FEC Element Length: 32

                    Prefix: 1.1.1.1

        Generic Label

            00.. .... = TLV Unknown bits: Known TLV, do not Forward (0x0)

            TLV Type: Generic Label (0x200)

            TLV Length: 4

            .... .... .... 0000 0000 0100 0000 0000 = Generic Label: 1024 (0x00400)

        Unknown TLV type (0x0900)

            11.. .... = TLV Unknown bits: Unknown TLV, do Forward (0x3)

            TLV Type: Unknown TLV type (0x900)

            TLV Length: 2

            TLV Value: 05dc

-----------------------------------------------------------------------------------------------------------------------------------

Frame 25: 98 bytes on wire (784 bits), 98 bytes captured (784 bits) on interface -, id 0

Ethernet II, Src: HuaweiTe_a8:76:56 (00:e0:fc:a8:76:56), Dst: HuaweiTe_ba:13:f8 (00:e0:fc:ba:13:f8)

Internet Protocol Version 4, Src: 2.2.2.2, Dst: 1.1.1.1

Transmission Control Protocol, Src Port: 49178, Dst Port: 646, Seq: 121, Ack: 121, Len: 44

Label Distribution Protocol

    Version: 1

    PDU Length: 40

    LSR ID: 2.2.2.2

    Label Space ID: 0

    Label Mapping Message

        0... .... = U bit: Unknown bit not set

        Message Type: Label Mapping Message (0x400)

        Message Length: 30

        Message ID: 0x0000000a

        FEC

            00.. .... = TLV Unknown bits: Known TLV, do not Forward (0x0)

            TLV Type: FEC (0x100)

            TLV Length: 8

            FEC Elements

                FEC Element 1

                    FEC Element Type: Prefix FEC (2)

                    FEC Element Address Type: IPv4 (1)

                    FEC Element Length: 32

                    Prefix: 2.2.2.2

        Generic Label

            00.. .... = TLV Unknown bits: Known TLV, do not Forward (0x0)

            TLV Type: Generic Label (0x200)

            TLV Length: 4

            .... .... .... 0000 0000 0000 0000 0011 = Generic Label: 3 (0x00003)

        Unknown TLV type (0x0900)

            11.. .... = TLV Unknown bits: Unknown TLV, do Forward (0x3)

            TLV Type: Unknown TLV type (0x900)

            TLV Length: 2

            TLV Value: ffff

 

查看R1和R2之间LDP的邻居关系:

1651144381319462.png

@第一个2.2.2.2表示对等体的LSR-ID;

@PEER ID后面的0就是标签空间的意思;

@第二个2.2.2.2表示邻居的传输地址;

查看R1和R2之间LDP的会话:

1651144402176268.png

@status:operational就是正常的;

@ssnrole:passive被动方,R2是active主动方,地址大的就是主动方。 //注意这个passive指的R1是passive(自己在会话中的角色),不是邻居是passive;

@KASENT/REC:keeplive发送和接收的计数器,用来维持TCP会话;

查看R1和R2之间LDP会话的详细信息:里面携带address

1651145024804527.png

查看R1和R2的标签转发表象:

1651145101821182.png

1651145119576839.png

欢迎关注WOLF-LAB网络实验室

HCIE Datacom可联系WOLF-LAB网络实验室

返回目录
在线咨询