Cisco Discovery Protocol (CDP) is a proprietary protocol designed by Cisco to help in finding information about neighboring devices. Devices connected to each other exchange CDP packets to learn about each other. This can be useful in troubleshooting and documenting the network.

CDP is enabled on all interfaces of all Cisco routers and switches. You can disable CDP globally using the no cdp run command in the global configuration mode. It can be enabled again using the cdp run command. CDP can be disabled on an interface using the no cdp enable command in the interface configuration mode.

Each device running CDP sends out a packet every 60 seconds to its neighbors. The timers associated with CDP on a device can be seen using the show cdp command in the privilege exec mode as shown below:

myRouter#show cdp
Global CDP information:
Sending CDP packets every 60 seconds
Sending a holdtime value of 180 seconds
Sending CDPv2 advertisements is enabled 

In the above output you can see that CDP is sending packets every 60 seconds. Each neighbor will keep the information contained in a packet for 180 seconds. The timers can be changed using the cdp timer command and the cdp holdtime command in the global configuration mode as shown below:

myRouter(config)#cdp ?
advertise-v2      CDP sends version-2 advertisements
holdtime          Specify the holdtime (in sec) to be sent in packets
log               Log messages generated by CDP
run               Enable CDP
source-interface  Insert the interface’s IP in all CDP packets
timer             Specify rate (in sec) at which CDP packets are sent

myRouter(config)#cdp timer ?
<5-254>  Rate at which CDP packets are sent (in  sec)

myRouter(config)#cdp timer 120
myRouter(config)#cdp holdtime ?
<10-255>  Length  of time  (in sec) that receiver must keep this packet

myRouter(config)#cdp holdtime 240
myRouter(config)#do show cdp
Global CDP information:
Sending CDP packets every 120 seconds
Sending a holdtime value of 240 seconds
Sending CDPv2 advertisements is  enabled
myRouter(config)#

As mentioned, earlier CDP can be used to troubleshoot as well as document a network. When you need information regarding devices directly connected to a device, you can check the neighbors learned by CDP using the show cdp neighbor command. An example is shown below:

myRouter#show cdp neighbors
Capability Codes: R – Router, T – Trans Bridge, B – Source Route Bridge
S – Switch, H – Host, I – IGMP, r – Repeater

Device ID        Local Intrfce     Holdtme    Capability  Platform  Port ID
Switch3                  Fas 0/0            172         S I       WS-C2960-     Fas 0/8

The output shows that myRouter is directly connect to a device named Switch3. Each column in the output gives information regarding Switch3. Each column is explained below:

  • DeviceID – This column gives the hostname of the directly connected device. In this case, the router is directly connected only to a single device named Switch3.
  • Local Intrface – This column shows the local interface of the device that is connected to the remote device. In this case, fa0/0 interface of myRouter is connected to Switch3
  • Holdtme – This column shows the amount of time in seconds, that the local device will keep the information about the remote device, if no further packets are received from it. In this example, if Switch3 does not send any more CDP packets before 172 seconds, it will be removed from the neighbor table of myRouter. The remote device advertises the holdtime.
  • Capability – This column shows the capabilities of the remote device. The meaning of each letter in that column is shown at the beginning of the output. In this example, Switch3 is shown as a Switch and has IGMP enabled on it.
  • Platform – This column shows the device model of the remote device. In this output you can see that Switch3 is a Cisco 2960 device.
  • Port ID – This column shows the interface number of the remote device that connects to this device. In this example, myRouter is connected to fa0/8 interface of Switch3.

The show cdp neighbor commands provides brief information on all directly connect device. A more detailed information of a neighbor can be see using the show cdp neighbors detail command as shown below:

myRouter#show cdp neighbors detail
————————-
Device ID: Switch3
Entry address(es):
  IP address: 192.168.1.3
Platform: cisco WS-C2960-48TT-L,  Capabilities: Switch IGMP
Interface: FastEthernet0/0,  Port ID (outgoing port): FastEthernet0/8
Holdtime : 142 sec\

Version :
Cisco IOS Software, C2960 Software (C2960-LANBASEK9-M), Version 12.2(50)SE4, RELEASE SOFTWARE (fc1)
Technical Support: http://www.cisco.com/techsupport
Copyright (c) 1986-2010 by Cisco Systems, Inc.
Compiled Fri 26-Mar-10 09:14 by prod_rel_team

advertisement version: 2
Protocol Hello:  OUI=0x00000C, Protocol ID=0x0112; payload len=27, value=00000000FFFFFFFF010221FF000000000000000AB875A380FF0000
VTP Management Domain: test.com’
Native VLAN: 26
Duplex: full

In the output above you will notice that apart from the information shown by the show cdp neighbor command, this output shows the IOS version, VTP and VLAN information as well as the duplex of the connection to the remote device. This output also shows the IP address of the remote device. This can be very useful if you want to connect to the remote device for troubleshooting. At this stage do not worry about VLAN and VTP. They are covered in the next chapter.

The exact same output can also be seen using the show cdp entry * command. An example of the output is shown below again:

myRouter#show cdp entry *
————————-
Device ID: Switch3
Entry address(es):
IP address: 192.168.1.3
Platform: cisco WS-C2960-48TT-L,  Capabilities: Switch IGMP
Interface: FastEthernet0/0,  Port ID (outgoing port): FastEthernet0/8
Holdtime : 135 sec

Version :
Cisco IOS Software, C2960 Software (C2960-LANBASEK9-M), Version 12.2(50)SE4, RELEASE SOFTWARE (fc1)
Technical Support: http://www.cisco.com/techsupport
Copyright (c) 1986-2010 by Cisco Systems, Inc.
Compiled Fri 26-Mar-10 09:14 by prod_rel_team

advertisement version: 2
Protocol Hello:  OUI=0x00000C, Protocol ID=0x0112; payload len=27, value=00000000FFFFFFFF010221FF000000000000000AB875A380FF0000
VTP Management Domain: test.com’
Native VLAN: 26
Duplex: full

While the output of both show cdp neighbors detail and show cdp entry * are the same, the latter gives you the option to just see the layer 3 protocol information or just the IOS version information from the remote device as shown below:

myRouter#show cdp entry * ?

protocol  Protocol information
version   Version information
|         Output modifiers
<cr>

myRouter#show cdp entry * protocol
Protocol information for 26dot3.cisco.com :
IP address: 192.168.26.3

myRouter#show cdp entry * version 

Version information for 26dot3.cisco.com :
Cisco IOS Software, C2960 Software (C2960-LANBASEK9-M), Version 12.2(50)SE4, RELEASE SOFTWARE (fc1)
Technical Support: http://www.cisco.com/techsupport
Copyright (c) 1986-2010 by Cisco Systems, Inc.
Compiled Fri 26-Mar-10 09:14 by prod_rel_team

In the above output, notice that show cdp entry * protocol gives only the IP address (layer 3 information) while show cdp entry * version gives only the IOS version of directly connected devices.

CDP is a simple protocol that just works always. There will hardly be a need to troubleshoot CDP but in case you ever need to do that, you can use the show cdp traffic and show cdp interface commands. The show cdp traffic command displays information regarding the CDP packets sent and received. If CDP traffic is not being sent or received or if there are errors, the output of this command will show that. An example of the output is shown below:

myRouter#show cdp traffic
CDP counters :
Total packets output: 64293, Input: 64294
Hdr syntax: 0, Chksum error: 0, Encaps failed: 0
No memory: 0, Invalid packet: 0, Fragmented: 0
CDP version 1 advertisements output: 0, Input: 0
CDP version 2 advertisements output: 64293, Input: 64294

The show cdp interface command on the other hand will show CDP information related to each interface of the device. This command will show you if CDP is enabled on an interface or not and what are the timers associated with each interface. It will also show the status of the interface itself. An example of the output is given below:

myRouter#show cdp interface
FastEthernet0/0 is up, line protocol is up
Encapsulation ARPA
Sending CDP packets every 120 seconds
Holdtime is 240 seconds
FastEthernet0/1 is administratively down, line protocol is down
Encapsulation ARPA
Sending CDP packets every 120 seconds
Holdtime is 240 seconds

One drawback of CDP is that it is a Cisco proprietary protocol and will not work if you have another vendors devices connected to a Cisco device. In such cases, you can use the Link Layer Discovery Protocol (LLDP). LLDP is an open standard protocol that does the same work as CDP but can be used between devices belonging to different vendors.

Not all Cisco devices currently support LLDP and it is not covered in CCNA, but you should know that it could be used in place of CDP.