Message Header Requirements¶
This section defines Software Low-Level Requirements (SW-LLR) for the SOME/IP Message Header parsing logic. All multi-byte fields use Big Endian (network byte order) encoding.
Overview¶
The SOME/IP message header is 16 bytes and contains the following fields:
Message ID (4 bytes): Service ID (16 bits) + Method ID (16 bits)
Length (4 bytes): Message length minus 8 bytes
Request ID (4 bytes): Client ID (16 bits) + Session ID (16 bits)
Protocol Version (1 byte)
Interface Version (1 byte)
Message Type (1 byte)
Return Code (1 byte)
Message ID Parsing¶
The software shall parse the Message ID field from bytes 0-3 of the SOME/IP header in Big Endian byte order. Rationale: The Message ID is a 32-bit field that identifies the service and method/event. Code Location: |
The software shall extract the Service ID from the upper 16 bits (bits 31-16) of the Message ID field. Rationale: Service ID identifies the service offering the method. Code Location: |
The software shall extract the Method ID from the lower 16 bits (bits 15-0) of the Message ID field. Rationale: Method ID identifies the specific method or event. Code Location: |
The software shall reject messages with Service ID 0x0000 for normal (non-reserved) message processing, as this value is reserved. Rationale: Service ID 0x0000 is reserved per specification. Error Handling: Return E_UNKNOWN_SERVICE (0x02). Code Location: |
The software shall recognize Service ID 0xFFFF as the Service Discovery service identifier. Rationale: SOME/IP-SD uses Service ID 0xFFFF for all SD messages. Code Location: |
The software shall accept Method IDs in the range 0x0000 to 0x7FFF as valid method identifiers. Rationale: Method IDs use the lower range of the 16-bit field. Code Location: |
The software shall accept Method IDs in the range 0x8000 to 0xFFFE as valid event identifiers. Rationale: Events use the upper range of the Method ID field. Code Location: |
The software shall reject messages with Method ID 0xFFFF for normal message processing, as this value is reserved. Rationale: Method ID 0xFFFF is reserved per specification. Error Handling: Return E_UNKNOWN_METHOD (0x03). Code Location: |
The software shall return error code E_UNKNOWN_SERVICE (0x02) when a message with an invalid or reserved Service ID is received. Rationale: Proper error reporting for debugging and diagnostics. Error Handling: Set return code to 0x02 in error response. Code Location: |
The software shall log an error message containing the invalid Service ID value when a reserved or invalid Service ID is received. Rationale: Diagnostics and troubleshooting support. Error Handling: Log at ERROR level with Service ID value. Code Location: |
Length Field Parsing¶
The software shall parse the Length field from bytes 4-7 of the SOME/IP header in Big Endian byte order. Rationale: The Length field indicates the size of the message excluding the first 8 bytes. Code Location: |
The software shall validate that the Length field value equals the total SOME/IP message size minus 8 bytes (Message ID + Length fields). Rationale: Length field covers Request ID, Protocol Version, Interface Version, Message Type, Return Code, and payload. Code Location: |
The software shall accept a minimum Length field value of 8 bytes, representing a message with header only and no payload. Rationale: Minimum message contains 16-byte header (8 bytes in Length field calculation). Code Location: |
The software shall limit the maximum payload size to 1400 bytes for UDP transport without SOME/IP-TP, to fit within a single Ethernet frame. Rationale: UDP binding limitation to avoid IP fragmentation. Code Location: |
The software shall reject messages where the received buffer size is less than the Length field value plus 8 bytes. Rationale: Prevents buffer overread and ensures complete message. Error Handling: Return E_MALFORMED_MESSAGE (0x09). Code Location: |
The software shall reject messages where the Length field value is less than 8 bytes. Rationale: Minimum Length of 8 covers the remaining header fields. Error Handling: Return E_MALFORMED_MESSAGE (0x09). Code Location: |
The software shall return error code E_MALFORMED_MESSAGE (0x09) when a message with an invalid Length field is received. Rationale: Consistent error reporting for malformed messages. Error Handling: Set return code to 0x09 in error response. Code Location: |
The software shall log an error message containing the actual Length field value when an invalid Length is received. Rationale: Diagnostics and troubleshooting support. Error Handling: Log at ERROR level with Length value and expected range. Code Location: |
The software shall detect truncated messages where the actual data received is shorter than indicated by the Length field. Rationale: Ensures data integrity and prevents processing incomplete data. Error Handling: Return E_MALFORMED_MESSAGE (0x09). Code Location: |
The software shall validate the Length field before any payload access to prevent buffer overflow when Length exceeds actual buffer size. Rationale: Security and safety requirement to prevent memory access violations. Error Handling: Return E_MALFORMED_MESSAGE (0x09) without accessing payload. Code Location: |
Request ID Parsing¶
The software shall parse the Request ID field from bytes 8-11 of the SOME/IP header in Big Endian byte order. Rationale: Request ID uniquely identifies a request for matching responses. Code Location: |
The software shall extract the Client ID from the upper 16 bits (bits 31-16) of the Request ID field. Rationale: Client ID identifies the requesting client. Code Location: |
The software shall extract the Session ID from the lower 16 bits (bits 15-0) of the Request ID field. Rationale: Session ID tracks individual requests within a session. Code Location: |
The software shall interpret Session ID 0x0000 as an indication that session handling is disabled for this communication. Rationale: Some implementations may not use session handling. Code Location: |
The software shall implement Session ID wrap-around such that after 0xFFFF, the next Session ID shall be 0x0001, skipping 0x0000. Rationale: 0x0000 is reserved for disabled session handling. Code Location: |
The software shall recognize Client ID 0x0000 as reserved for Service Discovery messages. Rationale: SD messages use Client ID 0x0000 per specification. Code Location: |
The software shall detect duplicate Session IDs when session handling is enabled and an active session with the same ID exists. Rationale: Prevents request/response mismatch. Error Handling: Log warning and handle based on configuration. Code Location: |
The software shall optionally validate that Session IDs are received in expected sequence (incrementing, with wrap-around handling). Rationale: Helps detect lost or reordered messages. Error Handling: Log warning; accept message but flag sequence gap. Code Location: |
Protocol Version Parsing¶
The software shall parse the Protocol Version field from byte 12 of the SOME/IP header. Rationale: Protocol Version identifies the SOME/IP protocol version. Code Location: |
The software shall validate that the Protocol Version field value equals 0x01 for SOME/IP version 1. Rationale: Current SOME/IP specification uses Protocol Version 1. Code Location: |
The software shall reject messages where the Protocol Version field does not equal 0x01. Rationale: Ensures compatibility with expected protocol version. Error Handling: Return E_WRONG_PROTOCOL_VERSION (0x07). Code Location: |
The software shall return error code E_WRONG_PROTOCOL_VERSION (0x07) when a message with an unsupported Protocol Version is received. Rationale: Standard error code for protocol version mismatch. Error Handling: Set return code to 0x07 in error response. Code Location: |
The software shall log an error message containing the received Protocol Version value when an unsupported version is detected. Rationale: Diagnostics for version compatibility issues. Error Handling: Log at ERROR level with received version value. Code Location: |
The software shall discard the entire message without further processing when the Protocol Version is invalid. Rationale: Cannot reliably parse a message with unknown protocol version. Error Handling: Do not process payload; optionally send error response. Code Location: |
Interface Version Parsing¶
The software shall parse the Interface Version field from byte 13 of the SOME/IP header. Rationale: Interface Version indicates the service interface version. Code Location: |
The software shall pass the Interface Version value to the application layer for service-specific version validation. Rationale: Interface version compatibility is application-specific. Code Location: |
The software shall return error code E_WRONG_INTERFACE_VERSION (0x08) when the application rejects the Interface Version. Rationale: Standard error code for interface version mismatch. Error Handling: Set return code to 0x08 in error response. Code Location: |
The software shall log an error message containing both the expected and received Interface Version values when a mismatch occurs. Rationale: Diagnostics for interface version compatibility issues. Error Handling: Log at WARNING level with both version values. Code Location: |
Message Type Parsing¶
The software shall parse the Message Type field from byte 14 of the SOME/IP header. Rationale: Message Type determines message semantics and processing. Code Location: |
The software shall accept Message Type 0x00 (REQUEST) for request/response method calls. Rationale: Standard message type for RPC requests. Code Location: |
The software shall accept Message Type 0x01 (REQUEST_NO_RETURN) for fire-and-forget method calls. Rationale: Standard message type for one-way requests. Code Location: |
The software shall accept Message Type 0x02 (NOTIFICATION) for event notifications and field updates. Rationale: Standard message type for events. Code Location: |
The software shall accept Message Type 0x80 (RESPONSE) for successful method responses. Rationale: Standard message type for RPC responses. Code Location: |
The software shall accept Message Type 0x81 (ERROR) for error responses to method calls. Rationale: Standard message type for error responses. Code Location: |
The software shall detect the TP flag (bit 5, value 0x20) in the Message Type field to identify SOME/IP-TP segmented messages. Rationale: TP flag indicates the message is a segment of a larger message. Code Location: |
The software shall accept Message Type 0x40 (REQUEST_ACK) for acknowledgment of received requests. Rationale: Optional acknowledgment message type. Code Location: |
The software shall accept Message Type 0xC0 (RESPONSE_ACK) for acknowledgment of received responses. Rationale: Optional acknowledgment message type. Code Location: |
The software shall accept Message Type 0xC1 (ERROR_ACK) for acknowledgment of received error responses. Rationale: Optional acknowledgment message type. Code Location: |
The software shall accept Message Type 0x20 (TP_REQUEST) for segmented request messages. Rationale: TP variant of REQUEST message type. Code Location: |
The software shall accept Message Type 0x21 (TP_REQUEST_NO_RETURN) for segmented fire-and-forget messages. Rationale: TP variant of REQUEST_NO_RETURN message type. Code Location: |
The software shall accept Message Type 0x22 (TP_NOTIFICATION) for segmented notification messages. Rationale: TP variant of NOTIFICATION message type. Code Location: |
The software shall reject messages with Message Type values not defined in the SOME/IP specification. Rationale: Unknown message types cannot be processed correctly. Error Handling: Return E_WRONG_MESSAGE_TYPE (0x0A). Code Location: |
The software shall return error code E_WRONG_MESSAGE_TYPE (0x0A) when a message with an unknown Message Type is received. Rationale: Standard error code for message type errors. Error Handling: Set return code to 0x0A in error response. Code Location: |
The software shall log an error message containing the unknown Message Type value when an invalid type is received. Rationale: Diagnostics for protocol compatibility issues. Error Handling: Log at ERROR level with Message Type value in hex. Code Location: |
The software shall validate that reserved bit combinations in the Message Type field are not used. Rationale: Reserved values may be used in future protocol versions. Error Handling: Return E_WRONG_MESSAGE_TYPE (0x0A). Code Location: |
Return Code Parsing¶
The software shall parse the Return Code field from byte 15 of the SOME/IP header. Rationale: Return Code indicates the result of a request. Code Location: |
The software shall validate that REQUEST, REQUEST_NO_RETURN, and NOTIFICATION messages have Return Code 0x00 (E_OK). Rationale: Request messages shall always have Return Code E_OK. Code Location: |
The software shall accept Return Codes in the range 0x00 to 0x5F as defined in the SOME/IP specification. Rationale: Standard return codes are defined for common error cases. Code Location: |
The software shall accept Return Code 0x00 (E_OK) indicating successful operation. Rationale: Standard success code. Code Location: |
The software shall accept Return Code 0x01 (E_NOT_OK) indicating an unspecified error. Rationale: Generic error code. Code Location: |
The software shall accept Return Code 0x02 (E_UNKNOWN_SERVICE) indicating the requested service is not available. Rationale: Standard error for unknown service. Code Location: |
The software shall accept Return Code 0x03 (E_UNKNOWN_METHOD) indicating the requested method is not available. Rationale: Standard error for unknown method. Code Location: |
The software shall accept Return Code 0x04 (E_NOT_READY) indicating the service is not ready. Rationale: Standard error for service not ready. Code Location: |
The software shall accept Return Code 0x05 (E_NOT_REACHABLE) indicating the service is not reachable. Rationale: Standard error for unreachable service. Code Location: |
The software shall accept Return Code 0x06 (E_TIMEOUT) indicating a timeout occurred. Rationale: Standard error for timeout. Code Location: |
The software shall accept Return Code 0x09 (E_MALFORMED_MESSAGE) indicating a malformed message was received. Rationale: Standard error for malformed messages. Code Location: |
The software shall reject REQUEST messages where the Return Code field is not 0x00. Rationale: Request messages must have E_OK return code. Error Handling: Return E_MALFORMED_MESSAGE (0x09). Code Location: |
The software shall accept unknown Return Codes (values > 0x5F) but log a warning for diagnostic purposes. Rationale: Forward compatibility with future return codes. Error Handling: Log warning with unknown Return Code value. Code Location: |
The software shall log an error message when a REQUEST message is received with a non-zero Return Code. Rationale: Diagnostics for protocol violations. Error Handling: Log at ERROR level with Return Code value. Code Location: |
Endianness Requirements¶
The software shall interpret all multi-byte header fields (Message ID, Length, Request ID) in Big Endian (network byte order). Rationale: SOME/IP specifies Big Endian for header fields. Code Location: |
The software shall convert multi-byte header fields from host byte order to Big Endian (network byte order) during serialization. Rationale: Ensures correct wire format regardless of host endianness. Code Location: |
The software shall convert multi-byte header fields from Big Endian (network byte order) to host byte order during deserialization. Rationale: Ensures correct interpretation regardless of host endianness. Code Location: |
The software shall not perform byte order conversion on single-byte fields (Protocol Version, Interface Version, Message Type, Return Code). Rationale: Single-byte fields have no endianness concern. Code Location: |
Header Validation Composite Requirements¶
The software shall validate the complete SOME/IP header by checking:
Rationale: Complete validation ensures message integrity. Code Location: |
The software shall safely reject deserialization requests where the input buffer pointer is null. Rationale: Prevents null pointer dereference. Error Handling: Return error immediately without dereferencing. Code Location: |
The software shall reject buffers smaller than 16 bytes, as they cannot contain a complete SOME/IP header. Rationale: Minimum header size is 16 bytes. Error Handling: Return E_MALFORMED_MESSAGE (0x09). Code Location: |
The software shall safely reject empty buffers (size 0) during deserialization. Rationale: Empty buffers cannot contain valid messages. Error Handling: Return E_MALFORMED_MESSAGE (0x09). Code Location: |
Identifier Ranges¶
The software shall support Service Instance IDs as 16-bit unsigned integers. Instance IDs 0x0000 (reserved) and 0xFFFF (all instances) shall not be used for a specific service instance. Rationale: Service Instance IDs enable multiple instances of the same service to coexist. Code Location: |
The software shall enforce that different services within the same vehicle have different Service IDs. Attempting to register a duplicate Service ID shall return an error; the existing registration remains unchanged. Rationale: Unique Service IDs prevent routing ambiguity in the vehicle network. Code Location: |
The software shall recognize Service ID 0xFFFE as the identifier for non-SOME/IP services, enabling interoperability with other protocols. Rationale: Service ID 0xFFFE enables interoperability with non-SOME/IP protocol stacks. Code Location: |
The software shall support Eventgroup IDs as 16-bit unsigned integers. Different eventgroups of a service shall have different Eventgroup IDs. Rationale: Eventgroup IDs enable selective event subscription per service. Code Location: |
RPC Communication Patterns¶
The software shall support constructing request headers (Message Type 0x00, Return Code 0x00) and response headers (Message Type 0x80/0x81) with fields copied from the corresponding request. Rationale: Correct header construction ensures responses are matched to requests. Code Location: |
The software shall support fire-and-forget messages (Message Type 0x01) that shall not trigger a response message. Error handling for fire-and-forget shall be implemented by the application. Rationale: Fire-and-forget reduces overhead for messages that do not require confirmation. Code Location: |
The software shall ensure response and error messages swap the source and destination IP addresses and port numbers relative to the request. Rationale: IP/port swapping ensures responses reach the originating client. Code Location: |
The software shall extract the payload field from the SOME/IP message following the 16-byte header. Rationale: Payload extraction provides application data for further processing. Code Location: |
The software shall use session handling (incrementing Session ID) for all request/response method calls. Rationale: Session handling for R/R enables detection of lost or reordered responses. Code Location: |
When event session handling is enabled via configuration, the software
shall use session handling for events, notification events, and
fire-and-forget methods and increment session IDs per event group
using the Rationale: Session handling for events enables detection of missed notifications. Code Location: |
The software shall support configuring a Client ID prefix or fixed value to enable vehicle-wide unique Client IDs. Rationale: Configurable Client ID prefix ensures vehicle-wide uniqueness. Code Location: |
Event and Field Support¶
The software shall deliver published events to all clients that are currently subscribed to the corresponding eventgroup. Rationale: Delivering events to all subscribers ensures no subscriber misses a notification. Code Location: |
The software shall not deliver events to clients that have not subscribed to the corresponding eventgroup. Rationale: Suppressing events to non-subscribers reduces unnecessary network traffic and CPU usage. Code Location: |
The software shall stop delivering events to a client immediately after the client unsubscribes from the eventgroup. Rationale: Immediate suppression after unsubscribe prevents unwanted event processing. Code Location: |
The software should support sending events to a subset of subscribed clients, controlled by the application. Rationale: Selective sending reduces bandwidth when not all subscribers need every event. Code Location: |
The software shall support field getters as request/response calls with an empty request payload and the field value in the response. Rationale: Field getters allow clients to read current field values on demand. Code Location: |
The software shall support field setters as request/response calls with the desired value in the request and the actual set value in the response. Rationale: Field setters allow clients to update field values with server-side validation. Code Location: |
The software shall support field notifiers that send notification event messages when the field value changes. Rationale: Field notifiers push value changes to interested clients without polling. Code Location: |
The software shall not allow a field without at least one accessor (getter, setter, or notifier). Rationale: A field without any accessor serves no purpose and indicates a design error. Code Location: |
Error Handling Extensions¶
The software shall not return error messages for fire-and-forget methods. Rationale: Fire-and-forget methods have no sender to receive error responses. Code Location: |
The software shall not return error messages for events and notifications. Rationale: Events/notifications are unidirectional and have no requester to receive errors. Code Location: |
The software shall copy the Message ID, Request ID, and Interface Version from the request into the error response message. Rationale: Copying header fields enables the requester to correlate errors with requests. Code Location: |
The software shall not send error responses to messages that already carry an error (return code not equal to 0x00). Rationale: Sending errors in response to errors would create infinite error loops. Code Location: |
The software shall support configurable generation and handling of return codes. Rationale: Configurable return codes support application-specific error semantics. Code Location: |
The software shall use Message Type 0x81 (ERROR) for exception messages when exception message support is configured. Rationale: Exception messages provide richer error information than a return code alone. Code Location: |
When exception messages are configured, the software shall include error detail information in the ERROR message payload. When not configured, errors shall be transported via Return Code in regular RESPONSE messages. Rationale: The payload carries details (error string, context) not expressible in a return code. Code Location: |
The software shall check the Protocol Version field first in the error handling sequence. Messages with invalid Protocol Version shall be rejected immediately without checking subsequent fields. Rationale: Checking Protocol Version first prevents misinterpreting messages from incompatible versions. Code Location: |
The software shall check the Message Type field after Protocol Version validation. Messages with unknown Message Type shall be rejected before service or method validation. Rationale: Checking Message Type before service/method prevents dispatching to handlers that cannot process it. Code Location: |
The software shall check Service ID and Method ID after Message Type validation. Unknown Service ID shall return E_UNKNOWN_SERVICE (0x02), unknown Method ID shall return E_UNKNOWN_METHOD (0x03). Rationale: Service/method validation reports specific errors to help clients correct their requests. Code Location: |
The software shall multiplex messages belonging to different service instances by the transport protocol port on the server side. Rationale: Port-based multiplexing allows multiple service instances to share infrastructure. Code Location: |
The software shall support two error handling mechanisms: the Return Code field in all messages, and the Exception Message type for detailed error information. Rationale: Supporting both return codes and exception messages gives flexibility for different error reporting needs. Code Location: |
Header Informational References¶
The software shall parse SOME/IP messages transported over IP/UDP or IP/TCP with correct IP address and port extraction. Rationale: IP/port extraction is fundamental for correct transport-layer routing. Code Location: |
The software shall support publish/subscribe handling as specified in SOME/IP-SD. Rationale: Publish/subscribe decouples event producers from consumers. Code Location: |
The software shall reject Service Instance ID 0x0000 (reserved) and 0xFFFF (wildcard) when used as a specific instance identifier. Rationale: Reserved Instance IDs have special semantics and cannot identify a specific instance. Error Handling: Return error and log invalid Instance ID value. Code Location: |
The software shall reject duplicate Eventgroup IDs within the same service. Rationale: Duplicate Eventgroup IDs cause subscription routing ambiguity. Error Handling: Return error and log the duplicate Eventgroup ID. Code Location: |
The software shall discard response messages that do not match any pending request. Rationale: Orphan responses may indicate protocol errors or stale replies. Error Handling: Discard message, log warning with Request ID. Code Location: |
The software shall report a timeout error when no response is received within the configured timeout for a request/response call. Rationale: Timeout handling prevents indefinite blocking on lost responses. Error Handling: Invoke error callback with E_TIMEOUT. Code Location: |
The software shall reject messages whose payload size exceeds the maximum allowed for the transport type. Rationale: Oversized payloads cause fragmentation or transport failures. Error Handling: Return E_MALFORMED_MESSAGE and log payload size vs maximum. Code Location: |
The software shall log a warning when Session ID 0x0000 is received in a context where session handling is expected to be active. Rationale: Session ID 0x0000 indicates disabled session handling, which may be unexpected. Error Handling: Log warning; process message based on configuration. Code Location: |
The software shall detect and report Client ID conflicts when two clients attempt to use the same Client ID. Rationale: Client ID conflicts cause request/response matching failures. Error Handling: Return error and log conflicting Client ID value. Code Location: |
The software shall handle event publication with zero subscribers gracefully without error. Rationale: Zero subscribers is a normal transient condition during service startup. Error Handling: No error; event is silently discarded. Code Location: |
The software shall return E_UNKNOWN_METHOD when a field getter is called but not configured for the field. Rationale: Unconfigured getters indicate client-side configuration errors. Error Handling: Return E_UNKNOWN_METHOD in error response. Code Location: |
The software shall return the current (unchanged) field value when a setter validation fails. Rationale: The response always carries the actual field value, enabling clients to detect rejected changes. Error Handling: Return E_NOT_OK with current field value in response payload. Code Location: |
The software shall log a warning when Interface Version 0x00 is received, as it may indicate an uninitialized field. Rationale: Version 0 is unusual and may indicate a programming error. Error Handling: Log warning, process message normally. Code Location: |
The software shall log a warning when a non-SD message has Request ID 0x00000000. Rationale: All-zero Request ID in non-SD messages may indicate initialization error. Error Handling: Log warning with message details. Code Location: |
The software shall reject messages with Length values that would cause integer overflow or exceed implementation limits. Rationale: Maximum length protection prevents denial-of-service from crafted length values. Error Handling: Return E_MALFORMED_MESSAGE (0x09), log declared length. Code Location: |
The software shall reject serialization when the output buffer cannot hold the complete message. Rationale: Partial serialization produces corrupted wire-format data. Error Handling: Return BUFFER_OVERFLOW error code, no partial write. Code Location: |
The software shall handle duplicate notifier registration for the same field by replacing the existing notifier with the new one. The previous notifier shall be released to prevent resource leaks. Rationale: Duplicate registration without cleanup causes dangling references. Error Handling: Replace existing notifier; release the old one. Code Location: |
The software shall log a warning when a RESPONSE message is received for a method configured as fire-and-forget. Rationale: RESPONSE for F&F methods indicates a sender misconfiguration. Error Handling: Log warning, discard response. Code Location: |
The software shall reject NOTIFICATION messages with non-zero Return Code. Rationale: Notifications must have Return Code E_OK per the SOME/IP specification. Error Handling: Return E_MALFORMED_MESSAGE (0x09). Code Location: |
The software shall reject event publication attempts after the publisher has been stopped. Rationale: Publishing after shutdown may cause use-after-free or dangling references. Error Handling: Return NOT_READY error. Code Location: |
Traceability¶
Implementation Files¶
include/someip/message.h- Message class definitioninclude/someip/types.h- Type definitionssrc/someip/message.cpp- Message implementationsrc/someip/types.cpp- Type implementationssrc/core/session_manager.cpp- Session ID management
Test Files¶
tests/test_message.cpp- Message unit tests