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

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

1. SOME/IP协议讲解

2. SOME/IP-SD协议讲解

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


5.1.2.5 Service Entries
find/offer/stop offer Entries 讲解

注:find/offer/stop offer Entries 发出的报文只提供服务ID信息 说明哪个服务可以被订阅,但不提供事件组 即显示哪些事件组可以被订阅 -- 隐藏起来了。所以client订阅时要参照客户发出的矩阵表订阅。

5.1.2.5.1 Find Service Entry
find报文entry

[PRS_SOMEIPSD_00350]
Upstream requirements: RS_SOMEIPSD_00008, RS_SOMEIPSD_00021
The Find Service entry type shall be used for finding service instances and shall
only be sent if the current state of a service is unknown (no current Service Offer was
received and is still valid).
find报文是在没有offer的情况下发出的,否则不能发送find报文了

[PRS_SOMEIPSD_00351]
Upstream requirements: RS_SOMEIPSD_00008, RS_SOMEIPSD_00021
Find Service entries shall set the entry fields in the following way:
• Type shall be set to 0x00 (FindService). -- 固定值
• Service ID shall be set to the Service ID of the service that shall be found.
• Instance ID shall be set to 0xFFFF, if all service instances shall be returned. It
shall be set to the Instance ID of a specific service instance, if just a single service
instance shall be returned.
0xFFFF 找所有的Instance 或是找指定的Instance 前面文章有讲

• Major Version shall be set to 0xFF, that means that services with any version shall
be returned. If set to value different than 0xFF, services with this specific major
version shall be returned only.
匹配所有的主版本号,则设置为0xff,否则设置为需要的版本号

• Minor Version shall be set to 0xFFFF FFFF, that means that services with any
version shall be returned. If set to a value different to 0xFFFF FFFF, services
with this specific minor version shall be returned only.
道理同 上面主版本号,只不过是值大了些

• TTL is not used for FindService entries and can be set to an arbitrary value.The
field is only defined for backward compatibility, and the value shall be ignored by
the receiver of the message.
对于 find报文来说 TTL不用设置 ,接收端应该忽略此值。一般设置为0 就行。

Note: It is expected that the Major Version on client side is configured to a specific
value in normal operation since the client should look for an specific interface version.
Different Major Versions are not compatible to each other.
[PRS_SOMEIPSD_00528]
Upstream requirements: RS_SOMEIPSD_00008, RS_SOMEIPSD_00025
A sender shall not reference Endpoint Options nor Multicast Options in a Find Service
Entry.
find报文不用设置 单播、多播 选项,如果有 接收端应该忽略。
其它选项可以配置

[PRS_SOMEIPSD_00529]
Upstream requirements: RS_SOMEIPSD_00013, RS_SOMEIPSD_00025
A receiver shall ignore Endpoint Options and Multicast Options in a Find Service
Entry.
[PRS_SOMEIPSD_00530]
Upstream requirements: RS_SOMEIPSD_00013, RS_SOMEIPSD_00025
Other Options (neither Endpoint nor Multicast Options), shall still be allowed to be
used in a Find Service Entry.
[PRS_SOMEIPSD_00825]
Upstream requirements: RS_SOMEIPSD_00008, RS_SOMEIPSD_00013
When receiving a FindService Entry the Service ID, Instance ID, Major Version, and
Minor Version shall match exactly to the configured values to identify a Service Instance, except if "any values" are in the Entry (i.e. 0xFFFF for Service ID, 0xFFFF for
Instance ID, 0xFF for Major Version, and 0xFFFFFFFF for Minor Version.)
接收端接收到 find报文,对于entry中的配置项 如果是指定的值 应该精确匹配 成功后再回复offer,否则是通配值 的话就算了

[PRS_SOMEIPSD_00839]
Upstream requirements: RS_SOMEIPSD_00008, RS_SOMEIPSD_00013
If a FindService Entry is received within the Initial Wait Phase for this Server Service
Instance, it shall be ignored.
初始化阶段 收到find 应该忽略 不用先解析 等到初始化完成给回复

5.1.2.5.2 Offer Service Entry

[PRS_SOMEIPSD_00355]
Upstream requirements: RS_SOMEIPSD_00013
The Offer Service entry type shall be used to offer a service to other communication
partners.
[PRS_SOMEIPSD_00356] -- 以下为格式定义 容易理解
Upstream requirements: RS_SOMEIPSD_00013, RS_SOMEIPSD_00025
Offer Service entries shall set the entry fields in the following way:
• Type shall be set to 0x01 (OfferService).
• Service ID shall be set to the Service ID of the service instance offered.
• Instance ID shall be set to the Instance ID of the service instance that is offered.
• Major Version shall be set to the Major Version of the service instance that is
offered.
• Minor Version shall be set to the Minor Version of the service instance that is
offered.
• TTL shall be set to the lifetime of the service instance. After this lifetime the
service instance shall considered not been offered.
offer的有效期 超过后 服务会失效。
• If TTL is set to 0xFFFFFF, the Offer Service entry shall be considered valid until
the next reboot. 长期有效
• If CYCLIC_OFFER_DELAY is defined, TTL shall be greater or equal to the value
for CYCLIC_OFFER_DELAY. 客户指定这个值 则应设置 >=这个值
• TTL shall not be set to 0x000000 since this is considered to be the Stop Offer
Service Entry. 设置为0 表示stop offer 所有offer中不能设置为0.

[PRS_SOMEIPSD_00357]
Upstream requirements: RS_SOMEIPSD_00013, RS_SOMEIPSD_00025
Offer Service entries shall always reference either an IPv4 or IPv6 Endpoint Option to
signal how the service is reachable.
offer应该携带IPv4或IPv6选项 表示服务的发出方式 和 源地址源Port
[PRS_SOMEIPSD_00358]
Upstream requirements: RS_SOMEIPSD_00013, RS_SOMEIPSD_00025
For each Transport Layer Protocol needed for the service (i.e. UDP and/or TCP) an
IPv4 Endpoint option shall be added if IPv4 is supported.
[PRS_SOMEIPSD_00359]
Upstream requirements: RS_SOMEIPSD_00013, RS_SOMEIPSD_00025
For each Transport Layer Protocol needed for the service (i.e. UDP and/or TCP) an
IPv6 Endpoint option shall be added if IPv6 is supported.

[PRS_SOMEIPSD_00826]
Upstream requirements: RS_SOMEIPSD_00012, RS_SOMEIPSD_00013, RS_SOMEIPSD_00025
When receiving the initial OfferService Entry the Service ID, Instance ID, Major Version and Minor Version shall match exactly to the configured values to identify a Service Instance, except if "any values" are in the service configuration (i.e. 0xFFFF for
Instance ID and 0xFFFFFFFF for Minor Version.)
[PRS_SOMEIPSD_00827]
Upstream requirements: RS_SOMEIPSD_00012, RS_SOMEIPSD_00013, RS_SOMEIPSD_-
00025
When receiving a subsequent OfferService Entry or a StopOfferService Entry the
Service ID, Instance ID, Major Version shall match exactly to the values in the initial
OfferService entry to identify a Service Instance.
在收到offer/stopoffer时 要精确匹配Service ID, Instance ID, Major Version 检查是否是自己需要订阅的

注意:sub /suback/ subnack entry 在5.1.3.1章节讲解

5.1.2.5.3 Stop Offer Service Entry

[PRS_SOMEIPSD_00363]
Upstream requirements: RS_SOMEIPSD_00014
The Stop Offer Service entry type shall be used to stop offering service instances.
[PRS_SOMEIPSD_00364]
Upstream requirements: RS_SOMEIPSD_00014
dStop Offer Service entries shall set the entry fields exactly like the Offer Service entry
they are stopping, except:
• TTL shall be set to 0x000000. -- 和offer报文基本一致除了要改TTL为0x000000

[PRS_SOMEIPSD_00840]
Upstream requirements: RS_SOMEIPSD_00014
A StopOfferService (type 0x01), shall carry, i.e. reference, the same options as the
entries trying to stop.


5.1.2.5.4 Usage of Options in Entries 不同类型entries 携带 options数量说明

5.1.2.6 Endpoint Handling for Services and Events -- 针对offer报文的讲解

[PRS_SOMEIPSD_00476]
Upstream requirements: RS_SOMEIPSD_00025
The Service Discovery shall overwrite IP Addresses and Port Numbers with those
transported in Endpoint and Multicast Options if the statically configured values are
different from those in these options.
Note: In other words if a mix of a static and dynamic configuration exists (static configuration that defines the communication endpoints exists and at the same time endpoint
options are exchanged via SD messages at runtime) and the endpoint options in the
static configuration are different from the endpoint options received via SD then the
endpoints options received over SD take precedence over the preconfigured endpoint
options.
SD报文中的IP和PORT 如果和静态配置不一致 则优先动态报文中的 ,并覆盖静态配置
其它 选项 也是优先 动态 覆盖静态

[PRS_SOMEIPSD_00360]
Upstream requirements: RS_SOMEIPSD_00013, RS_SOMEIPSD_00025
The IP addresses and port numbers of the Endpoint Options shall also be used for
transporting events and notification events.
端点选项的ip /port用来 传输 事件、通知。

[PRS_SOMEIPSD_00361]
Upstream requirements: RS_SOMEIPSD_00013, RS_SOMEIPSD_00025
In case of UDP the endpoint option shall be used for the source address and the
source port of the events and notification events, it is also the address the client can
send method requests to.
offer报文中 UDP 端点选项的ip /port用来 传输 事件、通知。同时client也可通过这个IP、PORT请求method
[PRS_SOMEIPSD_00362]
Upstream requirements: RS_SOMEIPSD_00013, RS_SOMEIPSD_00025
In case of TCP the endpoint option shall be used for the IP address and port the client
needs to open a TCP connection in order to receive events using TCP.
接收TCP的事件时 要先 tcp握手建链

[PRS_SOMEIPSD_00801]
Upstream requirements: RS_SOMEIPSD_00013, RS_SOMEIPSD_00025
SOME/IP shall allow services to use UDP and TCP at the same time.
同一个服务 可以同时使用TCP和UDP

[PRS_SOMEIPSD_00802]
Upstream requirements: RS_SOMEIPSD_00013, RS_SOMEIPSD_00025
Which message is sent by which underlying transport protocol shall be determined by
configuration: A Service can use UDP and TCP endpoints at the same time. But per
element of the service it shall to be configured whether TCP or UDP is used.
Note: It needs to be restricted in the configuration which methods and which events
are provided over TCP/UDP. This also means that the same event can not be provided
over TCP and UDP.
虽然可以同时使用TCP和UDP,但是对于具体的event/method/field 只能用一种 不能同时支持。

5.1.2.6.1 Service Endpoints offer报文中 服务端点的讲解

The referenced Endpoint Options of the Offer Service entries denotes the
• IP Address and Port Numbers the service instance is reachable at the server.
• IP Address and Port Numbers the service instance sends the events from.
offfer中的 端点选项中IP、PORT 是可以被访问的 且是用来发送events的,
注:如果这个报文没有events 就不用发送offer

[PRS_SOMEIPSD_00480]
Upstream requirements: RS_SOMEIPSD_00013, RS_SOMEIPSD_00025
Events of this service instance shall not be sent from any other Endpoints than those
given in the Endpoint Options of the Offer Service entries.
事件不能通过除了选项中描述的IP、PORT之外的地址发送。

[PRS_SOMEIPSD_00481]
Upstream requirements: RS_SOMEIPSD_00013, RS_SOMEIPSD_00025
If an ECU offers multiple service instances, SOME/IP messages of these service
instances shall be differentiated by the information transported in the Endpoint Options
referenced by the Offer Service entries.
就算是同一服务的不同instance 在同一个ECU中,端点的IP、PORT也必须不一样。

5.1.2.6.2 Eventgroup Endpoints

[PRS_SOMEIPSD_00484]
Upstream requirements: RS_SOMEIPSD_00015, RS_SOMEIPSD_00025
The Endpoint Options referenced in the Subscribe Eventgroup entries shall also be
used to send unicast UDP or TCP SOME/IP events for this Service Instance.
Thus the Endpoint Options referenced in the Subscribe Eventgroup entries are the IP
Address and the Port Numbers on the client side.

client发送订阅包时,订阅entry对应的Option中的ip/port 是client的,用以发送udp单播或TCP的events

[PRS_SOMEIPSD_00486]
Upstream requirements: RS_SOMEIPSD_00015, RS_SOMEIPSD_00025
TCP events are transported using the TCP connection the client has opened to the
server before sending the Subscribe Eventgroup entry.

如果被订阅的事件是TCP协议类型,则client在发送订阅之前 要先完成TCP的握手建链过程。

[PRS_SOMEIPSD_00487]
Upstream requirements: RS_SOMEIPSD_00015, RS_SOMEIPSD_00025
The initial value of field notifiers (i.e., fields and not pure events) shall be transported
using unicast from Server to Client.
field notifiers 的别订阅后的首次通知 要通过单播、TCP形式发送(单对单)
因为有可能有多个client订阅 如果广播通知的话 会让已经订阅的client端多次收到

[PRS_SOMEIPSD_00488]
Upstream requirements: RS_SOMEIPSD_00015, RS_SOMEIPSD_00025
Subscribe Eventgroup Ack entries shall reference up to 1 Multicast Option for the
Internet Protocol used (IPv4 or IPv6).
suback报文中的 最多只能包含一条 多播option(ipv4/ipv6)

[PRS_SOMEIPSD_00489]
Upstream requirements: RS_SOMEIPSD_00015, RS_SOMEIPSD_00025
The Multicast Option shall be set to UDP as transport protocol.
多播用于UDP -- 前面已经讲过了

[PRS_SOMEIPSD_00490]
Upstream requirements: RS_SOMEIPSD_00015, RS_SOMEIPSD_00025
The client shall open the Endpoint specified in the Multicast Option referenced by the
Subscribe Eventgroup Ack entry as fast as possible to not miss multicast events.
Example: Figure 5.15 shows an example with the different Endpoint and a Multicast
client收到订阅回复中有携带了server events的多播地址时,要尽快配置加入到这个组播中,否则有可能错过组播的事件

Option:
• The Server offers the Service Instance on Server UDP-Endpoint SU and Server
TCP-Endpoint ST
    服务端 offer 提供服务 option中有UDP 也有TCP
• The Client opens a TCP connection client 发起并完成tcp连接
• The Client sends a Subscribe Eventgroup entry with Client UDP-Endpoint CU
(unicast) and a Client TCP-Endpoint CT. client发送订阅报文 携带client的UDP单播 IP+PORT 以及 TCP IP+PORT
• The Server answers with a Subscribe Eventgroup Ack entry with Multicast MU
    服务端单播回复 client 订阅ack 包 ,并携带一个server的组播地址(有的事件要通过组播发送)
Then the following operations happen: 可能会有下面的交互情况
• The Client calls a method on the Server 
  client向server请求method(使用UDP协议 -- 因为假设矩阵中这个Method配置UDP协议)
  
• Request is sent from CU to SU and Response from SU to CU
    server用UDP单播回复
• For TCP this would be: Request dyn to ST and RESPONSE from ST to CT
    也有可能client向server请求TCP协议的method, server通过TCP 回复
• The Server sends a Unicast UDP Event: SU to CU
    server发送UDP单播事件
• The Server sends a Unicast TCP Event: ST to CT
    server发送TCP事件
• The Server sends a Multicast UDP Event: SU to MU
    server发送UDP广播事件
Keep in mind that Multicast Endpoints use a Multicast IP Address on the receiver side,
i.e. the client, and TCP cannot be used for Multicast communication.
    client端配置加入组播 但不能用组播主动发送消息。

注:30490端口号 是协议建议的SOME/IP组播端口号 

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/diannao/70906.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

APNG格式图片文件大小优化方案 转WEBP

文章目录 原因过程相关下载相关文档后记 原因 页面上有个特效动画,PNG文件,APNG格式,13M大小,太占用内容了,要优化一下。 过程 直接上命令吧 ffmpeg -i input.apng -vf "formatrgba" -loop 0 output.web…

个人电脑小参数GPT预训练、SFT、RLHF、蒸馏、CoT、Lora过程实践——MiniMind图文版教程

最近看到Github上开源了一个小模型的repo,是真正拉低LLM的学习门槛,让每个人都能从理解每一行代码, 从零开始亲手训练一个极小的语言模型。开源地址: GitHub - jingyaogong/minimind: 🚀🚀 「大模型」2小时…

PHP Zip 文件处理指南

PHP Zip 文件处理指南 引言 ZIP文件是一种流行的压缩格式,广泛用于文件压缩和归档。PHP作为一门强大的服务器端脚本语言,提供了丰富的类和方法来处理ZIP文件。本文将详细介绍PHP中ZIP文件的处理方法,包括创建、添加文件、提取文件以及压缩和…

Java使用ZXing库生成带有Logo的二维码图片,并去除白边动态伸缩上传到阿里云OSS

文章目录 引言二维码基本原理1、二维码概述2、QR Code结构3、错误纠正级别 QR Code生成技术1、ZXing库2、生成二维码的步骤 图像处理技术1、嵌入Logo2. 去除白边 阿里云OSS基本概念1、OSS概述2. 主要功能3. 基本概念 实战演示1、依赖库2、类结构3、生成普通二维码4. 去除白边5、…

AI工具箱最新使用教程

先克隆项目 电脑需要先安装 git ,安装的画看这个 Git安装教程(超详细)。 git镜像 git clone https://github.com/Escaflowne1985/MyToolsWebBackendUser.gitgitee镜像 git clone https://gitee.com/escaflowne/MyToolsWebBackendUser.git…

Android-创建mipmap-anydpi-v26的Logo

利用 Android Studio 自动创建 创建新项目:打开 Android Studio,点击 “Start a new Android Studio project” 创建新项目。在创建项目的过程中,当设置Target SDK Version为 26 或更高版本时,Android Studio 会在项目的res目录下…

SEO炼金术(4)| Next.js SEO 全攻略

在上一篇文章 SEO炼金术(3)| 深入解析 SEO 关键要素 中,我们深入解析了 SEO 关键要素,包括 meta 标签、robots.txt、canonical、sitemap.xml 和 hreflang,并探讨了它们在搜索引擎优化(SEO)中的作…

面试葵花宝典之React(持续更新中)

1.谈谈你对HOC的理解 定义: 高阶组件是一个接收组件作为参数并返回新组件的函数,用于复用组件逻辑,遵循纯函数特性(无副作用,输出仅依赖输入)。 组合性:可嵌套使用多个 HOC。 HOC(…

数据安全管理的AI工具有哪些?

数据安全管理的AI工具在不断演进,它们凭借强大的算法和学习能力,为企业筑起了一道坚不可摧的数字防线。 在数据安全管理领域,AI工具的应用日益广泛,以下是一些常见的工具及其功能: AI驱动的数据分类与标记 工具: Micr…

Matplotlib 绘图标记

Matplotlib 绘图标记 引言 Matplotlib 是一个功能强大的 Python 绘图库,广泛用于数据可视化。在 Matplotlib 中,绘图标记(markers)是数据点在图表中显示的方式。正确的使用绘图标记可以增强图表的可读性和美观性。本文将详细介绍…

【DeepSeek问答】QProcess::start是异步的吗?会使UI卡顿吗?

好的,我现在需要回答用户关于QProcess::start是否是异步的,以及它是否会导致UI卡顿的问题。用户之前已经询问过如何开发一个调用7-Zip的Qt应用,并且我给出了示例代码。现在用户可能在使用过程中遇到了问题,或者想更深入了解QProce…

Android 常用命令和工具解析之存储相关

1 基本概念 2 命令解读 2.1 adb shell df df 命令主要用于需要检查文件系统上已使用和可用的磁盘空间的数量。如果没有指定文件名,则显示在当前所有挂载的文件系统上可用的空间。其原理是从proc/mounts 或 /etc/mtab 中检索磁盘信息。 注意:df命令并…

使用ZFile打造属于自己的私有云系统结合内网穿透实现安全远程访问

文章目录 前言1.关于ZFile2.本地部署ZFile3.ZFile本地访问测试4.ZFile的配置5.cpolar内网穿透工具安装6.创建远程连接公网地址7.固定ZFile公网地址 前言 在数字化的今天,我们每个人都是信息的小能手。无论是职场高手、摄影达人还是学习狂人,每天都在创造…

HarmonyOS 5.0应用开发——鸿蒙接入高德地图实现POI搜索

【高心星出品】 文章目录 鸿蒙接入高德地图实现POI搜索运行结果:准备地图编写ArkUI布局来加载HTML地图 鸿蒙接入高德地图实现POI搜索 在当今数字化时代,地图应用已成为移动设备中不可或缺的一部分。随着鸿蒙系统的日益普及,如何在鸿蒙应用中…

idea + Docker + 阿里镜像服务打包部署

一、下载docker desktop软件 官网下载docker desktop,需要结合wsl使用 启动成功的画面(如果不是这个画面例如一直处理start或者是stop需要重新启动,不行就重启电脑) 打包成功的镜像在这里,如果频繁打包会导致磁盘空间被占满,需…

IP---网络类型

这只是IP的其中一块内容-网络类型,IP还有更多内容可以查看IP专栏,前一章内容为访问服务器流程,可通过以下路径查看IP----访问服务器流程-CSDN博客,欢迎指正 2.网络类型 网络类型---根据二层(数据链路层)所…

【监督学习】ARIMA预测模型步骤及matlab实现

ARIMA预测模型 ARIMA预测模型1.算法步骤2.参数选择(1)拖尾截尾判断法(2) AIC 准则(3) BIC 准则 3.MATLAB 实现参考资料 ARIMA预测模型 #mermaid-svg-mDhjwpnuA0YcEGnE {font-family:"trebuchet ms",verdana,arial,sans-serif;font-size:16px;fill:#333;}#mermaid-svg…

使用git管理uniapp项目

1.本地管理 1. 在项目根目录中新建 .gitignore 忽略文件,并配置如下: # 忽略 node_modules 目录 /node_modules /unpackage/dist 2. 打开终端,切换到项目根目录中,运行如下的命令,初始化本地 Git 仓库&#xff1…

Unity中动态切换光照贴图的方法

关键代码:LightmapSettings.lightmaps lightmapDatas; LightmapData中操作三张图:lightmapColor,lightmapDir,以及一张ShadowMap 这里只操作前两张: using UnityEngine; using UnityEngine.EventSystems; using UnityEngine.UI;public cl…

C# 运算符

C# 运算符 在C#编程语言中,运算符是用于执行数学或逻辑运算的符号。它们是构建程序逻辑和表达式的基石。C#支持多种类型的运算符,包括算术运算符、关系运算符、逻辑运算符、位运算符、赋值运算符、自增自减运算符以及一些特殊运算符。 算术运算符 算术运算符用于执行基本的…