当前位置:网站首页>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 
边栏推荐
- CyCa children's physical etiquette Yueqing City training results assessment successfully concluded
- Free platform for wechat applet making, steps for wechat applet making
- 单片机进阶---PCB开发之照葫芦画瓢(二)
- This is enough for request & response
- String implementation strstr()
- How much does a small program cost? How much does a small program cost? It's clear at a glance
- Fluent: target support file /pods runner / pods runner frameworks Sh: permission denied - stack overflow
- Ruiji takeout project (II)
- Identityserver4 definition concept
- [paper reading | deep reading] line: large scale information network embedding
猜你喜欢

ShardingSphere-Proxy 4.1 分库分表

MongoDB的原理、基本使用、集群和分片集群

ShardingSphere-Proxy 5.0 分库分表(一)

Minio基本使用与原理

Deep understanding of JVM - JVM memory model

Jetpack compose layout (II) - material components and layout

浅谈二叉树

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

The gradle configuration supports the upgrade of 64 bit architecture of Xiaomi, oppo, vivo and other app stores

【历史上的今天】6 月 24 日:网易成立;首届消费电子展召开;世界上第一次网络直播
随机推荐
View. post VS Handler. Differences and usage scenarios of post
Floating window --- create an activity floating window (can be dragged)
Yolov5 changing the upper sampling mode
[today in history] June 24: Netease was established; The first consumer electronics exhibition was held; The first webcast in the world
DDS learning notes of opendds
Identityserver4 definition concept
Wearable devices may reveal personal privacy
Basic use and principle of Minio
Best producer consumer code
[200 opencv routines] 210 Are there so many holes in drawing a straight line?
Ruiji takeout project (II)
Basic use and cluster construction of consult
How much does a wechat applet cost? Wechat applet development and production costs? Come and have a look
我希望按照我的思路尽可能将canvas基础讲明白
Houdini图文笔记:Your driver settings have been set to force 4x Antialiasing in OpenGL applications问题的解决
How to apply for a widget on wechat how to get a widget on wechat
如何在Microsoft Exchange 2010中安装SSL证书
How to build a wechat applet? How to open an applet?
New school: no fraud Economics
Flutter Gaode map privacy compliance error
