MessageSomeIPSD
Summary
Represents a SOME/IP-SD (Scalable service-Oriented MiddlewarE over IP Service discovery) message object.
- Methods
- Properties
- Events
Structure
- class MessageSomeIPSD
- add_configuration_string_option(configuration: IDictionary) Option
Adds configuration options from a dictionary.
- Parameters
configuration (
IDictionary
) – A dictionary containing the configuration option strings.- Returns
Option containing the added configuration.
- Return type
- add_configuration_string_option(configuration: str) Option
Creates an option of type “Configuration string” and adds it to the options array of the message, and updates length accordingly.
- add_entries(entries: Array[Entry]) bool
Adds a list of entries to the current entries of the message.
- add_entry(e: Entry) bool
Adds the entry to the entries array of the message, and updates length accordingly.
- add_find_entries(ecu_name: str, service_id: uint16, including_all_services: bool) Array[Entry]
Retrieves the entries of type FindService of the specific ECU and service, then adds it to the entries array of the message. Updating its length accordingly.
- Parameters
- Returns
List of entries created.
- Return type
- add_find_service_entry(entry: Entry) Entry
Creates an entry of type FindService and adds it to the entries array of the message, and updates length accordingly.
- add_find_service_entry(service_id: uint16, instance_id: uint16, ttl: int32, major_version: uint8, minor_version: uint32) Entry
Creates an entry of type FindService and adds it to the entries array of the message, and updates length accordingly.
- Parameters
- Returns
Entry created.
- Return type
- add_ipv4_option(address: str, port: uint16, is_udp: bool, is_multicast: bool) Option
Creates an option of type “IPv4”, which can be an endpoint or a multicast address, and adds it to the options array of the message, and updates length accordingly. If an entry is specified, a reference from this entry to the option will be added.
- Parameters
- Returns
Option created.
- Return type
- add_ipv4_option(entry: Entry, port: uint16, address: str, is_udp: bool, is_multicast: bool) Option
Creates an option of type “IPv4”, which can be an endpoint or a multicast address, and adds it to the options array of the message, and updates length accordingly. If an entry is specified, a reference from this entry to the option will be added.
- Parameters
entry (
Entry
) – (optional) previously created entry.port (
uint16
) – Port number.address (
str
) – IP address.is_udp (
bool
) – Transport protocol used.True
, UDP.False
, TCP.is_multicast (
bool
) – Flag that only SubscribeEventgroup entries that should set toTrue
, indicating that the SOME/IP messages of the subscribed service will be sent multicast.
- Returns
Option created.
- Return type
- add_ipv4_option(entry: Entry, port: uint16, address: str, is_udp: bool, is_multicast: bool, index: uint8) Option
Creates an option of type “IPv4”, which can be an endpoint or a multicast address, and adds it to the options array of the message, and updates length accordingly. If an entry is specified, a reference from this entry to the option will be added.
- Parameters
entry (
Entry
) – (optional) previously created entry.port (
uint16
) – Port number.address (
str
) – IP address.is_udp (
bool
) – Transport protocol used.True
, UDP.False
, TCP.is_multicast (
bool
) – Boolean flag that only SubscribeEventgroup entries that should set toTrue
, indicating that the SOME/IP messages of the subscribed service will be sent multicast.index (
uint8
) – (optional) index of the option in the options array.
- Returns
Option created.
- Return type
- add_ipv6_option(address: str, port: uint16, is_udp: bool, is_multicast: bool) Option
Creates an option of type “IPv6 endpoint” and adds it to the options array of the message, and updates length accordingly.
- Parameters
- Returns
Option created.
- Return type
- add_ipv6_option(entry: Entry, port: uint16, address: str, is_udp: bool, is_multicast: bool) Option
Creates an option of type “IPv6 endpoint” and adds it to the options array of the message, and updates length accordingly.
- Parameters
entry (
Entry
) – (optional) previously created entry.port (
uint16
) – Port number.address (
str
) – IP address.is_udp (
bool
) – Transport protocol used.True
, UDP.False
, TCP.is_multicast (
bool
) – Flag that only SubscribeEventgroup entries that should set toTrue
, indicating that the SOME/IP messages of the subscribed service will be sent multicast.
- Returns
Option created.
- Return type
- add_offer_entries(ecu_name: str, service_id: uint16, including_all_services: bool) Array[Entry]
Retrieves the entries of type OfferService of the specific ECU and service and adds it to the entries array of the message, and updates length accordingly.
- Parameters
- Returns
List Entry created.
- Return type
- add_offer_service_entry(entry: Entry) Entry
Creates an entry of type OfferService, adds it to the entries array of the message, and updates length accordingly.
- add_offer_service_entry(service_id: uint16, instance_id: uint16, ttl: int32, major_version: uint8, minor_version: uint32) Entry
Creates an entry of type OfferService, adds it to the entries array of the message, and updates length accordingly.
- Parameters
- Returns
Entry created.
- Return type
- add_offer_service_entry(service_id: uint16, instance_id: uint16, ttl: int32, major_version: uint8, minor_version: uint32, options: object) Entry
Creates an entry of type OfferService, adds it to the entries array of the message, and updates length accordingly.
- Parameters
service_id (
uint16
) – Identifier of the service offered.instance_id (
uint16
) – Identifier of the specific instance that offer the service.ttl (
int32
) – TTL of the offer message.major_version (
uint8
) – Major version of the service.minor_version (
uint32
) – Minor version of the service.options (
object
) – List of options associated with the entry.
- Returns
Entry created.
- Return type
- add_option(entry: Entry, option: Option) Option
Adds a given option, already created, to an entry.
- add_stop_offer_service_entry(service_id: uint16, instance_id: uint16, major_version: uint8, minor_version: uint32) Entry
Creates an entry of type OfferService, adds it to the entries array of the message, and updates length accordingly.
- Parameters
- Returns
Entry created.
- Return type
- add_stop_offer_service_entry(service_id: uint16, instance_id: uint16, major_version: uint8, minor_version: uint32, options: object) Entry
Creates an entry of type OfferService, adds it to the entries array of the message, and updates length accordingly.
- Parameters
service_id (
uint16
) – Identifier of the service offered.instance_id (
uint16
) – Identifier of the specific instance that offer the service.major_version (
uint8
) – Major version of the service.minor_version (
uint32
) – MnorVersion, Minor version of the service.options (
object
) – (optional) list of options associated with the entry.
- Returns
Entry created.
- Return type
- add_stop_subscribe_event_group_entry(entry: Entry, event_group_id: uint16) Entry
Creates an entry of type StopSubscribeEventgroup, adds it to the entries array of the message, and updates length accordingly.
- add_stop_subscribe_event_group_entry(service_id: uint16, instance_id: uint16, event_group_id: uint16, major_version: uint8) Entry
Creates an entry of type StopSubscribeEventgroup, adds it to the entries array of the message, and updates length accordingly.
- Parameters
service_id (
uint16
) – Identifier of the service to which the subscription wants to be stopped.instance_id (
uint16
) – Identifier of the service instance that includes the event group used for subscription.event_group_id (
uint16
) – Event group ID.major_version (
uint8
) – Major version of the service.
- Returns
Entry created.
- Return type
- add_subscribe_event_group_ack_entry(entry: Entry) Entry
Creates an entry of type SubscribeEventgroupACK, adds it to the entries array of the message, and updates length accordingly.
- add_subscribe_event_group_ack_entry(service_id: uint16, instance_id: uint16, event_group_id: uint16, ttl: int32, major_version: uint8) Entry
Creates an entry of type SubscribeEventgroupACK, adds it to the entries array of the message, and updates length accordingly.
- Parameters
service_id (
uint16
) – Identifier of the service to which the subscription is confirmed.instance_id (
uint16
) – Identifier of the service instance that includes the event group used for subscription.event_group_id (
uint16
) – Selected event group ID.ttl (
int32
) – TTL of the Subscribe message.major_version (
uint8
) – Major version of the service.
- Returns
Entry created.
- Return type
- add_subscribe_event_group_ack_entry(service_id: uint16, instance_id: uint16, event_group_id: uint16, ttl: int32, major_version: uint8, options: object) Entry
Creates an entry of type SubscribeEventgroupACK, adds it to the entries array of the message, and updates length accordingly.
- Parameters
service_id (
uint16
) – Identifier of the service to which the subscription is confirmed.instance_id (
uint16
) – Identifier of the service instance that includes the event group used for subscription.event_group_id (
uint16
) – Selected event group ID.ttl (
int32
) – TTL of the Subscribe message.major_version (
uint8
) – Major version of the service.options (
object
) – (optional) list of options associated with the entry.
- Returns
Entry created.
- Return type
- add_subscribe_event_group_entries(ecu_name: str, service_id: uint16, including_all_services: bool) Array[Entry]
Creates an entry of type SubscribeEventgroup based on the SubscribeEventgroup to which it responds, adds it to the entries array of the message, and updates length accordingly.
- Parameters
- Returns
List of entries created.
- Return type
- add_subscribe_event_group_entry(entry: Entry, event_group_id: uint16) Entry
Creates an entry of type SubscribeEventgroup based on the SubscribeEventgroup to which it responds, adds it to the entries array of the message, and updates length accordingly.
- add_subscribe_event_group_entry(service_id: uint16, instance_id: uint16, event_group_id: uint16, ttl: int32, major_version: uint8) Entry
Creates an entry of type SubscribeEventgroup based on the SubscribeEventgroup to which it responds, adds it to the entries array of the message, and updates length accordingly.
- Parameters
service_id (
uint16
) – Service identifier.instance_id (
uint16
) – Identifier of the service instance that includes the event group used for subscription.event_group_id (
uint16
) – Selected event group ID.ttl (
int32
) – TTL of the Subscribe message.major_version (
uint8
) – Major version of the service.
- Returns
Entry created.
- Return type
- add_subscribe_event_group_entry(service_id: uint16, instance_id: uint16, event_group_id: uint16, ttl: int32, major_version: uint8, options: object) Entry
Creates an entry of type SubscribeEventgroup based on the SubscribeEventgroup to which it responds, adds it to the entries array of the message, and updates length accordingly.
- Parameters
service_id (
uint16
) – Service identifier.instance_id (
uint16
) – Identifier of the service instance that includes the event group used for subscription.event_group_id (
uint16
) – Selected event group ID.ttl (
int32
) – TTL of the Subscribe message.major_version (
uint8
) – Major version of the service.options (
object
) – (optional) list of options associated with the entry.
- Returns
Entry created.
- Return type
- add_subscribe_event_group_nack_entry(entry: Entry) Entry
Creates an entry of type SubscribeEventgroupNACK based on the SubscribeEventgroup to which it responds, adds it to the entries array of the message, and updates length accordingly.
- append_message(message: MessageSomeIPSD)
Lets the user packs several messages into one packet, each appended message will have its own header.
- Parameters
message (
MessageSomeIPSD
) – The message to append
- capture(filter: Filter = None) MessageSomeIPSD
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) MessageSomeIPSD
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[MessageSomeIPSD]
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
- clear_entries()
Empties the entries array to be able to use the same message several times.
- close_writer()
Closes the file previously created with
open_writer(file)
.
- encapsulate_packet(message: Message)
Sets the encapsulated_packet of the message.
- Parameters
message (
Message
) – , message to set.
- get_all_entries() List[Entry]
Gets the content of the array entries of the message which is equivalent to the property entries.
- get_all_options() List[Option]
Gets the content of the array options of the message which is similar to the property options.
- get_entries_of_type(type: int32) List[Entry]
Gets a list of all the entries of type in the message.
- get_find_service_entries() List[Entry]
Gets a list of all the entries of type FindService found in the message.
- 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
- get_offer_service_entries() List[Entry]
Gets a list of all the entries of type OfferService found in the message.
- get_stop_offer_service_entries() List[Entry]
Gets a list of all the entries of type StopOfferService found in the message.
- get_stop_subscribe_event_group_entries() List[Entry]
Gets a list of all the entries of type SubscribeEventgroup found in the message.
- get_subscribe_event_group_ack_entries() List[Entry]
Gets a list of all the entries of type SubscribeEventgroupACK found in the message.
- get_subscribe_event_group_entries() List[Entry]
Gets a list of all the entries of type SubscribeEventgroup found in the message.
- get_subscribe_event_group_nack_entries() List[Entry]
Gets a list of all the entries of type SubscribeEventgroupNACK found in the message.
- 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() MessageSomeIPSD
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) MessageSomeIPSD
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[MessageSomeIPSD]
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
- request_service(timeout: int32) IReadOnlyList[IMessageBase]
Listens to the Ethernet bus for a while and returns a list with all the SOME/IP messages captured in that period containing the entry type of RequestService.
- Parameters
timeout (
int32
) – Max time in milliseconds to wait for a response.- Returns
List of messages containing the entry type of RequestService, captured from the Ethernet 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) MessageSomeIPSD
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_find(timeout: int32) IReadOnlyList[IMessageBase]
Sends the message if it contains at least one entry of type FindService and waits for responses during a certain period of time. An exception is thrown if the message contains no FindService entries.
- Parameters
timeout (
int32
) – Max time in milliseconds to wait for a response.- Returns
List of SOME/IP-SD messages as a response to the Find message sent.
- Return type
- send_receive_list(timeout: int32) IReadOnlyList[MessageSomeIPSD]
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
- send_receive_offer(timeout: int32) IReadOnlyList[IMessageBase]
Sends the message if it contains at least one entry of type OfferService and waits for responses during a certain period of time. An exception is thrown if the message contains no OfferService entries.
- Parameters
timeout (
int32
) – Max time in milliseconds to wait for a response.- Returns
List of SOME/IP-SD messages as a response to the Offer message sent.
- Return type
- send_receive_subscribe(timeout: int32) IReadOnlyList[IMessageBase]
Sends the message if it contains at least one entry of type SubscribeEventgroup and waits for responses during a certain period of time. An exception is thrown if the message contains no Subscribe entries.
- Parameters
timeout (
int32
) – Max time in milliseconds to wait for a response.- Returns
List of SOME/IP-SD messages as a response to the Subscribe message sent.
- Return type
- send_stop_offer(offer_entry: Entry)
Sends a given stop offer.
- Parameters
offer_entry (
Entry
) – Stop offer entry.
- send_stop_subscribe(subscribe_evt_grp_entry: Entry)
Creates a StopSubscribeEventgroup entry for the SubscribeEventgroup specified as a parameter, adds it to the message (clearing first the entries array) and sends it. No response is expected, so nothing is returned in this case.
- Parameters
subscribe_evt_grp_entry (
Entry
) – SubscribeEventgroup entry for the service to unsubscribe to.
- 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
- @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: MessageSomeIPSD)
Event is triggered every time a message is read from the Ethernet bus or a trace file. See start_capture.
- Parameters
message (
MessageSomeIPSD
) – 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
- flags
Flag bits of the SOME/IP-SD header that includes the unicast, reboot and explicit initial data control flags.
- Type
- 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
- length_of_options_array
Length of the options array, which has a variable length.
- Type
uint32
or None
- messages
Messages list.
- Type
- network_protocol
Network Protocol of the message.
- Type
- reboot_flag
Flag used, in combination with the session ID, to detect a reboot of the ECU. The reboot flag must be set to one for all the messages after reboot until the session ID in the SOME/IP header suffers an overflow and thus starts with
1
again. After this overflow the reboot flag is set to0
.- Type
- reserved
Reserved to possible uses in the future. It shall be set to
0x00
until further notice.- Type
- someip_header
Object containing all the information from the SOME/IP header.
- 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
- unicast_flag
Flag used to indicate whether the response to the message should be sent unicast
1
or multicast0
.- Type
- vlan_tag
Object containing all VLAN info.
- Type