# LLDP

Link Layer Discovery Protocol(LLDP, IEEE 802.1AB) http://standards.ieee.org/getieee802/download/802.1AB-2009.pdf

basic TLV format:

    octets | 1          | 2             | 3 ...             n + 2 |
           --------------------------------------------------------
           | TLV type | TLV information | TLV information string  |
           | (7bits)  | string length   | (0-507 octets)          |
           |          | (9bits)         |                         |
           --------------------------------------------------------
    bits   |8        2|1|8             1|

Organizationally specific TLV format:

    octets | 1          | 2        | 3 ...  5 | 6       | 7 ...    n + 6 |
           ---------------------------------------------------------------
           | TLV type | Length     | OUI      | Subtype | Infomation     |
           | (7bits)  | (9bits)    | (24bits) | (8bits) | (0-507 octets) |
           ---------------------------------------------------------------
    bits   |8        2|1|8        1|

LLDPDU format:

    ------------------------------------------------------------------------
    | Chassis ID | Port ID | TTL | optional TLV | ... | optional TLV | End |
    ------------------------------------------------------------------------

Chasis ID, Port ID, TTL, End are mandatory optional TLV may be inserted in any order

class os_ken.lib.packet.lldp.ChassisID(buf=None, *args, **kwargs)

  Chassis ID TLV encoder/decoder class

  Attribute | Description
  --- | ---
  buf | Binary data to parse.
  subtype | Subtype.
  chassis_id | Chassis id corresponding to subtype.

class os_ken.lib.packet.lldp.End(buf=None, *args, **kwargs)

  End TLV encoder/decoder class

  Attribute | Description
  --- | ---
  buf | Binary data to parse.

class os_ken.lib.packet.lldp.ManagementAddress(buf=None, *args, **kwargs)

  Management Address TLV encoder/decoder class

  Attribute | Description
  --- | ---
  buf | Binary data to parse.
  addr_subtype | Address type.
  addr | Device address.
  intf_subtype | Interface type.
  intf_num | Interface number.
  oid | Object ID.

class os_ken.lib.packet.lldp.OrganizationallySpecific(buf=None, *args, **kwargs)

  Organizationally Specific TLV encoder/decoder class

  Attribute | Description
  --- | ---
  buf | Binary data to parse.
  oui | Organizationally unique ID.
  subtype | Organizationally defined subtype.
  info | Organizationally defined information string.

class os_ken.lib.packet.lldp.PortDescription(buf=None, *args, **kwargs)

  Port description TLV encoder/decoder class

  Attribute | Description
  --- | ---
  buf | Binary data to parse.
  port_description | Port description.

class os_ken.lib.packet.lldp.PortID(buf=None, *args, **kwargs)

  Port ID TLV encoder/decoder class

  Attribute | Description
  --- | ---
  buf | Binary data to parse.
  subtype | Subtype.
  port_id | Port ID corresponding to subtype.

class os_ken.lib.packet.lldp.SystemCapabilities(buf=None, *args, **kwargs)

  System Capabilities TLV encoder/decoder class

  Attribute | Description
  --- | ---
  buf | Binary data to parse.
  system_cap | System Capabilities.
  enabled_cap | Enabled Capabilities.

class os_ken.lib.packet.lldp.SystemDescription(buf=None, *args, **kwargs)

  System description TLV encoder/decoder class

  Attribute | Description
  --- | ---
  buf | Binary data to parse.
  system_description | System description.

class os_ken.lib.packet.lldp.SystemName(buf=None, *args, **kwargs)

  System name TLV encoder/decoder class

  Attribute | Description
  --- | ---
  buf | Binary data to parse.
  system_name | System name.

class os_ken.lib.packet.lldp.TTL(buf=None, *args, **kwargs)

  Time To Live TLV encoder/decoder class

  Attribute | Description
  --- | ---
  buf | Binary data to parse.
  ttl | Time To Live.

class os_ken.lib.packet.lldp.lldp(tlvs)

  LLDPDU encoder/decoder class.

  An instance has the following attributes at least.

  Attribute | Description
  --- | ---
  tlvs | List of TLV instance.

  classmethod parser(buf)

    Decode a protocol header.

    This method is used only when decoding a packet.

    Decode a protocol header at offset 0 in bytearray buf. Returns the following three objects.

    - An object to describe the decoded header.

    - A packet_base.PacketBase subclass appropriate for the rest of the packet. None when the rest of the packet should be considered as raw payload.

    - The rest of packet.

  serialize(payload, prev)

    Encode a protocol header.

    This method is used only when encoding a packet.

    Encode a protocol header. Returns a bytearray which contains the header.

    payload is the rest of the packet which will immediately follow this header.

    prev is a packet_base.PacketBase subclass for the outer protocol header. prev is None if the current header is the outer-most. For example, prev is ipv4 or ipv6 for tcp.serialize.

this page last updated: 2026-04-10 03:11:34

Except where otherwise noted, this document is licensed under Creative Commons Attribution 3.0 License. See all OpenStack Legal Documents.

found an error? report a bug