Concepts / Switches

Switches

LLDP

Also called Link Layer Discovery Protocol, 802.1AB, LLDP-MED, neighbour discovery, neighbor table, voice VLAN

Devices announcing their name, port and addresses to whoever is at the other end of each cable.

The problem

Nothing on a cable says what is plugged into its other end.

  1. Every few seconds (30 by default) officeSwitch sends an LLDP frame, type 0x88cc, out of each port.
  2. It holds TLVs, small labelled fields: the switch's name, the port's name, its management address, a time to live.
  3. The laptop keeps what it hears in a neighbour table, for as long as the time to live says, and announces itself back.
  4. The switch never passes LLDP on: the printer never hears the laptop's announcements. Each one reaches only the next device.
One hop only
One hop only

Each announcement stops at the next device, which keeps it and never passes it on: you learn your direct neighbours only.

What you'd see

$ lldpcli show neighbors
Interface:    eth0, via: LLDP, RID: 1, Time: 0 day, 00:00:12
  Chassis:
    ChassisID:    mac e6:ea:e6:9b:2b:4d
    SysName:      officeSwitch
    SysDescr:     Access switch, floor 2 closet
    MgmtIP:       10.0.1.13
    Capability:   Bridge, on
  Port:
    PortID:       mac e6:ea:e6:9b:2b:4d
    PortDescr:    laptop
    TTL:          20
  • Run on the laptop. Interface: eth0, via: LLDP: heard on its card.
  • SysName: officeSwitch, MgmtIP: 10.0.1.13: who is at the other end, and where to log in to it.
  • PortDescr: laptop: the switch port its cable ends in.
  • TTL: 20: forget this after 20 seconds without a new announcement (announcements every 5 s here).

Guess first

The laptop's cable is moved from officeSwitch to another switch. How long can its table still name officeSwitch?

Show answer

Up to the TTL, 20 seconds here (120 with default timers), unless the new switch's announcement replaces it first.

In short

Every few seconds (30 by default) each device sends an Ethernet frame of type 0x88cc to a multicast address that switches keep to themselves, holding TLVs: chassis ID, port ID, time to live, then name, description, capabilities and management address. Neighbours keep it in a table for its TTL; it never crosses a second hop. LLDP-MED adds endpoint TLVs, among them the voice VLAN, priority and DSCP a phone should use. The same details are free reconnaissance for anyone on an access port, so announcements are turned off where they serve nothing.

See it on real machines

Read next

Learn it on real machines.

Every lab is a small network of real Linux machines in your browser. Sign in with Google or email to start.

Start this lab