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
| Bit of the Flags byte | Name | Value sent |
|---|---|---|
| 0x80 (highest) | Reboot flag | 1 after a reboot until the Session ID wraps (lesson 16) |
| 0x40 | Unicast flag | always 1: "I can receive unicast SOME/IP-SD messages"; kept for compatibility |
| 0x20 | Explicit Initial Data Control flag | always 1: "I honour the Initial Data Requested flag" |
| others | undefined | 0 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).
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).
| Type | Option | Length | Content after the 4-byte start |
|---|---|---|---|
0x01 | Configuration option | variable | name=value strings, each behind a 1-byte length, ending with a zero byte |
0x02 | Load Balancing option | 0x0005 | priority (2 bytes, lower = preferred), weight (2 bytes) |
0x04 | IPv4 Endpoint option | 0x0009 | IPv4 address (4), reserved (1), protocol (1: 0x06 TCP, 0x11 UDP), port (2) |
0x06 | IPv6 Endpoint option | 0x0015 | IPv6 address (16), reserved, protocol, port |
0x14 | IPv4 Multicast option | 0x0009 | multicast address, reserved, protocol 0x11 (UDP only), port |
0x16 | IPv6 Multicast option | 0x0015 | as above, 16-byte address |
0x24 | IPv4 SD Endpoint option | 0x0009 | the sender's Sd address and port; first option, never referenced by an entry |
0x26 | IPv6 SD Endpoint option | 0x0015 | as 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
| Term | Meaning |
|---|---|
| Unicast flag | Bit 0x40 of the Flags byte: the sender can receive unicast SOME/IP-SD messages; always 1 |
| Explicit Initial Data Control flag | Bit 0x20 of the Flags byte: the sender honours the Initial Data Requested flag; always 1 |
| service entry | Entry format Type 1 for FindService and OfferService: ends with the Minor Version |
| eventgroup entry | Entry format Type 2 for SubscribeEventgroup and its Ack: ends with flag, Counter and Eventgroup ID |
| option run | The options an entry uses: a start index into the options array (Index 1st or 2nd options) and a number (# of opt 1 or 2) |
| Counter | 4 bits of an eventgroup entry that tell apart subscriptions of one client to one eventgroup; 0 if unused |
| Discardable flag | Top bit of the fourth byte of an option: a receiver that does not know the option may ignore it |
| Configuration option | Option 0x01: name=value strings for extra configuration |
| Load Balancing option | Option 0x02: priority and weight for choosing between several service instances |
| SD Endpoint option | Option 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.