Get Layer from PLP Packet

Getting a PLP packet

In order to get a PLP packet, either receive a PLP packet from a capture module or pcap file, or simply simulate one with Traffic Generator or Scripting Environment.

Note

PLP packet is defined by its Ethertype, it is sent with or without vlan tagging with an Ethertype of 0x2090

Getting layer from PLP packet

When decoding or receiving a PLP packet, getting the layer from that packet is done with the functions get_layer(Protocol_name) or the special functions to get that specific layer mentioned below.

Sample Script

received_msg = message_builder.create_ethernet_message("Receiver", "Receiver")
DATA = tuple(bytearray.fromhex('01 00 5e 00 00 00 00 50 c2 e4 30 00 20 90 00 40 \
0d b1 01 03 00 04 00 00 00 0f 00 00 00 03 80 00 \
00 00 c2 85 73 58 00 0b 00 01 2f 08 e2 \
57 fa dd ff ff ff fc fc'))
# Payload that contains a PLP packet encapsulating a LIN message.
received_msg.set_bytes(DATA)

received_msg.timestamp = 2
msg = received_msg.get_lin_layer()
# Getting the lin message encapsulated
print(msg)
decoded_msg = received_msg.get_layer(PROTOCOL_TYPE.LIN)
# Getting the lin message encapsulated
print(decoded_msg)
# Output of this script is the same message decoded twice
# LIN message (Unconditional Frame) :BUS: PLPBus:0x00000003( PLPBus:0x00000003 ) ID:0x0000002F Length:8 Data:{0xE2 0x57 0xFA 0xDD 0xFF 0xFF 0xFF 0xFC}

Note

Supported encapsulated messages are:

CAN / CAN FD / CAN FD raw
  • using msg.get_can_layer()

  • using msg.get_layer(PROTOCOL_TYPE.CAN)

LIN
  • using msg.get_lin_layer()

  • using msg.get_layer(PROTOCOL_TYPE.LIN)

ETHERNET
  • using msg.get_ethernet_layer()

  • using msg.get_layer(PROTOCOL_TYPE.ETHERNET_FRAME)

Important

When a PLP packet has a PLP type different than LoggingStream (0x03) or a MsgType different than the supported type or is malformed, get_layer will return None.
When trying to get a layer different than what the PLP packet is encapsulating, it will also return None (example, trying get_lin_layer on a packet encapsulating a can message).
Supported PLP message types:
  • CAN FD raw = 0x0001

  • CAN : 0x0002

  • CAN FD = 0x0003

  • LIN = 0x0004

  • ETHERNET = 0x0080