当前位置:网站首页>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
边栏推荐
- Shuttle JSON, list, map inter transfer
- Floating window --- create an activity floating window (can be dragged)
- String implementation strstr()
- 宏的运用接续符\
- The path of Architects
- How to make small programs on wechat? How to make small programs on wechat
- [today in history] June 24: Netease was established; The first consumer electronics exhibition was held; The first webcast in the world
- Flask博客实战 - 实现个人中心及权限管理
- 我希望按照我的思路尽可能将canvas基础讲明白
- Principle of distribution: understanding the gossip protocol
猜你喜欢
2台三菱PLC走BCNetTCP协议,能否实现网口无线通讯?
WPF Prism框架
ScheduleMaster分布式任务调度中心基本使用和原理
Yolov5更换上采样方式
Jetpack compose layout (I) - basic knowledge of layout
Can two Mitsubishi PLC adopt bcnettcp protocol to realize wireless communication of network interface?
Deep understanding of JVM - JVM memory model
[200 opencv routines] 210 Are there so many holes in drawing a straight line?
Etcd tutorial - Chapter 4 etcd cluster security configuration
Flask blog practice - archiving and labeling of sidebar articles
随机推荐
How to make a self-service order wechat applet? How to do the wechat order applet? visual editing
Jetpack compose layout (II) - material components and layout
浅谈二叉树
Unique Wulin, architecture selection manual (including PDF)
ShardingSphere-Proxy 4.1 分庫分錶
View. post VS Handler. Differences and usage scenarios of post
New school: no fraud Economics
【论文阅读|深读】LINE: Large-scale Information Network Embedding
How to make small programs on wechat? How to make small programs on wechat
Identityserver4 definition concept
ScheduleMaster分布式任务调度中心基本使用和原理
Linked list delete nodes in the linked list
Bitmap is converted into drawable and displayed on the screen
Kotlin advanced generic
单片机进阶---PCB开发之照葫芦画瓢(二)
Tiktok brand goes to sea: both exposure and transformation are required. What are the skills of information flow advertising?
Basic use and principle of Minio
How much does a small program cost? How much does a small program cost? It's clear at a glance
Oracle query comes with JDK version
String implementation strstr()