Discovering Neighbors on the Network
Most network devices, by definition, do not work in isolation. A Cisco device frequently has other Cisco devices as neighbors on the network, and being able to obtain information about those other devices is important to assist with network design decisions, troubleshooting, and completing equipment changes. The following sections describe how to gather information about the Cisco devices in a network and use that information to create a map of the network environment.
Cisco Discovery Protocol
The Cisco Discovery Protocol (CDP) is an information-gathering tool used by network administrators to obtain information about directly connected Cisco devices.
CDP is a proprietary tool that enables you to access a summary of protocol and address information about other Cisco devices that are directly connected to the Cisco device initiating the CDP commands.
CDP runs over the data link layer connecting the physical media to the upper-layer protocols (ULP). Because CDP operates at the data link layer, two or more Cisco network devices, such as routers that support different network layer protocols (for example, IP and Novell IPX), can learn about each other.
Physical media connecting CDP devices must support Subnetwork Access Protocol (SNAP) encapsulation. These can include all LANs, Frame Relay, other WANs, and ATM networks. This is illustrated by Figure 6-1.
Figure 6-1 CDP Runs at Layer 2
When a Cisco device boots, CDP starts by default, and automatically discovers neighboring Cisco devices running CDP, regardless of which protocol suite is running.
Information Obtained with CDP
Figure 6-2 displays an example of how CDP exchanges information with its directly connected neighbors. You can display the results of this information exchange on a console connected to a network device configured to run CDP on its interfaces.
Figure 6-2 CDP Works Between Neighbor Devices
CDP provides the following information about each neighboring device:
- Device identifiers: For example, the configured host name of the switch
- Address list: Up to one network layer address for each protocol supported
- Port identifier: The name of the local port and remote port, in the form of an ASCII character string such as ethernet0
- Capabilities list: Supported features; for example, the device acting as a source-route bridge and also as a router
- Platform: The hardware platform of the device; for example, Cisco 7200 series router
Notice that the upper router in Figure 6-2 is not connected directly to the console of the administrator. To obtain CDP information about this upper router from the console of the administrator, network staff could use Telnet to connect to a switch connected directly to this target device.
CDP version 2 is the most recent release of the protocol and provides more intelligent device-tracking features. These features include a reporting mechanism that allows more
rapid error tracking, thereby reducing costly downtime. Reported error messages can be sent to the console or to a logging server.
Implementation of Cisco Discovery Protocol
You can enable or disable CDP on a router as a whole (global) or on a port-by-port (interface) basis. You can view CDP information with the show cdp command. CDP has several keywords that enable access to different types of information and different levels of detail. It is designed and implemented as a very simple, low-overhead protocol. A CDP packet can be as small as 80 octets, mostly made up of the ASCII strings that represent information. Example 6-1 shows the different show cdp options.
Example 6-1 show cdp Options
RouterA# show cdp ? entry Information for specific neighbor entry interface CDP interface status and configuration neighbors CDP neighbor entries traffic CDP statistics
CDP functionality is enabled by default on all interfaces (except for Frame Relay multipoint subinterfaces), but can be disabled at the device level. However, some interfaces, such as ATM interfaces, do not support CDP. To prevent other CDP-capable devices from accessing information about a specific device, the no cdp run global configuration command is used. To disable CDP on an interface, the no cdp enable command is used. To enable CDP on an interface, the cdp enable interface configuration command is used.
Example 6-2 illustrates how to disable CDP globally and on a per-interface basis.
Example 6-2 Disabling CDP on an Interface
RouterA(config)# no cdp run ! Disable CDP Globally RouterA(config)#interface serial0/0/0 RouterA(config-if)#no cdp enable ! Disable CDP on just this interface
Using the show cdp neighbors Command
The show cdp neighbors command displays information about CDP neighbors.
Example 6-3 shows the CDP output for RouterA shown in Figure 6-3.
Figure 6-3 CDP Neighbor Information
Example 6-3 CDP Output for RouterA
RouterA# 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 SwitchA fa0/0 122 S I WS-C2960-fa0/2 RouterB s0/0/0 177 R S I 2811 s0/0/1
For each CDP neighbor, the following information is displayed:
- Device ID
- Local interface
- Holdtime value, in seconds
- Device capability code
- Hardware platform
- Remote port ID
The holdtime value indicates how long the receiving device should hold the CDP packet before discarding it. The format of the show cdp neighbors output varies between different types of devices, but the available information is generally consistent across devices.
The show cdp neighbors command can be used on a Cisco Catalyst switch to display the CDP updates received on the local interfaces. Note that on a switch, the local interface is referred to as the local port.
If you add the detail argument to the show cdp neighbors command, the resulting output includes additional information, such as the network layer addresses of neighboring devices. The output from the show cdp neighbors detail command is identical to that produced by the show cdp entry * command.
Monitoring and Maintaining Cisco Discovery Protocol
The show cdp entry, show cdp traffic, and show cdp interface commands display detailed CDP information. The show cdp entry command displays detailed information about neighboring devices. This output is shown in Example 6-4 for RouterA in Figure 6-3.
Example 6-4 Output of the show cdp entry Command
Device ID: RouterB Entry address(es): IP address: 10.1.1.2 Platform: Cisco 2811, Capabilities: Router Switch IGMP Interface: Serial0/0/0, Port ID (outgoing port): Serial0/0/1 Holdtime : 155 sec Version : Cisco IOS Software, 2800 Software (C2800NM-ADVIPSERVICESK9-M), Version 12.4(12), RELEASE SOFTWARE (fc1) Technical Support: http://www.cisco.com/techsupport Copyright (c) 1986-2006 by Cisco Systems, Inc. Compiled Fri 17-Nov-06 12:02 by prod_rel_team
To display information about a specific neighbor, the command string must include the IP address or device ID of the neighbor. The asterisk (*) is used to display information about all neighbors. The show cdp entry command outputs the following:
- Neighbor device ID
- Layer 3 protocol information (for example, IP addresses)
- Device platform
- Device capabilities
- Local interface type and outgoing remote port ID
- Holdtime value, in seconds
- Cisco IOS Software type and release
The output from this command includes all the Layer 3 addresses of the neighbor device interfaces (up to one Layer 3 address per protocol).
The show cdp traffic command displays information about interface traffic. It shows the number of CDP packets sent and received. Example 6-5 shows the output from the show cdp traffic command from RouterA in Figure 6-3.
Example 6-5 Output of the show cdp traffic Command
RouterA# show cdp traffic CDP counters : Total packets output: 8680, Input: 8678 Hdr syntax: 0, Chksum error: 0, Encaps failed: 5 No memory: 0, Invalid packet: 0, Fragmented: 0 CDP version 1 advertisements output: 0, Input: 0 CDP version 2 advertisements output: 8680, Input: 8678 RouterA# show cdp interface s0/0/0 Serial0/0/0 is up, line protocol is up Encapsulation PPP Sending CDP packets every 60 seconds Holdtime is 180 seconds
This output also displays the number of errors for the following error conditions:
- Syntax error
- Checksum error
- Failed encapsulations
- Out of memory
- Invalid packets
- Fragmented packets
- Number of CDP version 1 packets sent
- Number of CDP version 2 packets sent
The show cdp interface command displays the following interface status and configuration information about the local device:
- Line and data-link status of the interface
- Encapsulation type for the interface
- Frequency at which CDP packets are sent (default is 60 seconds)
- Holdtime value, in seconds (default is 180 seconds)
CDP is limited to gathering information about directly connected Cisco neighbors. Other tools, such as Telnet, are available for gathering information about remote devices that are not directly connected.
Creating a Network Map of the Environment
After all the devices on the internetwork have been discovered, it is important to document the network so that it can be readily supported. Topology documentation is used to validate design guidelines and to aid future design, change, and troubleshooting. Topology documentation should include both logical and physical documentation for the following components:
- Connectivity
- Addressing
- Media types
- Devices
- Rack layouts
- Card assignments
- Cable routing
- Cable identification
- Termination points
- Power information
- Circuit identification information
Figure 6-4 shows an example of the information that can be gathered using CDP.
Figure 6-4 Documentation Using CDP
Maintaining accurate network topology documentation is the key to successful configuration management. To create an environment where topology documentation maintenance can occur, the information must be available for updates. Cisco strongly recommends updating topology documentation whenever a network change occurs.