LLC

Logical Link Control(LLC, IEEE 802.2) parser/serializer http://standards.ieee.org/getieee802/download/802.2-1998.pdf

LLC format:

+-----------------+--------------+
| DSAP address    | 8 bits       |
+-----------------+--------------+
| SSAP address    | 8 bits       |
+-----------------+--------------+
| Control         | 8 or 16 bits |
+-----------------+--------------+

DSAP address field:

  LSB
+-----+---+---+---+---+---+---+---+
| I/G | D | D | D | D | D | D | D |
+-----+---+---+---+---+---+---+---+
 I/G bit = 0 : Individual DSAP
 I/G bit = 1 : Group DSA
 D : DSAP address

SSAP address field:

  LSB
+-----+---+---+---+---+---+---+---+
| C/R | S | S | S | S | S | S | S |
+-----+---+---+---+---+---+---+---+
 C/R bit = 0 : Command
 C/R bit = 1 : Response
 S : SSAP address

Control field:

Information transfer command/response (I-format PDU):

  1   2   3   4   5   6   7   8    9   10-16
+---+---+---+---+---+---+---+---+-----+------+
| 0 |           N(S)            | P/F | N(R) |
+---+---+---+---+---+---+---+---+-----+------+

Supervisory commands/responses (S-format PDUs):

  1   2   3   4   5   6   7   8    9   10-16
+---+---+---+---+---+---+---+---+-----+------+
| 1   0 | S   S | 0   0   0   0 | P/F | N(R) |
+---+---+---+---+---+---+---+---+-----+------+

Unnumbered commands/responses (U-format PDUs):

  1   2   3    4    5    6   7    8
+---+---+----+---+-----+---+----+---+
| 1   1 | M1  M1 | P/F | M2  M2  M2 |
+---+---+----+---+-----+---+----+---+

N(S) : sender send sequence number (Bit 2=lower-order-bit)
N(R) : sender receive sequence number (Bit 10=lower-order-bit)
S    : supervisory function bit
M1/M2: modifier function bit
P/F  : poll bit - command LLC PDUs
       final bit - response LLC PDUs
class os_ken.lib.packet.llc.ControlFormatI(send_sequence_number=0, pf_bit=0, receive_sequence_number=0)

LLC sub encoder/decoder class for control I-format field.

An instance has the following attributes at least. Most of them are same to the on-wire counterparts but in host byte order. __init__ takes the corresponding args in this order.

Attribute

Description

send_sequence_number

sender send sequence number

pf_bit

poll/final bit

receive_sequence_number

sender receive sequence number

class os_ken.lib.packet.llc.ControlFormatS(supervisory_function=0, pf_bit=0, receive_sequence_number=0)

LLC sub encoder/decoder class for control S-format field.

An instance has the following attributes at least. Most of them are same to the on-wire counterparts but in host byte order. __init__ takes the corresponding args in this order.

Attribute

Description

supervisory_function

supervisory function bit

pf_bit

poll/final bit

receive_sequence_number

sender receive sequence number

class os_ken.lib.packet.llc.ControlFormatU(modifier_function1=0, pf_bit=0, modifier_function2=0)

LLC sub encoder/decoder class for control U-format field.

An instance has the following attributes at least. Most of them are same to the on-wire counterparts but in host byte order. __init__ takes the corresponding args in this order.

Attribute

Description

modifier_function1

modifier function bit

pf_bit

poll/final bit

modifier_function2

modifier function bit

class os_ken.lib.packet.llc.llc(dsap_addr, ssap_addr, control)

LLC(IEEE 802.2) header encoder/decoder class.

An instance has the following attributes at least. Most of them are same to the on-wire counterparts but in host byte order. __init__ takes the corresponding args in this order.

Attribute

Description

dsap_addr

Destination service access point address field includes I/G bit at least significant bit.

ssap_addr

Source service access point address field includes C/R bit at least significant bit.

control

Control field [16 bits for formats that include sequence numbering, and 8 bits for formats that do not]. Either os_ken.lib.packet.llc.ControlFormatI or os_ken.lib.packet.llc.ControlFormatS or os_ken.lib.packet.llc.ControlFormatU object.

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.