Cisco Discovery Protocol (CDP) and Link Layer Discovery Protocol (LLDP)
Understanding your network’s physical and logical topology is a core skill for any network engineer. Whether you’re troubleshooting, planning an expansion, or documenting an existing environment, you need accurate information about which devices are connected and how. Manually mapping a large network is time-consuming and easy to get wrong. That’s where Layer 2 discovery protocols like Cisco Discovery Protocol (CDP) and Link Layer Discovery Protocol (LLDP) help.
These protocols operate at Layer 2 of the TCP/IP or OSI model, so they work independently of IP addressing. Devices use them to advertise identity, capabilities, and connectivity details to directly connected neighbors.
Cisco Discovery Protocol (CDP)
Cisco Discovery Protocol (CDP) is a proprietary Layer 2 protocol developed by Cisco. Its main purpose is to discover basic information about directly connected Cisco devices, even if those devices are running different Network Layer (Layer 3) protocols. CDP lets you learn a lot about a Cisco network’s topology without logging into every device.
How CDP works
CDP-enabled devices periodically send multicast advertisements out of each active interface. Each advertisement includes information about the sending device. When a neighboring Cisco device receives a CDP advertisement, it processes the information and stores it in its local CDP table.
One key point: CDP messages are not forwarded beyond the directly connected link. The receiving device processes the message and then discards it. As a result, CDP only discovers immediate neighbors.
CDP frames use a specific multicast destination MAC address in the Ethernet header: 0100.0CCC.CCCC. This allows CDP-enabled devices on the segment to receive and process the advertisements.
Device parameters learned by CDP
CDP can report many details about neighboring Cisco devices, including:
- Device Identifier: Typically the hostname of the neighboring device.
- Address List: Network Layer (for example, IP) and Data Link Layer (for example, MAC) addresses configured on the neighboring device.
- Port Identifier: The interface on the remote device that connects to the local device.
- Capabilities List: The type of device (for example, Router, Switch, IP phone, Host).
- Platform: The device model and its operating system (OS) level.
CDP is commonly used for two purposes:
- Supporting device functions: For example, Cisco IP Phones learn the Voice VLAN from the switch they’re connected to through CDP. This allows the phones to tag the frames containing the VoIP packets they originate, send them to the switch, and receive tagged VoIP frames from the switch.
- Aiding Network Engineers: CDP helps you map topology, verify connections, and troubleshoot by showing detailed information about neighboring devices.
Verifying CDP neighbors and information
You view CDP information using show commands. These commands are consistent across Cisco routers and switches.
This command provides a concise summary of each directly connected CDP neighbor. The output typically includes:
- Device ID: The hostname of the neighboring device.
- Local Intrfce: The local interface on your device connected to the neighbor.
- Holdtme: The time (in seconds) remaining before the neighbor’s entry is removed from the CDP table if no further advertisements are received.
- Capability: A single-character code indicating the neighbor’s capabilities (for example, ‘R’ for Router, ‘S’ for Switch, ‘H’ for Host, ‘I’ for IGMP).
- Platform: The model number and OS level of the neighboring device.
- Port ID: The interface on the neighboring device connected to your local interface.
Consider the example in the image below:
Image
Image Title - SW1, connected to SW2 and R1
SW1 is connected to SW2 and R1. The show cdp neighbors command on SW1 reveals the following entries:
- SW2 connected via SW1’s GigabitEthernet1/0/1 to SW2’s GigabitEthernet1/0/48. SW2 is identified as a Switch (S) with a platform like C9300.
- R1 connected via SW1’s GigabitEthernet1/0/2 to R1’s GigabitEthernet0/0/0. R1 is identified as a Router ® with a platform like C8000.
Image
Image Title - show cdp neighbors output on SW1
This output is useful for topology mapping. By matching the local interface to the remote interface, you can draw the physical connections between devices.
For a more complete view, show cdp neighbors detail provides additional information for each neighbor, including:
- IP Address: The Layer 3 address(es) configured on the neighbor’s interface.
- Platform: A more detailed device model description (for example, cisco C9300-48P).
- Capabilities: A list of capabilities, often more explicit than the summary output.
- Version: The full Cisco IOS Software version, including release name, version number, and build date.
- VTP Management Domain: If applicable, the VLAN Trunking Protocol (VTP) domain name.
- Native VLAN: The native VLAN configured on the trunk link.
- Duplex: The duplex setting (full or half) of the link.
This detailed output helps you verify software versions, IP addressing, and other configuration details without logging into the neighboring device.
Several other show commands help you check CDP operation:
- show cdp: Displays global CDP information, including whether it’s enabled, the current update and holdtime timers, and whether CDPv2 advertisements are enabled.
- show cdp interface [slot/port number]: Shows CDP status for all interfaces or a specific interface, including whether CDP is enabled on that port and the current timers.
- show cdp traffic: Displays global statistics for CDP advertisements sent and received, including errors.
Configuring CDP and verifying operations
By default, CDP is typically enabled globally on Cisco devices and on all interfaces. You might disable it for security reasons, or re-enable it if it was previously turned off.
In Global Configuration Terminal mode:
-
To disable CDP globally:
-
To enable CDP globally:
Interface-specific CDP configuration:
-
To disable CDP on a specific interface:
-
To enable CDP on a specific interface:
CDP advertisements are sent every 60 seconds by default, and a neighbor’s entry is held for 180 seconds (holdtime) before being removed if no new advertisements arrive. You can adjust these timers in Global Configuration mode:
-
To change the update interval:
For example:
-
To change the holdtime:
For example: