Abstract
We explore bridging an experimental setup, built with real-world in-vehicle components, with the powerful and widely used vehicle simulation environment CARLA. To this end, we design a system that enables the simulator to interact directly with the experimental platform, allowing us to leverage its rich ecosystem, including interactions with vehicles, pedestrians, and infrastructure, while preserving the real-world processing and communication constraints of automotive components. Within this setup, it becomes significantly easier and safer to experiment with in-vehicle attacks, as their effects can be investigated without endangering actual vehicles or participants, while attack impact can be analyzed in a broader driving context. We also experimentally compare a lightweight intrusion detection system based on plausibility checks with a more computationally demanding machine-learning-based approach. This allows us to assess detection performance and computational requirements under different driving conditions, while accounting for the communication and processing constraints of actual automotive hardware. We further assess the feasibility of embedded IDS deployment through an extensive computational evaluation across general-purpose and automotive-grade platforms, including the NXP S12 and Infineon AURIX TC275 as representative low-end and high-end automotive microcontrollers.
1. Introduction
In addition to traditional in-vehicle communication networks, such as the Controller Area Network (CAN), modern vehicles incorporate external connectivity, advanced perception and localization systems, complex automated-driving functions, and high-speed communication interfaces like Ethernet. Cameras, radar, ultrasonic sensors, geolocation receivers and inertial sensors provide continuous information that influences route perception, localization, route planning and vehicle control. However, while the increased connectivity and sensing capabilities enable higher levels of autonomy, they simultaneously expand the vehicle attack surface and introduce additional classes of attack that extend beyond the manipulation of control signals. In this context, for interconnected sensors integrated over a communication interface, attacks such as message injection, replay, spoofing, and fuzzing remain relevant, since they can directly manipulate the signals exchanged between the different electronic control units or interfere with the observations generated by vehicle sensors.
The careful validation of security mechanisms is essential, yet experimentation on actual vehicles can be demanding. In this respect, we distinguish between three levels of experimentation: (i) real vehicles, (ii) simulation environments such as CARLA, and (iii) car-on-bench experimental models, as summarized in Table 1. The differences between these environments are substantial. Real vehicles exhibit actual vehicle dynamics, incorporate real electronic components and communication networks, and inherently capture the propagation of effects from the cyber to the physical domain. However, experiments involving real vehicles are costly, require dedicated infrastructure and maintenance, may pose significant safety risks, and can be subject to regulatory constraints. Moreover, reproducing identical experimental and environmental conditions can be difficult. Simulation environments provide an attractive alternative at considerably lower cost. They offer excellent reproducibility, are largely free from the safety and regulatory constraints associated with real-vehicle experimentation, and allow potentially dangerous scenarios to be investigated safely. They can also provide a rich and configurable driving environment involving roads, traffic, pedestrians, infrastructure, and environmental conditions. However, they do not incorporate actual automotive electronic components or physical communication buses. Furthermore, the physical consequences observed in simulation depend on the fidelity of the underlying models and, importantly, on how cyber signals and control actions are mapped to the simulated physical state. Car-on-bench experimental models address some of these limitations by incorporating real automotive components and communication networks, allowing experiments to capture realistic communication behavior and the computational constraints of embedded devices. However, such platforms generally lack the vehicle dynamics and environmental context required to assess the physical consequences of cyber events. They therefore provide limited means of determining how an attack observed at the communication or Electronic Control Unit (ECU) level would propagate to vehicle behavior. Their cost is moderate: although automotive components and instrumentation can be expensive, the overall cost and maintenance requirements remain substantially lower than those associated with a complete experimental vehicle, while safety and regulatory constraints are also considerably reduced.
Table 1.
Comparison of automotive cybersecurity experimentation environments.
Consequently, and of particular importance to our work, experimenting with intrusion detection systems on a real vehicle is challenging due to limited access to its electronic components, safety concerns, and difficulties in reproducing identical experimental conditions. Nevertheless, real-vehicle experiments provide the highest degree of realism, including actual communication, computational constraints, and physical consequences. Simulation environments, in contrast, fix the shortcomings related to safety concerns and experimental conditions, but offer limited realism for intrusion detection experiments, as no physical communication buses or embedded automotive components are involved. Finally, car-on-bench setups bridge part of this gap between the two alternatives by providing access to real communication buses and embedded devices, but lack the vehicle dynamics and environmental interactions required to evaluate the physical consequences of attacks.
The CARLA (Car Learning to Act) open simulator for urban driving, which is built for flexibility and realism in the rendering and physics simulation, is implemented as an open-source layer over Unreal Engine 4 [1]. The engine itself is available free of charge for non-commercial use [2]. CARLA functions as a client-server model, where the server handles the simulations of the vehicle dynamics (such as vehicle speed, braking, steering, etc.), the onboard sensors (such as radar, LIDAR, GPS, IMU), and the traffic environment. In their simplest configuration, simulation environments can be used to generate synchronized datasets containing sensor observations, vehicle states, control commands, and communication information under normal driving conditions. In a more advanced configuration, such simulators can be integrated with external components, in particular, as we do in this work, by incorporating an attacker and an intrusion detection system (IDS) into the simulation loop. In such an architecture, the simulator generates the evolving driving environment and corresponding sensor and vehicle-state information, while the attacker component may inject malicious CAN messages during runtime. The IDS component can simultaneously observe the resulting communication and can perform detection while the simulation evolves.
In this paper, we implemented an architecture in which a car-on-bench experimental model is linked to the well-known simulator CARLA for data generation and connectivity with an attacker model as well as for testing a lightweight IDS. The high-level system architecture, illustrated in Figure 1, integrates the CARLA simulator [2] with the CSEAMAN car-on-bench experimental model [3] through a Raspberry Pi-based gateway ECU that also hosts the IDS. A second Raspberry Pi acts as the adversary, injecting manipulated CAN messages into the physical in-vehicle network. The contributions of our work can be summarized as follows:
- We bridge the CARLA simulation environment with a physical car-on-bench experimental model, allowing data generated by a vehicle operating in a virtual environment to be mapped onto real in-vehicle communication buses;
- We implement an adversary model capable of carrying out basic attacks against the in-vehicle communication interfaces, enabling their effects to be investigated within the combined experimental environment;
- We experimentally compare a plausibility-check-based IDS with two machine-learning-based classifiers, providing insight into their detection performance and computational requirements when deployed within the experimental setup.
Figure 1.
Integrated experimental setup for interaction between CARLA and the CSEAMAN model.
The rest of the paper is organized as follows. Section 2 presents some background on CAN buses and related works. Section 3 discusses the main points regarding the connectivity between CARLA and the CSEAMAN experimental model. Section 4 discusses the adversary model and the intrusion detection system as well as extensive computational results across various platforms, including the NXP S12 and Infineon AURIX TC275 automotive-grade platforms. Finally, Section 5 contains the conclusion of our work.
2. Background and Related Works
In this section, we discuss some background on CAN buses and related works on simulation environments and digital twins for in-vehicle networks.
2.1. Background on CAN Bus
The Controller Area Network (CAN) is a serial communication protocol originally developed by Bosch and officially introduced in 1986 to provide efficient and reliable communication between interconnected components in embedded control systems. The CAN protocol was first standardized by ISO in 1993 [4]. Over the years, the specification has evolved, with the latest revision (ISO 11898-1:2024) [5] covering Classical CAN, CAN FD, and CAN XL. In modern vehicles, it enables communication between multiple Electronic Control Units (ECUs), sensors, and actuators over a shared communication bus.
CAN was designed to provide reliable communication for real-time applications. Classical CAN supports data rates of up to 1 Mbit/s and allows up to eight data bytes to be transmitted within a single data frame. The protocol also incorporates mechanisms for error detection and fault confinement, which contribute to its robustness in environments where communication reliability is critical. One of the main characteristics of CAN is its multi-master and message-oriented communication model. Rather than exchanging messages using explicit source and destination addresses, each ECU is assigned a predefined set of message identifiers that it is allowed to transmit. Consequently, all network participants monitor bus traffic simultaneously, using local acceptance filtering on the identifier to process only the messages relevant to their operation. Figure 2 illustrates a typical CAN bus architecture, where multiple nodes communicate over a shared bus.
Figure 2.
Typical architecture of an automotive CAN bus network.
The CAN medium access control (MAC) sublayer implements Carrier Sense Multiple Access with Collision Resolution via Bitwise Arbitration (CSMA/CR). When multiple nodes attempt to transmit simultaneously, the node transmitting the frame with the lowest identifier gains bus access. This mechanism ensures that higher-priority messages are sent first, which is essential for time-critical automotive functions. CAN communication is based on the following frame types: data frames, remote frames, error frames, and overload frames. The Data Frame is used to exchange information between ECUs. It comprises several fields: the Start-of-Frame (SOF), arbitration, control, data, Cyclic Redundancy Check (CRC), acknowledgment (ACK), and End-of-Frame (EOF) fields, as illustrated in Figure 3. The arbitration field contains the CAN identifier, which is used for message identification and bus arbitration. The CAN identifier can be either 11 or 29 bits long. An 11-bit identifier is used in a standard data frame, whereas a 29-bit identifier is used in an extended data frame. The control field includes the Data Length Code (DLC), which indicates the length of the transmitted data. In Classical CAN, the data field can contain between zero and eight bytes.
Figure 3.
Structure of the standard CAN data frame format.
In automotive networks, the data field typically encodes one or more vehicle signals, such as vehicle speed, engine RPM, gear position, or warning states. The encoding of the data field is not defined by the ISO 11898 standard but is application-specific. The signals may be encoded in specific bits or bytes, with scaling factors and offsets applied to obtain their corresponding physical values. Depending on their specific functional requirements, CAN frames can be transmitted periodically, on event, or using a combination of both approaches. Their transmission intervals are determined by the system requirements.
2.2. Related Works on CARLA Simulations and Automotive Digital Twins
Early automotive digital twins were often built around CAN bus traffic replay and ECU-level signal reproduction, where the main goal was to replicate in-vehicle communication and validate control logic against recorded traces [6,7]. In this implementation, the twin is primarily a clone of the vehicle’s internal electronics and its communication interfaces. CAN-bus digital twins must reproduce not only message content but also transmission timing. The work in [8] evaluates the timing accuracy of CAN-traffic reproduction by integrating a CAN trace-scheduler within an industry-grade environment. Other recent works extend the digital twin concept beyond the communication layer. The authors from [9] propose an edge-based digital twin that combines CAN data with localization, perception, and environmental information and provides bidirectional interfaces between the vehicle and the virtual counterpart.
An integration of CARLA into a platform for cybersecurity attacks and detection is presented by [10]. The system uses several software nodes interconnected via a virtual CAN bus. The CARLA client module is used to interface the simulator with the virtual bus. An intrusion detection module checks the periodicity of the frames to detect spoofing, fuzzing, and DoS attacks executed by an attacker module. Another node takes commands from the user and transmits them on the virtual CAN bus. A hardware-in-the-loop (HIL) testbed for training and validating machine learning IDS implementations is proposed in [11]. The testbed is composed of CARLA, Vector CANoe, a VN8914 Vector hardware simulator with a VN8972 network interface, an STM32F105 development board, and an instrument cluster. CARLA is interfaced with CANoe by using the Fast Data eXchange (FDX) protocol. The simulated car information is distributed to simulated nodes connected to the CAN network. The STM32F105 is used to perform a man-in-the-middle attack that modifies the odometer value and sends it to the instrument cluster. For detecting the attack, a One-Class Support Vector Machine (OCSVM) classification algorithm is used. Sim2Real [12] was developed as a cybersecurity testbed that integrates CARLA. The setup consists of CARLA, the CAN–Simulator Bridge, and four Teensy 4.0/4.1 microcontrollers interconnected via CAN, based on the Toyota PASTA architecture. The four microcontrollers act as simplified gateway, powertrain, chassis, and body nodes. The authors analyze the behavior of the microcontroller and CARLA under flooding, spoofing, and replay attacks in the absence of intrusion detection mechanisms and without any mitigation procedures. In [13], CARLA is interfaced with a virtual CAN network, providing a suitable environment for carrying out attacks and implementing IDS algorithms. Commands generated through keyboard inputs in CARLA are encapsulated into CAN frames and sent over a virtual CAN interface. The frames are then read from the bus, decoded, and converted into commands to the simulated vehicle in CARLA.
More advanced simulation environments extend this concept beyond the CAN layer by integrating urban driving scenarios, localization, and perception sensors. In [14,15], the MetaDrive simulator [16] is primarily used to generate synchronized observations of steering, throttle, braking, vehicle state, environmental context, and malicious driver inputs, thus providing labeled datasets for model training and testing. Although the detector is included in the simulation framework, validation remains predominantly dataset-driven, since the IDS output is not returned to the simulator as a mitigation action capable of maintaining safe vehicle behavior. Therefore, the studies do not implement a fully closed-loop system in which detection and response influence the vehicle behavior. Other works, such as [17,18], use CARLA and extend the offline mode to an online mode by using the simulator as a virtual vehicle environment connected to embedded hardware and software components. The architectures include physical driving interfaces, CAN communication, and FPGA inferences, thereby moving from offline dataset generation to software- and hardware-in-the-loop evaluation. The works in [19,20] combine CARLA vehicle dynamics and onboard sensors with OMNeT++ to simulate a V2X communication interface, allowing the construction of a more precise model of the message transmission, considering properties of the wireless data packets, including attenuation, propagation delay, and other channel properties. More recently, the authors in [21] proposed a hybrid simulation framework including SUMO, CARLA, and NS-3 to evaluate perception, traffic management, and communication. The study employs as well an autoencoder-based anomaly detector to identify spoofed messages, therefore demonstrating the potential of combining traffic, driving and network simulations for cybersecurity tasks. An overview of the aforementioned studies, together with the features and algorithms used for intrusion detection, is presented in Table 2.
Table 2.
Hybrid frameworks for IDS over CAN bus.
Context-aware IDSs move beyond ID filtering, sequence checks, and message periodicity by incorporating the operational state of the vehicle and the relationship between signals and sensor readings. In a comparable in-vehicle architecture, [22] investigated instrument-cluster security risks, highlighting the potential safety risks of falsified vehicle information and motivating an ECU-level intrusion detection system combining signal checks with model-based observers. Early work [23] showed that context can be learned from normal driving behavior using sequence models, such as n-grams from driving data using small time windows. Other advanced methods use deep learning [24] to exploit correlations between sensor readings to identify anomalies. More recent hybrid frameworks [25] combine deterministic rules with LSTM temporal learning to capture both protocol violations and physically implausible behavior, making context-aware IDSs increasingly relevant for complex automotive environments, which incorporate internal and external connectivity and an increasing number of smart sensors.
Collectively, these studies show that simulation environments should not be regarded solely as a source of synthetic dataset generation. They can progressively support dataset construction, attack orchestration, anomaly detection, online inference, and closed-loop assessment before deployment on a physical vehicle.
3. Connecting the CSEAMAN Experimental Model with CARLA
This section presents the connectivity between the CSEAMAN experimental model [3] and CARLA, emphasizing the signals that we used, devices, and message flow.
3.1. Overview of the CSEAMAN Experimental Model
The CSEAMAN experimental model was built to reproduce a realistic vehicle electronics environment with multiple electronic control units (ECUs) and communication buses, which represent the most security-relevant interfaces. The experimental model consists of several off-the-shelf automotive components and development boards. The Body Control Module (BCM) is implemented on an NXP Freescale S12UB (Freescale Semiconductor, Austin, TX, USA) development board equipped with an MC9S12DG128 microcontroller, from the same manufacturer, responsible for functionalities related to the car body, interconnected via low-speed CAN, high-speed CAN, and LIN. Three off-the-shelf automotive components are connected by the Freescale S12UB development board: the instrument cluster, acceleration pedal, and a rain and light sensor (RLS). The instrument cluster represents the main source of information for the driver and is interconnected through low-speed CAN. Chassis and engine ECUs based on Freescale S12 controllers are available for potential implementation of ignition, traction control, fuel economy, as well as braking, stability control, steering, and safety-related tasks. These are connected through high-speed CAN and FlexRay.
In our architecture, the Freescale S12UB is also connected via the CAN bus to an external device that receives data from the simulation environment and transmits it over the CAN bus. For this external connection, we have implemented an interface by using socketcan running on a Raspberry Pi with a CAN click-shield.
3.2. Detailed System Model
The integration of the CSEAMAN experimental model [3] and the simulation environment is presented in Figure 4 and consists of the following four components:
- (i)
- The CARLA open simulator for urban driving that is responsible for managing the vehicle interactions and processing sensor data during simulation runtime.
- (ii)
- A gateway ECU implemented on a Raspberry Pi, which also hosts the IDS logic and uses the input data generated by the CARLA simulator.
- (iii)
- An adversary node implemented on a second Raspberry Pi to inject manipulated CAN messages.
- (iv)
- The CSEAMAN experimental model, which is a testbed that brings together multiple in-vehicle buses and subsystems, including CAN, LIN, and FlexRay, along with representative ECUs and off-the-shelf vehicle components.
More details on the role of these components are given in what follows. The CARLA simulator, which runs on a laptop, executes a virtual driving environment and is responsible for vehicle dynamics, sensor information, and control commands. Interaction with the simulation environment is established through the Python 3.11.9 client connected to the CARLA server via the TCP port 2000 on the localhost address. The client object manages the communication with the server and provides the interface required to control the simulation: issue commands, access simulation data, manage the virtual environment, and export data [26]. The custom Python client exchanges data with the Raspberry Pi gateway, which acts simultaneously as a communication node and an IDS. Incoming data from CARLA are converted into CAN frames and forwarded to CAN0. The additional IDS implemented in the gateway performs CAN bus traffic monitoring by implementing a set of seven verifications: DLC, unused byte, range, RPM, rolling counter, and message counter checks.
Figure 4.
Detailed diagram of the architecture connecting CARLA, the Gateway, the Attacker ECU, and the CSEAMAN experimental model.
For the gateway implementation, we used a Raspberry Pi equipped with two CAN click shields in order to communicate with the other subsystems. CAN0 is used for transferring simulator signals over CAN, whereas CAN1 is used to transfer the CAN traffic to the CSEAMAN model. Both CAN interfaces were configured through the Raspberry Pi Serial Peripheral Interface (SPI), which was enabled to support communication with the external CAN controllers. Following initialization, the two CAN channels, CAN0 and CAN1, were activated and configured with a bitrate of 500 kbps. This configuration enables bidirectional communication between the gateway and the external CAN network. CAN traffic was acquired through the Linux SocketCAN framework. To obtain reliable timing information for the subsequent IDS analysis, hardware-generated timestamps were used during traffic acquisition.
Specifically, CAN traffic was recorded using candump with the -H option, which selects the hardware timestamps provided by the CAN driver interface. The Attacker ECU was implemented on a second Raspberry Pi. It connects to the setup through an OBD port to CAN0 and injects malicious CAN messages into the network. The CSEAMAN experimental model is connected to the CAN gateway through a CAN bus. Its purpose is to allow experimentation with attack behavior in a network with realistic in-vehicle components. According to the digital-twin maturity levels proposed by [27,28], our system exhibits characteristics of the interaction level, enabling bidirectional communication between the CARLA simulation environment and the physical experimental model, providing a foundation for the later implementation of fully connected digital twin systems.
3.3. Connectivity Between CARLA Simulation and the Experimental Setup
The CARLA 0.9.16 simulator, based on Unreal Engine 4.26 and available at [29], is used in our architecture for simulating the driving environment and the physical vehicle dynamics. The simulator communicates bidirectionally over TCP with the Raspberry Pi Gateway ECU, which interfaces the virtual environment with the in-vehicle communication network by translating vehicle and sensor signals from the simulator into CAN frames, and transmitting lighting state signals back to the simulator.
The CARLA server manages the simulation of the environment representing the driving scene, vehicle dynamics, and onboard sensors. It can be launched from the command line using the Windows executable. The CARLA client transmits commands to the server and, in return, receives sensor data. Commands are used to control the vehicle, e.g., steering, acceleration, and braking. In contrast, simulation control commands manage the behavior of the server, including resetting the simulation and modifying the sensor setup [2]. Following initialization, as described by [30], a vehicle is instantiated in the virtual environment and operated using autopilot functionality. In all experiments, the vehicle.mercedes.coupe_2020 blueprint was used with the default vehicle physics parameters provided by CARLA, without introducing custom vehicle dynamics or modifying its physical configuration, in the predefined Town10HD_Opt urban environment. For simulation configuration, we configured the simulator in asynchronous mode with a variable time-step. This mode ensures that the server runs as fast as possible. Physics substepping was enabled, with a maximum substep delta time of 0.01 s and a maximum of 10 substeps. Communication between CARLA and the client is bidirectional. During the simulation, the client acquires vehicle and environment signals continuously, including speed, gear state, and selected status or light states, e.g., left turn, right turn, low beam, high beam, etc. To interface the virtual environment with the external in-vehicle communication experimental model, only the selected signals are forwarded to the gateway ECU by the Python application over TCP. The gateway ECU translates the simulator signals into corresponding CAN frames and transmits them over the CAN bus. The resulting traffic is subsequently analyzed by the IDS, after which the speed, RPM, gear, and lighting signals are sent over the CAN interface to the CSEAMAN experimental model for simulating vehicle reaction. The light states are also returned to CARLA through the same TCP connection to the simulation for display. This bidirectional communication enables interaction between the virtual environment and the IDS through a TCP connection, and between the IDS and the physical vehicle experimental model via the CAN bus, allowing CAN-based attacks to be injected and their effects to be observed on the experimental model.
The adversarial traffic is generated using a dedicated graphical user interface. The GUI allows the user to select the attack type, the target CAN identifier, and the parameters required for the selected attack. For the experiments presented in this work, the interface was used to generate spoofing, random modification, random injection, replay, and denial-of-service attacks. Depending on the selected attack, parameters such as the spoofed signal, speed or RPM value, target payload byte, bit mask, and signal state can be configured. The attack can then be started or stopped directly from the interface, and its status is displayed at the bottom of the GUI.
3.4. Signals Transmitted from the CARLA Simulation to the Setup
The signals of interest to our application are speed, RPM, gear position, and lights. They are received continuously from CARLA over the TCP connection, without imposing a fixed reception period. On the CAN network, speed and RPM are encapsulated in a frame with ID 0xB6 having a period of 100 ms, while gear position and light states are encapsulated in a frame with ID 0x128 having a period of 400 ms. The IDS processes each CAN frame upon reception before forwarding valid traffic to the experimental model. The engine RPM was not obtained directly from CARLA. Instead, it was estimated from the vehicle speed and drivetrain parameters using the following equation:
The vehicle velocity, gear ratio, drive ratio, and wheel radius were obtained from CARLA using these commands: vehicle.get_velocity(), physics.forward_gears[gear - 1].ratio, physics.final_ratio, and physics.wheels[0].radius, respectively. CARLA returns velocity as a three-dimensional vector in m/s, and vehicle speed was computed as the magnitude of this vector: Since CARLA provides the wheel radius in centimeters, it was divided by 100 to convert it to meters before applying the RPM equation. The factor 60 converts wheel revolutions per second into revolutions per minute. Since this value cannot be applied back to the simulated car, this value is not transmitted back to the simulated vehicle after IDS processing. The light state values that are implemented in CARLA are position lights, high/low beam headlights, front/rear fog lights, and left/right blinker lights. Collectively, these reference values are acquired from the simulator, converted by our Python script into CAN frames, and sent to the experimental model via the CAN bus.
3.5. Experimental Flowchart
In this section, we describe the experimental flowchart, as depicted in Figure 5, starting from initialization and configuration, followed by data acquisition, the generation of CAN frames, attacker intervention, IDS filtering, and interfacing with the CSEAMAN model.
Figure 5.
Detailed flowchart with the actions from the experimental setup.
Following initialization and configuration of the two Raspberry Pi components, and after the CARLA data acquisition, a frame sender application is executed on the gateway Raspberry Pi. Its primary function is to process the acquired signal values and encapsulate them into the corresponding frame. These frames are used to control and monitor vehicle parameters, including the vehicle speed, RPM, gear, dashboard warning lights, fuel and coolant levels. Vehicle speed, gear, and lighting state signals are received directly from the CARLA simulator, while the engine RPM is calculated from the vehicle speed and drivetrain parameters. These signals are then transmitted to the gateway ECU via the TCP connection. Each signal is assigned a predefined position and length within a corresponding CAN frame, as specified in the CAN database. For speed and RPM signals, additional scaling and encoding are applied during frame generation, as described in the previous section. Furthermore, the periodic transmission requirements defined in the CAN database are implemented to ensure compliance with the specified message cycle time. The acquired signal values are encoded using bit-wise operations and masking techniques, after which the CAN frames are assembled and transmitted over the CAN0 interface.
Following CAN message generation and IDS filtering, the bus traffic is forwarded by the CAN gateway across two communication channels: the CAN frames are forwarded through the CAN1 interface to the CSEAMAN experimental model, while in parallel the lighting state signals are transmitted back to CARLA and applied to the simulated vehicle.
4. Adversary Model and Intrusion Detection
In this section, we present the adversary model and the results obtained with the intrusion detection mechanisms.
4.1. Adversary Integration into a Raspberry Node
In the proposed experimental setup, a Raspberry Pi is configured as an attacker node and connected to the in-vehicle traffic via the OBD interface over CAN0. On this device, a graphical user interface (GUI) was developed to allow configuration and execution of CAN bus attacks by generating and injecting malicious messages over the CAN interface. The following classic types of attack are supported:
- Spoofing attack: In a spoofing attack, the intruder targets specific CAN IDs to introduce modifications in the data field, making the attack harder to detect since it carries a legitimate ID. In this case, we are assuming that the attacker has been monitoring the CAN bus traffic and analyzed the structure of the messages. As a result, the attacker is able to identify which CAN frames are associated with specific vehicle functions, such as speed, RPM, warning lights, etc. By understanding the position and meaning of certain bytes, the attacker is able to craft messages that imitate legitimate traffic. In our application interface, the spoofing attack can be configured, including the numerical value carried by the frame, through the GUI of the attack tool. The user can select the type of spoofed signal, such as vehicle speed, engine RPM, fuel level, coolant temperature, or warning lamps. Depending on the selected signal, additional parameters become available, allowing the attacker to introduce custom values. For example, in the case of vehicle speed or RPM spoofing, the interface provides input fields where the attacker can specify the values that will be injected into the CAN frame. For warning lamp manipulation, the interface allows selecting the target byte, the corresponding bit mask, and desired on/off state. The tool captures a legitimate CAN frame from the bus, preserves its identifier and overall structure, modifies the selected payload fields, and retransmits the forged frame onto the network.
- Random injection (Fuzzy) attack: This type of attack occurs when the adversary intercepts legitimate CAN frames and then injects malicious frames with the same identifier as the original messages, but with a random data field. The GUI allows the user to select the identifier of the target message, after which a legitimate frame with the corresponding CAN ID is captured from the bus in order to preserve the original payload length. As a result, the injected messages may contain inconsistent or unrealistic values that can disrupt normal behavior.
- Random modification attack: In this type of attack, the adversary intercepts legitimate CAN frames and then modifies them before retransmitting them on the bus; however, unlike random injections, the modified frames keep most of the original structure, but one or two bytes in the data field are changed randomly. Similarly to the previous attacks, the GUI allows selecting the identifier of the targeted message. A legitimate CAN frame with the selected ID is then captured from the bus in order to keep the same payload length and general frame structure. Afterwards, one or two randomly selected bytes from the payload are modified using randomly generated values, while the remaining bytes remain unchanged. The altered frame is then transmitted on the CAN bus, making the attack appear more similar to normal traffic compared to fully random payload injection.
- Replay attack: In this type of attack, the adversary captures legitimate CAN frames transmitted on the bus and retransmits them repeatedly at a later time. In this type of attack, the malicious frames are exact copies of valid frames, containing the same CAN identifier and the same data payload as the original messages. The CAN identifier can be selected through the graphical attacker interface. The application then continuously monitors the CAN traffic until a valid frame with the selected ID is received. Once captured, the payload of the message is extracted and stored for later retransmission. The previously captured frame is then injected into the CAN bus using random periodicity between 100 ms and 500 ms. Unlike random injection or fuzzy attacks, replay attacks reuse previously valid CAN messages, making them harder to detect using only static payload validation. For this attack type, the implemented IDS relies on an additional security mechanism, i.e., a rolling counter validation. These are generated by the frame sender program and are later verified by the IDS during frame analysis. Since replayed frames contain outdated counter values, they no longer match the normal order of the communication; the IDS can detect them easily as malicious traffic.
- Denial-of-service (DoS) attack: In this type of attack, the adversary continuously injects a large number of CAN frames onto the bus with lower IDs that have high priority in order to overload the communication channel and make it unavailable. Such behavior may disrupt the normal operation of the network and lead to unexpected system behavior. In the implemented attack scenario, the attacker repeatedly transmits CAN frames with an ID that is lower than the minimum value of legitimate IDs at a fixed rate of 200 messages per second, in order to overload the bus. The payload contains only zero-valued bytes.
The signals targeted by the aforementioned attacks are presented in Table 3.
Table 3.
Attack Surface and Cyber–Physical Signal Mapping.
4.2. Plausibility Check IDS
The IDS monitors the CAN network traffic in real time in order to detect potentially malicious messages. It is implemented as a Python program with a graphical user interface that allows enabling or disabling different validation rules. The script listens to CAN messages received on the CAN0 interface and analyzes them based on the selected validation rules. If a message is considered valid, it is forwarded to the CAN1 interface. For lighting-related messages, the validated signals are also transmitted to the CARLA simulation model through TCP. If an anomaly is detected, the message is not further propagated. For every received message, the IDS first checks whether the frame ID is part of a predefined whitelist. Only frames that are explicitly enabled are further analyzed. If a frame is not part of the list, it is ignored. Previous work of ours has also helped in establishing some of the rules for the IDS [22]. For the selected frames, multiple validation checks can be applied:
- Data length check—this validation ensures that the received frame has the expected number of bytes (DLC). Each CAN frame with a specific ID has a predefined structure, and any deviation from this expected length is considered suspicious and flagged as an attack.
- Unused bytes check—for each monitored CAN frame, certain bytes are known to be unused. If any of these bytes are modified, the frame is marked as malicious, since such changes should not occur during normal operation.
- Range check—this check validates whether specific signal values, such as vehicle speed and RPM, fall within predefined acceptable limits. The values are extracted from the CAN payload, and if they exceed the configured thresholds, the message is considered an attack. The acceptable values are 0–220 km/h for vehicle speed and 0–6000 RPM for engine speed. Any value outside these ranges is considered abnormal, and the message is classified as illegitimate.
- RPM formula check—this validation is used in order to ensure that the engine RPM value transmitted on the bus is consistent with the current vehicle speed and gear. First, the RPM value received from the CAN frame is converted into its physical value using a scaling factor. Afterwards, an estimated RPM is calculated using the measured vehicle speed together with the transmission ratio corresponding to the current gear, the axle ratio, and the wheel radius. The IDS will then compare the calculated RPM with the real value from the bus. If the difference between them is not within an error margin of 150, then the frame will be flagged as an attack. The consistency check does not account for drivetrain transients or sensor uncertainties and was intentionally simplified to demonstrate the feasibility of the proposed detector; deployment under real vehicle conditions would require additional calibration and validation. The RPM plausibility check demonstrates consistency with the drivetrain model implemented in CARLA rather than independently measured engine dynamics, allowing detection of attacks with uncoordinated signal manipulation.
- Rolling counter check—this mechanism validates whether the rolling counter inside the CAN payload follows the expected sequential order. For each newly received frame, the IDS calculates the expected counter value based on the previously received message. If the received counter value differs from the expected one, the frame is marked as an attack. The rolling counter check is effective against replay attacks in which the attacker retransmits previously recorded messages without modifying their counter values.
- Message rate check—this validation is used to detect denial-of-service (DoS) attacks by monitoring the number of CAN frames received within a fixed time interval. The IDS maintains a counter for every monitored CAN ID and increments it whenever a new frame is received. Every second, the measured message rate is compared against a predefined threshold. If the number of received frames exceeds the predefined threshold of 50 messages per second, the traffic is considered abnormal, and the IDS reports a potential DoS attack. After each one-second interval, the counters are reset, and the monitoring process continues.
For evaluation, the IDS has been tested separately against all five implemented attack types: spoofing, random modification, random injection, replay, and denial of service. For the first four attacks that we mentioned, each simulation was executed for a duration of 10 min, during which an average of 6000 legitimate frames plus 2000–6000 attack frames associated with the target ID were processed. All attacks were performed on the CAN frame with ID 0xB6 in order to maintain consistency across tests. The detailed detection results, including the number of true positives (TPs), true negatives (TNs), false positives (FPs), and false negatives (FNs), are presented in Table 4. Regarding the DoS attack, which uses a CAN identifier with a lower numerical value than all legitimate identifiers on the network, such an attack may have a noticeable impact on vehicle behavior. However, it is straightforward to detect, since the injected identifier does not belong to the set of legitimate identifiers used by the network. Therefore, we omit the evaluation of the detection rate for this type of DoS attack, as a simple identifier-filtering mechanism would achieve a detection rate of 100%.
Table 4.
Confusion Matrix Results for Each Attack Type for Plausibility Checks on ID 0x0B6.
All false positives in Table 4 are not the result of the attack scenario but are due to shortcomings in the RPM estimation formula and also to the fact that the gear and RPM are not in the same frame. Therefore, for a few milliseconds, the formula will be using the outdated gear value due to the lower frequency of the gear transmission. This gap was experimentally determined by logging the gear values received through the CAN bus and comparing them with the corresponding gear values obtained directly from CARLA. This also results in a decrease in specificity and precision for all attacks. We also attempted to transmit RPM and gear information within the same CAN frame, but false positives persisted, suggesting that the theoretical RPM estimation formula is not sufficiently accurate under all operating conditions. Given the small number of false positives, we did not pursue further investigation at this stage.
In the case of spoofing attacks, the modified signal was the speed value, which is easily detected by the IDS due to the implemented RPM formula validation rule. The IDS achieved an accuracy of 0.99 and a recall of 1.00, indicating that all spoofing attacks were successfully detected. In the random modification case, one or two bytes chosen at random from an existing legitimate frame were altered randomly, simulating small and subtle data corruption. The IDS achieved an accuracy of 0.92 and a recall of 0.88, while the precision and specificity remained at 0.97. The lower recall is caused by modifications that still produce values within acceptable ranges and are therefore not detected by the IDS. The random injection attack sends completely random frames, leading to values that often fall outside the expected ranges or to modifications of unused bytes, which explains the higher accuracy and recall achieved for this attack compared to the random modification attack. In the replay attack scenario, previously captured legitimate frames were retransmitted on the bus without modifying their original content. Since replay frames preserve valid signal values, payload-based plausibility checks alone may not distinguish them from the legitimate traffic, while the rolling counter validation can detect the outdated counter values contained in the retransmitted frames. The replay attack achieved an accuracy of 0.99 and a recall of 1.00, indicating that all the replayed frames were successfully detected as their outdated counter values did not match the expected sequence.
Overall, the evaluation shows that the IDS performs consistently well against all attack types, achieving near-perfect metrics in most cases. Replay, random injection, and spoofing attacks exhibit the highest detection performance, while random modification shows lower recall, as some attacks remain undetected when the changes are less noticeable. As stated, frames causing DoS attacks can be detected by filtering as they contain smaller IDs that are not part of the legitimate ID set; therefore, they are not part of the machine-learning experiments that follow. Although the 200 frames per second transmitted during the attack may introduce some additional bus load, this traffic remains well within the communication capacity of the 500 kbps CAN bus and did not disrupt normal communication during our experiments.
The resulting dataset with attacks on ID 0x0B6, which we will use in the next section with ML classifiers, comprises four CAN traffic scenarios generated using the CARLA-based experimental model presented in Section 3, covering spoofing, random injection, random modification, and replay attacks, and is publicly available. Each recording spans approximately 10 min and contains 17 unique CAN identifiers, with all attacks targeting ID 0x0B6. Table 5 summarizes the content of the traces.
Table 5.
Characteristics of the CARLA to CSEAMAN Attack Dataset.
4.3. Comparison to ML Tree Classifiers
Motivated by the ever-increasing use of supervised learning and the effectiveness of random forest (RF) and decision tree (DT) classifiers, which were already used in related works that we mentioned earlier [14,15], we contrast their performance with the performance of the plausibility-check-based IDS. Both classifiers were selected due to their advantage in interpretability, data type agnosticism, and limited processing requirements. The pipeline used for classification is presented in Figure 6 and detailed as follows. For evaluation of the results, the same attack and normal traffic files that served as input for the plausibility-check IDS were used, covering spoofing, random modification, random injection, and replay attack scenarios.
Figure 6.
Machine learning pipeline for IDS.
First, the CAN traffic is parsed into a data frame containing reception timestamp, CAN identifier, DLC, payload, and corresponding attack label. For model training and testing, the payload was subsequently decomposed into individual bytes. To ensure a fair comparison with the aforementioned plausibility check IDS, we approached the classification problem as a multiclass task comprising five classes: normal traffic, spoofing, random modification, random injection, and replay. For feature selection, we employed basic calculations on standard CAN frame attributes. We retained the CAN ID and DLC, and we computed inter-arrival time and payload byte differences between consecutive frames with the same ID. Evaluation of the results was done for both multiclass and binary classification. To avoid contamination, the attack label was removed from the inference input and used as the target variable. The four attack datasets were concatenated and split into training and test sets using (i) an 80:20 ratio and (ii) a 20:80 ratio for each class. For each class, the split was performed chronologically on each individual recording, preserving the temporal order of CAN frames and avoiding a random split that would otherwise introduce data leakage by including future observations in the training set. Although the train and test partitions were temporally separated, they originate from the same trace. Therefore, the evaluation uses later observations from the same recording rather than an independent recording. No feature normalization was applied because the selected classifiers, RF and DT, are tree-based models that split on feature-specific thresholds rather than relying on distance metrics. Feature completeness and value ranges were checked beforehand, and the data contained no missing or invalid values. The two scenarios are relevant for evaluation of model performance, footprint, and inference latency. To reduce class imbalance and avoid overfitting, the normal-class samples were downsampled to three times the number of samples in the largest attack class. Downsampling was performed separately for the training set. The complete test set was used for prediction, without any downsampling on any of the classes. The training data was used to train and optimize the two supervised classifiers: RF and DT. For the RF classifier, the number of estimators is varied from 50 to 95 in increments of five, with bootstrap sampling enabled, and the best-performing configuration is retained. The DT classifier is used in its default configuration, allowing the model to learn the single tree structure without imposing additional constraints on its depth or split criteria.
Table 6 and Table 7 summarize classifier detection performance for both multiclass and binary classification at the individual ID level. The multiclass evaluation assesses the ability of the classifier to distinguish normal traffic from the different attack types. The binary evaluation focuses on binary discrimination between normal and attack frames. The reported results include the confusion matrix components (TP, TN, FP, FN) together with accuracy, precision, recall, F1-score (per class, macro-averaged and weighted-averaged) and specificity, providing a complete evaluation of attack detection capability. When evaluating the tree-based classifiers, it can be observed that both models provide relatively good performance for the evaluated attacks. For the DT 80/20 configuration, the classification results show 18 false negatives and 443 false positives. Reducing the training dataset in the DT 20/80 configuration leads to an increase in misclassifications, with 71 false negatives and 1895 false positives. Misclassifications increase across all classes except for replay attacks. Nevertheless, the aggregated performance metrics remain above 0.94 for both configurations. Compared with the plausibility-based IDS, the DT achieves higher recall for random modification attacks while maintaining comparable detection performance for the remaining attack types. For the RF 80/20 configuration, normal and attack samples are classified with a limited number of misclassifications. The model produces 17 false positives and 45 false negatives for the normal class, while the highest number of false positives among attack classes is observed for spoofing. When reducing the training dataset, the RF 20/80 configuration shows an increase in misclassifications, particularly for normal and spoofing samples. Although the number of misclassifications increases, the test set size also increases to approximately four times that of the 80/20 configuration. The aggregated performance metrics remain above 0.98 for both configurations. In contrast to the plausibility check IDS, the RF shows higher recall for the random modification attack, while both approaches achieve comparable detection performance for all other attack types.
Table 6.
Multiclass and binary classification results for the decision tree (ID level).
Table 7.
Multiclass and binary classification results for the random forest (ID level).
To assess whether the detection performance results obtained by the proposed architecture are comparable to results obtained on established CAN bus attack datasets from the literature, the two proposed classifiers were trained and tested using the popular Car Hacking dataset [31], which includes DoS, fuzzy, and spoofing of the gear and RPM signals. While the detection rates obtained for our dataset were close to 1.0, similarly high performance was observed on the Car Hacking dataset, as presented in Table 8 and Table 9. In particular, the gear and RPM spoofing attacks provide a relevant comparison to our work. For the 80–20 split, both the RF and DT achieved, for binary classification, an F1-score and a recall of 0.99. For the 20–80 split, both classifiers retained an F1-score of 0.99 and a recall of 0.98 for binary classification. These results support the effectiveness of the evaluated classification approaches. Nevertheless, the higher number of misclassifications in the comparison dataset can be partly attributed to the larger number of frames and suggests a cautious interpretation of the results, particularly considering the long operational lifetime of a vehicle, variations in traffic conditions, and attack complexity.
Table 8.
Multiclass and binary classification results for the decision tree (Car Hacking dataset).
Table 9.
Multiclass and binary classification results for the random forest (Car Hacking dataset).
4.4. Runtime Performance on General-Purpose and Automotive-Grade Platforms
We first examine the CPU processing activity on the Raspberry Pi, which acts as a gateway and implements the plausibility-based detection mechanism. Figure 7 summarizes the distribution of CPU cycles between Raspberry Pi processes under normal traffic and a spoofing attack. The CPU profiling results distinguish between the Python-based IDS application and concurrent operating-system activities, including desktop management (pcmanfm, labwc, and wf-panel-pi), remote connectivity (rpi-connectd), and kernel worker tasks. During the attack, the share of the CPU cycles attributed to the Python process that executes the plausibility checks increased from to , indicating a modest increase in the relative computational contribution of the Python process, which is due to the fact that the number of frames per second increases in case of an attack. The measured CPU cycle utilization provides only an initial indication of the computational feasibility of the proposed approach, while real-time suitability requires further evaluation under representative load conditions. This evaluation shows that the Python script implementing the gateway between CARLA and the CSEAMAN model experiences only a small increase in its relative CPU processing activity during an attack.
Figure 7.
Raspberry Pi CPU-cycle profile: no attack vs. attack.
Now we evaluate the computational requirements of machine-learning-based detection. Specifically, we present results obtained on an Intel Core i7 notebook, where the models were trained; a Raspberry Pi 4, to which the trained models were subsequently ported; and two automotive-grade platforms representative of low-end and high-end controllers. For the low-end platform, we used the NXP EVB9S12XF512E evaluation board (NXP Semiconductors N.V., Eindhoven, The Netherlands), based on the automotive-grade MC9S12XF512 MCU (NXP Semiconductors N.V., Eindhoven, The Netherlands), which is also part of the CSEAMAN experimental model. This 16-bit microcontroller features 512 KB of program Flash memory, 32 KB of data Flash memory, and 32 KB of RAM. For automotive communication, it provides one FlexRay controller, two CAN controllers, and two SCI interfaces that can support the LIN protocol. The development board includes two NXP TJA1080 FlexRay transceivers (NXP Semiconductors N.V., Eindhoven, The Netherlands), two NXP TJA1041 High-Speed CAN transceivers (NXP Semiconductors N.V., Eindhoven, The Netherlands), and two NXP TJA1020 LIN transceivers (NXP Semiconductors N.V., Eindhoven, The Netherlands). The CPU operates at a maximum frequency of 50 MHz, while the XGATE coprocessor runs at up to 100 MHz. Our implementation uses only the CPU, without the XGATE coprocessor. For the high-end platform, we used the AURIX TC275 Lite evaluation board (Infineon Technologies AG, Neubiberg, Germany), based on the automotive-grade TC275 AURIX TriCore MCU, which features a 32-bit multicore architecture operating at 200 MHz. This board was not part of the original CSEAMAN experimental model. The MCU supports ISO 26262 [32] (up to ASIL-D) and IEC 61508 (SIL-3) functional safety requirements. It has a 3+2 multicore configuration, comprising two performance cores, one efficiency core, and two additional lockstep checker cores. The MCU provides 4 MB of program Flash memory, 56 KB of cache memory, 384 KB of Data Flash for EEPROM emulation, and 472 KB of RAM. It supports several automotive communication protocols, including CAN/CAN-FD, LIN, PSI5/PSI5S, and SENT (SAE J2716). The MCU integrates four CAN/CAN-FD controllers, while the evaluation board includes an Infineon TLE9251VSJ CAN transceiver (Infineon Technologies AG, Neubiberg, Germany). Figure 8 depicts the measurement setup.
Figure 8.
Experimental setup for runtime measurements on the NXP S12 and Infineon AURIX TC275 automotive-grade platforms.
Table 10 presents the detailed frame inference latencies and memory footprint under the more demanding 80–20 training-testing configuration. For the evaluation, we exported the models and 200 test vectors into C header files, and we compiled them into C executables for the respective target platforms, using both default and optimized compiler options. Optimizations were enabled using gcc -O3 -march=native on the Raspberry Pi and cl /O2 /arch:AVX2 /nologo on the Windows-based platform. For the memory footprint evaluation, on the Intel notebook and Raspberry Pi, we compiled only the model prediction function and retained the size of the generated .o file. For the S12, compiler optimizations were enabled in CodeWarrior using the Optimize for Size -Os option, but no noticeable differences in either compiled code size or inference latency were observed compared with the default compiler settings. The reported size was obtained from main.c.o, the relocatable object file generated by CodeWarrior for the Freescale S12X target, when compiled without the test vectors, from which we subtracted the size of the baseline build, which did not contain the machine learning code. This file contains the compiled machine code for main.c, including the main loop and the inference routines defined in the included model header. It may also contain symbol and relocation information or debugging metadata generated during compilation. Consequently, the reported size may not precisely represent the memory footprint of the classifier alone but nevertheless serves as a useful practical reference. The reported code size for the TC275 was estimated as the difference between the total memory allocated to CPU0 in the build containing the inference code without the test vectors and that of a baseline build without machine-learning-related code. This estimate may also include additional code and data placed in the corresponding memory regions by the linker that are not directly associated with the classifier. On the Infineon TC275, optimizations were configured in Release mode using the TASKING C/C++ compiler at optimization level -O1 with maximum size trade-off –tradeoff=4 and code compaction enabled –compact-max-size=200.
Table 10.
Model complexity and inference latency across hardware platforms (s).
Obviously, due to differences in processor architectures, compiler toolchains, optimization options, and platform-specific measurement procedures, the reported implementation sizes and inference latencies may not be directly comparable. But these measurements provide useful practical insights into the computational requirements of the evaluated classifiers and their potential for deployment on general-purpose and automotive-grade hardware. A fully standardized cross-platform benchmarking study is beyond the scope of the present work. Regarding model inference latencies, for the DT algorithm, both Intel i7-1165G7 and Raspberry Pi achieved inference latencies well below s. Infineon TC275 showed an increased inference time of s with the optimized compiler option and s in the default configuration, and the NXP S12 presented the highest inference latency, with s/frame. For the more demanding RF model, the inference latencies increased on all platforms. Intel i7-1165G7 remained below s under both compiler options. For the Raspberry Pi, the inference latency increased to s with compiler optimization and almost doubled with the default compiler option. The Infineon TC275 showed the highest inference latency, reaching s with the optimized compiler option and s with the default configuration. RF inference could not be evaluated on the NXP S12 platform due to memory limitations imposed by the compiler that we used. The results demonstrate that DT imposes relatively low computational demands across all evaluated platforms, including the resource-constrained NXP S12, whereas RF requires substantially more computation. The particularly low inference times observed for the optimized C implementations on the Intel Core i7 and Raspberry Pi can be attributed, at least in part, to compiler optimizations and the relatively simple operations involved in DT inference.
Figure 9 summarizes the relationship between the reported implementation size and mean inference latency across the evaluated hardware platforms and models, highlighting two reference thresholds: a processing time budget of s and a Flash memory budget of 256 KB. These thresholds were chosen considering that the transmission time of a typical CAN frame at 500 kbps is approximately s and that the S12 microcontroller used in our experimental setup provides 512 KB of Flash memory. In practice, only a fraction of the available computational and memory resources can be allocated to the IDS, as the controller must also perform other vehicle-related tasks. We therefore consider the s and 256 KB thresholds useful reference points for assessing the feasibility of embedded IDS deployment, rather than strict deployment requirements.
Figure 9.
Inference Latency versus Reported Code Size Across Hardware Platforms. (C) denotes the unoptimized implementation, while (C*) denotes the optimized implementation.
As stated above, the measurements were performed using a common set of 200 test vectors to accommodate the resource constraints of the evaluated platforms. The measurements were also repeated using the full test set on the Intel platform, yielding consistent results. These measurements characterize the offline computational requirements of the detection algorithms, with input data already available in memory, and should not be interpreted as complete message-processing latencies in a deployed gateway. In a real-world deployment, additional overhead may arise from communication processing, feature extraction, scheduling, buffering, and concurrent vehicle-related tasks. Nevertheless, the measured inference times for all classifier configurations evaluated on the two automotive-grade platforms remain below the approximately required to transmit a typical CAN frame at 500 kbps, providing an encouraging indication of their computational feasibility for real-time detection. The automotive-grade platforms used in our experiments do not implement a complete production gateway software stack, and a comprehensive evaluation of end-to-end latency under representative gateway workloads remains outside the scope of the current work.
4.5. Limitations and Future Work
Attack complexity and generalization to unseen attacks. Indeed, our attacker model was simple, and more complex attacks, such as stealthy, context-aware, as well as coordinated multi-signal attacks, could have been considered. Attacks such as gradual signal manipulation or replay of previously valid signal trajectories may remain undetected if they do not violate these constraints. Such attacks can require more advanced detection mechanisms, requiring a potential extension of the existing plausibility check IDS with additional temporal and cross-signal consistency checks. One advantage of plausibility-based checks is their potential to detect previously unseen attacks, provided that these attacks violate the defined plausibility constraints. In contrast, the machine-learning approaches evaluated in this work rely on supervised classification of known attack patterns, which limits their ability to generalize to unseen attacks. Investigating approaches with improved generalization capabilities, particularly anomaly-based detection methods, represents an interesting direction for future work.
Vehicle dynamics and control-system-level detections. The CSEAMAN experimental model has certain limitations regarding the available vehicle components. Although it includes an accelerator pedal that communicates over CAN, it lacks a brake pedal and a steering wheel. Consequently, braking and steering actions cannot be initiated directly from the physical hardware. In our experiments, the vehicle trajectory was therefore controlled by the CARLA autopilot. Furthermore, the CAN bus attacks considered in this work target only the vehicle speed signal. To further evaluate the impact of such an attack on vehicle behavior within the simulator, we ran additional experiments that returned the manipulated speed values back to the simulator through the existing interface. The experiments considered two configurations, with the plausibility-check IDS disabled and enabled, and were repeated three times. When the IDS was disabled, the manipulated speed values returned to the simulator could register a sudden top speed of , which produced abnormal vehicle motion over the Z-axis with a displacement of m. When the IDS was enabled, such effects were not observed. However, this does not necessarily reflect the actual vehicle behavior under a real-world attack targeting acceleration, and further investigation is needed to assess such effects. Furthermore, as previously stated in the case of RPM attacks, we have not considered models related to engine dynamics. The current CSEAMAN experimental model incorporates automotive-grade development boards interconnected through CAN interfaces. However, these components do not implement vehicle control functions such as acceleration, braking, or steering. Consequently, the current setup does not support the evaluation of attacks targeting these control functions or their detection at the control-system level.
5. Conclusions
In this paper, we presented an interactive digital-twin cybersecurity testbed that bridges the CARLA urban-driving simulator with the CSEAMAN car-on-bench model through a Raspberry Pi that plays the role of a gateway ECU. The proposed integration combines the simulator’s configurable vehicle dynamics, sensor data, traffic scenarios, and environmental interactions with the communication buses and embedded devices from an automotive-grade setup. This approach may enable cybersecurity experiments to be conducted safely and repeatedly while preserving a higher degree of realism. The experiments were focused on Classical CAN attacks: spoofing, random injection, random modification, and replay. On this platform, our lightweight plausibility-based IDS achieved near-perfect detection for spoofing, random injection, and replay attacks, matching the performance of the ML-based baselines at a much lower computational cost, while random modifications showed some limitations for detection, likely when the modifications were small. For the replay attack, the plausibility-based IDS may have a slight advantage over the ML-based classifiers, mainly due to its explicit rolling-counter verification mechanism, which enabled more effective detection of replayed CAN frames. Both approaches have advantages and limitations. While the proposed plausibility-based IDS can detect previously unseen attack patterns that violate the defined signal and communication constraints, it cannot guarantee detection of attack frames that evade the implemented checks. On the other hand, ML algorithms learn more complex patterns; generalization to unseen samples is not ensured and requires future dedicated evaluation. The computational evaluation across four hardware platforms provides encouraging evidence for the feasibility of embedded machine-learning-based intrusion detection and highlights the importance of compiler optimizations. Decision trees exhibit particularly favorable computational requirements, demonstrating their potential for deployment even on the resource-constrained NXP S12. Random forests impose considerably higher computational and memory demands but remain computationally feasible on the higher-end Infineon AURIX TC275.
Finally, we regard the current work as a proof-of-concept validation platform that demonstrates the integration of a vehicle simulation environment with real-world automotive hardware. Several limitations remain, as previously discussed, particularly regarding attack complexity, IDS generalization to unseen attacks, the modeling of vehicle dynamics and control-system behavior, and the computational requirements of deploying complete IDS implementations on automotive-grade microcontrollers. In practice, such controllers must also execute other tasks related to vehicle functions, often under the supervision of an operating system, rather than operating in the simplified bare-metal conditions considered in our experiments. Addressing these limitations represents an important direction for future work.
Author Contributions
Conceptualization, M.D., I.F., E.C., H.G. and B.G.; methodology, B.G. and H.G.; software, M.D., I.F. and E.C.; validation, M.D., I.F. and E.C.; investigation, M.D., I.F., E.C., H.G. and B.G.; writing—original draft preparation, E.C., H.G. and B.G.; writing—review and editing, M.D., I.F., E.C., H.G. and B.G.; visualization, M.D., I.F. and E.C.; supervision, B.G. and H.G.; project administration, B.G. All authors have read and agreed to the published version of the manuscript.
Funding
This work was partially supported by the project “Romanian Hub for Artificial Intelligence-HRIA”, Smart Growth, Digitization and Financial Instruments Program, 2021–2027, MySMIS no. 351416.
Institutional Review Board Statement
Not applicable.
Informed Consent Statement
Not applicable.
Data Availability Statement
Data generated in the model is publicly available on GitHub: https://github.com/EmiliaCaragea/CARLA_2_CSEAMAN.git (accessed on 29 November 2026).
Acknowledgments
ChatGPT-5 was used to assist with language editing and the refinement of code.
Conflicts of Interest
The authors declare no conflicts of interest.
References
- Games, E. Unreal Engine 4. Available online: https://www.unrealengine.com (accessed on 2 April 2026).
- Dosovitskiy, A.; Ros, G.; Codevilla, F.; Lopez, A.; Koltun, V. CARLA: An open urban driving simulator. In Proceedings of the Conference on Robot Learning, PMLR, Mountain View, CA, USA, 13–15 November 2017; pp. 1–16. [Google Scholar]
- CSEAMAN: Cryptographic Security for Automotive Embedded Systems and Networks. Available online: https://www.aut.upt.ro/~bgroza/projects/cseaman/ (accessed on 16 October 2026).
- ISO 11898:1993; Road Vehicles—Interchange of Digital Information—Controller Area Network (CAN) for High-Speed Communication. International Organization for Standardization: Geneva, Switzerland, 1993.
- ISO 11898-1:2024; Road Vehicles—Controller Area Network (CAN)—Part 1: Data Link Layer and Physical Coding Sublayer. International Organization for Standardization: Geneva, Switzerland, 2024.
- Popa, L.; Berdich, A.; Groza, B. CarTwin—Development of a digital twin for a real-world in-vehicle CAN network. Appl. Sci. 2022, 13, 445. [Google Scholar] [CrossRef] [Scilit]
- Toyama, T.; Yoshida, T.; Oguma, H.; Matsumoto, T. 1 PASTA: Portable Automotive Security Testbed with Adaptability. In Proceedings of the Black Hat Europe 2018, London, UK, 3–6 December 2018. [Google Scholar]
- Caragea, E.; Groza, B. Toward In-Vehicle Network Digital Twins: Timing Accuracy of CAN Traffic Reproduction Using Industry-Grade Interfaces and API-Based Solutions on Windows IoT Enterprise. IEEE Access 2026, 14, 131152–131177. [Google Scholar] [CrossRef] [Scilit]
- Campolo, C.; Genovese, G.; Molinaro, A.; Pizzimenti, B.; Ruggeri, G.; Zappalà, D.M. An edge-based digital twin framework for connected and autonomous vehicles: Design and evaluation. IEEE Access 2024, 12, 46290–46303. [Google Scholar] [CrossRef] [Scilit]
- da Luz, L.F.M.; Ventura, V.L.; Campelo, D.R. Yes, CARLA CAN: Extending the CARLA Simulator for In-Vehicle Network Cybersecurity Experimentation. In Proceedings of the Simpósio Brasileiro de Redes de Computadores e Sistemas Distribuídos (SBRC), Porto Alegre, Brazil, 25–29 May 2024; pp. 198–209. [Google Scholar]
- Jadidbonab, H.; Tomlinson, A.; Nguyen, H.N.; Doan, T.; Shaikh, S. A realtime in-vehicle network testbed for machine learning-based ids training and validation. In Proceedings of the Workshop on AI and Cybersecurity: Co-Located with 41st SGAI International Conference on Artificial Intelligence (SGAI 2021), CEUR Workshop Proceedings, Cambridge, UK, 14 December 2021; pp. 53–68. [Google Scholar]
- Văduva, J.A.; Popescu, C.M.; Florea, R.; Ciorgan, A.F.; Tirşu, V. Sim2Real cybersecurity testbed for modern automotive architectures. In Proceedings of the 2025 24th RoEduNet Conference: Networking in Education and Research (RoEduNet), Chișinău, Moldova, 17–20 September 2025; pp. 1–6. [Google Scholar]
- Kövesi, K.Z.; Bánáti, A. From Attack to Defense: Automotive Cyber Range for Can Bus Security Research. In Proceedings of the 2025 IEEE 19th International Symposium on Applied Computational Intelligence and Informatics (SACI), Budapest, Hungary, 19–24 May 2025; pp. 000075–000080. [Google Scholar]
- Micale, D.; Costantino, G.; Matteucci, I.; Fenzl, F.; Rieke, R.; Patanè, G. Cahoot: A context-aware vehicular intrusion detection system. In Proceedings of the 2022 IEEE International Conference on Trust, Security and Privacy in Computing and Communications (TrustCom), Wuhan, China, 9–11 December 2022; pp. 1211–1218. [Google Scholar]
- Micale, D.; Matteucci, I.; Fenzl, F.; Rieke, R.; Patanè, G. A context-aware on-board intrusion detection system for smart vehicles. Int. J. Inf. Secur. 2024, 23, 2203–2223. [Google Scholar] [CrossRef] [Scilit]
- Li, Q.; Peng, Z.; Feng, L.; Zhang, Q.; Xue, Z.; Zhou, B. Metadrive: Composing diverse driving scenarios for generalizable reinforcement learning. IEEE Trans. Pattern Anal. Mach. Intell. 2022, 45, 3461–3475. [Google Scholar] [CrossRef] [Scilit] [PubMed]
- Pascale, F.; Adinolfi, E.A.; Avagliano, M.; Bellacosa, E.; Coppola, S.; Santonicola, E. Cardian: A context aware cybersecurity system for real time diagnostic intrusion detection using a probabilistic approach with bayesian network. In Proceedings of the 2022 6th International Conference on System Reliability and Safety (ICSRS), Venice, Italy, 23–25 November 2022; pp. 424–429. [Google Scholar]
- Casillo, M.; Coppola, S.; De Santo, M.; Pascale, F.; Santonicola, E. Embedded intrusion detection system for detecting attacks over CAN-BUS. In Proceedings of the 2019 4th International Conference on System Reliability and Safety (ICSRS), Rome, Italy, 20–22 November 2019; pp. 136–141. [Google Scholar]
- Sun, N.; Wang, W.; Liu, K.; Li, D.; Lü, J. Hybrid framework for security evaluation in Internet of Vehicles. Comput. Secur. 2025, 153, 104398. [Google Scholar] [CrossRef] [Scilit]
- Finkenzeller, A.; Mathur, A.; Lauinger, J.; Hamad, M.; Steinhorst, S. Simutack-an attack simulation framework for connected and autonomous vehicles. In Proceedings of the 2023 IEEE 97th Vehicular Technology Conference (VTC2023-Spring), Florence, Italy, 20–23 June 2023; pp. 1–7. [Google Scholar]
- Astya, R.; Chauhan, M.; Buhari, A.; Lbrahim, F.; Alfiras, M. Deep Learning for Vehicular Intelligent Networks Architecture and Simulation-Based Evaluation. In Proceedings of the 2025 12th International Conference on Reliability, Infocom Technologies and Optimization (Trends and Future Directions) (ICRITO), Noida NCR, India, 18–19 September 2025; pp. 1–6. [Google Scholar]
- Gurban, E.H.; Groza, B.; Murvay, P.S. Risk assessment and security countermeasures for vehicular instrument clusters. In Proceedings of the 2018 48th Annual IEEE/IFIP International Conference on Dependable Systems and Networks Workshops (DSN-W), Luxembourg, 25–28 June 2018; pp. 223–230. [Google Scholar]
- Kalutarage, H.K.; Al-Kadri, M.O.; Cheah, M.; Madzudzo, G. Context-aware anomaly detector for monitoring cyber attacks on automotive CAN bus. In Proceedings of the 3rd ACM Computer Science in Cars Symposium, Kaiserslautern, Germany, 8 October 2019; pp. 1–8. [Google Scholar]
- Balaji, P.; Ghaderi, M. NeuroCAN: Contextual anomaly detection in controller area networks. In Proceedings of the 2021 IEEE International Smart Cities Conference (ISC2), Manchester, UK, 7–10 September 2021; pp. 1–7. [Google Scholar]
- Nguyen, T.P.; Nam, H.; Kim, D. Transformer-based attention network for in-vehicle intrusion detection. IEEE Access 2023, 11, 55389–55403. [Google Scholar] [CrossRef] [Scilit]
- First Steps with CARLA. Available online: https://carla.readthedocs.io/en/latest/tuto_first_steps/ (accessed on 1 April 2026).
- Klar, R.; Arvidsson, N.; Angelakis, V. Maturity of vehicle digital twins: From monitoring to enabling autonomous driving. In Proceedings of the 2024 IEEE 27th International Conference on Intelligent Transportation Systems (ITSC), Edmonton, AB, Canada, 24–27 September 2024; pp. 3673–3679. [Google Scholar]
- Klar, R.; Arvidsson, N.; Angelakis, V. Digital twins’ maturity: The need for interoperability. IEEE Syst. J. 2023, 18, 713–724. [Google Scholar] [CrossRef] [Scilit]
- CARLA Simulator. CARLA 0.9.16. Available online: https://github.com/carla-simulator/carla/releases/tag/0.9.16 (accessed on 1 April 2026).
- Quick Start Package Installation. Available online: https://carla.readthedocs.io/en/latest/start_quickstart/ (accessed on 1 April 2026).
- Song, H.M.; Woo, J.; Kim, H.K. In-vehicle network intrusion detection using deep convolutional neural network. Veh. Commun. 2020, 21, 100198. [Google Scholar] [CrossRef] [Scilit]
- ISO 26262:2018; Road Vehicles—Functional Safety. Standard International Organization for Standardization: Geneva, Switzerland, 2018.
Disclaimer/Publisher’s Note: The statements, opinions and data contained in all publications are solely those of the individual author(s) and contributor(s) and not of MDPI and/or the editor(s). MDPI and/or the editor(s) disclaim responsibility for any injury to people or property resulting from any ideas, methods, instructions or products referred to in the content. |
© 2026 by the authors. Licensee MDPI, Basel, Switzerland. This article is an open access article distributed under the terms and conditions of the Creative Commons Attribution (CC BY) license.








