As described in this document, CanTSyn works with StbM. StbM is responsible for managing the time domain, providing an interface for CanTSyn to update the synchronized time, and providing interfaces for other users to get/notify the synchronized time. CanTSyn is responsible for time synchronization over the CAN bus.
The CanTSyn module has no dedicated partition configuration parameters; it acquires the partition distribution from the CanIfController associated with the CanTSynPort. When using a CAN hardware clock, it is necessary to consider whether the hardware supports cross-partition access.
CanTSynGlobalTimeDomin引用的CanIfCcontroller分区,为各个 port 定义全局变量分配到相应的分区及定义MainFunction。
Based on the partition of the CanIfController referenced by CanTSynGlobalTimeDomain, global variables are defined for each port and allocated to their respective partitions, and the MainFunction is defined accordingly.
The memmap file is dynamic. There are CANTSYN_START_SEC_CODE、CANTSYN_STOP_SEC_CODE、CANTSYN_START_SEC_CODE_FAST、CANTSYN_STOP_SEC_CODE_FAST、CANTSYN_START_SEC_CONFIG_DATA_32、CANTSYN_STOP_SEC_CONFIG_DATA_32、CANTSYN_START_SEC_CONFIG_DATA_UNSPECIFIED、CANTSYN_STOP_SEC_CONFIG_DATA_UNSPECIFIED、CANTSYN_START_SEC_VAR_CLEARED_GLOBAL_8、CANTSYN_STOP_SEC_VAR_CLEARED_GLOBAL_8、CANTSYN_START_SEC_VAR_CLEARED_GLOBAL_PTR、CANTSYN_STOP_SEC_VAR_CLEARED_GLOBAL_PTR、CANTSYN_START_SEC_CONST_PTR、CANTSYN_STOP_SEC_CONST_PTR、CANTSYN_START_SEC_VAR_CLEARED_GLOBAL_UNSPECIFIED、CANTSYN_STOP_SEC_VAR_CLEARED_GLOBAL_UNSPECIFIED、CANTSYN_START_SEC_VAR_CLEARED_{{PartitionName}}_UNSPECIFIED、CANTSYN_STOP_SEC_VAR_CLEARED_{{PartitionName}}_UNSPECIFIED fields.
CanTSyn can be configured as a Time Slave to receive synchronization messages from the Time Master on the same network and synchronize its own time with the master’s time.
The CanTSyn module supports the use of the CAN hardware timestamping function to obtain transmission and reception timestamps, thereby improving the accuracy of time synchronization. The prerequisite is to use a CAN controller that supports the timestamping function and to enable the hardware timestamping support option in the configuration.
Secure time synchronization is achieved by adding additional authentication information to the Follow_Up message. The security authentication information primarily consists of two parts: the Freshness Value (FV) and the Integrity Check Value (ICV).
During the process of obtaining the FV and generating or verifying the ICV, if acquisition or verification fails, the processing is skipped and the corresponding security event is reported.
The FV points to a monotonically increasing counting mechanism used to ensure the freshness of the time base, guaranteeing that the received time information does not regress in chronological order to prevent the replay of old time information. This monotonic mechanism can be implemented through an independent Message Counter (Freshness Counter) or via a Freshness Timestamp.
When transmitting a Follow_Up message, the FV corresponding to the current Timebase is obtained from the StbM via the specified API based on the configuration and attached to the Follow_Up message.
When the receiver processes the incoming Follow_Up message, it obtains the FV corresponding to the current Timebase from the StbM and uses it to construct the ICV generation message for integrity verification.
If FV acquisition fails, the ICV calculation and attachment process is skipped, and a flag is written into the Follow_Up message to indicate that the message does not possess authentication capability.
ICV refers to the calculation result of a cryptographic function, used to ensure that unauthorized modifications to the message can be detected. This cryptographic function can employ any cryptographic primitive and be implemented in combination with a corresponding cryptographic key.
The use of ICV on the receiver side is optional. To achieve greater flexibility across multiple time observation units, relevant configurations determine how messages with ICV are processed.
如果接收端不启用 ICV 校验,则可能仅使用接收到的数值,而不对 ICV 本身进行验证。
If the receiver does not enable ICV verification, it may only use the received values without verifying the ICV itself.
ICV 的计算和验证算法由 Csm 模块负责实现:
The ICV calculation and verification algorithms are implemented by the Csm module:
When the transmitter sends a Follow_Up message, after obtaining the FV, it constructs the data for ICV generation and calls the API provided by the Csm to calculate the ICV, attaching it to the authentication TLV of the Follow_Up message.
When the receiver processes the received Follow_Up message, it extracts the ICV; similarly, it must first obtain the FV and construct the data for ICV verification, then call the API provided by the Csm to verify the correctness of the ICV.
The range of the constructed data starts from a beginning byte of the Follow_Up message to the end byte of the FV field, excluding the ICV field itself.
If the configuration selects the use of a truncated FV, the full FV is used when constructing the verification data, but the truncated FV is filled into the actually transmitted Follow_Up message.
The Time Validation feature is introduced to enable the time synchronization system to detect time deviations between master and slave nodes during operation, identify time synchronization degradation or anomalies, and determine from a system-wide perspective whether a trusted and consistent time base has been established.
TimeSync 模块需要能够采集时间同步状态信息,并将这些信息提供给应用(即Validator SWC),以支持 Time Validation 功能的实现。Time Slave、Time Master 以及 Time Gateway 会从相应的 TimeSync 模块中收集时间同步过程的相关信息,例如:基于其本地的全局时间实例(通过使用 SyncLocal Time Tuple)、时间同步报文的接收时间戳、时间同步报文中的全局时间信息等,来计算时间偏差和其他相关指标。
The TimeSync module must be able to collect time synchronization status information and provide this information to the application (i.e., Validator SWC) to support the implementation of the Time Validation function. Time Slave, Time Master, and Time Gateway will collect information related to the time synchronization process from the corresponding TimeSync modules—for example, based on their local global time instances (by using SyncLocal Time Tuple), reception timestamps of time synchronization messages, and global time information within time synchronization messages—to calculate time deviations and other relevant metrics.
CanTSyn 模块通过 StbM 各个接口将各个阶段的时间同步信息传递到 StbM。
The CanTSyn module passes time synchronization information from each stage to the StbM through various StbM interfaces.
包含需要使用的宏定义,类型定义,配置结构体声明,外部函数声明(Contains macro definitions, type definitions, configuration structure declarations, and external function declarations that need to be used)
CanTSyn_Cbk.h
包含需要使用的宏定义,类型定义,配置结构体声明,外部回调函数声明(Contains macro definitions, type definitions, configuration structure declarations, and external callback function declarations that need to be used)
CanTSyn_Internal.h
包含需要使用的内部宏定义,内部类型定义,外部数据声明和外部函数声明(Contains internal macro definitions, internal type definitions, external data declarations, and external function declarations that need to be used)
CanTSyn.c
包含需要使用的宏定义,内部变量,内部函数,全局函数(Contains macro definitions, internal variables, internal functions, and global functions that need to be used)
Definition of whether or not ICV verification shall be supported.
CanTSyn_GlobalTimeTxIcvSecuredType
enum
Definition of whether or not ICV generation shall be supported.
CanTSyn_CriptographySelection
enum
This type shall define Symmetric or asymmetric cryptography selection for the ICV generation.
CanTSyn_CryptoProcessingType
enum
Define the encryption and decryption process, synchronous or asynchronous.
CanTSyn_InitStatusType
enum
define CanTSyn module initiation status
CanTSyn_MasterStatusType
enum
define CanTSyn master operation status
CanTSyn_TransmissionModeType
enum
Handles the enabling and disabling of the transmission mode.
CanTSyn_RxCsmJobType
struct
Define information about the Csm job of verification.
CanTSyn_GlobalTimeRxIcvVerificationType
struct
This type shall define the configuration of ICV verification.
CanTSyn_TxCsmJobType
struct
Define information about the Csm job of generation.
CanTSyn_GlobalTimeTxIcvGenerationType
struct
This type shall define the configuration of ICV generation.
CanTSyn_AuthenticatedFieldInofoType
struct
This type shall describe the Time Authenticated Field.
CanTSyn_CircularBufferType
struct
This type shall define the parameters of circular buffer.
CanTSyn_ICVGenarationType
struct
This type shall define the runtime variables related to ICV generation.
CanTSyn_ICVVerificationType
struct
This type shall define the runtime variables related to ICV verification.
CanTSyn_MasterTimeInfoType
struct
store the time information for a time master
CanTSyn_SlaveTimeInfoType
struct
store the time information for a time slave
CanTSyn_GlobalTimeMasterType
struct
define configuration of the global time master
CanTSyn_GlobalTimeSlaveType
struct
define configuration of the global time slave
CanTSyn_DataIDListElementType
struct
define DataIDList messages
CanTSyn_GlobalTimeDomainType
struct
define CanTSyn GlobalTimeDomain
CanTSyn_ConfigType
struct
This is the base type for the configuration of the Time Synchronization over CAN. A pointer to an instance of this structure will be used in the initialization of the Time Synchronization over CAN.
If CRC checksum is enabled, CanTSynGlobalTimeSyncDataIDList and CanTSynGlobalTimeFupDataIDListElement configuration items must be identical for the Master and Slave within the same CanTSynGlobalTimeDomainId; otherwise, the check will fail.
Add a sub-container CanTSynGlobalTimeTxIcvGeneration to CanTSynGlobalTimeMaster for configuring the relevant parameters of the Integrity Check Value transmitter side:
Add a sub-container CanTSynGlobalTimeRxIcvVerification to CanTSynGlobalTimeSlave for configuring the relevant parameters of the Integrity Check Value receiver side:
当 Can 硬件支持时间戳功能时,可以通过配置使能 CanTSynHardwareTimeStampSupport 选项来使能硬件时间戳功能.
When the CAN hardware supports the timestamping function, the hardware timestamping function can be enabled by configuring the CanTSynHardwareTimeStampSupport option.
Meanwhile, the CanIfGlobalTimeSupport option needs to be configured in the CanIf to enable global time support. (The enablement of this configuration item depends on CanIfPublicCtrlDrvVersion; controllers with older functionality do not support the hardware clock.)