MessageARP
Summary
Represents an ARP Message object.
- Methods
- Properties
- Events
Structure
- class MessageARP
- capture(filter: Filter = None) MessageARP
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
- capture(timeout: int32, filter: Filter = None) MessageARP
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
- Returns
First message captured from the bus or
None
in case no message is received.- Return type
- capture_list(timeout: int32, filter: Filter = None) IReadOnlyList[MessageARP]
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
- Returns
List of messages captured from the bus during a given period of time.
- Return type
- close_writer()
Closes the file previously created with
open_writer(file)
.
- 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
- hex_view() str
Allows to visualize messages in hexadecimal format.
- Returns
Hexadecimal representation of the whole message.
- Return type
- 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 storedfileFormat (
FILEFORMAT
or None) – Obsolete, you don't need to specify this argument anymore
- ping(target_ip: str) IMessageBase
Creates an ARP ping message to discover the target MAC address, sends it and waits for a response.
- Parameters
target_ip (
str
) – IP address of the target device.- Returns
ARP message got as a response to the ping sent, if there is any.
- Return type
- ping(target_ip: str, timeout: int32) IMessageBase
Creates an ARP ping message to discover the target MAC address, sends it and waits for a response. A timeout is specified to guarantee that the script can continue if no message is captured in a certain time interval.
- Parameters
- Returns
ARP message got as a response to the ping sent, if there is any.
- Return type
- receive() MessageARP
Matches a response for the used message.
- Returns
Listens to the bus until a message is received and returns this first message
- Return type
- receive(timeout: int32) MessageARP
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
- receive_list(timeout: int32) IReadOnlyList[MessageARP]
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
- 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
- send_receive(timeout: int32 = 1000) MessageARP
Sends the message (the one used to call the method) through the Ethernet bus and waits for a possible response, i.e. a message from the target address to our own address. It is possible to specify a timeout to guarantee that the script can continue if no response is detected in a certain time interval.
- Parameters
timeout (
int32
) – (optional) Max time in milliseconds to wait for the response. Default1
second- Returns
First message detected from the destination address to our address. This can be the response to the message sent but it is not
100%
guaranteed; additional traffic can be captured before this expected response and thus returned.- Return type
- send_receive_list(timeout: int32) IReadOnlyList[MessageARP]
Sends the message through the Ethernet bus, listens for a while and returns a list with all the messages captured in that period. It is possible to specify a timeout to guarantee that the script can continue if no response is detected in a certain time interval.
- Parameters
timeout (
int32
) – Max time in milliseconds to wait for the response.- Returns
List of messages detected from the destination address to our address. This can be the response to the message sent but it is not
100%
guaranteed; additional traffic can be captured before this expected response and thus returned.- Return type
- set_all_bytes(all_packet: Array[uint8]) bool
Sets the content of the whole message from Ethernet layer, byte per byte.
- start_arp_responder()
Starts a process in charge of filtering the ARP request messages sent to the tester address and generates the corresponding responses. It answers using the same criteria for the VLAN tags as the request: if the request was sent with VLAN, it uses VLAN in the response; if not, no VLAN tags are used.
- start_arp_responder(timeout_milliseconds: int32)
Starts a process in charge of filtering the ARP request messages sent to the tester address and generates the corresponding responses. It answers using the same criteria for the VLAN tags as the request: if the request was sent with VLAN, it uses VLAN in the response; if not, no VLAN tags are used.
- Parameters
timeout_milliseconds (
int32
) – (optional) Max time in milliseconds to keep the ARP responder working.
- 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.
- 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_arp_responder()
Stops the responding machine activated with start_responding_machine.
- 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
- @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: MessageARP)
Event is triggered every time a message is read from the Ethernet bus or a trace file. See start_capture.
- Parameters
message (
MessageARP
) – 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
- ethernet_header
Object containing all the information from the Ethernet header like the source and destination MAC addresses of the message.
- Type
- frame_number
Number of the frame received, in the context of all the ethernet traffic captured.
- Type
- hardware_size
This field corresponds to the length of the physical address. The length should be taken into bytes.
- Type
- hardware_type
Indicates the format of the ARP header.
- Type
- operation
The operation performed by the sender. See Operation enum for a list of valid values.
- Type
- protocol_size
This field corresponds to the length of the network address. The length should be taken into bytes
- Type
- protocol_type
The protocol type of the message.
- Type
- vlan_tag
Object containing all VLAN info.
- Type