当前位置:网站首页>Key points of lldp protocol preparation
Key points of lldp protocol preparation
2022-06-10 20:13:00 【buildroot】
LLDP A protocol is a protocol that identifies a switch , The name of the switch comes to mind first , Description, etc. , In fact, there are many other contents , such as , Description of the port ,ttl, management ip,mac Address, etc .
Grab one lldp message , Its composition is shown in the figure below

There is a destination address (01:80:c2:00:00:0e) And source address (00:26:f8:99:00:77), There are also protocol types 0x88cc
Down there tlv 了 , such as Chassis subtype、port subtype、Time to Live(ttl)、port description wait
These data are put into the array in the form of characters
Analyze one by one
One 、 The destination address is 01:80:c2:00:00:0X form , This is the management frame , You can refer to stp Destination address of message , It means that you can pass block or discard Status port message , This kind of message will enter cpu Processed . After opening some ring network protocols, the processing methods of these messages are different from those of ordinary messages .
Two 、 The source address is the address of the switch , This address can be changed as needed
3、 ... and 、TLV As shown in the figure below

The first few of them are necessary data , But generally speaking, all of the above tlv Write it into the code . Of course, only when sending shutdown The above several... Will be used directly during the frame . And will ttl=0, In that way, the device can be directly aged to remove it from the switch lldp In the table to delete .
PS: Connect at the switch PC Computer time , The computer will also send lldp message , But it has only the first few contents . It is advisable to write code to identify these messages , Then cancel such messages . The messages sent in some old exchanges will only contain the first few TLV Suggestions and computer lldp Let the switch discard the message .
TLV Generally, it is composed of three or four parts. Of course, for specific composition, please refer to the instruction documents
One 、 Four parts

The picture above is in 88cc Followed by tlv

Its type is 02, however wireshark It is shown that 1, In fact, this value has been shifted to the left , Therefore, you need to shift one bit to the right when restoring 2>>1=1, The length is 07 Refer to 04-00-26-f8-99-00-77 this 7 Array values , The subtype is 04 Please refer to lldp In the manual chassis Type values of subtypes , among 4 The corresponding is mac Address , What follows is the content ,mac The address is 6 individual 16 Composed of hexadecimal numbers . It is the source mac Address . When we send and receive this type, we can use the corresponding function to process one by one in the array , Note that the value here is char The number of types 0 The corresponding is ascii The code 0 value , So when it is transferred or printed into character or string form , Note the conversion type , For example, it's the same 0,0 yes ascii The first of the codes BLANK NULL Nonprintable characters for , And characters ‘0’ The corresponding value is 48.
Two 、 In the third part of

As shown in the above figure, the meaning of its value is somewhat different from the above , It is the system name , There are no subtypes
The first value is 0x0a>>1=5 That is, its type , The second value represents a length of 5, The system name has no subtypes . That is, the following value is its name , These values are 16 It's binary , Find their corresponding ascii code ,0x54,0x39,0x30,x034 The decimal system is 84,57,48,48,52 Look up the table below and you will find that T9004

The composition of the message has been finished , It is relatively simple. You only need to write it in the corresponding position
Next is the point , The state machine , But I put it simply , Only the most basic form , For example, there is a status of only receiving but not sending , Only send but not receive status 、 The state of receiving and sending 、 Neither receive nor send status ( The closed position ) And so on
I look for a picture on the Internet , What initialization is there on it , What is the sending status , Receiving status , When the state changes , Idle state processing , Beginners may be confused , What is this? , How do you write it . In fact, it's not hard to . Library functions written by others are only used to #define It's just written in the advanced usage of .
But it's better to read other people's code and realize that the biggest thing is .
Create a new thread . Those who have learned SCM can be understood as a while(1) Circulatory body of , But in linux Real time and other operations can be used in the operating system while(1) The program is running . This while(1) There is one 1s Time delay of , That is, run the program every second .
The core of the program 1 yes ttl That is, survival time , In fact, it is the aging time in the switch . Once it's time , The device will be deleted by the table .
The core 2 If the state of the switch changes, the state machine will enter another state , In fact, simply put, it's just a switch sentence , If something changes, go to another case In the . For example idle state ( Idle state ) Turn it off when , Switchboard lldp The status immediately enters shutdown state , Send a ttl=0 Message of , After receiving this message, the peer switch will send it ttl Set up 0 Then it will age immediately , The peer switch switches it from lldp Delete... From the equipment list
The core 3 Is the interval transmission time , In fact, it is to keep it in the peer switch table , Prevent aging , Will be sent automatically at regular intervals lldp message . The message transmission time should be less than the interval time 1/4. There is an interval , Survival time multiplier , Reinitialization delay , Transmission delay and other parameters . If you are interested, please visit Baidu , There is no discussion here .
The core 4 Combine this information with mib Libraries , There is no discussion here
边栏推荐
- Deep understanding of lightgbm
- 8.4v双节锂电池专业充电ic(FS4062A)
- How to add independent hotspots in VR panoramic works?
- Source code analysis of Tencent libco collaborative process open source library (II) -- persimmon starts from the soft pinch, and the sample code officially begins to explore the source code
- Mixin -- mixed
- On the development trend of enterprise storage: cold thoughts on open source storage
- 今年高考期间各考点秩序井然,未发生影响安全的敏感案事件
- It took 2 years, 442 authors and 132 institutions! Google released the new benchmark big bench for language model evaluation. 204 tasks comprehensively evaluated the language model ability, with paper
- FPGA状态机
- 户外太阳能野营灯移动电源方案
猜你喜欢

Trilogy to solve the problem of playing chess first and then

FS2117升压IC输出5V2.4A同步整流

HM3416H降压IC芯片PWM/PFM 控制 DC-DC 降压转换器

How do big factories write data analysis reports?

高考开启,VR全景可以这样看考点

After the college entrance examination, VR panoramic tour will show you the beautiful scenery of the scenic spot

MySQL数据库基础

2022.05.29 (lc_6079_price reduction)

大厂测试员年薪30万到月薪8K,吐槽工资太低,反被网友群嘲?

DDD landing practice repeat record of theoretical training & Event storm
随机推荐
2022.05.29 (lc_6079_price reduction)
First batch! Sinomenine has passed CWPP capability assessment and inspection of Xintong Institute
Logback排除指定包/类/方法日志输出
Solution to the problem that JLINK CDC UART driver cannot be installed normally under win7 system
Tencent libco collaboration open source library source code analysis full series summary blog
Zabbix_原理架构-安装部署-自定义监控
Source code analysis of Tencent libco collaborative process open source library (II) -- persimmon starts from the soft pinch, and the sample code officially begins to explore the source code
PDU会话流程
Only three steps are needed to learn how to use low code thingjs to connect with Sen data Dix data
Nature Biotechnol | 李家洋/余泓团队利用平铺删除策略打破性状连锁,突破水稻产量瓶颈
Bit operation topic
一文详解EventMesh落地华为云的探索及实践
How to increase the monthly salary of software testing from 10K to 30K? Only automated testing can do it
How to use the low code platform of the Internet of things for worksheet management?
历时2年442位作者132个机构!Google发布语言模型评价新基准BIG-bench,204个任务全面评价语言模型能力,附论文
【观察】昇腾智行:场景驱动,创新先行,为智慧交通按下“加速键”
ZABBIX server trapper Remote Code Execution Vulnerability (cve-2017-2824)
FPGA状态机
MySQL backup and manual execution of shell scripts are OK, and crontab scheduled execution fails
seata 还是不支持sqlserver吗?