# MAC-Based Compression Ratio Improvement for CAN Security
## 4 Simulation  
In this section, we present the MATLAB simulation results using CAN data from Kia Sorento vehicle and an LS Mtron tractor. MATLAB simulations were performed on a computer equipped with an Intel(R) i5-9600 KF CPU @3.70 Ghz. The transmission and reception flows shown in Figures 5 and 6 were programmed in MATLAB. The automobile dataset was used for the AI/ML based driver classification challenge track in '2018 Information Security R&D dataset challenge' in South Korea and can be downloaded from the site introduced in [31]. The compression ratio in this simulation is defined as follows:  
\[\text{Comp. ratio}=\left(1-\frac{\text{bytes of compressed data}}{\text{bytes of original data}}\right)\times 100\%. \tag{7}\]  
Tables 5 and 6 show the length (in bytes) of compressed data using the Triple ID algorithm and the proposed algorithm in a Kia Sorento, respectively. A total of 1,295,920 frames with 8 CAN IDs were used for the simulation. The simulation results in Tables 5 and 6 are summarized in Tables 7 and 8. Table 7 shows the difference in compression ratios between the Triple ID algorithm and the proposed algorithm for each ID. It can be seen that a higher compression ratio can be obtained by the proposed algorithm, ranging from a maximum of 17.94% to a minimum of 0.10% (average 8.07%). In the case of the Triple ID algorithm, a total of 10,367,360 bytes in the data field are compressed into 1,335,718 bytes, showing a compression ratio of 89.54%. On the other hand,  
\begin{table}
\begin{tabular}{c c c c c c c c c c c} \hline \hline \multirow{2}{*}{**ID**} & \multirow{2}{*}{**No. of Frames**} & \multicolumn{8}{c}{**No. of Occurrences by Compressed Data Length**} \\ \cline{3-11}  & & **0 Byte** & **1 Byte** & **2 Byte** & **3 Byte** & **4 Byte** & **5 Byte** & **6 Byte** & **7 Byte** & **8 Byte** \\ \hline
260 & 163,078 & 162,380 & 698 & 0 & 0 & 0 & 0 & 0 & 0 & 0 \\ \hline
2A0 & 163,078 & 163,078 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 \\ \hline
316 & 163,078 & 111,928 & 34,911 & 10,410 & 3607 & 1047 & 1115 & 60 & 0 & 0 \\ \hline
32 in the case of the proposed algorithm, the same CAN data is compressed into 247,399 bytes, showing a compression ratio of 97.61%. Therefore, an additional compression ratio of 8.07% can be obtained by the proposed algorithm. As explained in Section 2.4, it is important to compress CAN data to 4 bytes or less for communication efficiency. Table 8 summarizes the number of occurrences where the compressed data length exceeds 4 bytes. It can be seen that the proposed algorithm reduces the occurrences of compressed data exceeding 4 bytes by 73.02%, compared to the Triple ID algorithm. A simulation using an LS Mtron tractor was performed to show that the proposed algorithm can be applied to various industrial machines. Table 9 shows that the proposed algorithm can achieve higher compression ratios compared to the Triple ID algorithm, ranging from a maximum of 22.76% to a minimum of 12.50% (average 17.44%). Table 10 shows a comparison based on the compressed data length greater than 4 bytes for an LS Mtron tractor. It can be seen that the proposed algorithm reduces the occurrences of compressed data exceeding 4 bytes by 99.57%, compared to the Triple ID algorithm. The bus load is defined as  
\[\text{Busload}(\%)=\frac{\text{used capacity}}{\text{maxcapacity}}=\frac{ \text{\# bits sent}}{\text{speed}}. \tag{8}\] \begin{table}
\begin{tabular}{c c c c} \hline \hline \multirow{2}{*}{**ID**} & \multicolumn{2}{c}{**Compressed Data Length Greater than 4 Bytes**} & \multirow{2}{*}{**No. of Frames**} \\ \cline{2-3}  & **Triple ID** & **Proposed** & \\ \hline CF00300 & 1007 & 0 & 8234 \\ \hline CF00400 & 1469 & 12 & 19,119 \\ \hline CFE4523 & 50 & 0 & 4113 \\ \hline
18 FE4321 & 6 & 0 & 4090 \\ \hline
18 FEDF00 & 107 & 0 & 8127 \\ \hline
18 FE200 & 137 & 0 & 4036 \\ \hline
19 FFA030 & 12 & 0 & 4092 \\ \hline Total & 2788 (100\%) & 12 (0.43\%) & 51,811 \\ \hline \hline \end{tabular}
\end{table} 
Table 10: Comparison based on compressed data length greater than 4 bytes for an LS Mtron tractor.