当前位置:网站首页>Network protocol learning -- lldp protocol learning
Network protocol learning -- lldp protocol learning
2022-06-25 10:21:00 【Fat brother, Miss Wang】
brief introduction
LLDP(Link Layer Discovery Protocol) Link Layer Discovery Protocol , The main purpose of protocol design is to announce information , Further, information about network topology and related management configuration can be obtained . This is a layer 2 protocol , It provides a standard way to discover the link connection relationship , So that a device connected to the network can transfer its main capabilities , Management address , Device identifier , Information such as interface identification is organized into different groups TLV(Type/Length/Value), And it's packaged in LLDPDU(Link Layer Discovery Protocol Data Unit, Link layer discovery protocol data unit ) in , Sent to other devices connected to the same local area network .
We usually use LLDP Protocol to view , Which port of the switch is our device plugged into …… The colorful world , It's not easy to understand 
working principle
LLDP agreement , In essence, it is an information discovery and Notification Protocol . In the equipment LLDP The entity maintains two MIB(Management Information Base) library , One is local system MIB, Used to maintain relevant information of local equipment ; One is remote system MIB, It is used to maintain the relevant information of the remote device .
LLDP By relating to MIB Library interaction to initialize and maintain local MIB, And announce it through local relevant information , Receive notification information from other devices at the same time , And update it to remote system MIB. In this way , You can get the neighbor information of the device . Users can use these two MIB Library to complete their own needs .
LLDP Message format
Packaging has a LLDPDU (lldp Protocol data unit of the protocol ) Message of , be called LLDP frame . There are two packaging formats :Ethernet II and SNAP(Subnetwork Access Protocol, Subnet access protocol ). What we often use is Ethernet frame , So let's focus on... Based Ethernet II Of LLDP message .
| Field | meaning |
|---|---|
| Destination MAC address | Purpose MAC Address , For fixed multicast MAC Address 0x0180-C200-000E. |
| Source MAC address | Source MAC Address , Is the port MAC Address or device bridge MAC Address ( If there is a port address, use port MAC Address , Otherwise, use the equipment bridge MAC Address ) |
| Type | Message type , Fixed for 0x88CC. |
| Data | data , by LLDPDU |
| FCS | Frame check sequence |
among LLDPDU Is encapsulated in LLDP The data unit of the message data part . Just making up LLDPDU Before , The device will first encapsulate the local relevant information into TLV, Then add more TLV Combine into one LLDPDU, Packaged in LLDP The data part of the message is transmitted .
LLDPDU Format 
Every LLDPDU You can carry at most 28 Kind of TLV,LLDP Message reservation ,Chasis ID TLV, Port ID TLV, TTL TLV and End TLV These four must be carried , The rest TLV It's optional .
Here is a basic TLV Of list:

TLV Format
TLV It's the composition LLDPDU Unit of , The basic format is as follows :
among TLV Type and TLV Info String Length be called TLV Of header, The rest of the message is TLV The data part of , according to TLV Length Value of field , You can get the specific TLV data .
among TLV Type The definition and distribution of are as follows :
among type 0-8 Basic TLV aggregate , among Mandatory Is necessary TLV, Must be included in lldp In the data message .
The above is from cloudman《 How to use LLDP Get network topology ?》
Method
There are two ways to get LLDP Information .
One is lldpad, The other is lldpd.
First check the network card information .
[[email protected] ~]# lspci | grep Eth
1a:00.0 Ethernet controller: Intel Corporation Ethernet Connection X722 for 10GbE SFP+ (rev 09)
1a:00.1 Ethernet controller: Intel Corporation Ethernet Connection X722 for 10GbE SFP+ (rev 09)
1a:00.2 Ethernet controller: Intel Corporation Ethernet Connection X722 for 1GbE (rev 09)
1a:00.3 Ethernet controller: Intel Corporation Ethernet Connection X722 for 1GbE (rev 09)
When the network card is X722 perhaps 711 Type , Need a common configuration , Turn off the network card itself lldp
echo 'lldp stop' > /sys/kernel/debug/i40e/0000\:1a\:00.2/command
Just do it .
Then introduce two methods
lldpad
First installation yum install lldpad
And then start the service lldpad -d
Finally, configure and display
lldptool set-lldp -i eno3 adminStatus=rxtx
lldptool -T -i eno3 -V sysName enableTx=yes
lldptool -T -i eno3 -V portDesc enableTx=yes
lldptool -T -i eno3 -V sysDesc enableTx=yes
lldptool -T -i eno3 -V mngAddr enableTx=yes
Finally, check
[[email protected] ~]# lldptool -t -n -i eno3
Chassis ID TLV
MAC: 5c:a7:21:b0:46:58
Port ID TLV
Ifname: GigabitEthernet1/0/11
Time to Live TLV
121
Port Description TLV
GigabitEthernet1/0/11 Interface
System Name TLV
H3C
System Description TLV
H3C Comware Platform Software, Software Version 7.1.070, Release 6318P01
H3C S5130S-28TP-EI
Copyright (c) 2004-2020 New H3C Technologies Co., Ltd. All rights reserved.
System Capabilities TLV
System capabilities: Bridge, Router
Enabled capabilities: Bridge, Router
Management Address TLV
IPv4: 192.168.32.5
Ifindex: 635
Port VLAN ID TLV
PVID: 1
Link Aggregation TLV
Aggregation capable
Currently not aggregated
Aggregated Port ID: 0
MAC/PHY Configuration Status TLV
Auto-negotiation supported and enabled
PMD auto-negotiation capabilities: 0x6c01
MAU type: 1000 BaseTFD
Power via MDI TLV
Bad Power Via MDI TLV: 0101011000000000
Maximum Frame Size TLV
10240
End of LLDPDU TLV
You can see that the machine is plugged into the switch “GigabitEthernet1/0/11 Interface” On the mouth . Contains TLV That's a lot , What a naked child ----- What let you know .
lldpd
Install the software
yum install lldpd -y
Start the service
systemctl start lldpd.service
Call the command
[[email protected] ~]# lldpcli show neighbors
-------------------------------------------------------------------------------
LLDP neighbors:
-------------------------------------------------------------------------------
Interface: eno3, via: LLDP, RID: 1, Time: 0 day, 00:00:51
Chassis:
ChassisID: mac 5c:a7:21:b0:46:58
SysName: H3C
SysDescr: H3C Comware Platform Software, Software Version 7.1.070, Release 6318P01
H3C S5130S-28TP-EI
Copyright (c) 2004-2020 New H3C Technologies Co., Ltd. All rights reserved.
MgmtIP: 192.168.32.5
Capability: Bridge, on
Capability: Router, on
Port:
PortID: ifname GigabitEthernet1/0/11
PortDescr: GigabitEthernet1/0/11 Interface
TTL: 121
-------------------------------------------------------------------------------
You can also see the connected network port , Switch information , Management port IP etc. .
C The method of language
You can also use socket Simulation mode , receive lldp agreement , The main function is
int sock = socket(PF_PACKET, SOCK_RAW, htons(0x88CC));
The received Ethernet frame type is 0x88cc.
Conclusion
If it's true , That's really sinister 
边栏推荐
- BUG-00x bug description + resolve ways
- Wearable devices may reveal personal privacy
- JS tool function, self encapsulating a throttling function
- Exception: gradle task assemblydebug failed with exit code 1
- Flask博客实战 - 实现个人中心及权限管理
- The title of my composition is - "my district head father"
- Create menu file
- 【论文阅读|深读】LINE: Large-scale Information Network Embedding
- An auxiliary MVP architecture project quick development library -mvpfastdagger
- What is CRA
猜你喜欢

I hope to explain the basics of canvas as clearly as possible according to my ideas
![[dynamic planning] - Digital triangle](/img/79/79259ed8931a7968fb55f98a34d9e1.png)
[dynamic planning] - Digital triangle

How to apply for a widget on wechat how to get a widget on wechat
![[RPC] i/o model - Rector mode of bio, NiO, AIO and NiO](/img/29/1945b130c7c6a575f7a56c51136e3a.jpg)
[RPC] i/o model - Rector mode of bio, NiO, AIO and NiO

Kotlin advanced generic

Etcd tutorial - Chapter 4 etcd cluster security configuration

Mengyou Technology: six elements of tiktok's home page decoration, how to break ten thousand dollars in three days

How to make a self-service order wechat applet? How to do the wechat order applet? visual editing

How to install SSL certificates in Microsoft Exchange 2010

单片机开发---基于ESP32-CAM的人脸识别应用
随机推荐
SparseArray details
Android database security: after the user exits, the transaction rollback log still stores relevant data information
新学派:不诈骗经济学
[paper reading | depth] role based network embedding via structural features reconstruction with degree regulated
What is CRA
JS【中高级】部分的知识点我帮你们总结好了
Puzzle (019.2) hexagonal lock
Summary of considerations for native applet development
How do wechat sell small commodity programs do? How to open wechat apps to sell things?
Comparison and evaluation of digicert and globalsign single domain ov SSL certificates
什么是 CRA
[200 opencv routines] 210 Are there so many holes in drawing a straight line?
Solutions using protobuf in TS projects
Modbus协议与SerialPort端口读写
Repo sync will automatically switch the correspondence between the local branch and the remote branch - how to customize this behavior
WPF 绑定表达式和绑定数据源(一)
JS tool function, self encapsulating a throttling function
How to apply for a widget on wechat how to get a widget on wechat
Deep understanding of JVM - JVM memory model
Kotlin Foundation
