Demos

This chapter describes the demo projects showcasing the core features of the SIL Kit. Available demos are:

Demo

Abstract

CAN Demo

The CanWriter application sends CAN frames to the CanReader application including frame acknowledgment handling.

Ethernet Demo

The EthernetWriter application sends Ethernet frames to the EthernetReader application including frame acknowledgment handling.

LIN Demo

A two-node LIN Setup with a LinMaster and a LinSlave application. Includes a simple scheduling mechanism and demonstrates controller sleep / wakeup handling.

FlexRay Demo

A two-node FlexRay Setup with a full cluster and node parametrization. Includes POC Status handling, buffer updates and reconfiguration. This Demo requires a separate Network Simulator application to simulate the details of the FlexRay cluster, which is not included in the SIL Kit.

Publish/Subscribe Demo

One application publishes GPS and temperature data, another application subscribes to these topics. Including (de-)serialization of the C++ structures into a transmittable format.

RPC Demo

The RPC server application provides two simple functions which are called by a RPC client application. Includes (de-)serialization of the function parameters.

Benchmark Demo

This demo sets up a simulation with various command line arguments for benchmarking purposes. A configurable amount of participants are spawned by a single process on different threads. The demo calculates averaged running times, throughput, speed-up and message rates for performance evaluation.

Latency Demo

A sender and a receiver application use the Publish/Subscribe services and measure the round trip time of the communication. This setup is useful to evaluate the performance of a SIL Kit setup running on different platforms. E.g., between a local host, a virtual machine, a remote network, etc.

Network Simulator Demo

Demonstrates the usage of the experimental SIL Kit NetworkSimulator API. A custom network simulation for CAN is set up, the network simulator application can be used together with the CAN demo.

Building the Demos

The SIL Kit Demos are not available as pre-built binaries and have to be compiled from source first.

  • If you plan to use the demos as a starting point for further development, start by cloning the SIL Kit git repository. Don’t forget to call git submodule update --init --recursive after cloning the repository for the first time. Using the build instructions below will build the complete SIL Kit library including the Demos.

  • If you just want to try out the demos, download a SIL Kit release package which also includes all sources. Using the build instructions below will only build the SIL Kit Demos and use the precompiled library of the package.

  • Building the Demos from the installation folder of the SIL Kit MSI Installer is strongly discouraged, as all involved tools require administrative privileges if the default installation directory is used.

There are several options to build the demos, all require the installation of a C++ compiler and CMake.

Note

If you don’t have any experience with setting up C++ / CMake projects, we recommend using VS Code and a SIL Kit release package. VS Code is free to use, and the prerequisites can be quickly set up using the recommended VS Code extensions.

VS Code

  1. Install the VS Code extensions C/C++ and CMake

  2. Open the folder with VS Code

    1. For the git repository: open the root folder of the repository

    2. For a SIL Kit package: open the SilKit-Demos folder

  3. Opening the folder automatically starts the CMake configuration step. You can also manually call this step in the CMake extension page under Project Status | Configure.

  4. In the CMake extension page, build the project under Project Status | Build

  5. Locate the binaries

    1. For the git repository: The binaries reside in _build/<build config>/<build type, e.g. Debug, Release>/

    2. For a SIL Kit package: The binaries reside in <package folder>/SilKit/bin

Visual Studio

  1. Make sure Visual Studio is set up for C++ and CMake is installed

  2. Open the folder with Visual Studio

    1. For the git repository: open the root folder of the repository

    2. For a SIL Kit package: open the SilKit-Demos folder

  3. Opening the folder automatically starts the CMake configuration step. You can also manually call this step under Project | Configure Cache.

  4. Build the project with Build | Build All

  5. Locate the binaries

    1. For the git repository: The binaries reside in _build/<build config>/<build type, e.g. Debug, Release>/

    2. For a SIL Kit package: The binaries reside in <package folder>/SilKit/bin

Command Line

  1. Make sure a C++ compiler and CMake is installed

  2. Open a terminal

    1. For the git repository: navigate to the root folder of the repository

    2. For a SIL Kit package: navigate to <package folder>/SilKit-Demos

  3. Run the following commands:

    • mkdir build

    • cd build

    • cmake ..

    • cmake --build .

  4. Locate the binaries

    1. For the git repository: The binaries reside in build/<build config>/<build type, e.g. Debug, Release>/

    2. For a SIL Kit package: The binaries reside in <package folder>/SilKit/bin

Due to the large variety of terminals, different operating systems and availability of environment variables, the previous instruction can fail for several reasons. Usually, the configuration step performed in cmake .. will give useful hints of what went wrong.

Advanced CMake configuration

Build the Demos from a SIL Kit package against your own target library

The distributed Demos, as packaged by CPack, are preconfigured to build against a copy of the SIL Kit binaries in ../SilKit/. This can be overridden by providing your own SilKit CMake target library, before the demos are configured by CMake. Or by changing the find_package(SilKit ... PATHS path/to/SilKit) statement directly in the ./SilKit-Demos/CMakeLists.txt directory.

Note

In the following, the paths to run the demos are relative to the top level of the pre-built SIL Kit package. To adapt them to run from a git repository build, you have to change the relative path to the configuration file. E.g. use ../../../Demos/Can/DemoCan.silkit.yaml instead of ./SilKit-Demos/Can/DemoCan.silkit.yaml.

Further, the command line instructions use forward slashes for paths. When using Windows (e.g. Powershell), these have to be replaced with backward slashed. E.g., instead of ./SilKit/bin/SilKitDemoCan ./SilKit-Demos/Can/DemoCan.silkit.yaml CanReader, use .\SilKit\bin\SilKitDemoCan .\SilKit-Demos\Can\DemoCan.silkit.yaml CanReader

CAN Demo

Abstract

The CanWriter application sends CAN frames to the CanReader application including frame acknowledgment handling.

Source location

./SilKit-Demos/Can

Requirements
Parameters
  • <ParticipantConfiguration.yaml> File name of the participant configuration to be used; use DemoCan.silkit.yaml for an example configuration.

  • <ParticipantName> The name of the participant within the simulation; must either be CanWriter or CanReader.

  • [RegistryUri] The silkit:// URI of the registry to connect to; defaults to silkit://localhost:8500 (optional).

  • [--async] If async flag is set, the participant will join the simulation unsynchronized and it will not need the ./SilKit/bin/sil-kit-system-controller to start.

Parameter Example
# Creates a CAN Writer Process with the registry's default URI
./SilKit/bin/SilKitDemoCan ./SilKit-Demos/Can/DemoCan.silkit.yaml CanWriter
System Example

Run the following commands in separate terminals:

# Registry (if not already running):
./SilKit/bin/sil-kit-registry

# Monitor (optional):
./SilKit/bin/sil-kit-monitor

# CAN Reader:
./SilKit/bin/SilKitDemoCan ./SilKit-Demos/Can/DemoCan.silkit.yaml CanReader

# CAN Writer:
./SilKit/bin/SilKitDemoCan ./SilKit-Demos/Can/DemoCan.silkit.yaml CanWriter

# System Controller:
./SilKit/bin/sil-kit-system-controller CanReader CanWriter

To run the demo without virtual time synchronization, use the following commands in separate terminals:

# Registry (if not already running):
./SilKit/bin/sil-kit-registry

# CAN Reader:
./SilKit/bin/SilKitDemoCan ./SilKit-Demos/Can/DemoCan.silkit.yaml CanReader --async

# CAN Writer:
./SilKit/bin/SilKitDemoCan ./SilKit-Demos/Can/DemoCan.silkit.yaml CanWriter --async
Notes
  • The writer sends CAN frames at a fixed rate of one frame per simulation step (1ms).

  • Both reader and writer sleep for 1 second per simulation step to slow down the execution.

Ethernet Demo

Abstract

The EthernetWriter application sends Ethernet frames to the EthernetReader application including frame acknowledgment handling.

Source location

./SilKit-Demos/Ethernet

Requirements
Parameters
  • <ParticipantConfiguration.yaml> File name of the participant configuration to be used; use DemoEthernet.silkit.yaml for an example configuration.

  • <ParticipantName> The name of the participant within the simulation; must either be EthernetWriter or EthernetReader.

  • [RegistryUri] The silkit:// URI of the registry to connect to; defaults to silkit://localhost:8500 (optional).

  • [--async] If async flag is set, the participant will join the simulation unsynchronized and it will not need the ./SilKit/bin/sil-kit-system-controller to start.

Parameter Example
# Creates an Ethernet Writer Process with the registry's default URI:
./SilKit/bin/SilKitDemoEthernet ./SilKit-Demos/Ethernet/DemoEthernet.silkit.yaml EthernetWriter
System Example

Run the following commands in separate terminals:

# Registry (if not already running):
./SilKit/bin/sil-kit-registry

# Monitor (optional):
./SilKit/bin/sil-kit-monitor

# Ethernet Reader:
./SilKit/bin/SilKitDemoEthernet ./SilKit-Demos/Ethernet/DemoEthernet.silkit.yaml EthernetReader

# Ethernet Writer:
./SilKit/bin/SilKitDemoEthernet ./SilKit-Demos/Ethernet/DemoEthernet.silkit.yaml EthernetWriter

# System Controller:
./SilKit/bin/sil-kit-system-controller EthernetReader EthernetWriter

To run the demo without virtual time synchronization, use the following commands in separate terminals:

# Registry (if not already running):
./SilKit/bin/sil-kit-registry

# Ethernet Reader:
./SilKit/bin/SilKitDemoEthernet ./SilKit-Demos/Ethernet/DemoEthernet.silkit.yaml EthernetReader --async

# Ethernet Writer:
./SilKit/bin/SilKitDemoEthernet ./SilKit-Demos/Ethernet/DemoEthernet.silkit.yaml EthernetWriter --async
Notes
  • The writer sends Ethernet frames at a fixed rate of one frame per simulation step (1ms).

  • Both reader and writer sleep for 1 second per simulation step to slow down execution.

LIN Demo

Abstract

A two-node LIN Setup with a LinMaster and a LinSlave application. Includes a simple scheduling mechanism and demonstrates controller sleep / wakeup handling.

Source location

./SilKit-Demos/Lin

Requirements
Parameters
  • <ParticipantConfiguration.yaml> File name of the participant configuration to be used; use DemoLin.silkit.yaml for an example configuration.

  • <ParticipantName> The name of the participant within the simulation; must either be EthernetWriter or EthernetReader.

  • [RegistryUri] The silkit:// URI of the registry to connect to; defaults to silkit://localhost:8500 (optional).

  • [--async] If async flag is set, the participant will join the simulation unsynchronized and it will not need the ./SilKit/bin/sil-kit-system-controller to start.

Parameter Example
# Creates a LIN Master Process with the registry's default URI:
./SilKit/bin/SilKitDemoLin ./SilKit-Demos/Lin/DemoLin.silkit.yaml LinMaster
System Example

Run the following commands in separate terminals:

# Registry (if not already running):
./SilKit/bin/sil-kit-registry

# Monitor (optional):
./SilKit/bin/sil-kit-monitor

# LIN Master:
./SilKit/bin/SilKitDemoLin ./SilKit-Demos/Lin/DemoLin.silkit.yaml LinMaster

# LIN Slave:
./SilKit/bin/SilKitDemoLin ./SilKit-Demos/Lin/DemoLin.silkit.yaml LinSlave

# System Controller:
./SilKit/bin/sil-kit-system-controller LinSlave LinMaster

To run the demo without virtual time synchronization, use the following commands in separate terminals:

# Registry (if not already running):
./SilKit/bin/sil-kit-registry

# LIN Master:
./SilKit/bin/SilKitDemoLin ./SilKit-Demos/Lin/DemoLin.silkit.yaml LinMaster --async

# LIN Slave:
./SilKit/bin/SilKitDemoLin ./SilKit-Demos/Lin/DemoLin.silkit.yaml LinSlave --async
Notes
  • Both Master and Slave sleep for 100ms per simulation step to slow down execution.

FlexRay Demo

Abstract

A two-node FlexRay Setup with a full cluster and node parametrization. Includes POC Status handling, buffer updates and reconfiguration. This Demo requires a separate Network Simulator application to simulate the details of the FlexRay cluster, which is not included in the SIL Kit.

Source location

./SilKit-Demos/FlexRay

Requirements
Parameters
  • <ParticipantConfiguration.yaml> File name of the participant configuration to be used; use DemoFlexRay.silkit.yaml for an example configuration.

  • <ParticipantName> The name of the participant within the simulation; must either be Node0 or Node1.

  • [RegistryUri] The silkit:// URI of the registry to connect to; defaults to silkit://localhost:8500 (optional).

Parameter Example
# Creates a FlexRay Process for Node 0 with the registry's default URI:
./SilKit/bin/SilKitDemoFlexRay ./SilKit-Demos/FlexRay/DemoFlexRay.silkit.yaml Node0
System Example

Run the following commands in separate terminals:

# Registry (if not already running):
./SilKit/bin/sil-kit-registry

# Network Simulator (assumed to be in PATH, necessary):
sil-kit-network-simulator ./SilKit-Demos/FlexRay/NetworkSimulatorConfig.yaml

# Monitor (optional):
./SilKit/bin/sil-kit-monitor

# Node 0:
./SilKit/bin/SilKitDemoFlexRay ./SilKit-Demos/FlexRay/DemoFlexRay.silkit.yaml Node0

# Node 1:
./SilKit/bin/SilKitDemoFlexRay ./SilKit-Demos/FlexRay/DemoFlexRay.silkit.yaml Node1

# System Controller:
./SilKit/bin/sil-kit-system-controller Node0 Node1 NetworkSimulator
Notes
  • Starting the FlexRay cycle takes quite some time, which is accurately modeled by the SIL Kit Network Simulator.

  • It takes somewhat between 50 and 100 ms until the first FlexRay messages are transmitted.

Publish/Subscribe Demo

Abstract

One application publishes GPS and temperature data, another application subscribes to these topics. Including (de-)serialization of the C++ structures into a transmittable format.

Source location

./SilKit-Demos/PubSub

Requirements
Parameters
  • <ParticipantConfiguration.yaml> File name of the participant configuration to be used; use DemoPubSub.silkit.yaml for an example configuration.

  • <ParticipantName> The name of the participant within the simulation; must either be Publisher or Subscriber.

  • [RegistryUri] The silkit:// URI of the registry to connect to; defaults to silkit://localhost:8500 (optional).

  • [--async] If async flag is set, the participant will join the simulation unsynchronized and it will not need the ./SilKit/bin/sil-kit-system-controller to start.

Parameter Example
# Creates a publisher with the registry's default URI:
./SilKit/bin/SilKitDemoPubSub ./SilKit-Demos/PubSub/DemoPubSub.silkit.yaml Publisher
System Example

Run the following commands in separate terminals:

# Registry (if not already running):
./SilKit/bin/sil-kit-registry

# Monitor (optional):
./SilKit/bin/sil-kit-monitor

# Publisher:
./SilKit/bin/SilKitDemoPubSub ./SilKit-Demos/PubSub/DemoPubSub.silkit.yaml Publisher

# Subscriber:
./SilKit/bin/SilKitDemoPubSub ./SilKit-Demos/PubSub/DemoPubSub.silkit.yaml Subscriber

# System Controller:
./SilKit/bin/sil-kit-system-controller Publisher Subscriber

To run the demo without virtual time synchronization, use the following commands in separate terminals:

# Registry (if not already running):
./SilKit/bin/sil-kit-registry

# Publisher:
./SilKit/bin/SilKitDemoPubSub ./SilKit-Demos/PubSub/DemoPubSub.silkit.yaml Publisher --async

# Subscriber:
./SilKit/bin/SilKitDemoPubSub ./SilKit-Demos/PubSub/DemoPubSub.silkit.yaml Subscriber --async
Notes
  • The publisher and subscriber show how to serialize/deserialize different kinds of data with the built-in Data Serialization API.

RPC Demo

Abstract

The RPC server application provides two simple functions which are called by a RPC client application. Includes (de-)serialization of the function parameters.

Source location

./SilKit-Demos/Rpc

Requirements
Parameters
  • <ParticipantConfiguration.yaml> File name of the participant configuration to be used; use DemoRpc.silkit.yaml for an example configuration.

  • <ParticipantName> The name of the participant within the simulation; must either be Server or Client.

  • [RegistryUri] The silkit:// URI of the registry to connect to; defaults to silkit://localhost:8500 (optional).

  • [--async] If async flag is set, the participant will join the simulation unsynchronized and it will not need the ./SilKit/bin/sil-kit-system-controller to start.

Parameter Example
# Creates an RPC server process with the registry's default URI:
./SilKit/bin/SilKitDemoRpc ./SilKit-Demos/Rpc/DemoRpc.silkit.yaml Server
System Example

Run the following commands in separate terminals:

# Registry (if not already running):
./SilKit/bin/sil-kit-registry

# Monitor (optional):
./SilKit/bin/sil-kit-monitor

# Server:
./SilKit/bin/SilKitDemoRpc ./SilKit-Demos/Rpc/DemoRpc.silkit.yaml Server

# Client:
./SilKit/bin/SilKitDemoRpc ./SilKit-Demos/Rpc/DemoRpc.silkit.yaml Client

# System Controller:
./SilKit/bin/sil-kit-system-controller Server Client

To run the demo without virtual time synchronization, use the following commands in separate terminals:

# Registry (if not already running):
./SilKit/bin/sil-kit-registry

# Server:
./SilKit/bin/SilKitDemoRpc ./SilKit-Demos/Rpc/DemoRpc.silkit.yaml Server --async

# Client:
./SilKit/bin/SilKitDemoRpc ./SilKit-Demos/Rpc/DemoRpc.silkit.yaml Client --async
Notes
  • Client participant has two RPC clients which call the Add100 and Sort functions on the Server participant’s two RPC servers.

Benchmark Demo

Abstract

This demo sets up a simulation with various command line arguments for benchmarking purposes. A configurable amount of participants are spawned by a single process on different threads. The demo calculates averaged running times, throughput, speed-up and message rates for performance evaluation.

Source location

./SilKit-Demos/Benchmark

Requirements

None (The demo starts its own instance of the registry and system controller).

Positional Parameters
  • [numberOfSimulationRuns] Sets the number of simulation runs to perform.

  • [simulationDuration] Sets the virtual simulation duration <S>.

  • [numberOfParticipants] Sets the number of simulation participants <N>.

  • [messageCount] Sets the number of messages <M> to be send in each simulation step.

  • [messageSizeInBytes] Sets the message size <B>.

  • [registryURi] The URI of the registry to start.

Optional Parameters
  • --help Show the help message.

  • --registry-uri The URI of the registry to start. Default: silkit://localhost:8500

  • --message-size Sets the message size <B> in bytes. Default: 1000

  • --message-count Sets the number of messages <M> to be send in each simulation step. Default: 50

  • --number-participants Sets the number of simulation participants <N>. Default: 2

  • --number-simulation-runs Sets the number of simulation runs to perform. Default: 4

  • --simulation-duration Sets the simulation duration <S> (virtual time). Default: 1s

  • --configuration Path and filename of the participant configuration YAML file. Default: empty

  • --write-csv Path and filename of CSV file with benchmark results. Default: empty

System Examples
  • Launch the benchmark demo with default arguments but 3 participants:

    ./SilKit/bin/SilKitDemoBenchmark --number-participants 3
  • Launch the benchmark demo with positional arguments and a configuration file that enforces TCP communication:

    ./SilKit/bin/SilKitDemoBenchmark 4 1 2 1 10 --configuration ./SilKit-Demos/Benchmark/DemoBenchmarkDomainSocketsOff.silkit.yaml
Notes
  • This benchmark demo produces timings of a configurable simulation setup. <N> participants exchange <M> messages of <B> bytes per simulation step with a fixed simulation step size of 1ms and run for <S> seconds (virtual time).

  • This simulation run is repeated <K> times and averages over all runs are calculated. Results for average runtime, speedup (virtual time/runtime), throughput (data size/runtime), message rate (count/runtime) including the standard deviation are printed.

  • The demo uses publish/subscribe controllers with the same topic for the message exchange, so each participant broadcasts the messages to all other participants. The configuration file DemoBenchmarkDomainSocketsOff.silkit.yaml can be used to disable domain socket usage for more realistic timings of TCP/IP traffic. With DemoBenchmarkTCPNagleOff.silkit.yaml, Nagle’s algorithm and domain sockets are switched off.

  • The demo can be wrapped in helper scripts to run parameter scans, e.g., for performance analysis regarding different message sizes. See .\SilKit-Demos\Benchmark\msg-size-scaling\Readme.md and .\SilKit-Demos\Benchmark\performance-diff\Readme.md for further information.

Latency Demo

Abstract

A sender and a receiver application use the Publish/Subscribe services and measure the round trip time of the communication. This setup is useful to evaluate the performance of a SIL Kit setup running on different platforms. E.g., between a local host, a virtual machine, a remote network, etc.

Source location

./SilKit-Demos/Benchmark

Requirements
Positional Parameters
  • [messageCount] Sets the number of messages to be send in each simulation step.

  • [messageSizeInBytes] Sets the message size.

  • [registryURi] The URI of the registry to start.

Optional Parameters
  • --help Show the help message.

  • --isReceiver This process is the receiving counterpart of the latency measurement. Default: false

  • --registry-uri The URI of the registry to start. Default: silkit://localhost:8500

  • --message-size Sets the message size. Default: 1000

  • --message-count Sets the number of messages to be send in each simulation step. Default: 1000

  • --configuration Path and filename of the participant configuration YAML file. Default: empty

  • --write-csv Path and filename of csv file with benchmark results. Default: empty

System Examples
  • Launch the two LatencyDemo instances with positional arguments in separate terminals: .. parsed-literal:

    |DemoDir|/SilKitDemoLatency 100 1000
    |DemoDir|/SilKitDemoLatency 100 1000 --isReceiver
    
  • Launch the LatencyDemo instances with a configuration file that enforces TCP communication: .. parsed-literal:

    |DemoDir|/SilKitDemoLatency 100 1000 --configuration ./SilKit-Demos/Benchmark/DemoBenchmarkDomainSocketsOff.silkit.yaml
    |DemoDir|/SilKitDemoLatency 100 1000 --isReceiver
    
Notes
  • This latency demo produces timings of a configurable simulation setup. Two participants exchange <M> messages of <B> bytes without time synchronization.

  • The demo uses publish/subscribe controllers performing a message round trip (ping-pong) to calculate latency and throughput timings.

  • Note that the two participants must use the same parameters for valid measurement and one participant must use the --isReceiver flag.

Network Simulator Demo

Abstract

Demonstrates the usage of the experimental SIL Kit NetworkSimulator API. A custom network simulation for CAN is set up, the network simulator application can be used together with the CAN demo.

Source location

./SilKit-Demos/NetworkSimulator

Requirements
Parameters
  • <ParticipantConfiguration.yaml> File name of the participant configuration to be used; use DemoNetSim.silkit.yaml for an example configuration.

  • <ParticipantName> The name of the participant within the simulation.

  • [RegistryUri] The silkit:// URI of the registry to connect to; defaults to silkit://localhost:8500 (optional).

Parameter Example
# Start the Network Simulator Demo with the given configuration file and participant name
./SilKit/bin/SilKitDemoNetSim ./SilKit-Demos/NetworkSimulator/DemoNetSim.silkit.silkit.yaml NetworkSimulator
System Example

Interplay with the CAN Demo:

# Registry (if not already running):
./SilKit/bin/sil-kit-registry

# Monitor (optional):
./SilKit/bin/sil-kit-monitor

# CAN Reader:
./SilKit/bin/SilKitDemoCan ./SilKit-Demos/Can/DemoCan.silkit.yaml CanReader

# CAN Writer:
./SilKit/bin/SilKitDemoCan ./SilKit-Demos/Can/DemoCan.silkit.yaml CanWriter

# System Controller:
./SilKit/bin/sil-kit-system-controller CanReader CanWriter NetworkSimulator

# Network Simulator Demo:
./SilKit/bin/SilKitDemoNetSim ./SilKit-Demos/NetworkSimulator/DemoNetSim.silkit.silkit.yaml NetworkSimulator
Notes
  • The CAN Reader and Writer configure their controller on the network “CAN1”, which is simulated by the network simulator demo.

  • In the simple bus logic of the network simulation demo (see Demos\NetworkSimulator\src\Can\MySimulatedCanController.cpp), the acknowledgment (CanFrameTransmitEvent) is sent directly to the CAN Writer. The frame itself (CanFrameEvent) is sent with a delay of 2ms.