The Cisco Definition

Unidirectional Link Detection or UDLD is a Layer 2 protocol that works with the Layer 1 mechanisms to determine the physical status of a link. At Layer 1, auto-negotiation takes care of physical signaling and fault detection. UDLD performs tasks that auto-negotiation cannot perform, such as detecting the identities of neighbors and shutting down disconnected ports. When you enable both auto-negotiation and UDLD, Layer 1 and Layer 2 detection work together to prevent physical and logical unidirectional connections and the malfunctioning of other protocols.

UDLD works by exchanging protocol packets between neighboring devices. In order for this to work, both devices on the link must support UDLD and have it enabled on their respective ports. Each switch port configured for UDLD sends protocol packets that contain the port’s own device / port ID, and the neighbor’s device / port ID seen by UDLD on that port. Neighboring ports should see their own device / port ID ( echo ) in the packets received from the other side.

The above diagram depicts a couple of scenarios where UDLD might be used. The first depicts a long distance single mode fiber run between two separate physical locations, and the other much simpler, and sorter multi-mode fiber run between to Switches in the same physical location. Both are prefect scenarios for UDLD, and as a best practice should probably always be used. Another aspect to consider is the use of UDLD with regards to Etherchannel bundles over fiber optics. Personally that’s were I think UDLD really plays a major role. Consider a fiber Etherchannel with 4 member in the bundle, and losing one of the RX or TX optics.     

Operational Modes

Normal

In normal mode, if the link state of the port was determined to be bi-directional and the UDLD information times out no action is taken by UDLD, and the port state is marked as undetermined. The port or ports will continue to behave according to their respective STP state.

Aggressive

In aggressive mode, if the link state of the port is determined to be bi-directional and the UDLD information times out while the link on the port is still up, UDLD tries to re-establish the state of the port. If not successful, the port is put into an errdisable state.

Layer 2 Discovery

Switches participating in the exchange of Layer 2 UDLD frames will discover one another based on a well know Cisco proprietary MAC address of 01:00:0C:CC:CC:CC. Within this exchange each Switch will include it’s own ID or Device ID along with the originating port number. This exchange of frames between the Switches is often referred to as echoing.

When configuring UDLD on a switch it can be enabled globally or directly on the interface. I’m going to configure it directly on the fiber interface between switches SW1, and SW2 in aggressive mode which is actually the preferred or recommended mode to use when configuring Unidirectional Link Detection.

SW1#configure terminal
SW1(config)#interface GigabitEthernet 0/49
SW1(config-if)#switchport mode trunk
SW1(config-if)#switchport nonegotiation
SW1(config-if)#udld port aggressive
SW1(config-if)#end
SW1#

Now lets jump over to switch SW2 and configure the same respective fiber port. 

SW2#configure terminal
SW2(config)#interface GigabitEthernet 0/49
SW2(config-if)#switchport mode trunk
SW2(config-if)#switchport nonegotiatate
SW2(config-if)#udld port aggressive
SW2(config-if)#end
SW2#

Now that we have UDLD configured on the fiber links between SW1, and SW2 lets jump back over to switch SW1 and take a look at the current port status between the two switches. Notice that the operational status of the port is aggressive, and the current state is bidirectional.

SW1#show udld Gi0/49

Interface Gi0/49
----------------------------------------------------------------------------------------
Port enable administrative configuration setting: Enabled / in aggressive mode
Port enable operational state: Enabled / in aggressive mode
Current bidirectional state: Bidirectional
Current operational state: Advertisement - Single neighbor detected
Message interval: 7
Time out interval: 5
 
  Entry 1
  ----------------------
  Expiration time: 43
  Device ID: 1
  Current neighbor state: Bidirectional
  Device name: FOC1721Z3NH 
  Port ID: Gi0/49 
  Neighbor echo 1 device: FOC1653X039
  Neighbor echo 1 port: Gi0/49

  Message interval: 12
  Time out interval: 5
  CDP Device name: S2

If a port was placed into an errdisable state due to a some unforeseen Layer 1 issue with either the TX or RX pair we have a couple of option to bring the error disabled port back into service.

Option # 1

SW2#configure terminal
SW2(config)#interface GigabitEthernet 0/49
SW2(config-if)#shutdown
SW2(config-if)#no shutdown
SW2(config-if)#end
SW2#

Option # 2

SW2#configure terminal
SW2(config)#interface GigabitEthernet 0/49
SW2(config-if)#udld reset
SW2(config-if)#end
SW2#

Millage may vary with the reset command depending on the IOS version your running. 

I hope you found this post on UDLD helpful and informative. Be sure to let me know what you think by leaving suggestions, and feedback in the comments section below. You can find out more about these and other articles be checking out recent posts and archives. To learn more about me be sure to check out the About page. And as always thanks again for visiting The Packet.