Capture, dumping and decoding cdp and lldp packets
What port am I plugged into on a switch? or maybe what VLAN are you on?
the wireshark command
below will tell you ( may need to wait 90 seconds) but the
simplest way to dump and decode cdp and lldp packets is to use wireshark.
with the following capture filter:
tshark -i eth0 'multicast and (ether[12:2]=0x88cc or ether[20:2]=0x2000)'
Which will give you output like:
27.946203 00:1c:f6:a0:77:87 -> CDP/VTP/DTP/PAgP/UDLD CDP Device ID: jolley545-swr.cec.wustl.edu Port ID: GigabitEthernet2/0/7
29.922084 00:1c:f6:a0:77:87 -> LLDP_Multicast LLDP Chassis Id = 00:1c:f6:a0:77:87 Port Id = Gi2/0/7 TTL = 120
the -V flag will give lots more.
or you can use the display filter in wireshark:
eth.type == 0x88cc or cdp.version == 2
if you want to get picky you can specify the destination address
lldp uses: 01:80:c2:00:00:0e while cdp uses 01:00:0c:cc:cc:cc
There are other tools like openlldp and cdp-tools which are written in C.