Layer 2 Discovery Protocols Introduction
Layer 2 Discovery Protocols Introduction
R1 will periodically send frames to SW1, telling it information like R1‟s hostname,
device type, interface ID, and interface IP address. SW1 likewise will periodically
send frames to R1 telling R1 about SW1.
CDP (Cisco Discovery Protocol) introduction
CDP is enabled by default on Cisco devices, such as Cisco routers, Cisco
switches, Cisco firewalls, and Cisco IP phones.
CDP messages are periodically sent to multicast MAC address
0100.0CCC.CCCC.
CDP messages use a multicast MAC address but the messages are not
forwarded to other devices. When a device receives a CDP message, it
processes and then discards the message. It does not forward it to other
devices. Only directly connected neighbors can become CDP neighbors.
CDP messages are sent once every 60 seconds by default out of all interfaces
which are in an up state. These are the messages that contain information such
as host name and IP address. When a device receives the CDP messages from
a neighboring device, it adds an entry for the device in its CDP neighbor table.
If a neighbor is disconnected, there is a default CDP holdtime of 180 seconds.
If a message is not received from a neighbor for 180 seconds, the neighbor is
removed from the CDP neighbor table.
There are two versions of CDP, version 1 and version 2. Version 2 is used by
default. Version 2 provides some additional advanced features such as the
ability to identify native VLAN mismatches. CDP version 1 is very old so
you‟ll probably never need to use it.
Let‟s get right into the CLI to see exactly what information is shared by CDP.
CDP verification (show commands)
Here is our demo network. Two routers and two multilayer switches. We are not
using any Layer 3 functions on the switches.
Let‟s look at a few CDP show commands before looking at the CDP neighbor
table. We will look at three CDP show commands, SHOW CDP, SHOW CDP
TRAFFIC, and SHOW CDP INTERFACE.
SHOW CDP tells us the CDP timer, 60 seconds by default, the CDP holdtime, 180
seconds by default, and which version of CDP is being used.
The SHOW CDP TRAFFIC command tells us how many CDP packets, how many
CDP advertisements, the device has sent and received.
>In this case, R1 sent 105 CDP messages and received 112 CDP messages, and all
of those messages were CDP version 2 messages.
If you enter SHOW CDP INTERFACE you will get some basic information about
all interfaces. You can also specify a certain interface when entering the command.
>In the blue rectangle in the above CLI output, you can see the information for
G0/0. You can see the same CDP message timer and holdtime as above. Notice the
entry “Encapsulation ARPA”. ARPA is a type of Ethernet encapsulation. This type
of Ethernet is also known as Ethernet 2. Ethernet types are beyond the scope of the
CCNA.
>Note at the bottom of the above CLI output how many CDP enabled interfaces
are there, and how many interfaces are in an up state and a down state.
Now let‟s look at R1‟s CDP neighbor table.
Use the command SHOW CDP NEIGHBORS to view it.
>Device ID column lists the host name of each of R1‟s CDP neighbors. R1 has
received CDP messages from SW1 and R2.
>Local interface column gives the interface on the local device, R1. SW1 is
connected to R1‟s G0/0 interface, and R2 is connected to R1‟s G0/1 interface, as
shown in the network diagram (our demo network).
>Holdtime column: holdtime will reset to 180 each time R1 receives a CDP
message from the neighbor. With the default timers, the hold timer should count
down to 120, by this time, normally, R1 would receive a CDP message and reset
the timer to 180. This cycle repeats. If this timer reaches 0, the neighbor will be
removed from the CDP neighbor table.
>Capability column helps you identify what kind of device you are connected to.
SW1 has the letters R, S, and I. R is router. S is switch. I is IGMP. SW1 is listed as
both R and S because SW1 is a multilayer switch, so it has routing capabilities.
IGMP is related to multicast and is beyond the CCNA. R2 has two letters, R and B.
B is source route bridge. Source route bridge is beyond the scope of the CCNA.
>Platform column displays the model of the neighboring device. Cisco has various
models of routers, switches, firewalls, etc., and the model will be displayed here.
But nothing is showing because the CLI is a virtual device running in GNS3, with
its own limitations.
>Port ID column tells you the port ID on the neighboring device. So R1 is
connected to SW1‟s G0/0 interface and R2‟s G0/0 interface.
We can use SHOW CDP NEIGHBORS DETAIL to view more information for
each neighbor. Here‟s SW1‟s entry.
>The SHOW CDP NEIGHBORS DETAIL command lets you see the IOS version
running on the neighbor device. This information does not show up with the
regular SHOW CDP NEIGHBORS command.
>Because SW1 is a switch, you can also see VTP information here. VTP is a Cisco
proprietary protocol.
>You can also see the native VLAN of SW1‟s interface, currently it‟s the default
of 1.
>The duplex setting of SW1‟s interface is also displayed.
There is another command which lets you view this detailed information for a
single neighbor, SHOW CDP ENTRY, followed by the neighbor‟s host name, R2
in this case. The output here is exactly the same as in SHOW CDP NEIGHBORS
DETAIL, but it only shows the specified neighbor.
Let‟s check out some LLDP show commands, the LLDP equivalents of the ones
we used for CDP. Those commands are very similar to their CDP equivalents.
>First, SHOW LLDP gives the same information as SHOW CDP does for CDP. It
shows that LLDP is enabled, and displays each of the LLDP timers, currently at
the default settings of 30, 120, and 2 seconds.
>First up, the device ID, the host name, of each neighbor is displayed.
>Then the local interface. Just like in SHOW CDP NEIGHBORS, this is the
interface of the local device, R1 in this case.
>Then the hold time. This is a little different than in SHOW CDP NEIGHBORS.
In SHOW CDP NEIGHBORS, you could watch the timer count down from 180,
and then reset to 180 when a CDP message is received. However SHOW LLDP
NEIGHBORS just displays the holdtime that is configured on this device, 120
seconds.
>Then the capability column. Notice, there is no entry for SW1. You would
normally expect to see B for Bridge as an entry for SW1 (there is no SWITCH
capability code). But B is not displaying for SW1. This is likely because these
virtual devices are being run in GNS3 so it is not detecting that SW1 is an active
switch, but when we look at SHOW LLDP NEIGHBORS DETAIL, in the below
diagram, we will see this bridge code for SW1.
>Just like in SHOW CDP NEIGHBORS, the last column is the port ID, the
interface ID of the neighboring device. R1 is connected to SW1‟s G0/0 interface
and R2‟s G0/0 interface.
Here‟s SHOW LLDP NEIGHBORS DETAIL on R1. The output is too long. For
convenience, R2‟s entry is cut off a little at the bottom.
>Notice SW1‟s entry gives us additional information, such as the operating system
version running on SW1.
>We can also see the „time remaining‟ in the countdown to the default holdtime of
120 seconds.
>Notice, LLDP has two fields for the device‟s capabilities, shown when you use
SHOW LLDP NEIGHBORS DETAIL: System capabilities and enabled
capabilities.
If you look at system capabilities, you can see B and R. B is for bridge, meaning
switch. And R is for Router. This is what you would expect because SW1 is a
multilayer switch. It has the functions of both a router and a switch. However, in
this case the “enabled capabilities” field displays “not advertised”.
If we use the IP ROUTING command on SW1, SW1‟s router functionality will be
enabled and the “R” from “system capabilities” will show in “enabled
capabilities”. However, the reason B is not displayed next to enabled capabilities is
likely because SW1 is a virtual device running in GNS3 and it‟s not recognized as
an active switch.
*Like in CDP, there is a command you can use to view the exact same output as
SHOW LLDP NEIGHBORS DETAIL but for a single neighbor instead of all
neighbors. Use SHOW LLDP ENTRY, followed by the neighbor‟s host name.
Before using this command IP ROUTING was enabled on SW1, and now you can
see R is displayed next to enabled capabilities for SW1.
LLDP show commands summary
The LLDP show commands are the same as the CDP show commands, just replace
the word CDP with LLDP.
R#show lldp
→to display basic information about LLDP (timers, version)
R#show lldp traffic
→to display how many LLDP messages were sent and received
R#show lldp interface
→to display which interfaces have tx/rx enabled
R#show lldp neighbors
→to display basic information about LLDP neighbors
R#show lldp neighbors detail
→to list LLDP neighbors with more detailed information
R#show lldp entry host-name
→to display the same information as above for a specified neighbor
Command review (CDP and LLDP)
1. CDP (Cisco Discovery Protocol)
1.1. CDP verification (show commands)
R#show cdp
→to display basic information about CDP (timer, holdtime, CDP version)
R#show cdp traffic
→to display the number of CDP messages (advertisements) the device has sent and
received
R#show cdp interface
→to display basic information about the interfaces CDP is enabled on. You can
also specify a certain interface when entering the command
R#show cdp neighbors
→to display the CDP neighbor table
R#show cdp neighbors detail
→to view more information for each CDP neighbor – the IOS version running on
the neighbor device, VTP information, and the native VLAN and duplex setting of
the neighbor interface
R#show cdp entry host-name
→to display the same information as above for a specified neighbor
1.2. CDP configuration
R(config)#[no] cdp run
→to enable or disable CDP globally
CDP is globally enabled on Cisco devices by default. Each interface also has CDP
enabled by default.
R(config-if)#[no] cdp enable
→to enable/disable CDP on a specific interface
R(config)#cdp timer seconds
→to configure the CDP timer
R(config)#cdp holdtime seconds
→to configure the CDP holdtime
R(config)#[no] cdp advertise-v2
→to enable/disable CDPv2
2. LLDP (Link Layer Discovery Protocol)
2.1. LLDP configuration
LLDP configuration commands are similar to the CDP commands, the biggest
difference is the interface configuration.
LLDP is globally disabled by default, and it‟s also disabled on each interface by
default. To enable LLDP you need to enable it globally and then enable it on each
interface.
R(config)#lldp run
→to enable LLDP globally. To disable it, use NO in front of the command
In LLDP, you need to use two separate commands to enable the interface to send
and receive LLDP messages.
R(config-if)#lldp transmit
→to enable LLDP on specific interfaces in the transmit direction (tx)
R(config-if)#lldp receive
→to enable LLDP on specific interfaces in the receive direction (rx)
Now let‟s see how to configure each LLDP timer.
R(config)#lldp timer seconds
→to configure the LLDP timer
R(config)#lldp holdtime seconds
→to configure the LLDP holdtime
R(config)#lldp reinit seconds
→to configure the LLDP reinitialization timer
2.2. LLDP verification (show commands)
The LLDP show commands are the same as the CDP show commands, just replace
the word CDP with LLDP.
R#show lldp
→gives the same information as SHOW CDP does for CDP. It shows that LLDP is
enabled, and displays each of the LLDP timers
R#show lldp traffic
→to display statistics about how many LLDP frames were sent and received
R#show lldp interface
→to show whether TRANSMIT and RECEIVE are enabled or disabled on each
interface, as well as the current Tx and Rx state
R#show lldp neighbors
→to check the router‟s LLDP neighbor table
R#show lldp neighbors detail
→to list LLDP neighbors with more detailed information
R#show lldp entry host-name
→to display the same information as above for a specified neighbor