MessageEthernet

Summary

Represents an ethernet message object.

See also

Message

Methods
Properties
Events

Structure

class MessageEthernet
capture(filter: Filter = None) MessageEthernet

Matches any message with the same protocol.

Parameters

filter (Filter) – Filter to use to narrow down packets to capture

Returns

Listens to the bus until a message is received and returns this first message

Return type

MessageEthernet

capture(timeout: int32, filter: Filter = None) MessageEthernet

Waits for the first message having the same protocol that the sent message without verify the IP address and the port between send and respond message and return it. A timeout is specified to guarantee that the script can continue if no message is captured in a certain time interval.

Parameters
  • timeout (int32) – Max time in milliseconds to wait for the response.

  • filter (Filter) – Filter to use to narrow down packets to capture

Returns

First message captured from the bus or None in case no message is received.

Return type

MessageEthernet

capture_list(timeout: int32, filter: Filter = None) IReadOnlyList[MessageEthernet]

Waits for any response having the same protocol that the sent message without verify the IP address and the port between send and respond message and return them all as a list. A timeout is specified to guarantee that the script can continue if no message is received in a certain time interval.

Parameters
  • timeout (int32) – Max time in milliseconds to wait for the response.

  • filter (Filter) – Filter to use to narrow down packets to capture

Returns

List of messages captured from the bus during a given period of time.

Return type

IReadOnlyList[MessageEthernet]

close_writer()

Closes the file previously created with open_writer(file).

get_arp_layer() MessageARP

Extracts the ARP layer from the message.

Returns

ARP packet extracted. If no ARP layer found, None is returned.

Return type

MessageARP

get_bytes() Array[uint8]

Gets the content of the payload.

Returns

Array of bytes representing the payload of the message.

Return type

Array[uint8]

get_can_layer() MessageCAN

Extracts the CAN layer from the message.

Returns

CAN packet extracted. If no CAN layer found, None is returned.

Return type

MessageCAN

get_dhcp_layer() MessageDHCP

Extracts the DHCP layer from the message.

Returns

DHCP packet extracted. If no DHCP layer found, None is returned.

Return type

MessageDHCP

get_dlt_layer() MessageDlt

Extracts the DLT layer from the message, if present.

Returns

Encapsulated DLT packet including both header and data. If no DLT layer found, None is returned.

Return type

MessageDlt

get_ethernet_layer() MessageEthernet

Extracts the ethernet layer from the message, if present.

Returns

Encapsulated Ethernet Packet if the parent message is an Ethernet Gateway. If no Ethernet Layer is found, None is returned.

Return type

MessageEthernet

get_flexray_layer() MessageFlexray

Extracts the FlexRay layer from the message.

Returns

FlexRay packet extracted. If no FlexRay layer found, None is returned.

Return type

MessageFlexray

get_hex_bytes() str

Converts the payload of the message from decimal to hex and outputs it to a string of bytes.

Returns

Payload of message in hex bytes.

Return type

str

get_hsfz_layer() MessageHSFZ

Extracts the HSFZ layer from the message.

Returns

HSFZ packet extracted. If no HSFZ layer found, None is returned.

Return type

MessageHSFZ

get_icmp_layer() MessageICMPv4

Extracts the ICMP layer from the message.

Returns

ICMP packet extracted. If no ICMP layer found, None is returned.

Return type

MessageICMPv4

get_ieee1722_layer() MessageIEEE1722

Extracts the IEEE1722 layer from the message.

Returns

IEEE1722 packet extracted. If no IEEE1722 layer found, None is returned.

Return type

MessageIEEE1722

get_ipv4_layer() MessageIpv4

Extracts the IPv4 layer from the message, if present.

Returns

IPv4 packet, including both header and data. If no IPv4 layer found, None is returned.

Return type

MessageIpv4

get_ipv6_layer() MessageIPv6

Extracts the IPv6 layer from the message, if present.

Returns

IPv6 packet, including both header and data. If no IPv6 layer found, None is returned.

Return type

MessageIPv6

get_layer(type: PROTOCOL_TYPE) IMessageBase

Extracts a layer from the message given its type.

Parameters

type (PROTOCOL_TYPE) – Desired layer.

Returns

Packet extracted, if the layer is not found, None is returned.

Return type

IMessageBase

get_lin_layer() MessageLIN

Extracts the LIN layer from the message.

Returns

LIN packet extracted. If no LIN layer found, None is returned.

Return type

MessageLIN

get_nm_layer() MessageNM

Extracts the NM layer from the message, if present.

Returns

NM packet extracted. If no NM layer found, None is returned. NOTE: Due to its simplicity, it has no header or payload sections, so the whole message is treated as NM payload.

Return type

MessageNM

get_pdu_layer() MessagePDU

Extracts the PDU layer from the message, if present.

Returns

PDU packet, including both header and data. If no PDU layer found, None is returned.

Return type

MessagePDU

get_ptp_layer() MessagePTP

Extracts the PTP layer from the message.

Returns

PTP packet extracted. If no PTP layer found, None is returned.

Return type

MessagePTP

get_someip_layer() MessageSomeIP

Extracts the SOME/IP layer from the message, if present.

Returns

SOME/IP packet extracted. If no SOME/IP layer found, None is returned.

Return type

MessageSomeIP

get_someip_sd_layer() MessageSomeIPSD

Extracts the SOME/IP-SD layer from the message, if present.

Returns

Whole SOME/IP-SD packet extracted. If no SOME/IP-SD layer found, None is returned.

Return type

MessageSomeIPSD

get_tcp_layer() MessageTCP

Extracts the TCP layer from the message.

Returns

TCP packet extracted. If no TCP layer found, None is returned.

Return type

MessageTCP

get_tls_layer() MessageTls

Extracts the TLS layer from the message.

Returns

TLS packet extracted. If no TLS layer found, None is returned.

Return type

MessageTls

get_udp_layer() MessageUDP

Extracts the UDP layer from the message.

Returns

UDP packet extracted. If no UDP layer found, None is returned.

Return type

MessageUDP

has_layer(protocol: PROTOCOL_TYPE) bool

Checks if the message has a layer of the given protocol.

Parameters

protocol (PROTOCOL_TYPE) – Desired protocol layer. see Protocol type enum for a list of valid values.

Returns

True if the layer is present in the message. Otherwise, False.

Return type

bool

hex_view() str

Allows to visualize messages in hexadecimal format.

Returns

Hexadecimal representation of the whole message.

Return type

str

hex_view(nb_bytes_per_line: int32) str

Allows to visualize messages in hexadecimal format.

Parameters

nb_bytes_per_line (int32) – (optional) number of bytes per line.

Returns

Hexadecimal representation of the whole message.

Return type

str

open_writer(file: str, fileFormat: FILEFORMAT or None = None)

Creates a PCAP or PCAPNG file for writing the received messages. If the file already exists, it will be overwritten (old file data will be lost). Use the store() method to record received messages into the file.

Parameters
  • file (str) – Absolute path of the file where the messages will be stored

  • fileFormat (FILEFORMAT or None) – Obsolete, you don't need to specify this argument anymore

receive() MessageEthernet

Matches a response for the used message.

Returns

Listens to the bus until a message is received and returns this first message

Return type

MessageEthernet

receive(timeout: int32) MessageEthernet

Waits for the first response having the IP address destination equals to the IP address source of the sent message and return it. A timeout is specified to guarantee that the script can continue if no message is received in a certain time interval.

Parameters

timeout (int32) – Max time in milliseconds to wait for the response.

Returns

First message received from the bus or None in case no message is received.

Return type

MessageEthernet

receive_list(timeout: int32) IReadOnlyList[MessageEthernet]

Waits for any response having the IP address destination equals to the IP address source of sent message and return them all as a list. A timeout is specified to guarantee that the script can continue if no message is received in a certain time interval.

Parameters

timeout (int32) – Max time in milliseconds to wait for the response.

Returns

List of messages received from the bus during a given period of time.

Return type

IReadOnlyList[MessageEthernet]

send() bool

Sends the message (the one used to call the method) through the Ethernet bus.

Returns

Returns True if the message is sent successfully. Otherwise, an exception will be thrown.

Return type

bool

set_bytes(payload: Array[uint8])

Sets the content of the payload, byte per byte.

Parameters

payload (Array[uint8]) – Array of bytes to set.

start_capture(filter: Filter = None)

Used for online capture(capturing network traffic from an adapter). Used with callback function(on_message_received()) and stop_capture() method.

Parameters

filter (Filter) – Filter to use to narrow down packets to capture

start_capture(file: str, wait_eof: bool, filter: Filter = None)

Used for offline capture(reading packets from pcap or asc file). Used with callback function(on_message_received()) and stop_capture() method.

Parameters
  • file (str) – The trace file from where the messages will be read.

  • wait_eof (bool) – If True the function would block until all frames in the file are read. If False the function would read the frames in the background.

  • filter (Filter) – Filter to use to narrow down packets to capture

start_responding_machine()

With this function, it is possible to simulate an ECU. It captures packets and, for every received message, it calls is_request callback. If it returns True, then it calls the make_reply callback

stop_capture()

Stops capturing Ethernet messages, either directly from the bus or from a trace file (depending on the version used to start the capture).

stop_responding_machine()

Stops the responding machine activated with start_responding_machine.

store(file: str)

Writes the message into the trace file.

Parameters

file (str) – Path of the file where the messages will be stored.

store()

Writes the message into the trace file opened with open_writer(file).

tree_view() str

Gives the tree view of the message.

Returns

Tree view representation of the message.

Return type

str

@on_capture_start

The event is triggered when the capture of Ethernet messages is started. See start_capture .

@on_capture_stop

The event is triggered when the capture of Ethernet messages is stopped. See stop_capture .

@on_message_received(message: MessageEthernet)

Event is triggered every time a message is read from the Ethernet bus or a trace file. See start_capture.

Parameters

message (MessageEthernet) – The message object being handled.

capture_info

General information about the context in which the message was captured from. None if the message was not captured

Type

CaptureInfo

data_base

Takes the database object.

Type

Database

ether_type

This field contains the ethernet type of the frame.

Type

EtherType

frame_number

Number of the frame received, in the context of all the ethernet traffic captured.

Type

int64

mac_address_destination

The destination MAC address.

Type

str

mac_address_source

This field contains the mac address source.

Type

str

payload

Content, in bytes, of the payload of the message.

Type

Array[uint8]

timestamp

Timestamp of the message.

Type

decimal

vlan_tag

This field contains the vlan tag.

Type

HeaderVlan