第一步,获取节点lldpRemoteSystemsData的信息用NET SNMP来Walk MIB节点lldpRemoteSystemsData,OID: 1.0.8802.1.1.2.1.4
***** SNMP QUERY STARTED *****
1: lldpRemChassisIdSubtype.15745436.216.1 (integer) macAddress(4)
2: lldpRemChassisId.15745436.216.1 (octet string) 00.23.89.14.FB.D0 (hex)
3: lldpRemPortIdSubtype.15745436.216.1 (integer) interfaceName(5)
4: lldpRemPortId.15745436.216.1 (octet string) GigabitEthernet2/0/17
5: lldpRemPortDesc.15745436.216.1 (octet string) GigabitEthernet2/0/17 Interface [47.69.67.61.62.69.74.45.74.68.65.72.6E.65.74.32.2F.30.2F.31.37.20.49.6E.74.65.72.66.61.63.65 (hex)]
6:lldpRemSysName.15745436.216.1(octet string) S5820X
[53.35.38.32.30.58 (hex)]
7: lldpRemSysDesc.15745436.216.1 (octet string) H3C Comware Platform Software, Software Version 5.20, Release 1211<0D><0A>
H3C S5820X-28C<0D><0A>Copyright (c) 2004-2011 Hangzhou H3C Tech. Co., Ltd. All rights reserved.
[48.33.43.20.43.6F.6D.77.61.72.65.20.50.6C.61.74.66.6F.72.6D.20.53.6F.66.74.77.61.72.65.2C.20.53.6F.66.74.77.61.72.65.20.56.65.72.73.69.6F.6E.20.35.2E.32.30.2C.20.52.65.6C.65.61.73.65.20.31.32.31.31.0D.0A.48.33.43.20.53.35.38.32.30.58.2D.32.38.43.0D.0A.43.6F.70.79.72.69.67.68.74.20.28.63.29.20.32.30.30.34.2D.32.30.31.31.20.48.61.6E.67.7A.68.6F.75.20.48.33.43.20.54.65.63.68.2E.20.43.6F.2E.2C.20.4C.74.64.2E.20.41.6C.6C.20.72.69.67.68.74.73.20.72.65.73.65.72.76.65.64.2E (hex)]
8: lldpRemSysCapSupported.15745436.216.1 (octet string) (
9: lldpRemSysCapEnabled.15745436.216.1 (octet string) (
10: lldpRemManAddrIfSubtype.15745436.216.1.1.4.5.5.5.2
(integer) ifIndex(2)
11: lldpRemManAddrIfId.15745436.216.1.1.4.5.5.5.2 (integer) 20
12: lldpRemManAddrOID.15745436.216.1.1.4.5.5.5.2 (object identifier) (null-oid) null
节点lldpRemoteSystemsData下面包含如下节点:
第一个节点为lldpRemChassisIdSubtype,表示对端设备标识lldpRemChassisId的解码类型,这里的值为4,表示用MAC地址来标识对端设备;
第二个节点为lldpRemChassisId,表示对端设备标识,这里的值为MAC地址00.23.89.14.FB.D0;
第三个节点为lldpRemPortIdSubtype,表示对端设备端口lldpRemPortId的解码类型,这里值为5,表示用端口名称来标识对端的端口;
第四个节点为lldpRemPortId,表示对端设备端口,GigabitEthernet2/0/17;
第五个节点为lldpRemPortDesc,表示对端设备端口描述信息,GigabitEthernet2/0/17 Interface;
第六个节点为lldpRemSysName,表示对端设备的系统名称,S5820X;
第七个节点为lldpRemSysDesc,表示对端设备的系统描述,H3C Comware Platform Software, Software Version 5.20, Release 1211<0D><0A>H3C S5820X-28C<0D><0A>Copyright (c) 2004-2011 Hangzhou H3C Tech. Co., Ltd. All rights reserved.
第八个节点为lldpRemSysCapSupported,表示对端设备支持的能力集,用位图的方式来表示;
第九个节点为lldpRemSysCapEnabled,表示对端设备使能的能力集,用位图的方式来表示;
第十个节点为lldpRemManAddrIfSubtype,表示对端设备管理IP地址的接口lldpRemManAddrIfId的标识方式,这里的值为2,表示用ifIndex来表示对端设备管理IP地址的接口;
第十一个节点为lldpRemManAddrIfId,表示对端设备管理IP地址的接口ID,为20;
第十二个节点为ldpRemManAddrOID都是null,不用关注。
Walk完这个节点,就知道了对端的端口为GigabitEthernet2/0/17,对端设备MAC为00.23.89.14.FB.D0,对端设备系统名称为S5820X,对端设备系统描述为H3C Comware Platform Software, Software Version 5.20, Release 1211<0D><0A>H3C S5820X-28C<0D><0A>Copyright (c) 2004-2011 Hangzhou H3C Tech. Co., Ltd. All rights reserved.
第二步,获取本端的端口信息
lldpRemoteSystemsData的前九个节点的索引都是15745436.216.1,其中15745436表示LLDP发现对端设备的时间戳,216表示本端接口的逻辑端口号,1表示远端设备索引。
通过节点lldpLocPortId,OID: 1.0.8802.1.1.2.1.3.7.1.3或lldpLocPortDesc, OID: 1.0.8802.1.1.2.1.3.7.1.4,可以知道本端接口的逻辑端口号和端口ID之间和端口描述的对应关系。
1.0.8802.1.1.2.1.3.7.1.3 | lldpLocPortId | 0 | 0 | The string value used to identify the port component associated with a given port in the local system. |
1.0.8802.1.1.2.1.3.7.1.4 | lldpLocPortDesc | 0 | 0 | The string value used to identify the 802 LAN station's port description associated with the local system. If the local agent su… |
----------------------------------------------
通过节点dot1dBasePortIfIndex,OID: 1.3.6.1.2.1.17.1.4.1.2,可以知道本端接口的逻辑端口号和端口ID之间的对应关系,逻辑端口号216对应的端口ID为61。
***** SNMP QUERY STARTED *****
55: dot1dBasePortIfIndex.215 (integer) 60
56: dot1dBasePortIfIndex.216 (integer) 61
57: dot1dBasePortIfIndex.217 (integer) 119
58: dot1dBasePortIfIndex.218 (integer) 120
59: dot1dBasePortIfIndex.337 (integer) 118
***** SNMP QUERY FINISHED *****
通过节点ifDescr,OID: 1.3.6.1.2.1.2.2.1.2,可以知道端口ID和端口名称之间的对应关系,端口ID为61的端口名称为GigabitEthernet4/0/24。
26: ifDescr.60 (octet string) GigabitEthernet4/0/23
[47.69.67.61.62.69.74.45.74.68.65.72.6E.65.74.34.2F.30.2F.32.33 (hex)]
27: ifDescr.61 (octet string) GigabitEthernet4/0/24
[47.69.67.61.62.69.74.45.74.68.65.72.6E.65.74.34.2F.30.2F.32.34 (hex)]
28: ifDescr.62 (octet string) Vlan-interface4
[56.6C.61.6E.2D.69.6E.74.65.72.66.61.63.65.34 (hex)]
29: ifDescr.86 (octet string) GigabitEthernet3/0/1
[47.69.67.61.62.69.74.45.74.68.65.72.6E.65.74.33.2F.30.2F.31 (hex)]
30: ifDescr.87 (octet string) GigabitEthernet3/0/2
[47.69.67.61.62.69.74.45.74.68.65.72.6E.65.74.33.2F.30.2F.32 (hex)]
31: ifDescr.88 (octet string) GigabitEthernet3/0/3
[47.69.67.61.62.69.74.45.74.68.65.72.6E.65.74.33.2F.30.2F.33 (hex)]
32: ifDescr.89 (octet string) GigabitEthernet3/0/4
[47.69.67.61.62.69.74.45.74.68.65.72.6E.65.74.33.2F.30.2F.34 (hex)]
则本端端口为GigabitEthernet4/0/24。
--------------------------------------------------
第三步,获取对端设备的管理IP地址和管理地址接口
lldpRemoteSystemsData的前十、十一,十二个节点的索引为
15745436.216.1.1.4.5.5.5.2 ,其中15745436表示LLDP发现对端设备的时间戳,216表示本端接口的逻辑端口号,紧接着的1表示远端设备索引,再后面的1表示管理地址的类型为ipv4地址,最后面的4.5.5.5.2表示长度为4个字节,对端设备的管理IP地址为5.5.5.2。
在对端设备5.5.5.2上,通过节点ifDescr,OID: 1.3.6.1.2.1.2.2.1.2,可以知道接口ID和接口名称之间的对应关系,接口ID为20对应的接口名为Vlan-interface1。
***** SNMP QUERY STARTED *****
1: ifDescr.1 (octet string) GigabitEthernet2/0/15
[47.69.67.61.62.69.74.45.74.68.65.72.6E.65.74.32.2F.30.2F.31.35 (hex)]
2: ifDescr.2 (octet string) GigabitEthernet2/0/16
[47.69.67.61.62.69.74.45.74.68.65.72.6E.65.74.32.2F.30.2F.31.36 (hex)]
3: ifDescr.3 (octet string) GigabitEthernet2/0/17
[47.69.67.61.62.69.74.45.74.68.65.72.6E.65.74.32.2F.30.2F.31.37 (hex)]
4: ifDescr.4 (octet string) GigabitEthernet2/0/18
[47.69.67.61.62.69.74.45.74.68.65.72.6E.65.74.32.2F.30.2F.31.38 (hex)]
15: ifDescr.15 (octet string) Ten-GigabitEthernet2/0/10
[54.65.6E.2D.47.69.67.61.62.69.74.45.74.68.65.72.6E.65.74.32.2F.30.2F.31.30 (hex)]
16: ifDescr.16 (octet string) Ten-GigabitEthernet2/0/11
[54.65.6E.2D.47.69.67.61.62.69.74.45.74.68.65.72.6E.65.74.32.2F.30.2F.31.31 (hex)]
17: ifDescr.17 (octet string) Ten-GigabitEthernet2/0/12
[54.65.6E.2D.47.69.67.61.62.69.74.45.74.68.65.72.6E.65.74.32.2F.30.2F.31.32 (hex)]
18: ifDescr.18 (octet string) Ten-GigabitEthernet2/0/13
[54.65.6E.2D.47.69.67.61.62.69.74.45.74.68.65.72.6E.65.74.32.2F.30.2F.31.33 (hex)]
19: ifDescr.19 (octet string) Ten-GigabitEthernet2/0/14
[54.65.6E.2D.47.69.67.61.62.69.74.45.74.68.65.72.6E.65.74.32.2F.30.2F.31.34 (hex)]
20: ifDescr.20 (octet string) Vlan-interface1
[56.6C.61.6E.2D.69.6E.74.65.72.66.61.63.65.31 (hex)]
***** SNMP QUERY FINISHED *****
根据以上三步,我们就知道了本端端口为GigabitEthernet4/0/24;
对端端口的端口为GigabitEthernet2/0/17,对端设备MAC为0023-8914-fbd0,对端设备系统名称为S5820X,对端设备系统描述为H3C Comware Platform Software, Software Version 5.20, Release 1211 H3C S5820X-28C Copyright (c) 2004-2011 Hangzhou H3C Tech. Co., Ltd. All rights reserved.对端管理IP地址为5.5.5.2,管理IP地址的接口ID为20,管理IP地址接口名称为Vlan-interface1。
第四步,在设备上通过命令行来验证:
dis lldp neighbor-information
LLDP neighbor-information of port 216[GigabitEthernet4/0/24]:
Neighbor index : 1
Update time : 1 days,19 hours,44 minutes,14 seconds
Chassis type : MAC address
Chassis ID : 0023-8914-fbd0
Port ID type : Interface name
Port ID : GigabitEthernet2/0/17
Port description : GigabitEthernet2/0/17 Interface
System name : S5820X
System description : H3C Comware Platform Software, Software Version 5.20, Release 1211 H3C S5820X-28C
Copyright (c) 2004-2011 Hangzhou H3C Tech. Co., Ltd. All rights reserved.
System capabilities supported : Bridge,Router
System capabilities enabled : Bridge,Router
Management address type : ipv4
Management address : 5.5.5.2
Management address interface type : IfIndex
Management address interface ID : 20
Management address OID : 0
Port VLAN ID(PVID): 1
Port and protocol VLAN ID(PPVID) : 0
Port and protocol VLAN supported : Yes
Port and protocol VLAN enabled : No
VLAN name of VLAN 1: VLAN 0001
Auto-negotiation supported : Yes
Auto-negotiation enabled : Yes
OperMau : speed(1000)/duplex(Full)
Power port class : PD
PSE power supported : No
PSE power enabled : No
PSE pairs control ability : No
Power pairs : Signal
Port power classification : Class 0
Link aggregation supported : Yes
Link aggregation enabled : No
Aggregation port ID : 0
Maximum frame Size: 10000
注:LLDP的MIB节点会记录历史信息,当发现一个端口有多个相同邻居时,根据节点lldpRemoteSystemsData索引中的时间戳,以时间戳大的值为准。