上一篇文章SecOC 模块介绍 我们介绍了SecOC的基本原理,本文我们介绍下SecOC中重要的一部分FVM 模块。
Autosar SecOC规范中定义了四种FVM的usecase: 基于单一计数器、基于时间戳、基于多计数器(截断)、基于多计数器(完整)。
基于单一计数器
由单一计数器组成,每次发送成功 Secured I-PDU,counter+1.
- FVM module 组Freshness Verify Value流程
if (SecOCFreshnessValueTruncLength = FreshnessValueLength)
{
FreshnessVerifyValue = FreshnessValue parsed from Secured I-PDU;
}
else
{
If (FreshnessValue parsed from Secured I-PDU > least significant bits of
FreshnessValue corresponding to SecOCFreshnessValueID)
{
Attempts = 0;
FreshnessVerifyValue = most significant bits of FreshnessValue corresponding to
SecOCFreshnessValueID | FreshnessValue parsed from Secured I-PDU;
}
else
{
Attempts = 0;
FreshnessVerifyValue = most significant bits of FreshnessValue corresponding to
SecOCFreshnessValueID + 1 | FreshnessValue parsed from payload;
}
}
- 优缺点
- 优点:实现逻辑简单,不需要时间同步
- 缺点:couter需要存储在NVM中,需要频繁写NVM。
基于时间戳
基于车内全局时间进行同步。
- FVM module 组Freshness Verify Value流程
if (SecOCFreshnessValueTruncLength = FreshnessValueLength)
{
FreshnessVerifyValue = FreshnessValue parsed from Secured I-PDU;
}
else
{
if ((most significant bits of FreshnessValue corresponding to SecOCFreshnessValueID |
FreshnessValue parsed from Secured I-PDU) < (max(0: (most significant bits of
FreshnessValue corresponding to SecOCFreshnessValueID | least significant bits of
FreshnessValue corresponding to SecOCFreshnessValueID) – SecOCRxAcceptanceWindow)))
{
Attempts = 0;
FreshnessVerifyBaseValue = most significant bits of FreshnessValue corresponding to
SecOCFreshnessValueID + 1;
}
else
{
Attempts = 0;
FreshnessVerifyBaseValue = most significant bits of FreshnessValue corresponding to
SecOCFreshnessValueID;
}
FreshnessVerifyValue = FreshnessVerifyUpperValue = FreshnessVerifyLowerValue =
FreshnessVerifyBaseValue | FreshnessValue parsed from Secured I-PDU;
}
- 优缺点
- 优点:逻辑实现简单,不需要写NVM
- 缺点:依赖各个ECU之间的时间同步
基于多计数器(截断)目前主流形式
由多个计数器组成的。这边先介绍几个概念
- FV management master ECU(FVM):负责发送同步报文(包含trip counter 和reset counter)
- Sender ECU :SecOC报文发送节点
- Receive ECU:SecOC报文接收节点
FVM应具备主同步功能和从传输同步功能。这将使其能够实现以下两种FV管理方法。
单主多从(目前主流)
多主多从
FV 组成
完整的新鲜值由同步计数器、重置计数器、消息计数器以及重置标志未组成,在Sec-IPDU中只发送消息计数器的低有效位和重置计数器,如上图中的SecOCFreshnessValueTxLength部分。
- Trip Counter(同步计数器)::FVM每次启动、休眠唤醒、复位后,IG off-> IG on后 ,同步计数器自增1,该值需要存储到NVM中。
- Reset Counter(重置计数器):FVM每次启动后,重置计数器设置为初始值1,在每个重置周期到达时,重置计数器自增1。
- Message Counter(消息计数器):SecOC I-PDU发送节点每次启动后,消息计数器重置为初始值0,发送端每次成功发送安全PDU后,消息计数器自增1。高位表示高有效位,低位表示低有效位。
- Reset Flag(重置标志值):重置计数器低有效位。
初始值及增长条件见下表
如下是官方给出的一个例子
下面介绍下各个计数器达到最大值的处理方式
- 对于FVM ECU
- Trip Counter达到最大值:Trip Counter和Reset Counter都回到初始值。
- Reset Counter到达最大值:保持在最大值
- 对于Slave ECU
- Trip Counter达到最大值:满足如下两个条件时更新
- 同步计数器最大值-“ClearAcceptanceWindow”<=Slave ECU 最新的同步计数器值< =同步计数器最大值
- 同步计数器初始值<同步报文中的同步计数器值<=同步计数器初始值+“ClearAcceptanceWindow”
注:“ClearAcceptanceWindow”:同步计数器窗口值,OEM可自定义,这是为了提供一个允许的范围(清除接受窗口),考虑到FVM ECU和Slave ECU的同步计数器在最大值附近出现偏差的情况。
- Reset Counter到达最大值:Message Counter 填充最大值
- Message Counter到达最大值:保持最大值
- Trip Counter达到最大值:满足如下两个条件时更新
同步报文格式
新鲜度值的构建
-
Sender ECU 传输新鲜度值的构建
-
Receive ECU 接收新鲜度值的构建
基于多计数器(完整)
同上面描述的多计数器基本一致,只不过在发送Sec I-PDU时,传输完整的新鲜值。
新鲜度值格式
参考文档
- AUTOSAR_SWS_SecureOnboardCommunication.pdf