MessageTFTP
Summary
Represents a TFTP (Trivial File Transfer Protocol) message object.
- Methods
- Properties
- Events
Structure
- class MessageTFTP
- capture(filter: Filter = None) MessageTFTP
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) MessageTFTP
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[MessageTFTP]
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)
.
- do_ack(block: uint16)
Sends an acknowledgment packet to inform the other side that the last packet(s) has (have) been correctly received.
- Parameters
block (
uint16
) – The packet's content.
- do_error(error: str, errcode: ErrorCodes)
Sends an error packet to inform the other side that the last packet(s) has (have) been lost.
- Parameters
error (
str
) – Error name.errcode (
ErrorCodes
) – Error code.
- do_write_data(files_bytes: object)
Writes the data included in the file specified as parameter.
- Parameters
files_bytes (
object
) – Writes the data included in the file specified as parameter.
- do_write_request(file_names: str, is_octet_mode: bool)
Sends a request to write a particular file to the other side .
- get_file_bytes(path: str) Array[uint8]
Gets the bytes included in the file specified as parameter.
- 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
- is_segmented() bool
Checks if the message is segmented.
- Returns
True
if the message is segmented.False
if not- 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
- receive() MessageTFTP
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) MessageTFTP
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[MessageTFTP]
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
- set_all_bytes(all_packet: Array[uint8]) bool
Sets the content of the whole message from Ethernet layer, byte per byte.
- 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_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
- write_bytes_to_file(path: str, b: object) bool
Writes the received bytes in the file specified as parameter.
- @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: MessageTFTP)
Event is triggered every time a message is read from the Ethernet bus or a trace file. See start_capture.
- Parameters
message (
MessageTFTP
) – 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
- error_code
TFTP error code which can be of value not defined, File not found, Access violation, Disk full, Illegal TFTP operation, Unknown port, File already exists or No such user.
- Type
- ethernet_header
Object containing all the information from the Ethernet header like the source and destination MAC addresses of the message.
- Type
- file_data
Each data packet contains
512
bytes of data, except the final one that must contain less than a full-sized block of data to signal that it is the last. If the size of the transferred file is a exact multiple of the block-size, the source sends a final DATA packet containing0
bytes of data.
- frame_number
Number of the frame received, in the context of all the ethernet traffic captured.
- Type
- ip_header
Object containing all the information from the IP header like the source and destination IP addresses of the message.
- Type
- ipv4_header
Object containing all the information from the IPV4 header.
- Type
- ipv6_header
Object containing all the information from the IPV6 header.
- Type
- mode
The transfer modes are either
NETASCII
for transferring text files orOCTET
for transferring binary files.- Type
- network_protocol
Network Protocol of the message.
- Type
- op_codes
The first
2
bytes of the TFTP message are an opcode. For a read request (RRQ) and write request (WRQ) the filename specifies the file on the server that the client wants to read from or write to. OPCODE takes one of the value,RRQ
= Read Request,WRQ
= Write Request,DATA
= Data,ACK
= Acknowledgement,Error
= Error orOACK
= Option Acknowledgement.- Type
- transport_header
Object containing all the information from the transport header (usually TCP or UDP) like the source and destination ports.
- Type
- transport_protocol
Object containing all the information from the transport protocol (usually TCP or UDP) like the source and destination ports.
- Type
- vlan_tag
Object containing all VLAN info.
- Type