Situations can arise where the transmit or receive side of a physical cable breaks or interface transceivers malfunction; one side is sending but the other side isn’t receiving. This situation is more common in fiber optic cabling where either the transmit or receive plug is mispatched, dirty, or breaks leading to unidirectional communication.
Spanning Tree relies on constant and consistant reception of BPDU messages from neighbor switches. If a switch stops receiving BPDUs on a designated port, STP ages out the information for the port and transitions it into forwarding state. This will ultimately lead to a unidirectional loop condition.
Cisco Unidirectional Link Detection
Unidirectional Link Detection, or UDLD, is one of many loop-prevention mechanisms available on Cisco switches to detect and stop unidirectional link failures. UDLD is a Cisco proprietary layer 2 protocol that uses UDLD messages as a heartbeat mechanism between switches on the same segment.
UDLD messages contain the local switch’s identity,port pair IDs, and a list of all neighbor switch/port pairs on the same segment. Using that information, UDLD can detect an explicit unidirectional link event if any of the following are seen:
- Received UDLD messages do not exactly match the switch/port pair as those the switch is sending out. This could be due to something as simple as remote optical Tx and Rx connectors having been split up into different physical ports.
- Received UDLD neighbor messages contain the same switch/port pair as the local switch. This suggests a cable looped into the same switch.
- The local switch only knows of a single neighbor connected to the port, but the received UDLD messages contain more than one switch/port ID pair. This suggests a shared-media segment where the local switch cannot detect all neighbors on the link.
If any of the three conditions above present themselves, UDLD will err-disable the port – operationally shutting it down to contain the error condition.
UDLD Operational Modes
UDLD works by sending periodic UDLD messages, after which neighbors are expected to echo the packet back. If echo responses stop being received, it could mean a unidirectional link condition has occurred (as in the case of a cut Tx or Rx strand). This isn’t always the case however.Consider the scenario of two switches directly connected using powered media converters in between. In this case, if one of the switches is powered off, the other switch’s interface will still stay up (due to the inline powered converters), but UDLD messages will stop being received. This is not a unidirectional link failure situation (one switch is just off) but as you will soon see, how UDLD responds to message disruptions depends on its UDLD mode.
UDLD has two modes of operation available, normal mode and aggressive mode. If any of the explicit unidirectional link failure scenarios outlined in the bullets above exist, UDLD err-disables the port, regardless of mode. By placing the port in err-disables state, UDLD effectively disables the port – preventing a potential unidirectional loop scenario.
The difference between normal and aggressive modes is how they respond when UDLD messages suddenly stop being received.
UDLD Normal Mode
Under normal mode, if incoming UDLD messages stop being received the switch tries to reconnect with its neighbor 8 times. If it is unable to reconnect, UDLD takes no action other than logging a message to syslog. The port stays up.
UDLD Aggressive Mode
Under aggressive mode, if incoming UDLD messages stop being received the switch tries to reconnect with its neighbor 8 times. If it is unable to reconnect, UDLD err-disables the port. This operationally disables the port and assumes a unidirectional link failure has occurred.If aggressive mode err-disables the port if no response is received, then what happens when you first configure the link? I don’t know about you, but I often can’t configure two interfaces on two switches before UDLD in aggressive mode would timeout! UDLD accommodates for the first-time configuration by initially sending UDLD frames out the port, but not err-disabling the interface until it first hears an echo response from the remote switch. At that point if the switch stopped receiving UDLD echos, the port would be shut down.
UDLD can be applied globally using the udld enable
UDLD Global Configuration
Since UDLD requires an echo response from neighbor switches, UDLD must be enabled on both ends of a link to operate successfully. When UDLD is activated at the global level of a switch, it only applies to fiber ports by default. Using the enable option activates normal mode; using the aggressive option activates (you guessed it) aggressive mode.
UDLD Interface-Level Configuration
UDLD normal mode is enabled on an interface using the udld port command. Aggressive mode requires the aggressive keyword added. Unlike global mode, when UDLD is activated at the interface-level it enables UDLD on the port regardless of media type.
The show udld and show udld neighbors commands can be used to verify UDLD operation locally and between neighbors.