Home  
  Cisco  
  Practice Exams  
  TechNotes  
  - CCNA -  
  - CCSP -  
  - CCIE -  
  TechSims  
  TechLabs  
  Links  
  Forums  
  Blogs  
  Topsites  
  Search the Web  
  Certification Kits
     
  Subnet Calculator  
  Online Degrees  
  Exam Vouchers  
  Free Magazines  

   
   
CCNA TechLab: Cisco Discovery Protocol (CDP)

In this TechLab, we will cover the Cisco Discovery Protocol (CDP) . CDP is a layer 2 protocol that is used for discovering information about neighboring network devices. Because CDP operates at the Data Link layer, it does not need a network layer protocol, such as IP or IPX, to transfer information. CDP devices send out periodic advertisements to the MAC multicast address 0100.0ccc.cccc, every 60 seconds by default.

CDP runs on all Cisco equipment such as routers, switches, bridges and access servers. It discovers information about neighboring devices such as the type of device and its capabilities, software version, the local and remote interface, and even configured network layer addresses. This information is stored in a table in the device's RAM and is flushed on reboot.

Create the network

Connect 2 switches, 2 routers, and 1 PC as shown in the network diagram depicted above. Connect the serial cable so the router on the right becomes the DCE (not required, just remember which one is the DCE). The PC does not require any configuration and is optional.


Configure the routers and switches

Before we move on to CDP, we need to configure and enable the connections of the routers – they are currently down as you can tell by the red color of the connections.

> Open a console/telnet session with Router1, and use the following commands sequence to configure it:

Router#enable
Router#configure terminal
Router(config)#hostname Router1
Router1(config)#interface fastethernet 0/1
Router1(config)#no shutdown
Router1(config)#interface serial 1/0
Router1(config)#no shutdown
Router1(config)#end

> Open a session with Router2, and use the following commands sequence to configure it:

Router#enable
Router#configure terminal
Router(config)#hostname Router2
Router2(config)#interface serial 1/0
Router2(config)#clock rate 64000 (use this command on the DCE side of serial connection, see yellow dot in network diagram)
Router2(config)#no shutdown
Router2(config)#end

> Configure the hostnames of the switches to match the names in map (Switch1 and Switch2) because the hostname is used to identify entries in the CDP table.

Using the Cisco Discovery Protocol (CDP)

Because CDP is enabled by default, several CDP advertisements should be exchanged by now. If it doesn't work, you need to make sure the ‘link' and ‘line' is up for all connections. You can also use the show interfaces command on the routers and switches to determine the status of the connections.

Remember CDP is a layer 2 protocol, so it only needs layer 2 connectivity. In this case Ethernet on the links to the switches, the default HDLC on the serial link. While in reality you are likely configuring the router interfaces and the switches with IP addresses, it is not required for CDP.

Routers do not forward layer-2 traffic by default, so they do not forward CDP ads either. Cisco switches recognize the MAC multicast address 0100.0ccc.cccc used by CDP as a special address and won't forward it out of other interfaces either. This means only directly connected neighbors receive the CDP ads.

Now let's see what CDP can do for us without any further configuration. One of the most important CDP commands is the show cdp neighbors command. It displays the following information for the neighbors from which it received CDP ads:

  • Name of the neighboring device
  • Local interface – type & ID of the local interface on which ads of this neighbor were received.
  • Holdtime – specifies the time left before this entry is flushed if no new updates are received. (covered in more detail later on in this lab)
  • Device capability – see the first line in the command output below for a list of codes.
  • Device platform – the neighboring device model.
  • Port ID – the connected interface of the neighbor.

> Open a console session with Switch1, and use the show cdp neighbors command in User Exec or Privileged Exec mode to display the contents from the CDP table. It should contain an entry for the other switch connected to interface Fa0/2.

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

Switch1#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
Switch2     Fas 0/2        125     S I         WS-C2950-12  Fas 0/1 

> Open a console session with Switch2, and run the show cdp neighbors command again. The CDP table on Switch2, should contain an entry for Switch1 and an entry for Router1.

Sitch2#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
Switch1     Fas 0/1        162     S I         WS-C2950-12  Fas 0/2
Router1     Fas 0/2        167     R           C2600        Fas 0/1

Two devices can be each other's neighbors multiple times, through redundant connections for example.

> Run the show cdp neighbors command again, but add the detail keyword:

Switch2#show cdp neighbors detail
-------------------------
Device(ID) : Switch1
Entry(address(es)):
Platform: cisco WS-C2950-12, Capabilities: Switch IGMP
Interface: FastEthernet0/1, Port ID (outgoing port): FastEthernet0/2
Holdtime : 165 sec

Version :
Cisco Internetwork Operating System Software
Cisco IOS (tm) C2950 Software Version 12.1(9)EA1
Copyright (c) 1986-2002 by Cisco Systems, Inc
Compiled Wed 27-Jul-06 06:51 by johanh

advertisement version: 2
Duplex : full
-------------------------
Device(ID) : Router1
Entry(address(es)):
Platform: cisco C2600, Capabilities: Switch IGMP
Interface: FastEthernet0/2, Port ID (outgoing port): FastEthernet0/1
Holdtime : 170 sec

Version :
Cisco Internetwork Operating System Software
IOS (tm) C2600 Software Version 12.3(19)
Copyright (c) 1986-2005 by Cisco Systems, Inc.
Compiled Wed 27-Jul-06 06:51 by johanh

advertisement version: 2
Duplex : full

The exact output differs per device and IOS versions. Notice the following additional fields in the output:

  • Entry addresses – These are Network (layer 3) addresses (e.g. IP, IPX, AppleTalk) configured on the neighbor.
  • Version – The IOS version of the neighbor (use the show version command to display the local version info).
  • CDP advertisement version
  • Duplex setting for Ethernet interfaces
  • VTP Domain (not present on router output, can be on switches.)

The Entry address field is empty because we didn't configure IP addresses on the switches or routers to illustrate we don't need TCP/IP to carry CDP traffic. If you want to see the output results including the Entry addresses field configure an IP address on the (VLAN interface of the) switches and/or on the connected interfaces of the routers.

Another command that can be used to display the contents of the CDP neighbors table is the show cdp entry [* | ID] command, which displays all entries or a specific entry of the CDP table. The show cdp entry * results in the same output as the show cdp neighbors detail command. Specify the Device ID to display a specific entry. Note that the Device ID is case sensitive.

Router>show cdp entry Router1
-------------------------
Device(ID) : Router1
Entry(address(es)):
Platform: cisco C2600, Capabilities: Switch IGMP
Interface: FastEthernet0/2, Port ID (outgoing port): FastEthernet0/1
Holdtime : 170 sec

Version :
Cisco Internetwork Operating System Software
IOS (tm) C2600 Software Version 12.3(19)
Copyright (c) 1986-2005 by Cisco Systems, Inc.
Compiled Wed 27-Jul-06 06:51 by johanh

advertisement version: 2
Duplex : full

To see if CDP is enabled for the router, and to display the current CDP timers, use the following command:

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

The show cdp interface command displays the interfaces for which CDP is enabled including the encapsulation type and CDP timers.

Router1#show cdp interface
FastEthernet0/1 is up, line protocol is up
Sending CDP packets every 60 seconds
Holdtime is 180 seconds
FastEthernet0/2 is down, line protocol is down
Sending CDP packets every 60 seconds
Holdtime is 180 seconds
Serial1/0 is up, line protocol is up
Sending CDP packets every 60 seconds
Holdtime is 180 seconds
Serial1/1 is down, line protocol is down
Sending CDP packets every 60 seconds
Holdtime is 180 seconds
Serial1/2 is down, line protocol is down
Sending CDP packets every 60 seconds
Holdtime is 180 seconds
Serial1/3 is down, line protocol is down
Sending CDP packets every 60 seconds
Holdtime is 180 seconds

The default update timer of 60 seconds can be changed by using the cdp timer command in global configuration mode. For example, the following command will configure the router to send CDP advertisements every 90 seconds:

Router1(config)#cdp timer 90

The holdtime is 180 seconds by default, when exceeded without receiving advertisements the CDP entry is removed from the CDP table. It can be changed by using the cdp holdtime command in global configuration mode:

Router1(config)#cdp holdtime 270

The show cdp traffic command displays the CDP counters regarding CDP packets sent and received as well as error statistics:

Router>show cdp traffic
CDP counters :
Total Packets output: 48, Input: 131
Hdr syntax: 0, Chksum error: 0, Encaps failed: 6
No memory: 0, Invalid packet: 0, Fragmented: 0

Besides providing information about neighboring devices to the person managing the device, the information included in CDP messages is used for several different purposes. For example, it can be used in combination with SNMP and a Network Management Station to gather information. It can also be used to determine whether device connected to a switch needs power over Ethernet (PoE). Another example is that CDP will log a warning message (by default to the console) if it notices a duplex mismatch setting between two FastEthernet interfaces. For example, set the Fa0/2 interface on Switch1 to half-duplex and the other end, the Fa0/1 interface on Switch2 to full duplex. The warning message indicating the duplex mismatch will appear when the next CDP message is received.

Disabling CDP

Although running CDP in your network can be very helpful for managing and troubleshooting a Cisco network, it can also provide malicious individuals sensitive information (Device types, names, IOS version and IP addresses for example), so if you don't need or use it, you may want to disable it. After all it does create additional traffic at least twice per minute by default (both sides each advertise one per 60 seconds).

You can use the following command in global configuration mode to disable CDP for the entire router:
Router(config)#no cdp run

Use the cdp run command to enable CDP (default).

If you do need CDP, there is a good chance you don't need it on all your active interfaces. In our example network, there is a PC connected to the Cisco switch. The PC will ignore the CDP ads so sending them is a waste of resources (bandwidth, CPU, but also the PC that first needs to reassemble the frames to determine it's not addressed to the PC). To disable CDP on a particular interface, use the no cdp enable command, for example:

Switch1(config)#interface fa0/1
Switch1(config-if)#no cdp enable

Debug Command

You can use the show commands for CDP at a local device and neighboring devices to see whether CDP is working properly, but you can also use debug commands to see what's going on in detail. For CDP the debug command supports the following main three debugging options:

Switch1 #debug cdp ?
 adjacency         CDP neighbor info
 events              CDP events
 packets            CDP packet-related information                  

For example, the following command will log actions related to incoming and outgoing CDP packets:

Switch1#debug cdp packets
CDP packet info debugging is on

Debug information is output to the console by default, so for example, the next time this switch receives a CDP packet, the following notification should appear in the console window:

00:01:03: CDP-PA: Packet received from Switch on interfaceFa0/1
00:01:03: **Entry NOT found in cache**

If the neighbor was already known through a previous packet the second line would not include the ‘NOT'. Although you don't need to know the output by heart, I encourage you to enable CDP debugging entirely and watch the console for some time to become familiar with CDP's behavior. (You can use the commands no debug cdp or undebug cdp or undebug all to disable debugging again.)

For a shorter overview of CDP read our Cisco Discovery Protocol TechNotes.


Cisco CCNA Labs – Are you looking for additional Cisco Labs? We have Cisco CCNA Labs, Cisco CCNP Labs and Cisco Video Training that you will bring your Cisco routing & switching skills to the next level. Click Here for more Cisco Training!



Ciscokits.com – Experience the real thing, build your own lab. Free study labs and documents, command lists, router/switch procedures, lab suggestions, and more.


Discuss this Lab here
Back to the list of CCNA TechNotes & Labs
Author: Johan Hiemstra




 
 
 

All images and text are copyright protected, violations of these rights will be prosecuted to the full extent of the law.
2002-2015 TechExams.Net | Advertise | Disclaimer


IT Showcase