当前位置: 首页 > news >正文

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

前言
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 发送事件 也是支持这三种模式:
周期 、变化、门限

相关文章:

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

前言 SOME/IP协议越来越多的用于汽车电子行业中,关于协议详细完全的中文资料却没有,所以我将结合工作经验并对照英文原版协议做一系列的文章。基本分三大块: 1. SOME/IP协议讲解 2. SOME/IP-SD协议讲解 3. python/C举例调试讲解 4.2.2 Req…...

欢乐力扣:赎金信

文章目录 1、题目描述2、 代码 1、题目描述 赎金信,给你两个字符串:ransomNote 和 magazine ,判断 ransomNote 能不能由 magazine 里面的字符构成。如果可以,返回 true ;否则返回 false 。magazine 中的每个字符只能在…...

【量化科普】Standard Deviation,标准差

【量化科普】Standard Deviation,标准差 🚀🚀🚀量化软件开通🚀🚀🚀 🚀🚀🚀量化实战教程🚀🚀🚀 在量化投资领域&#xf…...

stm32单片机个人学习笔记15(I2C通信协议)

前言 本篇文章属于stm32单片机(以下简称单片机)的学习笔记,来源于B站教学视频。下面是这位up主的视频链接。本文为个人学习笔记,只能做参考,细节方面建议观看视频,肯定受益匪浅。 STM32入门教程-2023版 细…...

网络安全防护

一:物理安全防护 直接的物理破坏所造成的损失远大于通过网络远程攻击 提高物理安全需关注的问题: 1: 服务器和安全设备是否放置在上锁的机房内? 2: 网络设备是否被保护和监控? 3: 是否有无关人员单独在敏感区域工作&…...

YOLOV7的复现过程

复现 YOLOv7 代码的步骤相对清晰,主要分为以下几个部分: 环境准备克隆 YOLOv7 仓库准备数据集训练模型验证和测试推理(Inference) 下面是一个简化的流程来帮助你复现 YOLOv7 代码: 1. 环境准备 首先,你…...

uniapp实现app的pdf预览

实现效果 文件准备 static下添加该pdf文件&#xff08;下载地址&#xff1a;https://gitee.com/shallow-winds/resource_package/tree/master/%E6%96%B9%E6%B3%95%E4%B8%80/html&#xff09; 使用web-view进行展示&#xff1a; 在这里插入代码片 <web-view :src"u…...

用Java创建一个验证码的工具类

在Java中创建一个验证码工具类&#xff0c;可以通过以下代码实现。该工具类支持生成包含字母和数字的随机验证码图片&#xff0c;并添加干扰线和噪点以提高安全性。以下是详细实现&#xff1a; 完整代码实现 import javax.imageio.ImageIO; import java.awt.*; import java.aw…...

uvm中的激励是如何发送出去的

在UVM中&#xff0c;Sequence生成的激励&#xff08;Transaction&#xff09;通过以下协作流程发送到Driver并最终驱动到DUT&#xff0c;其核心机制如下&#xff1a; --------------- --------------- ------------ ----- | Sequence | → | Seque…...

一只企鹅如何改变世界

一、历史的转折点:一只企鹅如何改变世界 1991年,芬兰大学生Linus Torvalds在邮件列表中写道:“我正在做一个自由的操作系统(只是爱好,不会像GNU那样庞大专业)”。这个后来被称为Linux内核的项目,与GNU项目的结合,点燃了开源运动的燎原之火。 关键演化: 1996年:Tux企…...

拦截器VS过滤器:Spring Boot中请求处理的艺术!

目录 一、拦截器&#xff08;Interceptor&#xff09;和过滤器&#xff08;Filter&#xff09;&#xff1a;都是“守门员”&#xff01;二、如何实现拦截器和过滤器&#xff1f;三、拦截器和过滤器的区别四、执行顺序五、真实的应用场景六、总结 &#x1f31f;如果喜欢作者的讲…...

C语言预处理学习笔记

1. 预处理器的功能 预处理器&#xff08;Preprocessor&#xff09;在编译C语言程序之前对源代码进行预处理。预处理指令以#号开头&#xff0c;主要包括文件包含、宏定义、条件编译等功能。 2. 文件包含 文件包含功能用于在一个文件中包含另一个文件的内容&#xff0c;通常用…...

LLM基础环境准备-云服务器

软件环境 腾讯云 操作系统&#xff1a; TencentOS Server 3.1 (TK4) Python: 3.9.0(使用 conda的虚拟python环境&#xff0c;可根据实际需要更换版本&#xff0c;当前使用的是3.9.0的版本) CUDA Version: 12.2&#xff08;腾讯云会自动安装&#xff09; Driver Version: 5…...

网络协议相关知识有哪些?

前言 网络协议的基础是OSI和TCP/IP模型,这两个模型是理解协议分层的关键。 正文(仅是个人理解,如有遗漏望海涵) 网络协议是网络中设备间通信的规则和标准,涉及数据传输、路由、错误控制等多个方面。以下是网络协议相关知识的系统梳理: 一、网络协议分层模型 1、OSI七…...

基于Llama 3.2-Vision的医学报告生成

记录运用大模型解决医学报告实例&#xff0c;仅介绍本地调用的情况。 前情提要 已安装 Python 显存不少于8G&#xff08;8G设备上测试成功&#xff0c;其他环境可以自行测试&#xff09;。 需要安装Ollama (Ollama 是一个允许在本地运行多模态模型的平台)。 方式1&#xff1…...

离线部署大模型:ollama+deepseek+open-webui

ollama 是一个开源的本地大语言模型运行框架&#xff0c;它提供了非常简单便捷的使用形式&#xff0c;让用户可以十分方便的在本地机器上部署和运行大型语言模型&#xff0c;从而实现免费离线的方式使用 LLM 能力&#xff0c;并确保私有数据的隐私和安全性。 1 ollama 安装 o…...

如何看nginx.conf文件?

是的&#xff0c;你的理解是对的&#xff01;在 Nginx 配置中&#xff0c;最内层的 location 确实是决定请求最终处理的“入口”。当请求进入 Nginx 时&#xff0c;Nginx 会根据请求的路径&#xff08;即 URL&#xff09;匹配 location 块&#xff0c;然后按照匹配的顺序逐层向…...

3月营销日历:开启春日盛宴,绽放生活魅力

关键营销节点∶惊蛰、女生节、妇女节、 植树节、315消费者权益日、春分 营销关键词 养生、女生魅力、感恩女性、环保、品质 01.重点关注品类 春季服饰&#xff1a;如轻薄外套、春装等&#xff0c;适合惊蛰后的市场需求&#xff1b; 美妆护肤&#xff1a;妇女节期间&#xf…...

pdf预览在vue项目中的使用兼容ie浏览器

一、下载pdf预览插件 链接: https://pan.baidu.com/s/1wuzay-saAfiqtS-efd-cvw?pwd6m78 提取码: 6m78 二、创建一个pdf文件夹&#xff0c;将下载下来的文件build和web文件夹复制到pdf文件夹下 三、项目中使用 (路径由两部分组成&#xff0c;第一部分是项目存放pdf插件的路径…...

Unity面板介绍_Project工程面板(23.1.1)

一、project(工程界面) 显示当前工程所有资源文件&#xff08;场景、脚本、音频、图片。。&#xff09; Assets资源文件、Library库文件、Project setting项目设置、Temp临时文件 二、面板大致...

后进先出(LIFO)详解

LIFO 是 Last In, First Out 的缩写&#xff0c;中文译为后进先出。这是一种数据结构的工作原则&#xff0c;类似于一摞盘子或一叠书本&#xff1a; 最后放进去的元素最先出来 -想象往筒状容器里放盘子&#xff1a; &#xff08;1&#xff09;你放进的最后一个盘子&#xff08…...

手游刚开服就被攻击怎么办?如何防御DDoS?

开服初期是手游最脆弱的阶段&#xff0c;极易成为DDoS攻击的目标。一旦遭遇攻击&#xff0c;可能导致服务器瘫痪、玩家流失&#xff0c;甚至造成巨大经济损失。本文为开发者提供一套简洁有效的应急与防御方案&#xff0c;帮助快速应对并构建长期防护体系。 一、遭遇攻击的紧急应…...

java_网络服务相关_gateway_nacos_feign区别联系

1. spring-cloud-starter-gateway 作用&#xff1a;作为微服务架构的网关&#xff0c;统一入口&#xff0c;处理所有外部请求。 核心能力&#xff1a; 路由转发&#xff08;基于路径、服务名等&#xff09;过滤器&#xff08;鉴权、限流、日志、Header 处理&#xff09;支持负…...

【Oracle APEX开发小技巧12】

有如下需求&#xff1a; 有一个问题反馈页面&#xff0c;要实现在apex页面展示能直观看到反馈时间超过7天未处理的数据&#xff0c;方便管理员及时处理反馈。 我的方法&#xff1a;直接将逻辑写在SQL中&#xff0c;这样可以直接在页面展示 完整代码&#xff1a; SELECTSF.FE…...

【Web 进阶篇】优雅的接口设计:统一响应、全局异常处理与参数校验

系列回顾&#xff1a; 在上一篇中&#xff0c;我们成功地为应用集成了数据库&#xff0c;并使用 Spring Data JPA 实现了基本的 CRUD API。我们的应用现在能“记忆”数据了&#xff01;但是&#xff0c;如果你仔细审视那些 API&#xff0c;会发现它们还很“粗糙”&#xff1a;有…...

【Zephyr 系列 10】实战项目:打造一个蓝牙传感器终端 + 网关系统(完整架构与全栈实现)

🧠关键词:Zephyr、BLE、终端、网关、广播、连接、传感器、数据采集、低功耗、系统集成 📌目标读者:希望基于 Zephyr 构建 BLE 系统架构、实现终端与网关协作、具备产品交付能力的开发者 📊篇幅字数:约 5200 字 ✨ 项目总览 在物联网实际项目中,**“终端 + 网关”**是…...

鸿蒙中用HarmonyOS SDK应用服务 HarmonyOS5开发一个生活电费的缴纳和查询小程序

一、项目初始化与配置 1. 创建项目 ohpm init harmony/utility-payment-app 2. 配置权限 // module.json5 {"requestPermissions": [{"name": "ohos.permission.INTERNET"},{"name": "ohos.permission.GET_NETWORK_INFO"…...

【Java_EE】Spring MVC

目录 Spring Web MVC ​编辑注解 RestController RequestMapping RequestParam RequestParam RequestBody PathVariable RequestPart 参数传递 注意事项 ​编辑参数重命名 RequestParam ​编辑​编辑传递集合 RequestParam 传递JSON数据 ​编辑RequestBody ​…...

OpenPrompt 和直接对提示词的嵌入向量进行训练有什么区别

OpenPrompt 和直接对提示词的嵌入向量进行训练有什么区别 直接训练提示词嵌入向量的核心区别 您提到的代码: prompt_embedding = initial_embedding.clone().requires_grad_(True) optimizer = torch.optim.Adam([prompt_embedding...

Typeerror: cannot read properties of undefined (reading ‘XXX‘)

最近需要在离线机器上运行软件&#xff0c;所以得把软件用docker打包起来&#xff0c;大部分功能都没问题&#xff0c;出了一个奇怪的事情。同样的代码&#xff0c;在本机上用vscode可以运行起来&#xff0c;但是打包之后在docker里出现了问题。使用的是dialog组件&#xff0c;…...