How CDP works in Cisco Devices Packet Tracer Topology
CDP- Cisco Discovery Protocol
CDP is a Cisco proprietary protocol used by network administrators to discover directly connected cisco devices like Routers, Switches and other devices.
CDP runs on data link layer and physical media must support SNAP(Sub Network Access Protocol),Frame relay, ATM,Ethernet,Token Ring all supports SNAP.
CDP discovers neighbor devices regardless of protocol running in neighbor devices.
It gives summary of directly connected devices only.
CDP runs on routers with Cisco IOS software releases 10.3 or later releases and Cisco switches.
CDP exchanges hardware and software device information with its neighbors.We can get information like,
Device ID
Device Capabilities
Port ID
IP address
Local Interface
Software version
Now, create a topology like this in a packet tracer and we are going to see how CDP(Cisco Discovery Protocol) learns the neighbor device detail.
In above topology Router R1 connected to Switch 0 and Router R2, Interface Fastethernet2/0 of R1 is connecting Switch0 and Interface Serial2/0 of R1 is connecting Router R2.
Ip address Configuration for Router R1 and Router R2 given below, configure devices with this IP address to appropriate interfaces.
After we configured the IP address, we are going to see how CDP learns the directly connected device information.
Below image shows CDP Frames forwarded from Switch to Router R1
Here,Cisco Discovery Protocol constructs a Frame and the Swich encapsulates the Protocol Data Unit into a ethernet frame.Switch always uses the 0100.0CCC.CCCC as destination MAC address.Physical layer must support SNAP, It was created because all protocols does not work well for 802.3 ethernet frame as 802.3 had no type filed replaced with length field.So, Sub Network Access Protocol(SNAP) is used at layer 2 to bring type field.Frame Relay,Ethernet,ATM,Token Ring all supports SNAP.
CDP frames Sent out to access port FastEthernet 0/24 with source MAC addres 000C.CF95.0E18and Destination MAC address 0100.0CCC.CCCC.
CDP frames received by R1 through the interface Fastethernet 0/0 that was sent from switch.Received frame MAC address matches the with multicast address 0100.0CCC.CCCC then the router decapsulates the PDU from the ethernet frame.
After getting the CDP frame, CDP process received frame and it will get,Neighbor Device ID,Port ID, Neighbor Capabilities,Device Software Version, Platform,etc...If the neighbor is already present in the CDP table,then the CDP resets the hold timer.All devices will do the same.
Now, we are going to check CDP details in this topology devices,
In Router R1 Privileged mode,give this command,
R1#show CDP neighbors detail
Capability Codes: R - Router, T - Trans Bridge, B - Source Route Bridge
S - Switch, H - Host, I - IGMP, r - Repeater, P - Phone
Device ID Local Intrfce Holdtme Capability Platform Port ID
Switch Fas 0/0 175 S 2950 Fas 0/24
R2 Ser 2/0 166 R PT1000 Ser 3/0
R1#
Above screenshot shows the information about the directly connected neighbor devices,
Device ID- 'Switch' and 'R2' is the hostname of the neighbor device.
Local Interface- This interafce in which this device Router R1 received the information of neighbor device.Here, 'Serial2/0' and 'Fastethernet0/0' is the interface that received CDP packets from the neighbor device.This two interface belongs to this device.
Holdtime- 179(set to180) is the time the router will keep this neighbor device information before dropping it from the memory.CDP packets will be updated every 60 seconds,if CDP packet not received for the maximum interval of Holdtime then device will drop stored information about neighbor.
Capability- Type of service it is capable of doing.Here 'S' means Switching, 'R' means Routing.
Platform- Hardware platform of the directly equipment.Here '2950'is the switching platform and 'PT1000' is routing platform.
Port ID- Port that sent the CDP packets from neighboring device.Here 'Fastethernet0/24' is the port of neighbor device.
Result for Switch and Router R2 given below,
Other show command that gives information is "show cdp entry *".In this command we can get some more information that CDP neighbor command.If we need to find out IP address of neighbor device,Platform,Software Version,etc... this command will be helpful.
R1#show cdp entry ?
* all CDP neighbor entries
WORD Name of CDP neighbor entry
In Router R1,Privileged mode give 'show cdp entry *' command to get all directly connected device information.
Switch and Router R2 CDP entry image below,
Another CDP show command,
R1#show cdp interface serial2/0
Serial2/0 is up, line protocol is up
Sending CDP packets every 60 seconds
Holdtime is 180 seconds
Above command gives the time interval CDP sends CDP Frames and Hold timer.
Important Commands in CDP
To run CDP on all interfaces in cisco devices, we have to give this command in global configuration mode,
R1(config)#cdp run
This command is to Stop CDP on all interface
R1(config)#no cdp run
To run CDP on particular interfaces,give this command in specific interface mode,
R1(config)#interface serial2/0
R1(config-if)#cdp enable
To stop in particular interface,
R1(config)#interface serial2/0
R1(config-if)#no cdp enable
R1(config)#cdp timer 60 '60' seconds is the time interval the CDP packets will be updated.
R1(config)#cdp holdtime 180 '180' seconds holdtime interval.How long the neighbor information will be kept in the local CDP table
CDP is media and protocol independent, it runs on all cisco devices.By using CDP network management applications can get the device type and SNMP agent address of neighbor devices.This enables applications to send SNMP queries to neighbor devices.CDP runs on data link layer so devices that supports different network layer protocols can learn each other.Cisco devices always keep the new received information and it discards the old information.
.........