Skip to content

Fault Injection - Overview

API Documentation

feral.fault_injection

Explanation

The FERAL Framework distinguishes itself with a robust fault injection feature designed specifically for network simulation environments.

This capability enables users to rigorously test their systems' resilience and response to various failures and errors, a critical aspect of ensuring reliability and robustness in real-world applications. Through the fault injection mechanism, the framework intercepts network communication, allowing for the simulation of a wide range of fault conditions. Users can customize these conditions or rely on a set of predefined behaviors, thus offering a versatile tool for developing systems that are not only effective under ideal conditions but are also equipped to handle unexpected network disruptions. This feature is invaluable for researchers and developers aiming to enhance system performance and dependability in the face of network inconsistencies.

Usage

Fault Injection in a CAN Bus

Here the communication on a simulated CAN Bus is intercepted by fault injection, starting at a configured simulation time.

TwoNodesCANNGFaultInject.java
public class TwoNodesCANNGFaultInject {

    protected Scenario scenario = null;
    private final long STEP_SIZE_NS = SimulationTime.s(1);
    private final long SIMULATION_DURATION_NS = SimulationTime.s(10);
    private final long FAILURE_START_TIME_NS = SimulationTime.s(3);
    private final long FAILURE_END_TIME_NS = SimulationTime.s(6);

    public void createScenario() {

        scenario = new SimulationScenario();
        Director root = new DiscreteEventMOCC(scenario);
        root.setName("root");

        SenderEventWorker canSender = new SenderEventWorker(root, 1, STEP_SIZE_NS);
        canSender.setName("canSender");

        ReceiverEventWorker canReceiver = new ReceiverEventWorker(root);
        canReceiver.setName("canReceiver");


        CANNetwork network = new DefaultCANNetwork(root, 2);

        network.setBitRate(100000);
        network.getTopology().getApplicationInterface(0).addTxMessageType("63", "app1", 1);
        network.getTopology().getApplicationInterface(1).addRxMessageType("63", "app1", 1);
        new Link(canSender.getOutputPort("comm"),
                network.getTopology().getApplicationInterface(0).getInputPort("app1"));
        new Link(network.getTopology().getApplicationInterface(1).getOutputPort("app1"),
                canReceiver.getInputPort("comm"));

        ErrorModel errorModel = new SenderLinkFailure();

        ErrorProcessor errorProcessor = new ModifyIntegerSignFrameProcessor( );
        errorProcessor.addErrorType(new SenderLinkFailureError());
        ((DefaultFaultInjectionTopology) network.getTopology()).getTxFaultProcessor(0).addErrorProcessor(errorProcessor);

        ((DefaultFaultInjectionTopology) network.getTopology()).getTxFaultInjector(0).getErrorInjector()
                .addErrorModelInstance("txCRCFailure", errorModel);

        new BehaviorActivator(root, new SimulationTime(FAILURE_START_TIME_NS), errorModel);
        new BehaviorDeactivator(root, new SimulationTime(FAILURE_END_TIME_NS), errorModel);
    }

    /**
     * Run the simulation scenario
     */
    public void runSimulationScenario() {
        createScenario();

        scenario.startSimulation(SIMULATION_DURATION_NS);
    }

    /**
     * Main method
     */
    public static void main(String[] args) {
        new TwoNodesCANNGFaultInject().runSimulationScenario();
    }
}

Output Log
INFO:  Simulation time: 0.000ms starting the simulation...
DEBUG: Simulation time: 1000.620ms (DE_ReceiverEventWorker (ReceiverEventWorker)) RX | Payload: 1 | FERAL Msg ID: 13
DEBUG: Simulation time: 2000.620ms (DE_ReceiverEventWorker (ReceiverEventWorker)) RX | Payload: 2 | FERAL Msg ID: 81
DEBUG: Simulation time: 3000.620ms (DE_ReceiverEventWorker (ReceiverEventWorker)) RX | Payload: -3 | FERAL Msg ID: 149
DEBUG: Simulation time: 4000.620ms (DE_ReceiverEventWorker (ReceiverEventWorker)) RX | Payload: -4 | FERAL Msg ID: 217
DEBUG: Simulation time: 5000.620ms (DE_ReceiverEventWorker (ReceiverEventWorker)) RX | Payload: -5 | FERAL Msg ID: 285
DEBUG: Simulation time: 6000.620ms (DE_ReceiverEventWorker (ReceiverEventWorker)) RX | Payload: 6 | FERAL Msg ID: 353
DEBUG: Simulation time: 7000.620ms (DE_ReceiverEventWorker (ReceiverEventWorker)) RX | Payload: 7 | FERAL Msg ID: 421
DEBUG: Simulation time: 8000.620ms (DE_ReceiverEventWorker (ReceiverEventWorker)) RX | Payload: 8 | FERAL Msg ID: 489
DEBUG: Simulation time: 9000.620ms (DE_ReceiverEventWorker (ReceiverEventWorker)) RX | Payload: 9 | FERAL Msg ID: 557
INFO:  simulation finished!