SOME/IP in AUTOSAR Classic

SOME/IP

The SOME/IP header

Every SOME/IP message starts with the same SOME/IP header. It says which service and which method or event the message is about, what kind of message it is, and which request it belongs to.

Seven fields in a fixed order

Whatever the message carries, the header has the same fields in the same places, so every receiver can read it. After the header comes the payload (the serialized data of the message).

The SOME/IP header as a block of fields: Message ID (Service ID plus Method ID or Event ID); Length; Request ID (Client ID plus Session ID); Protocol Version, Interface Version, Message Type and Return Code; then the payload. Message ID = Service ID + Method ID or Event ID Length · number of bytes that follow Request ID = Client ID + Session ID Protocol Versionalways 0x01 Interface Versionthe major version Message TypeREQUEST, RESPONSE … Return CodeE_OK or an error code Payload the serialized data: arguments of a method, the value of an event …
Figure 1. Read the fields top to bottom, in the order they travel. The bracket on the right shows what the Length counts: everything after it, the rest of the header and the payload. Colours show which AUTOSAR module writes the field (lesson 20): green SoAd, purple the SOME/IP transformer.

32 bits

Message ID

The Message ID (what the message is about) is the Service ID plus the Method ID or Event ID. Together they name exactly one method or event in the whole vehicle.

32 bits

Length

The Length (the number of bytes that follow it) lets a receiver find the end of this message. Several messages can share one UDP datagram; each keeps its own header.

32 bits

Request ID

The Request ID (which request this message belongs to) is a Client ID (tells apart the clients on one ECU) plus a Session ID (a running counter). The server copies both into the response, so the client can match response to request.

8 bits each

Versions, type, result

A receiver checks the Protocol Version (the version of SOME/IP itself) and the Interface Version (the major version of the service interface) before trusting the data. The Message Type says what kind of message this is. The Return Code (the result) is only meaningful in responses and errors.

The Message Types

Message TypeSent byMeans
REQUESTclientA method call that expects a response, even when the response carries no data.
REQUEST_NO_RETURNclientA fire&forget method call: no response will come.
NOTIFICATIONserverAn event: a new value or something that happened. No response.
RESPONSEserverThe result of a REQUEST.
ERRORserverA response that reports a failure instead of a result.

Each Message Type has a twin with the TP flag set (a bit that marks one segment of a large message cut up by SOME/IP TP, lesson 23).

The Session ID

The Request ID has two halves. The Client ID names the client inside the calling ECU. The Session ID counts: every new request gets the next number, and after the highest number it starts again at 1, never at 0. This counting is called session handling (the Session ID goes 1, 2, … wrapping to 1). Notifications may count too, or may keep the Session ID at 0 when session handling is off for them.

Try it

Pick a Message Type and press "Send". Watch which header fields change. Send the same type twice to see the Session ID move.

Header fieldValueWhy

Things to notice. A RESPONSE never makes up its own Request ID: it copies the one of its REQUEST. A NOTIFICATION from the server has no client, so the Client ID is 0. Only RESPONSE and ERROR can carry a real Return Code; every other type sends E_OK (0x00, no error). Message ID, Protocol Version and Interface Version stay the same for every message of one method or event.

Check yourself optional

New terms in this lesson

TermMeaning
Message IDService ID plus Method ID or Event ID: what the message is about
LengthNumber of bytes that follow the Length field: rest of the header plus payload
Request IDClient ID plus Session ID; a response copies it from its request
Client IDTells apart the clients of a method on one ECU
Session IDRunning counter of requests or notifications
session handlingCounting the Session ID up with every message, wrapping to 1; off means always 0
Protocol VersionVersion of the SOME/IP protocol, 0x01
Interface VersionMajor version of the service interface
Message TypeKind of message: REQUEST, REQUEST_NO_RETURN, NOTIFICATION, RESPONSE, ERROR
Return CodeResult of a request: E_OK or an error code
payloadThe serialized data after the header

Source: SOME/IP Protocol Specification, R20-11, section 4.1.2 (header) and 4.2.1 (several messages in one UDP datagram).