【AUTOSAR.相關(guān)】-創(chuàng)新互聯(lián)

介紹

AUTOSAR (AUTomotive Open System ARchitecture) is a worldwide development partnership of vehicle manufacturers, suppliers, service providers and companies from the automotive electronics, semiconductor and software industry.
這是一個由整車廠,零配件供應(yīng)商,以及軟件、電子、半導體公司合起來成立的組織,從2003年以來, 致力于汽車電子行業(yè)提供一個開放、標準的軟件架構(gòu)。
核心成為有9個,分別為:博世,大陸,大眾,豐田,通用,PSA,福特,寶馬,奔馳。

成都創(chuàng)新互聯(lián)公司長期為數(shù)千家客戶提供的網(wǎng)站建設(shè)服務(wù),團隊從業(yè)經(jīng)驗10年,關(guān)注不同地域、不同群體,并針對不同對象提供差異化的產(chǎn)品和服務(wù);打造開放共贏平臺,與合作伙伴共同營造健康的互聯(lián)網(wǎng)生態(tài)環(huán)境。為寶豐企業(yè)提供專業(yè)的網(wǎng)站設(shè)計制作、網(wǎng)站制作,寶豐網(wǎng)站改版等技術(shù)服務(wù)。擁有10多年豐富建站經(jīng)驗和眾多成功案例,為您定制開發(fā)。SOMEIP

SOMEIP : Scalable service-Oriented MiddlewarE over IP

SOMEIP 通信單元理解:

  • SOMEIP 面向 service ,和service 相對的就是需要申請服務(wù)和訂閱需求的client。
  • 提供service 服務(wù)的 是一個個 servcie instance ,每個servcie instance 有一個 servcie id , 和 client 的client id 相對應(yīng)。
  • service 提供 interface 可以通過 service discover 協(xié)議廣播出去。
  • service interface 包括提供的method,field 和 event服務(wù)。 event服務(wù)通過eventgroup 進行組訂閱,避免event 服務(wù)碎片化。
  • Field 有 setter 、gettter、notifier 可選組成,至少有一個。
  • Setter 、getter 以及 method ,notifier 和一組 message 相對應(yīng)。
  • 一組 messages 里邊 對應(yīng)notifier 只提供單項的event 服務(wù)。 setter ,getter 消息組 包括request 和 response message。
  • message 中 包括 some/ip header 和 payload。 payload 根據(jù)具體情況進行區(qū)分。

SOMEIP 協(xié)議已經(jīng)有開源實現(xiàn), ghub 項目地址 : https://github.com/GENIVI/vsomeip。

SOME/IP Header在這里插入圖片描述

PayLoad 根據(jù)不同的應(yīng)用場景再進行區(qū)分。
針對各個字段理解如下:

Message ID

MessageID 是一個籠統(tǒng)的概念,因為 SOMEIP 是面向service 的, 一般 MessageID 會進一步分解為 service ID 和 method ID 或者 event ID。 如圖所示:
在這里插入圖片描述
在這里插入圖片描述

Length

Length field shall contain the length in Byte starting from Request ID/Client ID until the end of the SOME/IP message.

Request ID

PRS_SOMEIP_00043: The Request ID shall be unique for a provider- and subscriber-combination ,這一句應(yīng)該是說對于 provider,針對同一個 subscriber 針對不通的method 類請求,要使用不同的 request ID,這個ID 是 subscriber 自己生成的。 包括請求里邊的session ID 也是 subscriber 自己生成的。 對于 subscriber 它不關(guān)系 這個request ID,response的時候,直接copy 對應(yīng)的字段,填進去即可。
那么 有沒有 可能provider 收到兩個 request_ID 是一樣的消息呢? 有可能, 收到,反正它也不關(guān)注。 PRS_SOMEIP_00704 做了response 的說明。只是copy 過來,填進去。 區(qū)分不同的client 實體,是通過 udp 或tcp 的通信協(xié)議地址來的。 針對同一個client 中不通進程的請求,應(yīng)該是通過udp或 tcp 的port 進去分析, 不同線程的請求,是通過 client_id 來區(qū)分的。 我是這樣理解的。

Request ID 是 Client 用來請求 method 時區(qū)分不通的 method ,同時也要能區(qū)分不同的 client.
在 AUTOSAR 中 將Request ID 分成兩部分。
在這里插入圖片描述

Protocol Version

The Protocol Version identifies the used SOME/IP Header format
針對SOMEIP 頭的版本定義,方便對頭進行解析。

Interface version

針對 Service 做的版本定義,一般應(yīng)該都是1。用來做,針對service 的的向后兼容。
Interface Version shall be an 8 Bit field that contains the Major
Version of the Service Interface

Message Type

用來定義不通的Message ,如是Request 還是 Response,是正常response 還是異常 Response。Request 是否需要 Response等。
在這里插入圖片描述
在這里插入圖片描述
SOME/IP-TP: 非tcp 的 在SOMEIP 棧解決的分段協(xié)議, 全稱: Transporting large SOME/IP messages of UDP.
TP header OFFSET 的理解

TP header ,放在 SOMEIP header之后, payload 之前, 包括 一個 offerset value, 由于offset 占用的是高28位,第二個字節(jié)的高四位協(xié)議要求填0, 所以 第一個字節(jié) 的值的單位 是 16個字節(jié) 。 比如 協(xié)議上列舉的1392 ,第一個字節(jié) 是 0x57. 加上第二個字節(jié)高四位 ,就是 “0101 0111 0000” 。 0x57 就是 協(xié)議上說的 87。

PayLoad

PayLoad 大不超過1400字節(jié), 是為了后續(xù) header 變化做了預(yù)留。
The size of the SOME/IP payload field depends on the transport protocol used. With UDP the SOME/IP payload shall be between 0 and 1400 Bytes. The limitation to 1400 Bytes is needed in order to allow for future changes to protocol stack (e.g. changing to IPv6 or adding security means).

PayLoad 主要是解決parameter的序列化問題。核心就是序列化的規(guī)則(要考慮到解析效率,所以一般都需要進行對齊)。
對齊的意義:
There are processor architectures which can access data more efficiently (i.e. master) when they start at addresses which are multiples of a certain number (e.g multiples of 32 Bit).
要對齊進行 Padding,padding的東西一般都要丟棄,解析一般只管自己要的,其他都丟棄(前提是message 相關(guān)字段檢查沒問題)。
Paramter 可以分為 固定長度考慮和非固定長度考慮,固定長度的,可以考慮不用長度前綴,非固定長度的必須要有長度前綴,方便進行數(shù)據(jù)分割解析。
在這里插入圖片描述
The serialization of a struct shall be close to the in-memory layout. This means, only the parameters shall be serialized sequentially into the buffer. Especially for structs it is important to consider the correct memory alignment.
Struct 由于嵌套存在嵌套,尤其是內(nèi)部有array 或者 strings 類型的,長度不固定。 當前也有固定長度的struct ,但是大部分可能不太固定。

  • 正常struct 序列化
    在這里插入圖片描述
    Data ID,其實就是TAG,類似于 asn.1 TLV結(jié)構(gòu)中的T值。序列化的時候考慮T值,方便后續(xù)向后兼容(因為以前的內(nèi)容可以按照T值去檢索,而不用考慮在struct中的位置)。那么 Data ID 如何解析呢? Data ID 長度固定,為兩個字節(jié)(PRS_SOMEIP_00202)。 TAG 16bit 結(jié)構(gòu)如下:
  • reserved (Bit 7 of the first byte)
  • wire type (Bit 6-4 of the first byte)
  • Data ID (Bit 3-0 of the first byte and bit 7-0 of the second byte)
    在這里插入圖片描述
    Wire Type: include whether use length ,and length of length if length field exist.
    在這里插入圖片描述

Wire Type 協(xié)議描述如下:
wire type 4 ensures the compatibility with the current approach where the size of length fields is statically configured. This approach has the drawback that changing the size of the length field during evolution of interfaces is always incompatible. Thus, wire types 5, 6 and 7 allow to encode the size of the used length field in the transferred byte stream. A serializer may use this, if the statically configured size of the length field is not sufficient to hold the current size of the data struct.
在這里插入圖片描述在這里插入圖片描述
在這里插入圖片描述

String

String 分為 fixed 和 dynamic 的。 String 一般序列化結(jié)構(gòu)是 BOM(Byte order Mark)+ content + 結(jié)束符。 結(jié)束符根據(jù)是否 UTF-8 可以分為 “\0” 或者 “\0\0”,動態(tài)的String 需要在BOM 之前加上 length 字段。

Array

Array 不管是否fixed ,都要帶 length 。
在這里插入圖片描述
在這里插入圖片描述

Enumerate

枚舉定義使用 unsigned int 序列化。

Bitfield

Bitfield 轉(zhuǎn)化為 UNIT8,UNIT16,UNIT32等完成。

Union

Union 結(jié)構(gòu)如下:

  1. Length field [32 bit] //使用configuration 規(guī)定字段長度。
  2. Type field [32 bit]
  3. Data including padding [sizeof(padding) = length - sizeof(data)]

Pading Like this:
在這里插入圖片描述

SOMEIP-SD

Someip-SD 是SOMEIP 的一個子協(xié)議,是在SOMEIP 協(xié)議層實現(xiàn)的一個 Discover 協(xié)議,主要解決 service 發(fā)現(xiàn) ,事件訂閱管理等服務(wù)區(qū)。 有了SD 協(xié)議, SOMEIP的應(yīng)用場景更加靈活。

SOMEIP-SD Header

在這里插入圖片描述
Flags 字段定義:
在這里插入圖片描述

  • RebootFlag: 表示Service 的一個狀態(tài) , 當Sevice session id 出現(xiàn)整體切換的時候,rebootFlag 要配合進行切換。 比如 Service Initial 后 sessionID 從最小開始不斷增加,這些消息默認rebootflag為1, 如果session 到大,進行wrap 重新counter,就需要rebootflag =0 .
  • Unicast Flag 應(yīng)用場景有限?
Entry format

Entry 可以分為兩類,一類是 Service Entry ,另外一類是 EventGroup 訂閱。

  • Service Entry:
    在這里插入圖片描述

Type: 用來區(qū)分 ServiceEntry 類型; encodes FindService (0x00), OfferService (0x01) and StopOfferService (0x01) 。
Index of 1st options:這個值表示的是后續(xù)options 中的索引。

service entry 中包含的主要是一些ID 管理和識別類消息,其他entry content 需要通過options 進行存放。 這個是用來描述1st 在options 中的位置。 不用看,options 也是一個數(shù)據(jù),數(shù)據(jù)長度通過option 中的length來控制。(entry 大小固定為16個字節(jié),所以前邊+length 就可以知道 optional 的起始位置)。

#of opt 1: 定義 index of 1st options index 以后用了多少個option。0 表示沒有option。 and Index of 1st Options 要設(shè)置為0。
TTL: entry 的 lifetime ,不是太理解?

  • EventGroup Entry
    在這里插入圖片描述
    Type : encodes Subscribe (0x06), StopSubscribeEventgroup (0x06),SubscribeAck (0x07) and SubscribeEventgroupNack (0x07)
    Counter:Is used to differentiate identical Subscribe Eventgroups of the same subscriber. Set to 0x0 if not used.
Optional Array Optional Format:
  • Length [uint16]: Specifies the length of the option in Bytes.
  • Type [uint8]: Specifying the type of the option.
ValueType Name
1Configuration Option
2Load Balancing Option
4IPv4 Endpoint Option
6IPv6 Endpoint Option
  • Discardable Flag [1 bit]: Specifies if the option can be discarded.
  • Bit 1 to bit 7 are reserved and shall be 0.
Configuration Option

在這里插入圖片描述

Load Balance option

在這里插入圖片描述

IPv4 Endpoint Option

在這里插入圖片描述

IPv4 Endpoint Option

在這里插入圖片描述

參考及連接

AutoSAR 官網(wǎng)連接: https://www.autosar.org
wireshark SOMEIP: https://www.cnblogs.com/fll0601/p/16058136.html

vsomeip:

Git hub 地址
https://github.com/COVESA/vsomeip
windows: doxygen+graphviz生成工程中的類繼承樹及函數(shù)調(diào)用圖
http://t.zoukankan.com/chenyang920-p-5730149.html
graphviz 下載:
https://graphviz.org/download/
doxygen 下載:
https://www.doxygen.nl/download.html

你是否還在尋找穩(wěn)定的海外服務(wù)器提供商?創(chuàng)新互聯(lián)www.cdcxhl.cn海外機房具備T級流量清洗系統(tǒng)配攻擊溯源,準確流量調(diào)度確保服務(wù)器高可用性,企業(yè)級服務(wù)器適合批量采購,新人活動首月15元起,快前往官網(wǎng)查看詳情吧

網(wǎng)站欄目:【AUTOSAR.相關(guān)】-創(chuàng)新互聯(lián)
標題路徑:http://muchs.cn/article22/cedccc.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供電子商務(wù)、定制網(wǎng)站、自適應(yīng)網(wǎng)站、虛擬主機網(wǎng)站建設(shè)、微信公眾號

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)

成都定制網(wǎng)站建設(shè)