Friday, March 25, 2016

Find CDP or LLDP information on Windows Servers

The Cisco Discovery Protocol (CDP) is a proprietary Data Link Layer protocol developed by Cisco Systems. It is used to share information about other directly connected Cisco equipment, such as the operating system version and IP address. 

The Link Layer Discovery Protocol (LLDP) is a vendor-neutral link layer protocol in the Internet Protocol Suite used by network devices for advertising their identity, capabilities, and neighbors on an IEEE 802 local area network, principally wired Ethernet.

From Systems perspective You can view on which Switch and Switchport your Server or desktop NIC/Network cards are connected.
Finding CDP or LLDP information from ESXi very easy as VMware has provisioned separate interface for the same. As in the below screenshot click esxi server, then go to configuration tab, select Networking from Hardware, now as shown click on the CDP button after the Physical Network Card, and you will see CISCO Discovery Protocol, Now you can see I know which switch port I am connected, with this information I can connect to my networking team for any further troubleshooting issue or any changes if I required.
As I wanted to design HyperV/SCVMM solution, I was working on the same from networking part. and while architecturing Network solution for HyperV and I needed some Network side inventory like where my Windows Server HyperV Nic ports are connected on Physical switches for further designing, I don't see any separate interface or console where I can find such Information (if anyone know feel free to point out). So to find that information you can use Microsoft's tool Microsoft Network Monitor 3.4. It can capture network traffic and then you can filter the information you required. This topic is not only limited to Windows Server you can also use your own desktop to test this.
Here I will be using my favorite tool WiresharkWireshark is a network protocol analyzer for Unix and Windows, and it has many great features, I have download and installed it on my Windows Server., Here my server has got two physical ethernet cards and I want to know where both cards are connected on physical Switch. 
Search for wireshare and open it
Once Wireshark is running, you will detect all Network cards you have in your server, It matches the earlier screenshot I posted, Now You need to select one network card at a time, first NIC card I select is Team01, It will capture traffic on Team01 Nic.
Once you click on the network card it will start analyzing traffic in and out from the Nic. and you will see tons and tons of information. Now you will need to filter this captured information to find required CDP information. Type CDP and it will drop down the list of protocols from that list select CDP, incase you need LLDP information you can filter for LLDP.
Here I have got what I wanted. Very specific useful information regarding Switch name and Switch port number. 
Now I have collected information for one of the NIC card, I will be capturing data for another NIC card. from the capture menu press Stop to halt the capturing packets and go on selecting another Ethernet Card in the Options which is currently grayed out.
Now in the same Capture menu Options will be active once you stop capturing and we can click it to select another NIC.
You will again see 2 Nics in the list as we have already collected and captured information for one of the NIC in my scenario I had team01 and now will collect information for Management NIC card and click on start.
Now here is the info for another NIC card. As long as you keep wireshare capture starting and running, It will keep fetching the CDP data after some interval, Again you can capture LLDP information also with this tool. 
I found some of other tools exist which only CDP from tallsoft CDP monitor which is also handy, and there is windump.exe commandline utility which is available on the wireshark only.

My earlier useful script for collecting CDP and LLDP from VMWare ESXi environment.

Save complete virtual PortGroup information Settings - Powercli

Powercli Pull CDP and LLDP information in single nice table format - Part 2