SOME/IP--协议英文原文讲解10

news2025/2/23 6:55:43

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

1. SOME/IP协议讲解

2. SOME/IP-SD协议讲解

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


4.2.2 Request/Response Communication

One of the most common communication patterns is the request/response pattern.
One communication partner (Client) sends a request message, which is answered by
another communication partner (Server).
最常用的通信模型 就是 请求/响应模型,client请求 server回复响应.

[PRS_SOMEIP_00920]发送请求包 按照下面的步骤 就没错
Upstream requirements: RS_SOMEIP_00007
For the SOME/IP request message the client has to do the following for payload and
header:
• Construct the payload
• Set the Message ID based on the method the client wants to call
• Set the Length field to 8 bytes (for the part of the SOME/IP header after the length
field) + length of the serialized payload
8个字节是header length字段 后面的长度 
  +
payload的长度
• Optionally set the Request ID to a unique number (shall be unique for client only)
• Set the Protocol Version according [PRS_SOMEIP_00052]
• Set the Interface Version according to the interface definition
• Set the Message Type to REQUEST (i.e. 0x00)
• Set the Return Code to 0x00

[PRS_SOMEIP_00921]
Upstream requirements: RS_SOMEIP_00028, RS_SOMEIP_00007
To construct the payload of a request message, all input or inout arguments of the
method shall be serialized according to the order of the arguments within the signature
of the method.
不管是请求还是响应的参数列表 ,在序列化payload的时必须要按照规范的参数顺序进行序列化。

[PRS_SOMEIP_00922]
Upstream requirements: RS_SOMEIP_00007
The server builds the header of the response based on the header of the client’s
request and does in addition:
• Construct the payload
• take over the Message ID from the corresponding request
• Set the length to the 8 Bytes + new payload size
8个字节是header length字段 后面的长度 
  +
payload的长度
• take over the Request ID from the corresponding request
• Set the Message Type to RESPONSE (i.e. 0x80) or ERROR (i.e. 0x81)
• set Return Code to a return code according to [PRS_SOMEIP_00191].

[PRS_SOMEIP_00923]
Upstream requirements: RS_SOMEIP_00028, RS_SOMEIP_00007
To construct the payload of a response message, all output or inout arguments of the
method shall be serialized according to the order of the arguments within the signature
of the method.

[PRS_SOMEIP_00927]
Upstream requirements: RS_SOMEIP_00007
A server shall not sent a response message for a request with a specific Request ID
until the corresponding request message has been received.
如果client请求的 requestID 与pending的回复中的requestID 重复,则忽略这个消息 不做回复。

[PRS_SOMEIP_00928]
Upstream requirements: RS_SOMEIP_00007
A client shall ignore the reception of a response message with a specific Request ID,
when the corresponding request message has not yet been sent completely.
client收到重复的 requestID 的回复不做处理

4.2.3 Fire&Forget Communication

Requests without response message are called fire&forget.
不需要响应的请求 称为 fire&forget 很多需求规范也可以简写为F&F

[PRS_SOMEIP_00924] 组装格式如下
Upstream requirements: RS_SOMEIP_00006
For the SOME/IP request-no-return message the client has to do the following for
payload and header:
• Construct the payload
• Set the Message ID based on the method the client wants to call
• Set the Length field to 8 bytes (for the part of the SOME/IP header after the length
field) + length of the serialized payload
8个字节是header length字段 后面的长度 
  +
payload的长度
• Optionally set the Request ID to a unique number (shall be unique for client only)
• Set the Protocol Version according [PRS_SOMEIP_00052]
• Set the Interface Version according to the interface definition
• Set the Message Type to REQUEST_NO_RETURN (i.e. 0x01)
• Set the Return Code to 0x00

[PRS_SOMEIP_00171]
Upstream requirements: RS_SOMEIP_00006
Fire & Forget messages shall not return an error. Error handling and return codes
shall be implemented by the application when needed.
没有错误返回 上层应用自己记录处理

4.2.4 Notification Events

Notifications describe a general Publish/Subscribe-Concept. Usually the server publishes a service to which a client subscribes. On certain cases the server will send the
client an event, which could be for example an updated value or an event that occurred.
SOME/IP is used only for transporting the updated value and not for the publishing and
subscription mechanisms. These mechanisms are implemented by SOME/IP-SD.
服务端给向自己订阅的client端 发布 事件, 这些事件可能是周期 或者变化事件。
订阅的逻辑是在SOME/IP-SD协议中实现

[PRS_SOMEIP_00925]
Upstream requirements: RS_SOMEIP_00004
For the SOME/IP notification message the server has to do the following for payload
and header:
• Construct the payload
• Set the Message ID based on the event the server wants to send
• Set the Length field to 8 bytes (for the part of the SOME/IP header after the length
field) + length of the serialized payload
• Set the Client ID to 0x00. Set the Session ID according to
[PRS_SOMEIP_00932], [PRS_SOMEIP_00933], and [PRS_SOMEIP_00521].
In case of active Session Handling the Session ID shall be incremented upon
each transmission.
clientID  --- 设置为0
SessionID -- 按照之前的规范 要递增

• Set the Protocol Version according [PRS_SOMEIP_00052]
• Set the Interface Version according to the interface definition
• Set the Message Type to NOTIFICATION (i.e. 0x02)
• Set the Return Code to 0x00

[PRS_SOMEIP_00926]
Upstream requirements: RS_SOMEIP_00004
The payload of the notification message shall consist of the serialized data of the
event.
payload 要按照要求 序列化数据

[PRS_SOMEIP_00930]
Upstream requirements: RS_SOMEIP_00042
When more than one subscribed client on the same ECU exists, the system shall handle the replication of notifications in order to save transmissions on the communication
medium.

This is especially important, when notifications are transported using multicast messages

这段内容([PRS_SOMEIP_00930])描述了在 **SOME/IP** 中,当同一 ECU(电子控制单元)上有多个订阅客户端时,系统应如何处理通知消息的复制,以减少通信介质上的传输负载。以下是详细解释:

---

### 核心要求
1. **多客户端订阅**:
   - 当同一 ECU 上有多个客户端订阅了相同的服务或事件时,系统需要高效地处理通知消息的复制和分发。

2. **减少传输负载**:
   - 系统应优化通知消息的传输,避免在通信介质上重复发送相同的通知消息。
   - 特别是在使用 **组播(multicast)** 传输通知消息时,这种优化尤为重要。

---

### 关键点
1. **通知消息的复制**:
   - 当多个客户端订阅了相同的服务或事件时,服务端可能会生成相同的通知消息。
   - 系统需要在 ECU 内部复制这些通知消息,而不是通过通信介质多次发送。

2. **组播传输的优化**:
   - 组播是一种高效的通信方式,允许将单个消息发送给多个接收方。
   - 如果通知消息通过组播传输,系统应确保同一 ECU 上的多个客户端共享同一组播消息,而不是为每个客户端单独发送。

3. **通信介质的负载**:
   - 减少重复传输可以显著降低通信介质的负载,提高网络效率。
   - 这对于资源受限的嵌入式系统(如汽车电子系统)尤为重要。

---

### 实现建议
1. **ECU 内部消息复制**:
   - 在 ECU 内部实现消息复制机制,确保多个客户端可以共享同一通知消息。
   - 例如,使用共享内存或消息队列来分发通知消息。

2. **组播消息的共享**:
   - 如果通知消息通过组播传输,ECU 应确保所有订阅客户端都能接收到同一组播消息。
   - 避免为每个客户端单独发送组播消息。

3. **订阅管理**:
   - 实现高效的订阅管理机制,跟踪哪些客户端订阅了哪些服务或事件。
   - 在通知消息生成时,根据订阅列表进行消息分发。

4. **性能优化**:
   - 在 ECU 内部优化消息复制和分发的性能,确保实时性和低延迟。
   - 避免因消息复制导致的性能瓶颈。

---

### 示例场景
假设一个 ECU 上有三个客户端(Client A、Client B 和 Client C)订阅了同一个服务的事件通知。

#### 传统方式(未优化):
- 服务端为每个客户端单独发送通知消息,导致通信介质上传输三次相同的消息。

#### 优化方式:
1. 服务端通过组播发送一次通知消息。
2. ECU 接收到组播消息后,在内部复制并分发给 Client A、Client B 和 Client C。
3. 通信介质上只传输一次通知消息,减少了传输负载。

---

### 总结
[PRS_SOMEIP_00930] 强调了在 SOME/IP 中,当同一 ECU 上有多个订阅客户端时,系统应优化通知消息的复制和分发,以减少通信介质上的传输负载。特别是在使用组播传输通知消息时,这种优化可以显著提高网络效率和系统性能。实现时需要注意 ECU 内部的消息复制机制、组播消息的共享以及订阅管理的高效性。

4.2.4.1 Strategy for sending notifications

For different use cases different strategies for sending notifications are possible. The
following examples are common:
• Cyclic update — send an updated value in a fixed interval (e.g. every 100 ms for
safety relevant messages with Alive)
• Update on change — send an update as soon as a "value" changes (e.g. door
open)
• Epsilon change — only send an update when the difference to the last value is
greater than a certain epsilon. This concept may be adaptive, i.e. the prediction is
based on a history; thus, only when the difference between prediction and current
value is greater than epsilon an update is transmitted.
notifications 通知的 三种发送策略
1. 周期
2. 变化
3. 门限 -- 接触几家车企的规范 没看到使用这个

4.2.5 Fields

A field represents a status and has a valid value. The consumers subscribing for the
field instantly after subscription get the field value as an initial event.
一个Field 代表一种状态 并带有个有效值
client第一次订阅后 能立刻收到event的值

[PRS_SOMEIP_00179]
Upstream requirements: RS_SOMEIP_00009
A field shall be a combination of getter, setter and notification event.
Field是 getter / setter / notify的集合体

[PRS_SOMEIP_00180]
Upstream requirements: RS_SOMEIP_00009
A field without a setter and without a getter and without a notifier shall not exist. The
field shall contain at least a getter, a setter, or a notifier.
field 至少含有 getter/ setter/ notify 一种

[PRS_SOMEIP_00181]
Upstream requirements: RS_SOMEIP_00009
The getter of a field shall be a request/response call that has an empty payload in the
request message and the value of the field in the payload of the response message.
getter的 请求报文 不能带参数 ,只能响应包中携带返回值

[PRS_SOMEIP_00182]
Upstream requirements: RS_SOMEIP_00009
The setter of a field shall be a request/response call that has the desired value of the
field in the payload of the request message and the value that was set to the field in
the payload of the response message.
Note:
If the value of the request payload was adapted (e.g. because it was out of limits) the
adapted value will be transported in the response payload.
setter有请求 有响应。
请求 是想要设置的值。
返回 是设置后的实际值(如果请求的值超范围 server端会把调整后的值返回回去)

[PRS_SOMEIP_00909]
Upstream requirements: RS_SOMEIP_00002, RS_SOMEIP_00009
The notifier shall send an event message that transports the value of the field to the
client when the client subscribes to the field.
谁订阅field给谁发送 事件

[PRS_SOMEIP_00183]
Upstream requirements: RS_SOMEIP_00005, RS_SOMEIP_00009
The notifier shall send an event message that transports the value of a field and shall
follow the rules for events. Sending strategies include on change, on epsilon change,
and cyclic sending.
field的notify 发送事件 也是支持这三种模式:
周期 、变化、门限

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

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

相关文章

前端面试-网络协议篇

1.http网络协议中post和get有什么区别 在HTTP网络协议中,POST和GET主要有以下区别: 参数传递方式: GET:参数附加在URL后面,如example.com?key1value1&key2value2 。POST:参数放在HTTP请求体中。 数据…

1.1 go环境搭建及基本使用

golang下载地址: Download and install - The Go Programming Language (google.cn) 验证安装是否成功: go version 查看go环境 go env 注意:Go1.11版本之后无需手动配置环境变量,使用go mod 管理项目,也不需要把项目放到GO…

Gemini 2.0助力科学突破,AI联合科学家系统登场

每周跟踪AI热点新闻动向和震撼发展 想要探索生成式人工智能的前沿进展吗?订阅我们的简报,深入解析最新的技术突破、实际应用案例和未来的趋势。与全球数同行一同,从行业内部的深度分析和实用指南中受益。不要错过这个机会,成为AI领…

京东外卖骑手全部缴纳五险一金

刘强东这步棋,直击700万骑手软肋? 今天,京东突然甩出一张底牌:自2025年3月1日起,外卖全职骑手全员缴纳五险一金,兼职骑手配套意外医疗双保险。 消息一出,直接炸了外卖江湖。要知道&#xff0c…

百度云DeepSeek一体机:百舸、千帆和一见介绍及区别对比

百度智能云DeepSeek一体机百舸、千帆和一见,搭载昆仑芯等国产自研算力芯片,可支持在单机环境下一键部署DeepSeek R1/V3全系列模型。百度云服务器网bdyfwq.com分享百度智能云官方发布的百舸DeepSeek一体机、千帆DeepSeek一体机和一见DeepSeek一体机配置介…

【算法】直接插入排序、折半插入排序、希尔排序

1 直接插入排序 时间复杂度:O(N^2) 空间复杂度:O(1) 稳定性:稳定 元素集合越接近有序,直接插入排序算法的时间效率越高 1.1直接插入排序思想 把待排序的记录按其关键码值的大小逐个插入到一个已经排好序的有序序列中&#xff…

使用API有效率地管理Dynadot域名,为域名部署DNS安全拓展(DNSSEC)

关于Dynadot Dynadot是通过ICANN认证的域名注册商,自2002年成立以来,服务于全球108个国家和地区的客户,为数以万计的客户提供简洁,优惠,安全的域名注册以及管理服务。 Dynadot平台操作教程索引(包括域名邮…

【排版教程】如何在Word/WPS中优雅的插入参考文献

材料展示 随便选取一段综述内容,以及对应的参考文献,如下图所示: 1 参考文献编辑 首先对参考文献部分进行编辑,将其设置自动编号 在段落中,选择悬挂缩进 在编号中,设置自定义编号,然后按照…

神经形态视觉的实时动态避障系统:突破传统SLAM的响应延迟瓶颈

引言:机器人感知的实时性挑战 斯坦福机器人实验室采用异步脉冲神经网络处理DVS事件相机数据后,动态障碍物响应延迟从34ms降至0.9ms。在20m复杂场景避障测试中,基于神经形态芯片的路径规划系统将SLAM更新频率提升至10kHz,较传统GP…

Linux操作系统4-进程间通信5(共享内存实现两个进程通信)

上篇文章:Linux操作系统4-进程间通信4(共享内存原理,创建,查看,命令)-CSDN博客 本篇Gitee仓库:myLerningCode/l24 橘子真甜/Linux操作系统与网络编程学习 - 码云 - 开源中国 (gitee.com) 本篇重…

RFID测温技术:电力设备安全监测的新利器

在当今高度依赖电力的现代化社会中,稳定且可靠的电力供应是社会运转的基石。电力设备作为电力系统的关键核心,其运行状态直接关乎电力供应的品质。然而,电力设备长期运行过程中,受到诸如过载、接触不良以及环境因素等多重影响&…

(一)趣学设计模式 之 单例模式!

目录 一、啥是单例模式?二、为什么要用单例模式?三、单例模式怎么实现?1. 饿汉式:先下手为强! 😈2. 懒汉式:用的时候再创建! 😴3. 枚举:最简单最安全的单例&a…

自动化办公|xlwings生成图表

在日常的数据分析和报告生成中,Excel图表是一个非常重要的工具。它能够帮助我们直观地展示数据,发现数据中的规律和趋势。然而,手动创建和调整图表往往耗时且容易出错。幸运的是,借助Python的xlwings库,我们可以自动化…

Docker基于Ollama本地部署大语言模型

一、Ollama介绍 Ollama 是一个开源的大型语言模型(LLM)平台,旨在简化大型语言模型在本地环境中的运行、管理和交互。通过Ollama,用户可以轻松加载和使用各种预训练的语言模型,执行诸如文本生成、翻译、代码编写、问答…

centos9安装k8s集群

以下是基于CentOS Stream 9的Kubernetes 1.28.2完整安装流程(containerd版): 一、系统初始化(所有节点执行) # 关闭防火墙 systemctl disable --now firewalld# 关闭SELinux sed -i "s/SELINUXenforcing/SELINU…

pytest下allure

import pytestdef test_case01():用例01~print(用例01)class Test_mokuai01:def test_case02(self):用例02~print(用例02)if __name____main__:#pytest.main([-vs,test_sample-2.py])pytest.main([-vs,test_sample-2.py,--allure-dir,./result2])#生成allure报告,参…

JVM预热

阿里电商平台每年的各种大促活动,对于Java技术来说,其中重要一个操作环节就是预热操作。 目录 预热是什么?为什么要预热? java 程序不预热和预热的调用对比 预热是什么? 预热是指,在 JVM 启动后&#xff0…

【JavaWeb12】数据交换与异步请求:JSON与Ajax的绝妙搭配是否塑造了Web的交互革命?

文章目录 🌍一. 数据交换--JSON❄️1. JSON介绍❄️2. JSON 快速入门❄️3. JSON 对象和字符串对象转换❄️4. JSON 在 java 中使用❄️5. 代码演示 🌍二. 异步请求--Ajax❄️1. 基本介绍❄️2. JavaScript 原生 Ajax 请求❄️3. JQuery 的 Ajax 请求 &a…

网页制作06-html,css,javascript初认识のhtml如何建立超链接

超链接有外部链接、电子邮件链接、锚点链接、空链接、脚本链接 一、内部链接 与自身网站页面有关的链接被称为内部链接 1、创建内部链接 1&#xff09;语法&#xff1a; <a href"链接地址"> …… </a> 2&#xff09;举例应用&#xff1a; 3&#xf…

代码讲解系列-CV(七)——前沿论文复现

文章目录 一、论文速览1.1 确定baseline1.2 DepthMaster: Taming Diffusion Models for Monocular Depth Estimation 二、数据环境搭建2.1 环境搭建2.2 数据权重 三、推理debug3.1 单图推理3.2 数据集验证 四、模型训练4.1 数据读取4.2 训练流程 五、作业 一、论文速览 1.1 确…