SOME/IP-SD -- 协议英文原文讲解4

发布于:2025-02-27 ⋅ 阅读:(16) ⋅ 点赞:(0)

前言
SOME/IP协议越来越多的用于汽车电子行业中,关于协议详细完全的中文资料却没有,所以我将结合工作经验并对照英文原版协议做一系列的文章。基本分三大块:

1. SOME/IP协议讲解

2. SOME/IP-SD协议讲解

3. python/C++举例调试讲解


5.1.2.4.5 IPv4 Multicast Option  -- IPv4 组播选项
The IPv4 Multicast Option is either transmitted by the server (server multicast endpoint)
or by the client (client multicast endpoint):
• If it is transmitted by the server, then a server announces the IPv4 multicast address, the transport layer protocol, and the port number, to where the multicast
events are transmitted to.
• If it is transmitted by the client, then a client indicates the IPv4 multicast address,
the transport layer protocol, and the port number, where a client expects to receive multicast events.
用于sub/suback/stopsub 报文中
client发 sub/stopsub , server发送suback.  对server来说从哪发的组播地址,
对client来说是自己哪个用来接收的组播地址

多播仅针对 -- event/notify 事件
如果事件 需要用到多播的方式 则 用下面的方法配置多播地址

[PRS_SOMEIPSD_00323]
Upstream requirements: RS_SOMEIPSD_00003

IPv4 Multicast Options shall be referenced by SubscribeEventgroup or by StopSubscribeEventgroup or by SubscribeEventgroupAck entries:
• If it is referenced by a SubscribeEventgroup entry, it describes the client service
multicast endpoint (i.e. destination IP address and destination port), where the
multicast events shall be received by the client.
• If it is referenced by a StopSubscribeEventgroup entry, it reflects the intent to
stop the subscription of a client which has subscribed before via a client service
multicast endpoint (i.e. destination IP address and destination port) to the given
event group.
• If it is referenced by a SubscribeEventgroupAck entry, it describes the server
multicast endpoint (i.e. destination IP address and destination port), where a
server shall transmit the multicast events to.

[PRS_SOMEIPSD_00324]
Upstream requirements: RS_SOMEIPSD_00003
The IPv4 Multicast Option shall use the Type 0x14.
[PRS_SOMEIPSD_00325]
Upstream requirements: RS_SOMEIPSD_00003
The IPv4 Multicast Option shall specify the IPv4-Address, the transport layer protocol
(ISO/OSI layer 4) used, and its Port Number.
[PRS_SOMEIPSD_00326] -- 格式如下 容易理解
Upstream requirements: RS_SOMEIPSD_00003
The Format of the IPv4 Endpoint Option shall be as follows:
• Length [uint16]: Shall be set to 0x0009.
• Type [uint8]: Shall be set to 0x14.
• Discardable Flag [1 bit]: Shall be set to 0.
• Bit 1 to bit 7 are reserved and shall be 0.
• IPv4-Address [uint32]: Shall transport the multicast IP-Address as four Bytes.
• Reserved [uint8]: Shall be set to 0x00.
• Transport Protocol (L4-Proto) [uint8]: Shall be set to the transport layer protocol
(ISO/OSI layer 4) based on the IANA/IETF types (0x11: UDP). -- 只能是UDP tcp没有组播
• Transport Protocol Port Number (L4-Port) [uint16]: Shall be set to the port of the
layer 4 protocol.

SOME/IP-SD IPv4 Multicast Option shall be as shown in Figure 5.11


[PRS_SOMEIPSD_00847]
Upstream requirements: RS_SOMEIPSD_00003

The IPv4-Address field [32 bits] of the IPv4 Multicast Option shall be set according the
following rules:
• If a server service transmits a SubscribeEventgroupAck then the field shall be set
to the configured multicast IP address of the corresponding provided Eventgroup
(server multicast endpoint).
• If a client service transmit a SubscribeEventgroup or StopSubscribeEventgroup,
then the field shall be set to the configured multicast IP address of the corresponding consumed Eventgroup (client service multicast endpoint).
上面有讲

[PRS_SOMEIPSD_00848]
Upstream requirements: RS_SOMEIPSD_00003

The Port Number field [16 bits] of the IPv4 Multicast Option shall be set according the
following rules:
• If a server service transmits a SubscribeEventgroupAck then the field shall be set
to the configured port of the corresponding provided Eventgroup (server multicast
endpoint).
• If a client service transmits a SubscribeEventgroup or StopSubscribeEventgroup,
then the field shall be set to the configured port of the corresponding consumed
Eventgroup (client service multicast endpoint).
上面有讲

客户释放规范 一般单播的port和 组播的port 要分开

5.1.2.4.6 IPv6 Multicast Option -- IPv6 组播选项
IPv6的配置和注意事项 和IPv4相同,只是IP地址格式不同
The IPv6 Multicast Option is either transmitted by the server service (server multicast
endpoint) or by the client service (client service multicast endpoint):
• If it is transmitted by the server service, then a server announces the IPv6 multicast address, the transport layer protocol (ISO/OSI layer 4), and the port number,
to where the multicast events and multicast-notification-events are transmitted to.
• If it is transmitted by the client service, then a client indicates the IPv6 multicast address, the transport layer protocol (ISO/OSI layer 4), and the port number, where a client expects to receive multicast events and multicast-notificationevents.
[PRS_SOMEIPSD_00331]
Upstream requirements: RS_SOMEIPSD_00003
The IPv6 Multicast Option shall use the Type 0x16.
[PRS_SOMEIPSD_00332]
Upstream requirements: RS_SOMEIPSD_00003
The IPv6 Multicast Option shall specify the IPv6-Address, the transport layer protocol
(ISO/OSI layer 4) used, and its Port Number.

[PRS_SOMEIPSD_00333]
Upstream requirements: RS_SOMEIPSD_00003
The Format of the IPv6 Multicast Option shall be as follows:
• Length [uint16]: Shall be set to 0x0015.
• Type [uint8]: Shall be set to 0x16.
• Discardable Flag [1 bit]: Shall be set to 0.
• Bit 1 to bit 7 are reserved and shall be 0.
• IPv6-Address [uint128]: Shall transport the multicast IP-Address as 16 Bytes.
• Reserved [uint8]: Shall be set to 0x00.
• Transport Protocol (L4-Proto) [uint8]: Shall be set to the transport layer protocol
(ISO/OSI layer 4) based on the IANA/IETF types (0x11: UDP).
• Transport Protocol Port Number (L4-Port) [uint16]: Shall be set to the port of the
layer 4 protocol.

SOME/IP-SD IPv6 Multicast Option shall be as shown in Figure 5.12.

[PRS_SOMEIPSD_00849]
Upstream requirements: RS_SOMEIPSD_00003
The IPv6-Address field [128 bits] of the IPv6 Multicast option shall be set according
the following rules:
• If a server service transmits a SubscribeEventgroupAck then the field shall be set
to the configured multicast IP address of the corresponding provided Eventgroup
(server multicast endpoint).
• If a client service transmits a SubscribeEventgroup or StopSubscribeEventgroup,
then the field shall be set to the configured IP multicast address of the corresponding consumed Eventgroup (client service multicast endpoint).
[PRS_SOMEIPSD_00850]
Upstream requirements: RS_SOMEIPSD_00003
The Port Number field [16 bits] of the IPv6 Multicast Option shall be set according the
following rules:
• If a server service transmits a SubscribeEventgroupAck then the field shall be set
to the configured port of the corresponding provided Eventgroup (server multicast
endpoint).
• If a client service transmits a SubscribeEventGroup or StopSubscribeEventGroup, then the field shall be set to the configured port of the corresponding
consumed Eventgroup (client service multicast endpoint).

[PRS_SOMEIPSD_00545]
Upstream requirements: RS_SOMEIPSD_00003
IPv6 Multicast Options shall be referenced by SubscribeEventgroup or by StopSubscribeEventgroup or by SubscribeEventgroupAck entries:
• If it is referenced by a SubscribeEventgroup entry, it describes the client service
multicast endpoint (i.e. destination IP address and destination port), where the
multicast events shall be received by the client.
• If it is referenced by a StopSubscribeEventgroup entry, it reflects the intent to
stop the subscription of a client which has subscribed before via a client service
multicast multicast endpoint (i.e. destination IP address and destination port) to
the given event group.
• If it is referenced by a SubscribeEventgroupAck entry, it describes the server
multicast endpoint (i.e. destination IP address and destination port), where a
server shall transmit the multicast events to.

5.1.2.4.7 IPv4 SD Endpoint Option -- IPv4代理选项
The IPv4 SD Endpoint Option is used to transport the endpoint (i.e. IP-Address and
Port) of the senders SD implementation. This is used to identify the SOME/IP-SD
Instance even in cases in which the IP-Address and/or Port Number cannot be used.
Note:
This is used to identify the SOME/IP-SD Instance even in cases in which the IP-
Address and/or Port Number cannot be used. A use case would be a proxy service
discovery on one ECU which handles the multicast traffic for another ECU.

这个是IP代理选项,此选项位于选项数组最前面 ,依赖type=0x24标识,此选项不是任何entry的配置。
当发送端 和 接收端之间 需要代理或NAT转发时,接收端必须指到发送端的真实地址,对着这个真实地址和端口发送 才能被转发过去,否则直接发给代理是没用的。

SD报文的发送端 如果知道自己的报文 需要被代理,则需要在配置项中把自己的IP和端口添加到配置数组的首项中,这样经过转发后 接收端回复时能按照真实的IP 端口进行回复。


[PRS_SOMEIPSD_00547]
Upstream requirements: RS_SOMEIPSD_00006, RS_SOMEIPSD_00010
The IPv4 SD Endpoint Option may be included in any SD message up to 1 time.
这个选项最多只能被SD报文引用包含一次,这也容易理解 因为被代理的源地址 只有一个。

[PRS_SOMEIPSD_00650]
Upstream requirements: RS_SOMEIPSD_00006, RS_SOMEIPSD_00010
The IPv4 SD Endpoint Option shall only be included if the SOME/IP-SD message is
transported over IPv4.
这个选项 只能被通过IPv4传输的SD 报文包含,否则就矛盾了

[PRS_SOMEIPSD_00856]
Upstream requirements: RS_SOMEIPSD_00006, RS_SOMEIPSD_00010
do A receiver shall ignore all IPv4 SD Endpoint Options received over IPv6.
这个选项被IPv6协议携带传输 则应该忽略这个IPv4选项。

[PRS_SOMEIPSD_00651]
Upstream requirements: RS_SOMEIPSD_00006, RS_SOMEIPSD_00010
The IPv4 SD Endpoint Option shall be the first option in the options array, if existing.
选项只能放到最前面,也容易理解 因为解析端每解析一个选项 可能就会立即根据选项的IP来组装回复的报文。
所以 如果这个选线没有在最前面 对导致组装的回复报文IP配错

[PRS_SOMEIPSD_00854]
Upstream requirements: RS_SOMEIPSD_00006, RS_SOMEIPSD_00010
A receiver shall ignore all IPv4 SD Endpoint Options that are located after the first
position of the options array.
如果这个选项 没有在options数组第一个位置时 ,被解析到 则忽略整个选项。

[PRS_SOMEIPSD_00548]
Upstream requirements: RS_SOMEIPSD_00006, RS_SOMEIPSD_00010
The IPv4 SD Endpoint Option shall not be referenced by any SD Entry.
这个选项 不被任何 entry 引用。

[PRS_SOMEIPSD_00857]
Upstream requirements: RS_SOMEIPSD_00006, RS_SOMEIPSD_00010
A receiver shall ignore all references to the IPv4 SD Endpoint Option by Entries.
所有引用这个选项的 entry 应该被忽略。

[PRS_SOMEIPSD_00549]
Upstream requirements: RS_SOMEIPSD_00006, RS_SOMEIPSD_00010
If the IPv4 SD Endpoint Option is included in the SD message, the receiving SD
Service Instance shall use the content of this option instead of the Source IP Address
and Source Port for answering this SD message and for identifying the sender-receiver
relation for reboot detection according to [PRS_SOMEIPSD_00631].
Note:
This is important for answering the received SD message (e.g. Offer after Find or
Subscribe after Offer or Subscribe Ack after Subscribe) as well as the reboot detection
(channel based on SD Endpoint Option and not out addresses).
用这个选项的IP port 替换整条报文的 源地址 源Port进行回复。
SOME/IP头reboot标志位生效的 的源地址Port 也是这个sd选项中对应的。


[PRS_SOMEIPSD_00550]
Upstream requirements: RS_SOMEIPSD_00006, RS_SOMEIPSD_00010
The IPv4 SD Endpoint Option shall use the Type 0x24. -- 固定值
[PRS_SOMEIPSD_00551]
Upstream requirements: RS_SOMEIPSD_00006, RS_SOMEIPSD_00010
The IPv4 SD Endpoint Option shall specify the IPv4-Address, the transport layer protocol (ISO/OSI layer 4) and Port Number of the sender used for Service Discovery.
[PRS_SOMEIPSD_00552]
Upstream requirements: RS_SOMEIPSD_00006, RS_SOMEIPSD_00010
The Format of the IPv4 SD Endpoint Option shall be as follows:
• Length [uint16]: Shall be set to 0x0009. -- 固定值
• Type [uint8]: Shall be set to 0x24. -- 固定值
• Discardable Flag [1 bit]: Shall be set to 0. -- 固定值
• Bit 1 to bit 7 are reserved and shall be 0. -- 固定值
• IPv4-Address [uint32]: Shall transport the unicast IP-Address of SOME/IP-SD as
four Bytes. 
• Reserved [uint8]: Shall be set to 0x00. -- 固定值
• Transport Protocol (L4-Proto) [uint8]: Shall be set to the transport layer protocol
of SOME/IP-SD (currently: 0x11 UDP). -- 建议值
• Transport Protocol Port Number (L4-Port) [uint16]: Shall be set to the transport
layer port of SOME/IP-SD (currently: 30490). -- 建议值

5.1.2.4.8 IPv6 SD Endpoint Option -- IPv6代理选项
和上面IPv4 SD 端点选项 功能一样 ,就IP地址和type不一样
The Ipv6 SD Endpoint Option is used to transport the endpoint (i.e. IP-Address and
Port) of the senders SD implementation. This is used to identify the SOME/IP-SD
Instance even in cases in which the IP-Address and/or Port Number cannot be used.
SOME/IP-SD IPv6 SD Endpoint Option is shown in Figure 5.14
Note:
A use case would be a proxy service discovery on one ECU which handles the multicast traffic for another ECU.


[PRS_SOMEIPSD_00554]
Upstream requirements: RS_SOMEIPSD_00006, RS_SOMEIPSD_00010
The IPv6 SD Endpoint Option may be included in any SD message up to 1 time.
[PRS_SOMEIPSD_00654]
Upstream requirements: RS_SOMEIPSD_00006, RS_SOMEIPSD_00010
The IPv6 SD Endpoint Option shall be the first option in the options array, if existing.
[PRS_SOMEIPSD_00855]
Upstream requirements: RS_SOMEIPSD_00006, RS_SOMEIPSD_00010
A receiver shall ignore all IPv6 SD Endpoint Options that are located after the first
position of the options array.
[PRS_SOMEIPSD_00555]
Upstream requirements: RS_SOMEIPSD_00006, RS_SOMEIPSD_00010
The IPv6 SD Endpoint Option shall not be referenced by any SD Entry.
[PRS_SOMEIPSD_00859]
Upstream requirements: RS_SOMEIPSD_00006, RS_SOMEIPSD_00010
A receiver shall ignore all references to the IPv6 SD Endpoint Option by Entries.
[PRS_SOMEIPSD_00556]
Upstream requirements: RS_SOMEIPSD_00006, RS_SOMEIPSD_00010
If the IPv6 SD Endpoint Option is included in the SD message, the receiving SD Service Instance shall use the content of this option instead of the Source IP Address and
Source Port for answering this SD messages and for identifying the sender-receiver
relation for reboot detection according to [PRS_SOMEIPSD_00631].

[PRS_SOMEIPSD_00557]
Upstream requirements: RS_SOMEIPSD_00006, RS_SOMEIPSD_00010
The IPv6 SD Endpoint Option shall use the Type 0x26.
[PRS_SOMEIPSD_00558]
Upstream requirements: RS_SOMEIPSD_00006, RS_SOMEIPSD_00010
The IPv6 SD Endpoint Option shall specify the IPv6-Address, the transport layer protocol (ISO/OSI layer 4) and Port Number of the sender used for Service Discovery.
[PRS_SOMEIPSD_00559]
Upstream requirements: RS_SOMEIPSD_00006, RS_SOMEIPSD_00010
The Format of the IPv6 SD Endpoint Option shall be as follows:
• Length [uint16]: Shall be set to 0x0015.
• Type [uint8]: Shall be set to 0x26.
• Discardable Flag [1 bit]: Shall be set to 0.
• Bit 1 to bit 7 are reserved and shall be 0.
• IPv6-Address [uint128]: Shall transport the unicast IP-Address of SOME/IP-SD
as 16 Bytes.
• Reserved [uint8]: Shall be set to 0x00.
• Transport Protocol (L4-Proto) [uint8]: Shall be set to the transport layer protocol
of SOME/IP-SD (currently: 0x11 UDP).
• Transport Protocol Port Number (L4-Port) [uint16]: Shall be set to the transport
layer port of SOME/IP-SD (currently: 30490).

[PRS_SOMEIPSD_00837]
Upstream requirements: RS_SOMEIPSD_00006, RS_SOMEIPSD_00010
The IPv6 SD Endpoint Option shall only be included if the SOME/IP-SD message is
transported over IPv6.
[PRS_SOMEIPSD_00860]
Upstream requirements: RS_SOMEIPSD_00006, RS_SOMEIPSD_00010
A receiver shall ignore all IPv6 SD Endpoint Options received over IPv4.