Contents

Introduction

Prerequisites

Requirements

Components Used

CDP Timer and CDP Hold Time

Topology

Logs on the Router

Logs on the Switch

Scenario 1: The Switch Sends a Tagged CDP Packet

Scenario 2: The Switch Sends an Untagged CDP Packet

Introduction

This document describes the behavior of Cisco Discovery Protocol (CDP) between a router and a switch that run Cisco IOS®.

CDP is Cisco proprietary Layer 2 protocol that is media and protocol independent, and runs on all Cisco-manufactured equipment. Cisco devices send CDP announcements to the multicast destination address 01-00-0c-cc-cc-cc out each connected network interface. These multicast packets are received by Cisco switches and other network devices that support CDP through their connected network interface.

Prerequisites

Requirements

There are no specific requirements for this document.

Components Used

This document is not restricted to specific software and hardware versions. This document applies to all Cisco routers and switches that run Cisco IOS.

The information in this document was created from the devices in a specific lab environment. All of the devices used in this document started with a cleared (default) configuration. If your network is live, make sure that you understand the potential impact of any command.

CDP Timer and CDP Hold Time

By default, CDP announcements are sent every 60 seconds on interfaces that support Subnetwork Access Protocol (SNAP) headers, which include Ethernet, Frame Relay, and ATM. The hold time specifies the lifetime of an entry in the table. That is, if no announcements are received from a device for a period in excess of the holdtime, the device information is discarded (default 180 seconds).

In order to change the default CDP timer (60 seconds) and CDP holdtime (180 seconds), enter the cdp timer and cdp holdtime Cisco IOS configuration commands respectively. The changes can be verified with the show cdp command, which shows the current devices' CDP setting.

Router#show cdp

Global CDP information:

Sending CDP packets every 60 seconds

Sending a holdtime value of 180 seconds

Sending CDPv2 advertisements is enabled

CDP, by default, is enabled on all interfaces. However, there is an option to disable CDP for the router as a whole or on a per interface basis.

Topology

Switch Configuration

Router Configuration

Switch#show run int fa1/0/23

Building configuration...

Current configuration : 267 bytes

!

interface FastEthernet1/0/23

switchport trunk encapsulation dot1q

switchport trunk native vlan 10

switchport mode trunk

power inline never

spanning-tree portfast

spanning-tree guard root

end

int vlan 10

ip address 10.111.51.3 255.255.255.224

int vlan 21

ip address 10.111.48.3 255.255.255.128

Router#show run int gi0/1

interface GigabitEthernet0/1

no ip address

no ip redirects

duplex auto

speed auto

media-type rj45

end

interface GigabitEthernet0/1.1

encapsulation dot1Q 1

shutdown

end

interface GigabitEthernet0/1.10

encapsulation dot1Q 10

ip address 10.111.51.1 255.255.255.224

end

interface GigabitEthernet0/1.21

encapsulation dot1Q 21

ip address 10.111.48.1 255.255.255.128

end

The interface on the router has dot1q subinterfaces gi0/0.1, gi0/0.10, and gi0/0.21 configured with VLAN 1, 10, and 21 respectively. The interface on the switch is a trunk link where all the VLANs are allowed.

Router#show ip int brief

Interface                  IP-Address      OK? Method Status             Protocol

GigabitEthernet0/0         10.106.68.151   YES DHCP   up                    up

GigabitEthernet0/1         unassigned      YES NVRAM  up                    up

GigabitEthernet0/1.1       unassigned      YES unset  administratively down down

GigabitEthernet0/1.10      10.111.51.1     YES manual up                    up

GigabitEthernet0/1.21      10.111.48.1     YES manual up                    up

The switch shows the router as a valid CDP neighbor as shown here:

Switch#show cdp neighbor

Capability Codes: R - Router, T - Trans Bridge, B - Source Route Bridge

S - Switch, H - Host, I - IGMP, r - Repeater, P - Phone,

D - Remote, C - CVTA, M - Two-port Mac Relay

Device ID        Local Intrfce     Holdtme    Capability  Platform  Port ID

Router           Fas 1/0/23        145             R S I  3845      Gig 0/1.10

The same command on the router does not reveal the directly connected switch.

Router#show cdp neighbor

Capability Codes: R - Router, T - Trans Bridge, B - Source Route Bridge

S - Switch, H - Host, I - IGMP, r - Repeater, P - Phone,

D - Remote, C - CVTA, M - Two-port Mac Relay

Device ID        Local Intrfce     Holdtme    Capability  Platform  Port ID

Run a debug for CDP in order to help determine the reason ( debug cdp { packets | adjacency | events } ).

Logs on the Router

This entry is found in the cache.

CDP-PA: version 2 packet sent out on GigabitEthernet0/1 --->the packet is sent out on gi0/1

Logs on the Switch

CDP-PA: version 2 packet sent out on FastEthernet1/0/23

CDP-EV: No space for insertion of civic location

CDP-EV: No space (1068) for insertion of location information.

CDP-PA: Packet received from Router on interface FastEthernet1/0/23

As per the previous logs, the router did not receive any CDP packets from the switch on any of the connected interfaces. The interface with dot1q encapsulation is administratively shut down. Thus, when the switch sends the CDP packet, the packet is discarded by the router.

Note: On the router, the subinterface with the lowest VLAN/dot1q encapsulation is selected as the preferred subinterface to carry the CDP packets. On the switch, the CDP traffic is always preferred on the lowest VLAN configured. That is, VLAN 1 always, which cannot be deleted from the VLAN database. The CDP protocol behaves differently when the switch sends CDP as a tagged packet or untagged packet dependent upon the native VLAN configured on the trunk link.

On the switch, the CDP traffic is always preferred on the lowest VLAN configured. That is, VLAN 1 always, which cannot be deleted from the VLAN database.

The CDP protocol behaves differently when the switch sends CDP as a tagged packet or untagged packet dependent upon the native VLAN configured on the trunk link.

Scenario 1: The Switch Sends a Tagged CDP Packet

Switch configuration:

interface FastEthernet1/0/1

switchport trunk encapsulation dot1q

switchport trunk native vlan 10

switchport mode trunk

end

Case 1: The Subinterface Which Has VLAN 1 Configured on the Router Is Up/Up

interface GigabitEthernet0/1.1

encapsulation dot1Q 1

end

interface GigabitEthernet0/1.10

encapsulation dot1Q 10

ip address 10.111.51.1 255.255.255.224

end

interface GigabitEthernet0/1.21

encapsulation dot1Q 21

ip address 10.111.48.1 255.255.255.128

end

GL.S.14-3800-8#show ip int brief

Interface                  IP-Address      OK? Method Status             Protocol

GigabitEthernet0/0         10.106.68.151   YES DHCP   up                    up

GigabitEthernet0/1         unassigned      YES NVRAM  up                    up

GigabitEthernet0/1.1       unassigned      YES unset  up                    up

GigabitEthernet0/1.10      10.111.51.1     YES manual up                    up

GigabitEthernet0/1.21      10.111.48.1     YES manual up                    up

The switch sends the CDP packet on VLAN 1 which will be received by the router as a tagged packet. The router checks to see if any of its subinterfaces are configured with VLAN1 dot1q encapsulation and is UP. If this check is successful then the CDP packet is processed by the router on GigabitEthernet 0/1.1.

The router will generate a CDP packet on the lowest numbered subinterface which is up/up and configured with VLAN1 dot1q encapsulation (or the lowest VLAN).

In this scenario, the router sends untagged CDP packets on gi0/1.1 which are received by the switch on FastEthernet1/0/23.

Logs on the Switch

CDP-PA: version 2 packet sent out on FastEthernet1/0/23. This entry is found in the cache.

CDP-PA: Packet received from Router on interface FastEthernet1/0/23

Logs on the Router

CDP-PA: version 2 packet sent out on GigabitEthernet0/1.1. CDP-PA: Packet received from Switch on interface GigabitEthernet0/1.1. This entry is found in the cache.

CDP-EV: Lookup for ip phone with idb= GigabitEthernet0/1.1

ip= 10.111.51.3 mac= 0021.567e.e219 platform= cisco WS-C3750-24P

Enter the show cdp neighbor command on the router.

Switch#show cdp neighbor

Capability Codes: R - Router, T - Trans Bridge, B - Source Route Bridge

S - Switch, H - Host, I - IGMP, r - Repeater, P - Phone,

D - Remote, C - CVTA, M - Two-port Mac Relay

Device ID        Local Intrfce     Holdtme    Capability  Platform  Port ID

Router          Fas 1/0/23        149             R S I  3845      Gig 0/1.1

Enter the show cdp neigh command on the router.

Router#show cdp neigh

Capability Codes: R - Router, T - Trans Bridge, B - Source Route Bridge>

S - Switch, H - Host, I - IGMP, r - Repeater, P - Phone,>

D - Remote, C - CVTA, M - Two-port Mac Relay>

Device ID        Local Intrfce     Holdtme    Capability  Platform  Port ID>

Switch          Gig 0/1.1          158             S I   WS-C3750- Fas 1/0/23

Case 2: Change the Configuration on the Router Interfaces so That You Do Not Have Any Subinterface with VLAN 1

!

interface GigabitEthernet0/1.1

end

!

Router#show ip interface brief

Interface                  IP-Address      OK? Method Status             Protocol

GigabitEthernet0/0         10.106.68.151   YES DHCP   up                    up

GigabitEthernet0/0.1       unassigned      YES unset  up                    up

GigabitEthernet0/1         unassigned      YES NVRAM  up                    up

GigabitEthernet0/1.1       unassigned      YES unset  up                    up

GigabitEthernet0/1.10      10.111.51.1     YES manual up                    up

GigabitEthernet0/1.21      10.111.48.1     YES manual up                    up

Analysis

The switch sends the CDP tagged packet on fa1/0/23. When the router receives the packet, it checks to see if a subinterface on the router is configured for encapsulation dot1q for VLAN 1. Currently there is no subinterface configured.

Thus the router receives the CDP packet on the main interface. The reason the router receives the packet on the main interface is because VLAN 1 is active. Enter the show vlan-switch command for confirmation. Even if the router does not have any interface configured for VLAN 1 the CDP packet is still received.

Router#show vlan-switch

VLAN Name                             Status    Ports

---- -------------------------------- --------- -------------------------------

1    default                          active

1002 fddi-default                     act/unsup

1003 token-ring-default               act/unsup

1004 fddinet-default                  act/unsup

1005 trnet-default                    act/unsup

VLAN Type  SAID       MTU   Parent RingNo BridgeNo Stp  BrdgMode Trans1 Trans2

---- ----- ---------- ----- ------ ------ -------- ---- -------- ------ ------

1    enet  100001     1500  -      -      -        -    -        1002   1003

1002 fddi  101002     1500  -      -      -        -    -        1      1003

1003 tr    101003     1500  1005   0      -        -    srb      1      1002

1004 fdnet 101004     1500  -      -      1        ibm  -        0      0

1005 trnet 101005     1500  -      -      1        ibm  -        0      0

In such scenarios the CDP packet from the router is sent through gi0/1.

Logs on the Switch

CDP-PA: version 2 packet sent out on FastEthernet1/0/23

CDP-PA: Packet received from Router on interface FastEthernet1/0/23

This entry is found in the cache.

CDP-PA: version 2 packet sent out on FastEthernet1/0/23

Logs on the Router

CDP-PA: version 2 packet sent out on GigabitEthernet0/1>

CDP-PA: Packet received from Switch on interface GigabitEthernet0/1

This entry is found in the cache.

CDP-EV: Lookup for ip phone with idb= GigabitEthernet0/1 ip= 10.111.51.3

mac= 0021.567e.e219 platform= cisco WS-C3750-24P

On the switch:

Switch#show cdp neighbor

Capability Codes: R - Router, T - Trans Bridge, B - Source Route Bridge

S - Switch, H - Host, I - IGMP, r - Repeater, P - Phone,

D - Remote, C - CVTA, M - Two-port Mac Relay

Device ID        Local Intrfce     Holdtme    Capability  Platform  Port ID

Router          Fas 1/0/23        123             R S I  3845      Gig 0/1

On the router:

Router#show cdp neighbor

Capability Codes: R - Router, T - Trans Bridge, B - Source Route Bridge

S - Switch, H - Host, I - IGMP, r - Repeater, P - Phone,

D - Remote, C - CVTA, M - Two-port Mac Relay

Device ID        Local Intrfce     Holdtme    Capability  Platform  Port ID

Switch          Gig 0/1            160             S I   WS-C3750- Fas 1/0/23

You see similar behavior when any interface is configured with the encapsulation VLAN as native.

Scenario 2: The Switch Sends an Untagged CDP Packet

Switch configuration:

interface FastEthernet1/0/1

switchport trunk encapsulation dot1q

switchport trunk native vlan 1

switchport mode trunk

end

Case 1: The Interface Where the VLAN 1 Is Configured Is Up/Up

interface GigabitEthernet0/1.1

encapsulation dot1Q 1

end

interface GigabitEthernet0/1.10

encapsulation dot1Q 10

ip address 10.111.51.1 255.255.255.224

end

interface GigabitEthernet0/1.21

encapsulation dot1Q 21

ip address 10.111.48.1 255.255.255.128

end

When the switch sends the CDP packet to the router, it sends an untagged packet as native VLAN is used for this communication. Thus the router receives the packet on the interface where VLAN 1 is configured. The router checks if it has dot1q encapsulation VLAN 1 configured and the interface is up/up. If this check is successful, the router sends the packet through that interface.

Switch#show cdp neighbor

Capability Codes: R - Router, T - Trans Bridge, B - Source Route Bridge

S - Switch, H - Host, I - IGMP, r - Repeater, P - Phone,

D - Remote, C - CVTA, M - Two-port Mac Relay

Device ID        Local Intrfce     Holdtme    Capability  Platform  Port ID

Router          Fas 1/0/23        5               R S I  3845      Gig 0/1.1

Router#show cdp neighbor

Capability Codes: R - Router, T - Trans Bridge, B - Source Route Bridge

S - Switch, H - Host, I - IGMP, r - Repeater, P - Phone,

D - Remote, C - CVTA, M - Two-port Mac Relay

Device ID        Local Intrfce     Holdtme    Capability  Platform  Port ID

Switch          Gig 0/1.1          8               S I   WS-C3750- Fas 1/0/23

Logs on the Router

CDP-PA: version 2 packet sent out on GigabitEthernet0/1.1

CDP-PA: Packet received from Switch on interface GigabitEthernet0/1.1

An entry is NOT found in the cache.

Logs on the Switch

CDP-AD: Aging entry for Router, on interface FastEthernet1/0/23

CDP-PA: Packet received from Router on interface FastEthernet1/0/23

An entry is NOT found in the cache.

CDP-PA: version 2 packet sent out on FastEthernet1/0/23

Case 2: The Interface on the Router Where the VLAN Is Configured Is Up/Up and Neither of the Interfaces Has a Native VLAN Specified

interface GigabitEthernet0/1.1

encapsulation dot1Q 1

end

interface GigabitEthernet0/1.10

encapsulation dot1Q 10 native

ip address 10.111.51.1 255.255.255.224

end

interface GigabitEthernet0/1.21

encapsulation dot1Q 21

ip address 10.111.48.1 255.255.255.128

end

Analysis

When the switch sends the CDP packet to the router, it sends the untagged packet as native VLAN is used for communication. The router receives the packet over gi0/1.1 as it has VLAN 1 configured on itself. The router checks whether it has VLAN 1 configured or any other native VLAN configured. In the current case, the interface gi0/1.10 is configured with the native keyword. Thus the router sends the packet through gi0/1.10 subinterface.

This output is seen in this scenario:

Switch#show cdp neighbor

Capability Codes: R - Router, T - Trans Bridge, B - Source Route Bridge

S - Switch, H - Host, I - IGMP, r - Repeater, P - Phone,

D - Remote, C - CVTA, M - Two-port Mac Relay

Device ID        Local Intrfce     Holdtme    Capability  Platform  Port ID

Router          Fas 1/0/23        5               R S I  3845      Gig 0/1.1

The CDP neighbor result on the router is shown here:

Router#show cdp neighbor

Capability Codes: R - Router, T - Trans Bridge, B - Source Route Bridge

S - Switch, H - Host, I - IGMP, r - Repeater, P - Phone,

D - Remote, C - CVTA, M - Two-port Mac Relay

Device ID        Local Intrfce     Holdtme    Capability  Platform  Port ID

Switch          Gig 0/1.10         7               S I   WS-C3750- Fas 1/0/23

Logs on the Router

CDP-PA: version 2 packet sent out on GigabitEthernet0/1.10

CDP-PA: Packet received from Switch on interface GigabitEthernet0/1.1

An entry is NOT found in the cache.

Logs on the Switch

CDP-AD: Aging entry for Router, on interface FastEthernet1/0/23

CDP-PA: Packet received from Router on interface FastEthernet1/0/23

An entry is NOT found in the cache.

CDP-PA: version 2 packet sent out on FastEthernet1/0/23

Case 3: There Is No Interface Where the VLAN 1 Is Configured, but Neither of the Interfaces Has a Native Keyword Configured

interface GigabitEthernet0/1.1

end

interface GigabitEthernet0/1.10

encapsulation dot1Q 10 native

ip address 10.111.51.1 255.255.255.224

end

interface GigabitEthernet0/1.21

encapsulation dot1Q 21

ip address 10.111.48.1 255.255.255.128

end

When the switch sends the packet to the router, it sends the untagged packet over native VLAN. The router receives the packet over gi0/1. The router checks whether it has VLAN 1 configured or any other native VLAN configured.

Here, the gi0/1.10 interface is configured for encapsulation as native, thus the router sends the packet through gi0/1.10.

Switch#show cdp neighbor

Capability Codes: R - Router, T - Trans Bridge, B - Source Route Bridge

S - Switch, H - Host, I - IGMP, r - Repeater, P - Phone,

D - Remote, C - CVTA, M - Two-port Mac Relay

Device ID        Local Intrfce     Holdtme    Capability  Platform  Port ID

Router          Fas 1/0/23        156             R S I  3845      Gig 0/1

Router#sh cdp neigh

Capability Codes: R - Router, T - Trans Bridge, B - Source Route Bridge

S - Switch, H - Host, I - IGMP, r - Repeater, P - Phone,

D - Remote, C - CVTA, M - Two-port Mac Relay

Device ID        Local Intrfce     Holdtme    Capability  Platform  Port ID

Switch          Gig 0/1.10         0               S I   WS-C3750- Fas 1/0/23

Logs on the Router

CDP-PA: version 2 packet sent out on GigabitEthernet0/1.10

CDP-PA: Packet received from Switch on interface GigabitEthernet0/1

An entry is NOT found in the cache.

Logs on the Switch

CDP-AD: Aging entry for Router, on interface FastEthernet1/0/23

CDP-PA: Packet received from Router on interface FastEthernet1/0/23

An entry is NOT found in the cache.

CDP-PA: version 2 packet sent out on FastEthernet1/0/23

Case 4: The Router Does Not Have a VLAN dot1q Encapsulation and Native VLAN Is Not Specified

interface GigabitEthernet0/1.1

end

interface GigabitEthernet0/1.10

encapsulation dot1Q 10

ip address 10.111.51.1 255.255.255.224

end

interface GigabitEthernet0/1.21

encapsulation dot1Q 21

ip address 10.111.48.1 255.255.255.128

end

When the switch sends the packet to the router, it sends the untagged CDP packet as the communication is over native VLAN. The router receives the packet over gi0/1. The router checks whether it has VLAN 1 configured or any other native VLAN configured. Here there is no interface as such, thus the router sends the packet through gi0/1 (over the main interface).

This output is seen in this scenario :

Switch#show cdp neighbor

Capability Codes: R - Router, T - Trans Bridge, B - Source Route Bridge

S - Switch, H - Host, I - IGMP, r - Repeater, P - Phone,

D - Remote, C - CVTA, M - Two-port Mac Relay

Device ID        Local Intrfce     Holdtme    Capability  Platform  Port ID

Router          Fas 1/0/23        7               R S I  3845      Gig 0/1

The output on the router is shown here:

Router#show cdp neighbor

Capability Codes: R - Router, T - Trans Bridge, B - Source Route Bridge

S - Switch, H - Host, I - IGMP, r - Repeater, P - Phone,

D - Remote, C - CVTA, M - Two-port Mac Relay

Device ID        Local Intrfce     Holdtme    Capability  Platform  Port ID

Switch          Gig 0/1           7               S I   WS-C3750- Fas 1/0/23

Logs on the Router

CDP-PA: version 2 packet sent out on GigabitEthernet0/1

CDP-PA: Packet received from Switch on interface GigabitEthernet0/1

An entry is NOT found in the cache.

Logs on the Switch

CDP-AD: Aging entry for Router, on interface FastEthernet1/0/23

CDP-PA: Packet received from Router on interface FastEthernet1/0/23

An entry is NOT found in the cache.

CDP-PA: version 2 packet sent out on FastEthernet1/0/23

Summary

The router receives a tagged CDP packet:

The subinterface configured with VLAN1 is administratively down/down.

The router discards the CDP packet. The switch would not be listed as a CDP neighbor.

The subinterface configured with VLAN1 is UP/UP. A Native VLAN is not specified.

The router sends and receives the packet on this subinterface.

The router does not have VLAN1 configured and any of the subinterfaces is configured with/without native keyword.

The packets traverse over the main interface. CDP works in both direction.

The router receives an untagged CDP packet:

The subinterface configured with VLAN1 is administratively down/down.

The router discards the CDP packet. The switch would not be listed as a CDP neighbor.

The subinterface configured with VLAN1 is UP/UP. A Native VLAN is not specified.

The router sends and receives the packets on this subinterface. CDP works in both directions.

The router does not have VLAN1 configured and none of the subinterfaces is configured with the native keyword.

The router receives the CDP packets on the main interface, but sends them over the subinterface where the native keyword is configured.

The router has neither VLAN1 nor native keyword configured.

The CDP packets traverse over the main interface. CDP works in both directions.