# A Method for Translating Automotive Body-Related CAN Messages Based on Labeled Bits
## 3 Methodology
### Labeling and Filtering  
In this phase, the bit-flip rate is used to label the messages corresponding to the IDs appearing in the CAN traces and filter the candidate messages based on the labeling results. The main flow is shown in Figure 4.  
First, the valid IDs are extracted from each dataset, and the messages are grouped according to the IDs. Then, for each dataset grouped by ID, the message data fields are sorted by timestamps. After that, to quickly and efficiently filter CAN messages for body \begin{table}
\begin{tabular}{c c} \hline \hline
**Automotive Features** & **Body Operation** \\ \hline Light & Hazard Lights, Left Turn Signal, Right Turn Signal, Low Beam Light, \\  & High Beam Light, Fog Light, Emergency Flasher \\ Wiper & Low Windshield Wipers, High Windshield Wipers \\ Pedal & Brake Pedal, Accelerator Pedal \\ Gear & Gear \\ Seat Belt & Driver’s Seat Belt, Passenger’s Seat Belt \\ Door & Driver’s Door, Passenger’s Door, Left Back Door, \\ Right Back Door, All Doors Closed, Trunk \\ \hline \hline \end{tabular}
\end{table} 
Table 1: Vehicle-body-related functions and operations. Figure 4: Labeling and filtering process. related purposes, the bit flip rate is calculated for each message corresponding to each ID, and each bit is labeled based on the results of this calculation. Calculating the bit flip rate is the most intuitive way to characterize the change in each bit. First, Equation (1) is used to calculate the number of flips of the \(j\)th bit in the message with ID \(n\) (\(BFN_{n},j\)), and the standard CAN protocol with a bit length of 64 bits is taken as an example, where \(|id_{n}|\) indicates the number of messages with ID \(n\) and \(V_{n,i,j}\) indicates the value of the \(j\)th bit in the \(i\)-th message with ID \(n\). After that, Equation (2) is used to get the flip rate \(BFR_{n,j}\) of the \(j\)th bit in the message with ID \(n\). By traversing all bits in each legal ID in the CAN traffic, the flip rate of each bit in each message can be obtained. In this step, we perform the bit flip rate calculation operation for each ID appearing in the three datasets (\(\Omega_{s}\), \(\Omega_{m}\), \(\Omega_{b}\)) to get the flip rate of each ID corresponding to the message. \[BFN_{n,j}=\sum_{i=1}^{|id_{n}|-1}1\quad if\quad V_{n,i,j}\
eq V_{n,i+1,j} \tag{1}\]  
\[BFR_{n,j}=\frac{BFN_{n,j}}{|id_{n}|} \tag{2}\]  
After that, the data bits of each ID is labeled based on the result of the bit flip rate calculation in the three datasets. Table 2 shows the mapping between the labels of the bits corresponding to each ID and the results of the bit-flip rate calculation in each dataset. First, the bits in all three datasets with a bit flip rate of 0 are labeled \"None\". Second, the label is kept consistent with the dataset for the bits with a non-zero bit flip rate in only one of the datasets. In addition, bits with non-zero results in any two data sets are labeled \"Double\". Finally, the bits with non-zero results in all three datasets are labeled \"All\". Figure 5 shows the process and outcomes of label mapping for the bit-flip rate inversion of the message with the ID 0x225. Based on the labeling results, our method can more quickly filter out messages related to car body behavior and the bits in the message data fields that control or represent the body state than other methods. The analysis of the tags revealed that bits with only B tags are most likely to handle/represent the state of the car body and can be directly used as valid bits in the candidate messages. The bits with other labels are related to driving, the stationary state, CTR, and checksum. \begin{table}
\begin{tabular}{c c} \hline
**Bit-Flip Calculation Results** & **Label Results** \\ \hline Bit-flip rate is 0 in all datasets & None \\ Non-zero results exist only in \(\Omega_{s}\) & S \\ Non-zero results exist only in \(\Omega_{m}\) & M \\ Non-zero results exist only in \(\Omega_{b}\) & B \\ Non-zero results in only two datasets & Double \\ Non-zero results in all datasets & All \\ \hline \end{tabular}
\end{table}