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 發送事件 也是支持這三種模式:
周期 、變化、門限

本文來自互聯網用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務,不擁有所有權,不承擔相關法律責任。
如若轉載,請注明出處:http://www.pswp.cn/diannao/70441.shtml
繁體地址,請注明出處:http://hk.pswp.cn/diannao/70441.shtml
英文地址,請注明出處:http://en.pswp.cn/diannao/70441.shtml

如若內容造成侵權/違法違規/事實不符,請聯系多彩編程網進行投訴反饋email:809451989@qq.com,一經查實,立即刪除!

相關文章

Spring框架基本使用(Maven詳解)

前言: 當我們創建項目的時候,第一步少不了搭建環境的相關準備工作。 那么如果想讓我們的項目做起來方便快捷,應該引入更多的管理工具,幫我們管理。 Maven的出現幫我們大大解決了管理的難題!! Maven&#xf…

用大內存主機下載Visual Studio

用一臺內存達到128G的主機下載Visual Studio 2022,用的是公司網絡。下載速度讓我吃了一驚,沒人用網絡了?還是網站提速了?以前最大只能達到5MB/秒。記錄這段經歷,是用來分析公司網絡用的......

Ubuntu20.04.2安裝Vmware tools

軟件版本:Vmware Workstation Pro 17.6.2 操作系統鏡像文件:ubuntu-20.04.2-desktop-amd64 方式1:用iso鏡像安裝 沒用這種方法,太麻煩 方式2:用apt安裝Open VM Tools 如果你使用的是較新的Ubuntu版本(如…

Mac系統下使用Docker快速部署MaxKB:打造本地知識庫問答系統

隨著大語言模型的廣泛應用,知識庫問答系統逐漸成為提升工作效率和個人學習的有力工具。MaxKB是一款基于LLM(Large Language Model)大語言模型的知識庫問答系統,支持多模型對接、文檔上傳和自動爬取等功能。本文將詳細介紹如何在Ma…

2526考研資料分享 百度網盤

通過網盤分享的文件:01、2026【考研數學】 鏈接: https://pan.baidu.com/s/1N-TlXcCKMcX1U-KBr0Oejg?pwducbe 提取碼: ucbe 提取碼:98wg--來自百度網盤超級會員v3的分享 通過網盤分享的文件:01、2026【考研政治】 鏈接: https://pan.baidu.com/s/1N-T…

【信息系統項目管理師-案例真題】2013下半年案例分析答案和詳解

更多內容請見: 備考信息系統項目管理師-專欄介紹和目錄 文章目錄 試題一【問題? 1】(12 分)【問題? 2】(10 分)【問題 3】( 3 分 )試題二【問題? 1】(3? 分)【問題? 2】(10? 分)【問題? 3】(3? 分)【問題? 4】(9? 分)試題三【問題? 1】(12? 分)?【問題? 2】(8?…

idea連接gitee(使用idea遠程兼容gitee)

文章目錄 先登錄你的gitee拿到你的郵箱找到idea的設置選擇密碼方式登錄填寫你的郵箱和密碼登錄成功 先登錄你的gitee拿到你的郵箱 具體位置在gitee–>設置–>郵箱管理 找到idea的設置 選擇密碼方式登錄 填寫你的郵箱和密碼 登錄成功

UNIAPP開發之利用阿里RTC服務實現音視頻通話后端THINKPHP5

下面是一個使用ThinkPHP 5實現后端邏輯的示例。我們將創建一個簡單的ThinkPHP 5項目來處理生成推流和播流地址的請求。 后端部分(ThinkPHP 5) 1. 初始化ThinkPHP 5項目 首先,確保你已經安裝了Composer。然后使用Composer創建一個新的Think…

嵌入式開發崗位認識

目錄 1.核心定義2.崗位方向3.行業方向4.技術方向5.工作職責6.核心技能7.等級標準8.優勢與劣勢9.市場薪資10. 發展路徑11. 市場趨勢12. 技術趨勢 1.核心定義 嵌入式系統: 以應用為中心,以計算機技術為基礎,軟硬件可裁剪的專用計算機系統 特點…

圖解循環神經網絡(RNN)

目錄 1.循環神經網絡介紹 2.網絡結構 3.結構分類 4.模型工作原理 5.模型工作示例 6.總結 1.循環神經網絡介紹 RNN(Recurrent Neural Network,循環神經網絡)是一種專門用于處理序列數據的神經網絡結構。與傳統的神經網絡不同&#xff0c…

MySQL數據庫入門到大蛇尚硅谷宋紅康老師筆記 高級篇 part 2

第02章_MySQL的數據目錄 1. MySQL8的主要目錄結構 1.1 數據庫文件的存放路徑 MySQL數據庫文件的存放路徑:/var/lib/mysql/ MySQL服務器程序在啟動時會到文件系統的某個目錄下加載一些文件,之后在運行過程中產生的數據也都會存儲到這個目錄下的某些文件…

http 響應碼影響 video 標簽播放視頻

背景 使用后端給的文件下載接口地址實現視頻播放,但是 video 標簽一直無法播放視頻如下圖,把接口地址放到瀏覽器請求能直接下載。但就是不能播放 原因 http 響應碼不正確,返回201是無法播放視頻200可以如下圖 狀態碼的影響: 20…

OneNote手機/平板“更多筆記本”中有許多已經刪掉或改名的,如何刪除

問題描述: OneNote 在手機或平板上添加“更多筆記本”中,有許多已經刪掉或改名的筆記本!如何刪除? OR:如何徹底刪除OneNote中的筆記本? 處理做法: 這個列表對應365里面的【最近打開】&#…

LeetCode--23. 合并 K 個升序鏈表【堆和分治】

23. 合并 K 個升序鏈表 給你一個鏈表數組,每個鏈表都已經按升序排列。 請你將所有鏈表合并到一個升序鏈表中,返回合并后的鏈表。 正文 這道題有多種解決方案 堆 比較容易,又比較直觀的就是堆排序,將每個節點加入最小根堆中&…

【 Avalonia UI 語言國際化 I18n】圖文結合教學,保姆級教學,語言國際化就是這么簡單(.Net C#)

完整項目地址 github : https://github.com/Crazy-GrowUp/AvaloniaI18nTest/tree/master gitee :https://gitee.com/jack_of_disco/avalonia-i18n-test 0.項目新建 Properties 文件夾 對應的項目配置文件里面就會增加 <Folder Include"Properties\" /> 1.項…

點擊el-dialog彈框跳到其他頁面瀏覽器的滾動條消失了多了 el-popup-parent--hidden

點擊el-dialog彈框跳到其他頁面瀏覽器的滾動條消失了 在使用 el-dialog 彈框時&#xff0c;Element Plus 會在彈框打開時自動給 body 添加 el-popup-parent–hidden 類&#xff0c;以隱藏滾動條。如果在跳轉到其他頁面時滾動條沒有恢復&#xff0c;可能是因為 el-dialog 沒有正…

JWT認證機制

Session認證機制中需要配合cookie才能實現&#xff0c;由于cookie默認不支持跨域訪問&#xff0c;當涉及到前端跨域請求后端接口時&#xff0c;需要做很多額外的配置&#xff0c;才能實現跨域session認證。所以這里不推薦使用session身份認證機制&#xff0c;一般推薦使用jwt認…

netcore 啟用gzip壓縮及緩存

public void ConfigureServices(IServiceCollection services) {....// 配置gzip 與 br的壓縮等級為最優services.Configure<BrotliCompressionProviderOptions>(options > {options.Level CompressionLevel.Optimal;});services.Configure<GzipCompressionProvid…

qt:常見標簽操作,倒計時功能,進度條與日歷

1.標簽常見函數 函數功能void setext(const QString &text)設置文本QString text()const獲取文本void setPixmap(const QPixmap)與Pixmap()const設置和獲取圖像void setAlignment(Qt::Alignment alignment)設置對齊&#xff08;獲取和上面一樣&#xff09;void setWordWr…

STM32MP157A單片機移植Linux驅動

在stm32mp157a單片機移植Linux操作系統&#xff0c;并移植內核驅動&#xff0c;在應用程序中使用3個線程&#xff0c;分別實現控制單片機上3個led流水燈的功能、蜂鳴器控制的功能、風扇控制的功能。 需求整理&#xff1a; 1.驅動程序-->led1.c&#xff0c;led2.c&#xff…