Life’s an ocean with too much commotion

CDP tool

by koenvereeken on Jan.12, 2007, under Tech

Today I’ve played a bit with the Cisco Discovery Protocol.
This protocol is primarily used to obtain information about neighbouring devices:

  • IP addresses
  • Hostnames
  • IOS versions
  • Type cisco devices
  • on which interface they are connected

This means that you can test your network’s connectivity on layer 2 level.

The beauty is that this information is accessible through SNMP, in two different tables:

  • cdpInterface
  • cdpCache

I am mostly interested in the cdpCache table (which contains all the data as specified above), the cdpInterface is primarily used to configure CDP on the corresponding Cisco device.
The complete OID list is available on google.

I’ve made a perl wrapper script that recursively search for new devices.
This is how it works:

First you need a seed. In a network where everything’s connected to eachother (that means every Cisco device has at least one neighbour) you must have a starting point.
Choosing this seed is very important, because it will produce a network topology from the seed’s perspective. This seed can be specified as a hostname or IP address.

I use the perl library SNMP::Info(::CDP) for querying this information.
It will recursively search for the neighbours of the neighbours of the neighbours.. until every neighbour has been detected.
All discovered neighbours can be put into a queue. All discovered neighbours that have been queried for neighbours are pushed in an array so that they can be skipped if they are put in the queue again, eg. when there’s a loop in your network.
Yes this sounds extremely like a graphing algorithm ;)
This could all be stored into hash tables or some other data storage type.
I’ve simply printed out a cisco device and it’s neighbours when all neighbours of that cisco device have been detected and put into the queue.


Leave a Reply

Get Adobe Flash playerPlugin by wpburn.com wordpress themes

Looking for something?

Use the form below to search the site:

Still not finding what you're looking for? Drop a comment on a post or contact us so we can take care of it!