【AUTOSAR.相关】-创新互联

介绍

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.
这是一个由整车厂,零配件供应商,以及软件、电子、半导体公司合起来成立的组织,从2003年以来, 致力于汽车电子行业提供一个开放、标准的软件架构。
核心成为有9个,分别为:博世,大陆,大众,丰田,通用,PSA,福特,宝马,奔驰。

成都创新互联公司长期为数千家客户提供的网站建设服务,团队从业经验10年,关注不同地域、不同群体,并针对不同对象提供差异化的产品和服务;打造开放共赢平台,与合作伙伴共同营造健康的互联网生态环境。为宝丰企业提供专业的网站设计制作、网站制作,宝丰网站改版等技术服务。拥有10多年丰富建站经验和众多成功案例,为您定制开发。SOMEIP

SOMEIP : Scalable service-Oriented MiddlewarE over IP

SOMEIP 通信单元理解:

  • SOMEIP 面向 service ,和service 相对的就是需要申请服务和订阅需求的client。
  • 提供service 服务的 是一个个 servcie instance ,每个servcie instance 有一个 servcie id , 和 client 的client id 相对应。
  • service 提供 interface 可以通过 service discover 协议广播出去。
  • service interface 包括提供的method,field 和 event服务。 event服务通过eventgroup 进行组订阅,避免event 服务碎片化。
  • Field 有 setter 、gettter、notifier 可选组成,至少有一个。
  • Setter 、getter 以及 method ,notifier 和一组 message 相对应。
  • 一组 messages 里边 对应notifier 只提供单项的event 服务。 setter ,getter 消息组 包括request 和 response message。
  • message 中 包括 some/ip header 和 payload。 payload 根据具体情况进行区分。

SOMEIP 协议已经有开源实现, ghub 项目地址 : https://github.com/GENIVI/vsomeip。

SOME/IP Header在这里插入图片描述

PayLoad 根据不同的应用场景再进行区分。
针对各个字段理解如下:

Message ID

MessageID 是一个笼统的概念,因为 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 ,这一句应该是说对于 provider,针对同一个 subscriber 针对不通的method 类请求,要使用不同的 request ID,这个ID 是 subscriber 自己生成的。 包括请求里边的session ID 也是 subscriber 自己生成的。 对于 subscriber 它不关系 这个request ID,response的时候,直接copy 对应的字段,填进去即可。
那么 有没有 可能provider 收到两个 request_ID 是一样的消息呢? 有可能, 收到,反正它也不关注。 PRS_SOMEIP_00704 做了response 的说明。只是copy 过来,填进去。 区分不同的client 实体,是通过 udp 或tcp 的通信协议地址来的。 针对同一个client 中不通进程的请求,应该是通过udp或 tcp 的port 进去分析, 不同线程的请求,是通过 client_id 来区分的。 我是这样理解的。

Request ID 是 Client 用来请求 method 时区分不通的 method ,同时也要能区分不同的 client.
在 AUTOSAR 中 将Request ID 分成两部分。
在这里插入图片描述

Protocol Version

The Protocol Version identifies the used SOME/IP Header format
针对SOMEIP 头的版本定义,方便对头进行解析。

Interface version

针对 Service 做的版本定义,一般应该都是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 栈解决的分段协议, 全称: Transporting large SOME/IP messages of UDP.
TP header OFFSET 的理解

TP header ,放在 SOMEIP header之后, payload 之前, 包括 一个 offerset value, 由于offset 占用的是高28位,第二个字节的高四位协议要求填0, 所以 第一个字节 的值的单位 是 16个字节 。 比如 协议上列举的1392 ,第一个字节 是 0x57. 加上第二个字节高四位 ,就是 “0101 0111 0000” 。 0x57 就是 协议上说的 87。

PayLoad

PayLoad 大不超过1400字节, 是为了后续 header 变化做了预留。
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的序列化问题。核心就是序列化的规则(要考虑到解析效率,所以一般都需要进行对齐)。
对齐的意义:
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 相关字段检查没问题)。
Paramter 可以分为 固定长度考虑和非固定长度考虑,固定长度的,可以考虑不用长度前缀,非固定长度的必须要有长度前缀,方便进行数据分割解析。
在这里插入图片描述
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 由于嵌套存在嵌套,尤其是内部有array 或者 strings 类型的,长度不固定。 当前也有固定长度的struct ,但是大部分可能不太固定。

  • 正常struct 序列化
    在这里插入图片描述
    Data ID,其实就是TAG,类似于 asn.1 TLV结构中的T值。序列化的时候考虑T值,方便后续向后兼容(因为以前的内容可以按照T值去检索,而不用考虑在struct中的位置)。那么 Data ID 如何解析呢? Data ID 长度固定,为两个字节(PRS_SOMEIP_00202)。 TAG 16bit 结构如下:
  • 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 协议描述如下:
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 一般序列化结构是 BOM(Byte order Mark)+ content + 结束符。 结束符根据是否 UTF-8 可以分为 “\0” 或者 “\0\0”,动态的String 需要在BOM 之前加上 length 字段。

Array

Array 不管是否fixed ,都要带 length 。
在这里插入图片描述
在这里插入图片描述

Enumerate

枚举定义使用 unsigned int 序列化。

Bitfield

Bitfield 转化为 UNIT8,UNIT16,UNIT32等完成。

Union

Union 结构如下:

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

Pading Like this:
在这里插入图片描述

SOMEIP-SD

Someip-SD 是SOMEIP 的一个子协议,是在SOMEIP 协议层实现的一个 Discover 协议,主要解决 service 发现 ,事件订阅管理等服务区。 有了SD 协议, SOMEIP的应用场景更加灵活。

SOMEIP-SD Header

在这里插入图片描述
Flags 字段定义:
在这里插入图片描述

  • RebootFlag: 表示Service 的一个状态 , 当Sevice session id 出现整体切换的时候,rebootFlag 要配合进行切换。 比如 Service Initial 后 sessionID 从最小开始不断增加,这些消息默认rebootflag为1, 如果session 到大,进行wrap 重新counter,就需要rebootflag =0 .
  • Unicast Flag 应用场景有限?
Entry format

Entry 可以分为两类,一类是 Service Entry ,另外一类是 EventGroup 订阅。

  • Service Entry:
    在这里插入图片描述

Type: 用来区分 ServiceEntry 类型; encodes FindService (0x00), OfferService (0x01) and StopOfferService (0x01) 。
Index of 1st options:这个值表示的是后续options 中的索引。

service entry 中包含的主要是一些ID 管理和识别类消息,其他entry content 需要通过options 进行存放。 这个是用来描述1st 在options 中的位置。 不用看,options 也是一个数据,数据长度通过option 中的length来控制。(entry 大小固定为16个字节,所以前边+length 就可以知道 optional 的起始位置)。

#of opt 1: 定义 index of 1st options index 以后用了多少个option。0 表示没有option。 and Index of 1st Options 要设置为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 官网连接: 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生成工程中的类继承树及函数调用图
http://t.zoukankan.com/chenyang920-p-5730149.html
graphviz 下载:
https://graphviz.org/download/
doxygen 下载:
https://www.doxygen.nl/download.html

你是否还在寻找稳定的海外服务器提供商?创新互联www.cdcxhl.cn海外机房具备T级流量清洗系统配攻击溯源,准确流量调度确保服务器高可用性,企业级服务器适合批量采购,新人活动首月15元起,快前往官网查看详情吧


标题名称:【AUTOSAR.相关】-创新互联
文章URL:http://scyanting.com/article/cedccc.html