Friday, June 20, 2008

Cisco Discovery Protocol (CDP) for your PC

At my previous job I once saw an Engineer walk around with a Cisco 2500 router when he would go out to work on an end users network port. He used this to identify which switch and port that user was connected to by doing a show cdp neighbors. After that I remembered that I had seen a Linux module that allowed you to capture and decode CDP messages however not everyone runs Linux and Windows is much more common. To that end here is an open source project that runs not only on Linux, but on Windows as well.

You can find it on SourceForge here: http://sourceforge.net/projects/cdpr

It runs from the Windows Command prompt and when invoked lists your Network Adapters so that you can select which interface you would like to monitor for CDP messages. When a CDP message is recieved (and remember the default for CDP is 60 seconds so you may have to wait a bit) it will decode the message and display the neighbor information.


Example Output:

C:\Documents and Settings\carlfugate>cdpr
cdpr - Cisco Discovery Protocol Reporter Version 1.0.7
Copyright (c) 2002 - MonkeyMental.com

1. \Device\NPF_GenericDialupAdapter (Adapter for generic dialup and VPN capture)
2. \Device\NPF_{DD1F69AE-A3A2-463A-A382-34AA18C49A39} (3Com 3C90x Ethernet Adapter (Microsoft's Packet Scheduler) )
3. \Device\NPF_{7D01E702-D424-4232-884C-868EFFAEC66B} (3Com EtherLink PCI)
4. \Device\NPF_{A08F5F58-A83E-47DD-AF89-9BCAA20CA10B} (NOC Extranet Access Adapter (Microsoft's Packet Scheduler) )
Enter the interface number (1-4):3
Using Device: \Device\NPF_{7D01E702-D424-4232-884C-868EFFAEC66B}
Waiting for CDP advertisement
(default config is to transmit CDP packets every 60 seconds)
Device ID
value: lab-switch
Addresses
value: 192.168.3.10
Port ID
value: FastEthernet0/24


This is a great tool which sure beats having to go out and get a MAC address and track it down through several different switches.

4 comments:

Amr H said...

Dear Carl Fugate,
I need to get the IP address of my eathernet and i found ur post is so usefull, I downloaded ur code but it is not working, I need ur help in this issue.

kindly if you can contact me antiiika@live.com

Thanks,
Amr

Amr H said...

I tried your application but I cant start it, could u help?

Anonymous said...

The file on Sourceforge is the raw source. Has anbody got a compiled version?

Anonymous said...

Awesome, just what I needed...thanks !