SOME/IP in AUTOSAR Classic

SOME/IP

The SD message, byte by byte

A SOME/IP-SD message is a SOME/IP NOTIFICATION with a fixed SOME/IP header, a Flags byte, an array of 16-byte entries and an array of options.

The frame of every SD message

SOME/IP-SD message in 32-bit rows: Message ID 0xFFFF8100; Length; Request ID with Client ID 0 and Session ID; Protocol Version 1, Interface Version 1, Message Type 0x02, Return Code 0; Flags byte and 24 reserved bits; length of the entries array; the entries; length of the options array; the options. bit 08162431 0 Message ID = 0xFFFF 8100 4 Length 8 Client ID = 0x0000 Session ID (1…0xFFFF) 12 Protocol Version 0x01 Interface Version 0x01 Message Type 0x02 Return Code 0x00 16 Flags Reserved (24 bit) 20 Length of Entries Array in Bytes 24 Entries: 16 bytes each Length of Options Array in Bytes Options: variable length each green: written by SoAd as PDU header (header ID 0xFFFF8100) · pink: written by Sd
Figure 1. The first 16 bytes are an ordinary SOME/IP header with fixed values. From byte 16 on comes the SOME/IP-SD part: the Flags byte, then the entries array and the options array, each behind its own 4-byte length field.
Bit of the Flags byteNameValue sent
0x80 (highest)Reboot flag1 after a reboot until the Session ID wraps (lesson 16)
0x40Unicast flagalways 1: "I can receive unicast SOME/IP-SD messages"; kept for compatibility
0x20Explicit Initial Data Control flagalways 1: "I honour the Initial Data Requested flag"
othersundefined0 when sending, ignored when receiving

Entries

Every entry is 16 bytes long and comes in one of two formats: a service entry (Type 1 format, for FindService and OfferService) or an eventgroup entry (Type 2 format, for SubscribeEventgroup and SubscribeEventgroupAck). Each entry points to its options through two option runs (a start index into the options array plus a number of options).

Two entry formats of 16 bytes each. Service entry (Type 1): Type, Index 1st options, Index 2nd options, # of opt 1 and # of opt 2 in four bits each; Service ID, Instance ID; Major Version, TTL 24 bit; Minor Version 32 bit. Eventgroup entry (Type 2): the same first 12 bytes, then a reserved byte, a byte with the Initial Data Requested flag, three reserved bits and a 4-bit Counter, then the Eventgroup ID. Service entry (Type 1) FindService 0x00 · OfferService 0x01 · StopOfferService: OfferService with TTL 0 0 4 8 12 Type Index 1st options Index 2nd options # of opt 1 # of opt 2 Service ID Instance ID Major Version TTL · 24 bit, seconds Minor Version · 32 bit Eventgroup entry (Type 2) SubscribeEventgroup 0x06 · SubscribeEventgroupAck 0x07 · Stop and Nack: TTL 0 0 4 8 12 Type Index 1st options Index 2nd options # of opt 1 # of opt 2 Service ID Instance ID Major Version TTL · 24 bit, seconds Reserved Reserved Counter Eventgroup ID Initial Data Requested flag (1 bit) · Reserved (3 bit) · Counter (4 bit) Any: Instance ID 0xFFFF, Major Version 0xFF, Minor Version 0xFFFFFFFF. TTL 0xFFFFFF: until the next reboot. Option runs: # of opt 1 options from Index 1st options, # of opt 2 options from Index 2nd options. Counter: tells apart subscriptions of one client to one eventgroup that differ only in endpoint; 0 if unused.
Figure 2. The first 12 bytes of both formats are the same; only the last 4 differ: the Minor Version in a service entry; the Initial Data Requested flag, the Counter and the Eventgroup ID in an eventgroup entry. Two option runs let one entry share common options with other entries and still have its own.

Specification note: the R20-11 Service Discovery module specification still draws the 12 bits before the Counter as reserved and does not mention the Initial Data Requested flag or the Explicit Initial Data Control flag; the R20-11 protocol specification defines both. The course follows the protocol specification.

Options

Every option starts with a 2-byte Length (counting everything after the Type byte, so the reserved byte too), a 1-byte Type, and a byte whose top bit is the Discardable flag (set if a receiver that does not know this option may ignore it).

TypeOptionLengthContent after the 4-byte start
0x01Configuration optionvariablename=value strings, each behind a 1-byte length, ending with a zero byte
0x02Load Balancing option0x0005priority (2 bytes, lower = preferred), weight (2 bytes)
0x04IPv4 Endpoint option0x0009IPv4 address (4), reserved (1), protocol (1: 0x06 TCP, 0x11 UDP), port (2)
0x06IPv6 Endpoint option0x0015IPv6 address (16), reserved, protocol, port
0x14IPv4 Multicast option0x0009multicast address, reserved, protocol 0x11 (UDP only), port
0x16IPv6 Multicast option0x0015as above, 16-byte address
0x24IPv4 SD Endpoint option0x0009the sender's Sd address and port; first option, never referenced by an entry
0x26IPv6 SD Endpoint option0x0015as above for IPv6

The SOME/IP-SD port is 30490 (0x771A) by default. An OfferService references one Endpoint option per transport protocol it serves; a SubscribeEventgroup references the client's Endpoint options; a SubscribeEventgroupAck references at most one Multicast option; a FindService references no Endpoint options.

Specification note: one passage of the R20-11 protocol specification gives 0x0015 as length of the IPv4 SD Endpoint option; its figure and the module specification give 0x0009, which matches the 9 bytes that follow.

Try it

Build a SOME/IP-SD message, or paste one and decode it. The preset "Example from the specification" is the example PDU of the protocol specification (a FindService and an OfferService for a non-SOME/IP service).

Things to notice. A StopOfferService differs from the OfferService only in the three TTL bytes. A SubscribeEventgroupNack differs from the Ack only in its TTL and the missing options. In the OfferService, the single entry points to options 0 and 1 with Index 1st options 0 and # of opt 1 = 2. Decode the specification's example: its Configuration option carries "otherserv=internaldiag" behind the length byte 0x16 (22).

Check yourself optional

New terms in this lesson

TermMeaning
Unicast flagBit 0x40 of the Flags byte: the sender can receive unicast SOME/IP-SD messages; always 1
Explicit Initial Data Control flagBit 0x20 of the Flags byte: the sender honours the Initial Data Requested flag; always 1
service entryEntry format Type 1 for FindService and OfferService: ends with the Minor Version
eventgroup entryEntry format Type 2 for SubscribeEventgroup and its Ack: ends with flag, Counter and Eventgroup ID
option runThe options an entry uses: a start index into the options array (Index 1st or 2nd options) and a number (# of opt 1 or 2)
Counter4 bits of an eventgroup entry that tell apart subscriptions of one client to one eventgroup; 0 if unused
Discardable flagTop bit of the fourth byte of an option: a receiver that does not know the option may ignore it
Configuration optionOption 0x01: name=value strings for extra configuration
Load Balancing optionOption 0x02: priority and weight for choosing between several service instances
SD Endpoint optionOption 0x24 (IPv6 0x26): the address and port of the sender's Sd; never referenced by an entry

Source: SOME/IP-SD Protocol Specification, R20-11, sections 4.1.2 to 4.1.3 and the example of 4.1.5 (whose figure writes the configuration option length as "0x0025"; its 25 bytes are 0x0019, used here); Service Discovery, R20-11, sections 7.3 and 7.4.