Skip to main content

LLDP帧

帧格式

LLDP帧格式
+--------------15---------------31
|             DMAC             |
+               ----------------|
|             |               |
+--------------                 |
|             SMAC             |
+-------------------------------|
|             Type             |
|                               |
+-------------------------------|
|             Data             |
|           (n bytes)           |
+-------------------------------|
|             FCS               |
+-------------------------------|
LLDP帧字段解释
字段 长度 含义
DMAC 6字节 LLDP帧的目的MAC地址。IEEE 802.1AB规定可以取如下3种值:0x0180-C200-000E: 最近网桥(Nearest Bridge)组MAC地址。0x0180-C200-0003: 最近的非两端口MAC中继网桥(Nearest non-TPMR Bridge)组地址。0x0180-C200-0000: 最近的客户网桥(Nearest Customer Bridge)组MAC地址。在使用VRP ®(Versatile Routing Platform)软件的华为设备上,LLDP帧的目的MAC地址取值为0x0180-C200-000E。
SMAC 6字节 源MAC地址,为端口MAC地址或设备桥MAC地址(如果有端口地址则使用端口MAC地址,否则使用设备桥MAC地址)。
Type 2或8字节 协议类型:如果是Ethernet II封装,值为0x88CC。如果是802.3 LLC SNAP封装,值为0xAAAA-0300-0000-88CC。
Data 变长 数据字段,标识帧的负载,为LLDPDU。LLDPDU就是封装在LLDP报文数据部分的数据单元。在组成LLDPDU之前,设备先将本地信息封装成TLV格式,再由若干个TLV组合成一个LLDPDU封装在LLDP报文的数据部分进行传送。LLDPDU的格式请参见图2-59
FCS 4字节 帧校验序列FCS(Frame Check Sequence)是为接收网卡提供判断是否传输错误的一种方法,如果发现错误,丢弃此帧。FCS只是通用叫法,具体的FCS还可以细分多种校验方法。在以太帧中,FCS通常采用循环冗余码校验CRC(Cyclical Redundancy Check)。

LLDPDU格式

LLDPDU包含了多个TLV,以Chasis ID TLV、Port ID TLV、TTL TLV这三个TLV开头,以End TLV结尾,中间是可选TLV,如图 Format of the LLDPDU。LLDP报文中必须包含这4个TLV,并且不能多于一个,否则就属于非法报文。可选携带即LLDP报文中可以包含也可以不包含这些TLV。IEEE 802.1AB标准中将TLV分为基本TLV(Basic TLV)、组织TLV(Organizationally Specific TLVs)以及保留TLV。

Format of the LLDPDU
+----------------------------------------------+ No. of octet
|             Chassis ID TLV                   | 1
+----------------------------------------------+
|             Port ID TLV                     | 1
+----------------------------------------------+
|             TTL TLV                         | 3
+----------------------------------------------+
|             Optional TLV                     | 4
+----------------------------------------------+
:             ...                             :
+----------------------------------------------+
|             Optional TLV                     |
+----------------------------------------------+
|             End TLV                         |
+----------------------------------------------+
基本TLV的格式
+----------------------------------------------+ No. of octet
|             Chassis ID (Type = 1)           |
+----------------------------------------------+
|             Port ID (Type = 2)               |
+----------------------------------------------+
|             Time To Live (Type = 3)         |
+----------------------------------------------+
|           Port Description (Type = 4)       |
+----------------------------------------------+
|           System Name (Type = 5)           |
+----------------------------------------------+
|           System Description (Type = 6)     |
+----------------------------------------------+
|           System Capabilities (Type = 7)     |
+----------------------------------------------+
|           Management Address (Type = 8)     |
+----------------------------------------------+
|           End of LLDPDU                     | 2B
+----------------------------------------------+
Basic TLV字段解释
TLV名称 说明 是否必须发布
End of LLDPDU 2字节的全零的TLV,用于标记LLDPDU的结尾。当端口的状态发生改变(比如去使能LLDP或者端口shut down)时,端口会向邻接设备发送一个LLDPDU,其中Time to Live TLV中的TTL=0,这个报文就是shutdown报文。所以End of LLDPDU TLV只有类型和长度,没有TLV information string字段。
Chassis ID (Type = 1) 表示发送该LLDP报文的设备的ID,每个LLDP报文必须包含且只能包含一个Chassis ID TLV。LLDPDU的第一个TLV必须是Chassis ID TLV。
Port ID (Type = 2) LLDPDU的发送端口名称。每个LLDPDU必须包含且只能包含一个Port ID TLV。
Time To Live (Type = 3) 是一个4字节的TLV,用于标识LLDP在邻居设备的存活时间。该TLV的值是一个0–65535的整数,它用来告诉接收端发送信息的有效期限,所以如果发送端在一段时间后没有更新该信息的话,接收端将丢弃该信息,对端接受到此TLV后,会用这个有效时间去更新其远端邻居的信息老化时间,它的单位为秒。每个LLDPDU必须包含且只能包含一个Time To Live TLV。
Port Description (Type = 4) 标识了本地设备端口的描述信息,如果设备支持IETF RFC 2863,这个TLV的值应该与RFC 2863的iftable表项的ifDescr叶子节点值一致。在一个LLDPDU报文中,只能包含一个Port Description TLV。
System Name (Type = 5) 标识了本地设备的完整域名,如果设备支持IETF RFC 3418,这个TLV的值应该与RFC 3418中的sysName的值一致。在一个LLDPDU报文中,只能包含一个System Name TLV。
System Description (Type = 6) 标识了本地设备的全称、系统硬件类型的版本号、操作系统、网络软件等。如果设备支持IETF RFC 3418,这个TLV 的值应该与RFC 3418中的sysDesc的值一致。在一个LLDPDU报文中,只能包含一个System Description TLV。
System Capabilities (Type = 7) 标识设备支持的功能以及已使能的功能。如果该TLV列出的已使能功能不包含在系统支持功能中,该TLV会被视为有错误而被丢弃。
Management Address (Type = 8) 管理地址,以及对应的接口号和OID(Object Identifier,对象标识)。
End of LLDPDU
+----------------------------------------------+
|             TLV type = 0 (7 bits)           |
+----------------------------------------------+
| TLV information string length = 0 (9 bits) |
+----------------------------------------------+

2字节的全零的TLV,用于标记LLDPDU的结尾。当端口的状态发生改变(比如去使能LLDP或者端口shut down)时,端口会向邻接设备发送一个LLDPDU,其中Time to Live TLV中的TTL=0,这个报文就是shutdown报文。所以End of LLDPDU TLV只有类型和长度,没有TLV information string字段。

Chassis ID
+----------------------------------------------+ 
|             TLV type = 1 (7 bits)           |
+----------------------------------------------+
|   TLV information string length (9 bits)   |
+----------------------------------------------+
|       chassis ID subtype (8 bits)           |
+----------------------------------------------+
|       chassis ID (1 < n < 255 octets)       |
+----------------------------------------------+

Chassis ID TLV的TLV Value域必须以8比特的chassis ID subtype开头,详见Chassis ID subtype code。在使用VRP ®(Versatile Routing Platform)作为软件平台的华为设备上,Chassis ID TLV设置为设备的网桥MAC地址,子类为4。

Chassis ID subtype code
ID子类 含义 参考标准
0 预留 -
1 Chassis component IETF RFC 4133
2 Interface alias IETF RFC 2863
3 Port component IETF RFC 4133
4 MAC address IEEE Std 802
5 Network address 网络地址是个1字节的字符串,标识网络地址族和对应的网络地址。
5 Interface name IETF RFC 2863
6 Agent circuit ID IETF RFC 3046
7 Locally assigned 是一个本地分配的包含字母和数字的字符串
8-255 预留  
Port ID
+----------------------------------------------+ 
|             TLV type = 2 (7 bits)           |
+----------------------------------------------+
|   TLV information string length (9 bits)   |
+----------------------------------------------+
|         port ID subtype (8 bits)           |
+----------------------------------------------+
|         port ID (1 < n < 255 octets)         |
+----------------------------------------------+

Port ID TLV也携带了ID之类字段,含义详见Port ID subtype code。在使用VRP ®(Versatile Routing Platform)作为软件平台的华为设备上,Port ID TLV设置为IF-MIB(IETF RFC 2863)的ifName叶子节点的值,即子类为5。

Port ID subtype code
ID子类        含义                  参考标准 
0           预留                 -
1           Interface alias     IETF RFC 2863
2           Port component       IETF RFC 4133
3           MAC address         IEEE Std 802
4           Network address     网络地址是个1字节的字符串,标识网络地址族和对应的网络地址。
5           Interface name       IETF RFC 2863
6           Agent circuit ID     IETF RFC 3046
7           Locally assigned     是一个本地分配的包含字母和数字的字符串
8-255       预留
Time to Live
+----------------------------------------------+ 
|             TLV type = 3 (7 bits)           |
+----------------------------------------------+
| TLV information string length = 2 (9 bits) |
+----------------------------------------------+
|         time to live (TTL) (2 octets)       |
+----------------------------------------------+

是一个4字节的TLV,用于标识LLDP在邻居设备的存活时间。该TLV的值是一个0–65535的整数,它用来告诉接收端发送信息的有效期限,所以如果发送端在一段时间后没有更新该信息的话,接收端将丢弃该信息,对端接受到此TLV后,会用这个有效时间去更新其远端邻居的信息老化时间,它的单位为秒。每个LLDPDU必须包含且只能包含一个Time To Live TLV。

Port Description
+----------------------------------------------+
|             TLV type = 4 (7 bits)           |
+----------------------------------------------+
|   TLV information string length (9 bits)   |
+----------------------------------------------+
|     port description (0 < n < 255 octets)   |
+----------------------------------------------+

标识了本地设备端口的描述信息,如果设备支持IETF RFC 2863,这个TLV的值应该与RFC 2863的iftable表项的ifDescr叶子节点值一致。在一个LLDPDU报文中,只能包含一个Port Description TLV。

System name
+----------------------------------------------+ 
|             TLV type = 5 (7 bits)           |
+----------------------------------------------+
|   TLV information string length (9 bits)   |
+----------------------------------------------+
|       system name (0 < n < 255 octets)       |
+----------------------------------------------+

标识了本地设备的完整域名,如果设备支持IETF RFC 3418,这个TLV的值应该与RFC 3418中的sysName的值一致。在一个LLDPDU报文中,只能包含一个System Name TLV。

System Description
+----------------------------------------------+ 
|             TLV type = 6 (7 bits)           |
+----------------------------------------------+
|   TLV information string length (9 bits)   |
+----------------------------------------------+
|   system description (0 < n < 255 octets)   |
+----------------------------------------------+

标识了本地设备的全称、系统硬件类型的版本号、操作系统、网络软件等。如果设备支持IETF RFC 3418,这个TLV 的值应该与RFC 3418中的sysDesc的值一致。在一个LLDPDU报文中,只能包含一个System Description TLV。

System Capabilities
+----------------------------------------------+ 
|             TLV type = 7 (7 bits)           |
+----------------------------------------------+
| TLV information string length = 4 (9 bits) |
+----------------------------------------------+
|       chassis ID subtype (8 bits)           |
+----------------------------------------------+
|       system capabilities (2 octets)         |
+----------------------------------------------+
|       enabled capabilities (2 octets)       |
+----------------------------------------------+

标识设备支持的功能以及已使能的功能。如果该TLV列出的已使能功能不包含在系统支持功能中,该TLV会被视为有错误而被丢弃。系统功能及相应的标识位:

比特     支持能力                     参考标准 
1       Other                       -
2       Repeater                   IETF RFC 2108
3       MAC Bridge                 IEEE Std 802.1D
4       WLAN Access Point           IEEE Std 802.11 MIB
5       Router                     IETF RFC 1812
6       Telephone                   IETF RFC 4293
7       DOCSIS cable device         IETF RFC 4639 and IETF RFC 4546
8       Station Only               IETF RFC 4293
9       C-VLAN Component           IEEE Std 802.1Q
10     S-VLAN Component           IEEE Std 802.1Q
11     Two-port MAC Relay (TPMR)   IEEE Std 802.1Q
12–16   Reserved                   -
Management Address
+----------------------------------------------+ 
|             TLV type= 8 (7 bits)             |
+----------------------------------------------+
|   TLV information string length (9 bits)   |
+----------------------------------------------+
| management address string length (1 octet) |
+----------------------------------------------+
|   management address subtype (1 octet)     |
+----------------------------------------------+
|     management address ( 1-31 octets)       |
+----------------------------------------------+
|   interface numbering subtype (1 octet)     |
+----------------------------------------------+
|         interface number (4 octets)         |
+----------------------------------------------+
|       OID string length (1 octet)           |
+----------------------------------------------+
|     object identifier (0-128 octets)       |
+----------------------------------------------+

管理地址,以及对应的接口号和OID(Object Identifier,对象标识)。

 

组织自定义TLV的格式

该类TLV允许不同组织,例如IEEE 802.1、IEEE 802.3、IETF等标准组织,或者软件或设备厂商,自定义TLV。

为该类TLV的格式。

为IEEE 802.1标准组织定义的TLV。

为IEEE 802.3标准组织定义的TLV。

组织自定义TLV的格式
+----------------------------------------------+
|           TLV type= 127 (7 bits)             |
+----------------------------------------------+
|   TLV information string length (9 bits)   |
+----------------------------------------------+
|   organizationally unique identifier (OUI)   |
|               (3 octets)                     |
+----------------------------------------------+
| organizationally defined subtype (1 octet) |
+----------------------------------------------+
| organizationally defined information string |
|             (0 < n < 507 octets)           |
+----------------------------------------------+
组织自定义TLV的格式格式说明
Field Length Description
TLV type 7bits 值为127,所以组织自定义TLV都采用这个值。
TLV information string length 9bits 标识了TLV信息域的长度,字节为单位。
organizationally unique identifier (OUI) 3B 组织OUI标记,唯一标识了一个组织,在IEEE Std 802标准的第9章节定义了组织的OUI。
organizationally defined subtype 1字节 组织自定义的TLV子类。
organizationally defined information string 0 - 507字节 组织自定义TLV的信息域。

IEEE 802.1组织定义的TLV

IEEE 802.1组织定义的TLV
IEEE 802.1子类 TLV名称 含义
0x01 Port VLAN ID 是一个可选的固定长度的TLV,允许VLAN桥端口在untagged帧或者带有优先级值的帧中发布其端口VLAN ID(PVID)。
0x02 Port And Protocol VLAN ID 是一个可选的TLV,端口的协议VLAN ID。
0x03 VLAN Name 是一个可选TLV,设备端口VLAN的名称。
0x04 Protocol Identity 是一个可选TLV,标识设备端口支持的协议类型。
0x05 VID Usage Digest 是一个可选的TLV,标识设备的VID使用摘要信息。
0x06 Management VID 是一个可选的TLV,设备的管理VLAN ID。如果设备没有管理VID,该值设置为0。
0x07 Link Aggregation 标识端口的链路聚合能力和使能状态。
0x08 - 0xFF Reserved -
Port VLAN ID
+----------------------------------------------+ 
|           TLV type= 127 (7 bits)             |
+----------------------------------------------+
| TLV information string length = 6 (9 bits) |
+----------------------------------------------+
|       802.1OUI = 0x00-80-C2 (3 octets)       |
+----------------------------------------------+
|           802.1 subtype = 1 (1 octet)       |
+----------------------------------------------+
|   port VLAN identifier (PVID) (2 octets)   |
+----------------------------------------------+

是一个可选的固定长度的TLV,允许VLAN桥端口在untagged帧或者带有优先级值的帧中发布其端口VLAN ID(PVID)(请参见IEEE 802.1Q- 2005, 8.4.4章节)。其中,port VLAN identifier域是IEEE Std 802.1Q-2005标准第8.4.4章节中定义的桥端口的VLAN ID。如果设备不知道PVID值或者不支持基于端口的VLAN操作,那么此域的值为0。

Port And Protocol VLAN ID
+----------------------------------------------+ 
|           TLV type= 127 (7 bits)             |
+----------------------------------------------+
| TLV information string length = 7 (9 bits) |
+----------------------------------------------+
|       802.1OUI = 0x00-80-C2 (3 octets)       |
+----------------------------------------------+
|           802.1 subtype = 2 (1 octet)       |
+----------------------------------------------+
|               flags (1 octet)               |
+----------------------------------------------+
| port and protocol VLAN identifier (PPVID)   |
|               (2 octets)                   |
+----------------------------------------------+

是一个可选的TLV,端口的协议VLAN ID。其中,flags域各比特的含义如下:

Bit 功能 含义
1 标识是否支持端口的协议VLAN 1表示支持,0表示不支持
2 是否使能端口的协议VLAN 1表示使能,0表示未使能
3-8 预留 设置为0
VLAN Name
+----------------------------------------------+ 
|           TLV type= 127 (7 bits)             |
+----------------------------------------------+
|   TLV information string length (9 bits)   |
+----------------------------------------------+
|       802.1OUI = 0x00-80-C2 (3 octets)       |
+----------------------------------------------+
|           802.1 subtype = 3 (1 octet)       |
+----------------------------------------------+
|             VLAN ID (2 octets)               |
+----------------------------------------------+
|         VLAN name length (1 octet)           |
+----------------------------------------------+
|           VLAN name (0-32 octets)           |
+----------------------------------------------+

是一个可选TLV,设备端口VLAN的名称。如果一个端口定义了多个VLAN名称TLV,则VLAN ID及对应的VLAN名称的组合必须是唯一的。VLAN ID域是指VLAN名称所对应的VLAN ID。VLAN名称长度域是指VLAN名称的长度,字节为单位,如果VLAN名称长度为0,表示该VLAN没有配置对应的VLAN名称。如果设备支持IETF RFC 4363,则VLAN名称设置为dot1QVLANStaticName对象。

Protocol Identity
+----------------------------------------------+ 
|           TLV type= 127 (7 bits)             |
+----------------------------------------------+
|   TLV information string length (9 bits)   |
+----------------------------------------------+
|       802.1OUI = 0x00-80-C2 (3 octets)       |
+----------------------------------------------+
|           802.1 subtype = 4 (1 octet)       |
+----------------------------------------------+
|     protocol identity length (1 octet)     |
+----------------------------------------------+
|       protocol identity ( <= 255 octets)     |
+----------------------------------------------+

是一个可选TLV,标识设备端口支持的协议类型。

VID Usage Digest
+----------------------------------------------+ 
|           TLV type= 127 (7 bits)             |
+----------------------------------------------+
|   TLV information string length (9 bits)   |
+----------------------------------------------+
|       802.1OUI = 0x00-80-C2 (3 octets)       |
+----------------------------------------------+
|           802.1 subtype = 5 (1 octet)       |
+----------------------------------------------+
|         VID usage digest (4 octets)         |
+----------------------------------------------+

是一个可选的TLV,标识设备的VID使用摘要信息。

Management VID
+----------------------------------------------+ 
|           TLV type= 127 (7 bits)             |
+----------------------------------------------+
|   TLV information string length (9 bits)   |
+----------------------------------------------+
|       802.1OUI = 0x00-80-C2 (3 octets)       |
+----------------------------------------------+
|           802.1 subtype = 6 (1 octet)       |
+----------------------------------------------+
|           Management ID (2 octets)         |
+----------------------------------------------+

是一个可选的TLV,设备的管理VLAN ID。如果设备没有管理VID,该值设置为0。

+----------------------------------------------+ 
| TLV type= 127 (7 bits) |
+----------------------------------------------+
| TLV information string length (9 bits) |
+----------------------------------------------+
| 802.1OUI = 0x00-80-C2 (3 octets) |
+----------------------------------------------+
| 802.1 subtype = 7 (1 octet) |
+----------------------------------------------+
| aggregation status (1 octet) |
+----------------------------------------------+
| aggregated port ID (4 octets) |
+----------------------------------------------+

标识端口的链路聚合能力和使能状态。“link aggregation status”域各比特含义:

Bit 功能 含义
0 标识聚合能力 值为0标识不支持链路聚合,1标识支持链路聚合。
1 标识聚合状态 值为0标识当前端口不在聚合链路中,1标识当前端口在链路聚合中。
2-7 保留  

 

IEEE 802.3组织定义的TLV

IEEE 802.3组织定义的TLV
IEEE 802.3子类 TLV名称 描述
1 MAC/PHY Configuration/Status 该TLV是个可选的TLV,标识如下信息:发送设备的物理媒介的双工和比特速率的能力。发送设备的物理媒介的双工和比特速率的当前设置。标识这些设置是人工设置还是通过链路自动协商得到的。
2 Power Via Medium Dependent Interface (MDI) 该TLV允许网管发布和发现发送设备的端口供电能力。
3 Link Aggregation (deprecated) N/A
4 Maximum Frame Size 标识端口配置的MTU (Max Transmission Unit,最大传输单元)值。
5 - 255 Reserved -
MAC/PHY Configuration/Status
+----------------------------------------------+ 
| TLV type= 127 (7 bits) |
+----------------------------------------------+
| TLV information string length (9 bits) |
+----------------------------------------------+
| 802.1OUI = 0x00-12-0F (3 octets) |
+----------------------------------------------+
| 802.3 subtype = 1 (1 octet) |
+----------------------------------------------+
| auto-negotiation support/status (1 octet) |
+----------------------------------------------+
| PMD auto-negotiation advertised capability |
| (2 octets) |
+----------------------------------------------+
| operational MAU type (2 octets) |
+----------------------------------------------+

该TLV是个可选的TLV,标识如下信息:发送设备的物理媒介的双工和比特速率的能力。发送设备的物理媒介的双工和比特速率的当前设置。标识这些设置是人工设置还是通过链路自动协商得到的。“auto-negotiation support/status”域的各比特含义详见auto-negotiation support/status。“PMD auto-negotiation capability”域使用BITS pseudotype编码方式,0为字节的高位(最左)。“operational MAU type”域是个整数值,标识发送设备的MAU类型。该值设置为IETF RFC 4836或后续更新版本中的dot3MauType对应的位置或者dot3MauType OID对应的最后一个数。

auto-negotiation support/status
Bit    功能                   值/含义              IETF RFC 4836参考 
0 自协商的支持 1 = 支持
0 = 不支持 ifMauAutoNegSupported
1 自协商状态 1 = 使能
0 = 未使能 ifMauAutoNegAdminStatus
2–7 - 预留 -
Power Via Medium Dependent Interface (MDI)
+----------------------------------------------+ 
| TLV type= 127 (7 bits) |
+----------------------------------------------+
| TLV information string length (9 bits) |
+----------------------------------------------+
| 802.1OUI = 0x00-12-0F (3 octets) |
+----------------------------------------------+
| 802.3 subtype = 2 (1 octet) |
+----------------------------------------------+
| MDI power support (1 octet) |
+----------------------------------------------+
| PSE power pair (1 octet) |
+----------------------------------------------+
| power class (1 octet) |
+----------------------------------------------+

该TLV允许网管发布和发现发送设备的端口供电能力。IEEE 802.3定义了三种实现,10BASE-T、100BASE-TX和1000BASE-T。MDI power support域的含义详见MDI power support。PSE power pair域是一个整数值,设置为IETF RFC 3621的pethPsePortPowerPairs对象。power class域也是一个整数值,设置为IETF RFC 3621的pethPsePortPowerClassifications对象。

MDI power support
比特位  含义                   值/含义                 IETF RFC 3621对象 
0 Port class 1 = PSE
0 = PD
1 Power Sourcing 1 = supported Equipment (PSE)
0 = not supported MDI power support
2 PSE MDI power state 1 = enabled
0 = disabled pethPsePortAdminEnable
3 PSE pairs control 1 = pair selection ability can be controlled 0 = pair selection pethPsePortPowerPairContolAbility can not be controlled
4–7 - 预留 -
Maximum Frame Size
+----------------------------------------------+ 
| TLV type= 127 (7 bits) |
+----------------------------------------------+
| TLV information string length (9 bits) |
+----------------------------------------------+
| 802.1OUI = 0x00-12-0F (3 octets) |
+----------------------------------------------+
| 802.3 subtype = 4 (1 octet) |
+----------------------------------------------+
| maximum 802.3 frame size (2 octets) |
+----------------------------------------------+

标识端口配置的MTU (Max Transmission Unit,最大传输单元)值。该TLV的值是一个整数值,表示端口支持的最大帧长,以字节为单位:如果以太网媒体接入控制器(MAC)/物理接口收发器(PHY)仅支持IEEE Std 802.3- 2008章节3.1.1所定义的基本的MAC帧格式,则该TLV值设置为1518。如果MAC/PHY支持IEEE Std 802.3-2008的3.5章节所定义的扩展的Tagged MAC帧格式,则该TLV值设置为1522。如果MAC/PHY支持MAC帧格式不在上述范围内,则该TLV值设置为所支持的最大值。

参考标准

标准 描述
IEEE 802.1AB IEEE Standard for Local and Metropolitan Area Networks: Station and Media Access Control Connectivity Discovery