SOME/IP in AUTOSAR Classic

SOME/IP

The SOME/IP header, byte by byte

The SOME/IP header of lesson 4 is exactly 16 bytes: four rows of four. This lesson gives every header field its size, its byte position and its allowed values.

The layout

SOME/IP header as four 32-bit rows: Service ID 16 bits, a 1-bit method or event flag and a 15-bit Method or Event ID; Length 32 bits; Client ID 16 bits and Session ID 16 bits; Protocol Version, Interface Version, Message Type and Return Code 8 bits each; then the payload. Length covers everything from the Client ID to the end. bit 0byte8162431 0 Service ID · 16 bit 0/1 Method ID / Event ID · 15 bit 4 Length · 32 bit 8 Client ID · 16 bit Session ID · 16 bit 12 Protocol Version Interface Version Message Type Return Code 16 Payload · 0 or more bytes the Length field counts every byte inside the bracket on the right: 8 header bytes + the payload 0 = method · 1 = event
Figure 1. Bytes travel left to right, top row first. The two green rows (Message ID and Length) are written by SoAd as its PDU header, the purple rows by the SOME/IP transformer (lesson 20). Every multi-byte header field is big-endian (most significant byte first).

Field by field

Bytes 0–3 form the Message ID, bytes 8–11 the Request ID. The table splits them into their parts.

BytesFieldValues
0–1Service ID0x0000 reserved · 0xFF00–0xFF5F test and ECU-internal ranges · 0xFFFE non-SOME/IP services offered via SOME/IP-SD · 0xFFFF SOME/IP and SOME/IP-SD itself
2–3Method ID or Event IDHighest bit 0: Method ID, 0x0000–0x7FFF. Highest bit 1: Event ID of an event or field notifier, 0x8000–0xFFFF. 0x0000, 0x7FFF, 0x8000 and 0xFFFF are reserved.
4–7LengthNumber of bytes from byte 8 to the end of the message: 8 + payload length. So a message without payload has Length 8 and is 16 bytes long.
8–9Client IDIdentifies the client inside its ECU; may carry a fixed prefix (for example the upper byte) to be unique in the vehicle. 0x0000 for notifications.
10–11Session ID0x0000 when session handling is off; otherwise 0x0001–0xFFFF, wrapping from 0xFFFF to 0x0001.
12Protocol VersionAlways 0x01.
13Interface VersionMajor version of the service interface.
14Message TypeSee the next table.
15Return Code0x00 for everything except RESPONSE and ERROR. See below.

Big-endian (network byte order: the most significant byte goes first): Service ID 0x1234 is sent as 12 34, Length 12 as 00 00 00 0C. The header is always big-endian; the byte order of the payload is a configuration choice (lesson 29).

Message Type

ValueNameMeaningSegment (TP flag set)
0x00REQUESTmethod call expecting a response (even an empty one)0x20 TP_REQUEST
0x01REQUEST_NO_RETURNfire&forget method call0x21 TP_REQUEST_NO_RETURN
0x02NOTIFICATIONevent or field notifier, no response0x22 TP_NOTIFICATION
0x80RESPONSEresponse to a REQUEST0xA0 TP_RESPONSE
0x81ERRORresponse carrying an error0xA1 TP_ERROR

The TP flag is bit value 0x20, the third-highest bit of the byte. SOME/IP TP sets it on every segment and clears it again after reassembly (lesson 32). The top bit 0x80 marks the answers.

Return Code

ValueNameValueName
0x00E_OK0x08E_WRONG_INTERFACE_VERSION
0x01E_NOT_OK0x09E_MALFORMED_MESSAGE
0x02E_UNKNOWN_SERVICE0x0AE_WRONG_MESSAGE_TYPE
0x03E_UNKNOWN_METHOD0x0B–0x0FE2E errors (see below)
0x04E_NOT_READY0x10–0x1Freserved for generic SOME/IP errors
0x05E_NOT_REACHABLE (internal only)0x20–0x5Eservice- and method-specific errors
0x06E_TIMEOUT (internal only)
0x07E_WRONG_PROTOCOL_VERSION

In the Classic Platform an ApplicationError of a client-server operation (range 0x01–0x3F) travels as its value plus 0x1F, which lands in 0x20–0x5E. On E2E: the R20-11 protocol specification lists five E2E codes, 0x0B E_E2E_REPEATED to 0x0F E_E2E_NO_NEW_DATA; the SOME/IP transformer specification of the same release lists only 0x0B E_E2E and reserves 0x0C–0x1F.

Special messages of service 0xFFFF

In service 0xFFFF, Method ID 0x0000 and Event ID 0x8000 are the Magic Cookie messages (16-byte marker messages that test tools can insert into a TCP stream so a receiver finds the message boundaries again). They have Length 8 and Request ID DE AD BE EF: 0x0000 goes from client to server as REQUEST_NO_RETURN, 0x8000 from server to client as NOTIFICATION. Event ID 0x8100 marks the SOME/IP-SD message (lesson 30).

Try it

Build a SOME/IP header, or paste bytes and decode them. Click any byte to see its header field.

Things to notice. Switching from Method ID to Event ID only changes the top bit of byte 2: 0x0001 becomes 0x8001. The Length grows by exactly one for every payload byte. Decode the Magic Cookie preset: its Length is 8, so the message ends right after byte 15. Change the Message Type to a TP value and the decoder points out the SOME/IP TP header that must follow.

Check yourself optional

New terms in this lesson

TermMeaning
big-endianNetwork byte order: the most significant byte goes first. The SOME/IP header is always big-endian.
Magic CookieA 16-byte marker message of service 0xFFFF (Method ID 0x0000 or Event ID 0x8000) that lets a receiver find message boundaries in a TCP stream

Source: SOME/IP Protocol Specification, R20-11, sections 4.1.2, 4.1.3, 4.2.1.2 (magic cookies) and 4.2.6.1; SOME/IP-SD Protocol Specification, R20-11, section 4.1.7 (reserved IDs); SOME/IP Transformer, R20-11, section 7.3.4.1.