当前位置:网站首页>Hcip - MPLS Technology
Hcip - MPLS Technology
2022-07-26 07:15:00 【Cyg engaged in it】
MPLS --- Multi protocol label switching technology
Packet exchange --- Data facilitation packet , after , It is continuously transmitted in each network node , Finally, we reach our goal .
The problem of inefficient packet switching and forwarding :
1、 In the whole process of packet exchange , You need to query the routing table first and then check ARP Cache two tables to complete the forwarding process , Leading to low efficiency ;
2、 Matching rules of routing table --- The longest matching principle causes the query efficiency of the routing table not to be too high ;
3、 There is a recursive lookup process in the routing table ;
4、IP The head is a variable length head , Lead us to IP When the head is read, it needs to be processed by software , Unable to find fast based on hardware .
Label switching
Label switching Between two-layer and three-layer packaging , Add a label that has a mapping relationship with the routing entry , Then maintain a table that records the correspondence and forwarding interface , Bring tagged data to the device , Look at the label first , Then forward based on the maintained tag forwarding table , There is no need to view the three-tier content . Because the label itself Short and fixed length , therefore , Its Forwarding efficiency will be higher than packet switching .
But label exchange needs to label the packet first , Then you need to pop up the tag before reaching the target , therefore , Label switching only improves the efficiency in the forwarding process , On the whole, the improvement of intersecting packet exchange is not obvious .
Changes in packet exchange
1、 Process exchange --- process switching --- The earliest packet switching --- Every packet needs to check the router first , I'll see later ARP Cache the table to determine the content of the two-layer package .
2、 Fast packet switching (fast switching)--- Stream based packet switching --- One time routing , Exchange many times --- When a stream of data comes to the device , We only perform the routing process for the first packet , Route the results and packet characteristics ( Quintuples ) Record in the cache table . after , Other data in the data stream will be directly compared with the cached five tuples when it comes to the device , identical , Then it will be forwarded directly according to the forwarding method instead of the routing process .
3、 Cisco's fast switching technology --- Cisco EXpress Forwading --- abbreviation CEF technology .--- It is mainly to combine the routing table and ARP Pre read the contents of the cache table ( Is to recursively perform the recursive operation , Should check ARP Check the cache table in advance ), Then record the results in CEF surface in , and CEF It supports hardware forwarding , therefore , It can greatly improve the forwarding efficiency of routing .
although CEF technology It's Cisco's proprietary technology , However, major manufacturers have also designed their own express switching technology based on Cisco . Huawei devices are based on FIB( Forwarding information table ), This table supports hardware forwarding .
Although label switching cannot replace packet switching as the mainstream forwarding technology , however , Still in common development with packet exchange ,MPLS It is the product of the joint development of packet exchange and label exchange , Mainly because in some fields , Label switching Can do better :
1、 For resolution BGP The routing black hole of
2、MPLS VPN
3、MPLS TE --- Flow engineering --- Simply understand that traffic engineering is to control the path of traffic forwarding .

A forwarding network consisting of all routers running label switching , We can see it as a MPLS The Internet , We call him MPLS Domain . We run these MPLS Your device is called LSR --- Label switching router .
Based on the premise of label exchange, there must be labels first , The label is for each LSR It is generated based on the routing entries in the local routing table . We will all have the same characteristics ( All packets matching the same routing entry ) The packet is called FEC --- Equivalent forwarding class . The same FEC You need to configure a label .
Each station LSR Put your label and FEC The mapping information of is recorded in a local table , This table is called --- LIB( Label information table ). after , Will and FIB Combine tables , Generate LFIB surface --- Label forwarding information table .
In the whole process ,LSR The device needs to know other things besides assigning labels by itself LSR The device is for the same FEC Assigned tags , therefore , Label switching and packet switching are also divided into two levels --- Control level , Data level
Two levels of packet switching and label switching
Packet exchange
Control level --- The data flow direction of the routing protocol , The purpose is to obtain the routing information of unknown network segments , Generate routing table .
Data level --- The equipment is based on Routing table (FIB) To forward specific data information , Its direction is exactly opposite to the flow of the control layer .
Label switching
Control level --- be based on FEC Assign tags , And get other LSR To the same FEC Assigned tags , after , Record generation LIB surface , Then combine FIB Generate LFIB surface . --- This process can be done statically , It can also be done based on dynamic protocols --- LDP agreement --- Label distribution agreement
Data level --- The device is based on LBIB, Forward according to the tag .
Three LSR
Inbound LSR (ingress)--- MPLS The boundary of the domain , When a packet without a tag comes in LSR On , He needs to press a label into the packet ;
Central station LSR(transit) --- Complete the label replacement action LSR equipment ;
Departure LSR(egress) --- It's also MPLS The boundary of the domain , Complete the pop-up action of the label .
LSP --- Label switching path
The whole process , The flow path of data layer traffic is R1-R2-R3-R4, This path is called LSP --- Label switching path . need Pay attention to is ,LSP Is one-way , If you want data to go back and forth in two directions , You also need to build a R4-R3-R2-R1 The path of .
MPLS Tag message :

Label --- 20 position --- 0 - 2 Of 20 Power --- We call the value range of tag number as tag space , Each station LSR The label space of the device is independent .
among :
0 - 15 --- Special tag value --- When we allocate, we cannot directly allocate , Because every special label has its special meaning
16 - 1023 --- Generally applied to static LSP build
1024 - 2 Of 20 Power --- be applied to LDP And other dynamic label exchange protocols
EXP --- Occupy 3 position --- Do strategic use --- commonly 000, It can be understood as priority , If the priority is high, it can be forwarded first .
S --- Occupy 1 position --- At the bottom of the stack --- There is more than one label , You can play more than one , We call an ordered set of multiple tags a tag stack . If there are multiple tags , You need to use this flag bit to identify . If it is the last tag , Then the position 1, If not , Then put 0.
TTL --- Time to live --- And the third floor TTL Have the same value , The main purpose is to prevent data packets from circulating wirelessly in the loop . The data comes to the inbound LSR when , Will put three layers TTL Copy values into labels , stay MPLS There is no forwarding in the domain ,TTL reduce 1, after , At exit LSR Pop up the label , And then put TTL The value is copied into the three-level header .
Build static LSP:

One 、 Ensure routing conditions --- Static only requires the border device to have round-trip routing information
Two 、 To configure LSR
Inbound LSR:
1. to LSR To configure LSR-ID --- 32 Bit binary structure , This is the IP Address format to write , however , It can only be configured manually .
![]()
2. Activate MPLS
1、 Global activation MPLS
![]()
2、 Interface activation MPLS --- All need to participate MPLS All data receiving and sending interfaces need to be activated
![]()
3. Build static LSP ![]()
1、 Next jump --- It must be the same as the next hop in the routing table
2、out --- label --- Outbound label --- After the next hop device accepts it, it needs to judge which network segment the data reaches according to this tag .
Configure transit LSR:
![]()
in - label --- The inbound label must be the same as the outbound label configured in the previous hop
Configure outbound LSR:
![]()
![]()
LDP --- Label distribution agreement --- Mainly used in MPLS The control level of
MPLS Control level The main work to be done is to assign labels and transfer labels . The premise of assigning labels is that labels must first exist in the local routing table , The premise of transferring labels is also to have a routing foundation . therefore ,LDP Want to work properly , You need to IGP As the foundation .

1、 Assign tags
Not all devices assign labels to all routing entries in their local routing table , Instead, you decide that you are the outbound station of a certain network segment LSR when , Will actively assign labels .
Of course , In the form of reaching the target network segment LSP In the process , All the middle LSR Need to give the corresponding FEC Assign tags . Then other devices only receive the mapping relationship between the label and the target network segment , Will passively allocate labels . Before assigning labels, you need to complete the inspection , Mainly check whether the local routing table of the target network segment can reach , And whether the next hop is the same as the announcer . Labels can be assigned if the inspection is passed , If you fail, you cannot assign labels .
LDP How to assign tags to :
1、 In an orderly way --- By default, Huawei devices choose to allocate labels in an orderly manner
2、 Independent way --- There is no need to confirm that you are leaving LSR, You can also actively assign labels to the routing entries in the routing table .
2、 Transfer label
Departure LSR After assigning labels , It needs to be passed on to others LSR equipment . The prerequisite for transmission is that they must first LDP Peer relationship ,LDP The prerequisite for establishing peer relationship is to establish LDP conversation .
LDP Session classification :
Local LDP conversation --- A direct connection is established between two devices LDP conversation
long-range LDP conversation --- Between non directly connected devices , You can create remote LDP conversation .
LDP agreement Building local LDP conversation when , There is no need to manually specify the neighbor IP Address , It can automatically discover neighbor relationships . Mainly because LDP First, through multicast (224.0.0.2) Send periodically in the form of hello Bag to find neighbors .hello Package usage UDP 646 Port to complete .
Local LDP The process of establishing a session :
1、 stay LSR Activate on LDP after , First, send periodically hello Package to complete peer discovery .

stay hello Some parameters need to be carried in the package , It includes Transmission address and LDP ID.
Transmission address : This address is mainly established later TCP The address needed for the conversation , By default , We will use high address devices LSR ID As this address . So ask for ,LSR ID Must be available and accessible IP Address .
LDP ID: All active LDP Agreed LSR The equipment must have a LDP ID, This ID By 48 Bit binary structure , The expression is 32 position :16 position , front 32 Bit usage LSR ID, after 16 Bit use 0 Express . This is related to label space , All device based tag spaces , It's all worth 0.
hello The default sending cycle of packets is 5s, The survival time is hello Time , Default 15 second .
2、 Both sides are interacting hello After the package , Then go to the other party's transmission address , Based on this exclusive address TCP conversation .
In establishment TCP Between sessions ,LDP There are also check actions , You need to confirm the receipt of the forward address , Is it reachable in the local routing table , Reachable can be established normally TCP conversation .
If both sides establish TCP conversation , Two two-way channels will be created , Waste of resources . At the receiving end hello After the transmission address in the packet , Compare with the local transmission address , The party with the largest transmission address , We call it the active party , The active party can take the initiative to establish TCP conversation , The second passive party does not establish .

3、 complete TCP After the session is established , The party with a large delivery address will give priority to the initialization message , It contains some negotiated parameters and sends them to the passive party , If the other party confirms the parameters , Will reply keep live Message to confirm , At the same time, send your own local initialization message , Carry your own parameters . The active party will also confirm the parameters after receiving , If there is no problem, it will also be sent keep live message . Received by both parties keep live message , It means that the parameter negotiation is successful ,LDP Session successfully established .

after , It also needs to be sent periodically keeplive Keep the message alive , The default sending cycle is 15s, The survival time is 3 Times the cycle sending time , The default is 45 second .
Upstream downstream relationship
It is determined by the flow direction of data layer traffic , The data sender is upstream , The receiver is downstream . From the perspective of the control layer , Then the direction of label transmission should be from downstream to upstream . after Upstream equipment will collect downstream labels .
Label transfer method
DU Pattern --- Downstream autonomous mode --- Huawei equipment adopts this mode by default , all LSR After the assignment number label , You can actively transfer labels to others LSR. --- If you choose downstream autonomous mode , Then the device passes the label , Unable to judge the upstream and downstream relationship , The label will be sent to all peer relationships . When the device receives the label , Then the upstream and downstream relationship can be judged based on the route . Huawei equipment , Only the upstream equipment will record the labels sent by the downstream equipment , Labels sent by upstream devices will not be saved .( Another way to save labels is to save both upstream and downstream labels .)
DOD Pattern --- Downstream on demand mode --- Only the downstream equipment receives the notification from the upstream equipment , Will send labels to upstream devices .
Data level flow process
In the process of data level traffic passing , Inbound LSR Equipment and outbound LSR Both devices need to query two tables , a sheet FIB surface , a sheet LFIB Packets can complete the forwarding process , Resulting in reduced efficiency , Need to optimize .
Optimization idea :
Inbound LSR --- Because the inbound packet does not contain labels , therefore , Must view FIB surface . You can directly add the battle tag to FIB In the table , In this way, you will no longer need to view LFPB surface .
Departure LSR --- PHP --- Second end bounce mechanism --- Departure LSR In giving FEC Assign special labels directly when assigning labels ( Implicit empty tag ), after , Pass this tag to your upstream device , The upstream will record this tag as an outbound tag in LFIB In the table . When data comes to the device , matching LFIB It is found that the outbound tag is 3, Then he will pop up this label directly . Then exit like this LSR The device will receive an unlabeled packet , Then he can directly check FIB Table to realize forwarding .
Huawei devices enable the next end bounce mechanism by default .
LSB Configuration of :
1、 First of all LSR Start the IGP agreement , Ensure the routing foundation
2、 To configure MPLS Of LSR ID
![]()
3、 Activate MPLS and LDP
Global activation
![]()
![]()
Interface activation
![]()
see LDP Peer relationship :
![]()
see LDP conversation :
![]()
see LFIB surface :
![]()
Be careful : Huawei equipment only gives /32 Host bit routing assignment label , because MPLS It is not mainly used in data forwarding , If there are too many routing entries in the routing table , Will result in too many LSP. Waste of resources .
![]()
MPLS Solve the routing black hole problem :
![]()
![]()
边栏推荐
- 火焰图分析Flink反压
- 屏:框贴、0贴合、全贴合
- Apache dolphin scheduler version 3.0.0-beta-1 was released, and flinksql and Zeppelin task types were added
- 20220725 自动控制原理中的补偿器
- LTS(Light-Task-Scheduler)
- Advanced Mathematics (Seventh Edition) Tongji University General exercises two person solution
- 数据平台调度升级改造 | 从Azkaban 平滑过度到 Apache DolphinScheduler 的操作实践
- Drools (3): drools basic syntax (1)
- I don't understand the MySQL 57 version under centos7 when I encounter a problem. I was informed by big Shen who knows it
- 20220725 convolution in automatic control principle
猜你喜欢
![[arm learning (8) AXF tool analysis]](/img/6c/df2ebb3e39d1e47b8dd74cfdddbb06.gif)
[arm learning (8) AXF tool analysis]

从XSS Playload 学习浏览器解码

倒计时2日!基于 Apache DolphinScheduler&TiDB 的交叉开发实践,从编写到调度让你大幅提升效率

404 page best practices to improve user experience

Leetcode 1184: distance between bus stops

anaconda安装教程-手把手教你安装

Apache dolphin scheduler version 3.0.0-beta-1 was released, and flinksql and Zeppelin task types were added

LTS(Light-Task-Scheduler)

What are the basics of getting started with spot silver

Leetcode 1184:公交站间的距离
随机推荐
成为 Apache 贡献者,So easy!
Tips when entering a formula in latex
MySql 中应该如何将多行数据转为多列数据
Drools(2):Drools快速入门
[arm learning (8) AXF tool analysis]
Data platform scheduling upgrade and transformation | operation practice from Azkaban smooth transition to Apache dolphin scheduler
Redis migrate tool migration error.
What are the basics of getting started with spot silver
docker修改挂载到宿主机上的mysql配置文件不生效?
20220725 compensator in automatic control principle
From scratch, we will completely develop an online chess game [Gobang] Based on websocket, and only use dozens of lines of code to complete all the logic.
Business secret series -- Talking about the evaluation of commercial passwords from the perspective of Party A and Party B (I)
Why can't extern compile variables decorated with const?
redis-migrate-tool迁移报错。
MySQL read / write lock
Can you learn fast and well with dual stream network? Harbin Institute of Technology & Microsoft proposed a distillation dual encoder model for visual language understanding, which can achieve fast an
Linux c SQLite database usage
强网杯2021 pwn 赛题解析——baby_diary
MySQL execution plan
Shared lock