Demos
This chapter describes the demo projects showcasing the core features of the SIL Kit. Available demos are:
Demo |
Abstract |
---|---|
The CanWriter application sends CAN frames to the CanReader application including frame acknowledgment handling. |
|
The EthernetWriter application sends Ethernet frames to the EthernetReader application including frame acknowledgment handling. |
|
A two-node LIN Setup with a LinMaster and a LinSlave application. Includes a simple scheduling mechanism and demonstrates controller sleep / wakeup handling. |
|
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. |
|
One application publishes GPS and temperature data, another application subscribes to these topics. Including (de-)serialization of the C++ structures into a transmittable format. |
|
The RPC server application provides two simple functions which are called by a RPC client application. Includes (de-)serialization of the function parameters. |
|
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. |
|
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. |
|
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
Install the VS Code extensions C/C++ and CMake
Open the folder with VS Code
For the git repository: open the root folder of the repository
For a SIL Kit package: open the SilKit-Demos folder
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.
In the CMake extension page, build the project under Project Status | Build
Locate the binaries
For the git repository: The binaries reside in
_build/<build config>/<build type, e.g. Debug, Release>/
For a SIL Kit package: The binaries reside in
<package folder>/SilKit/bin
Visual Studio
Make sure Visual Studio is set up for C++ and CMake is installed
Open the folder with Visual Studio
For the git repository: open the root folder of the repository
For a SIL Kit package: open the SilKit-Demos folder
Opening the folder automatically starts the CMake configuration step. You can also manually call this step under Project | Configure Cache.
Build the project with Build | Build All
Locate the binaries
For the git repository: The binaries reside in
_build/<build config>/<build type, e.g. Debug, Release>/
For a SIL Kit package: The binaries reside in
<package folder>/SilKit/bin
Command Line
Make sure a C++ compiler and CMake is installed
Open a terminal
For the git repository: navigate to the root folder of the repository
For a SIL Kit package: navigate to
<package folder>/SilKit-Demos
Run the following commands:
mkdir build
cd build
cmake ..
cmake --build .
Locate the binaries
For the git repository: The binaries reside in
build/<build config>/<build type, e.g. Debug, Release>/
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 ownSilKit
CMake target library, before the demos are configured by CMake. Or by changing thefind_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
sil-kit-system-controller (not needed for unsynchronized execution)
sil-kit-monitor (optional)
SIL Kit Network Simulator (optional)
- Parameters
<ParticipantConfiguration.yaml>
File name of the participant configuration to be used; useDemoCan.silkit.yaml
for an example configuration.<ParticipantName>
The name of the participant within the simulation; must either beCanWriter
orCanReader
.[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
sil-kit-system-controller (not needed for unsynchronized execution)
sil-kit-monitor (optional)
SIL Kit Network Simulator (optional)
- Parameters
<ParticipantConfiguration.yaml>
File name of the participant configuration to be used; useDemoEthernet.silkit.yaml
for an example configuration.<ParticipantName>
The name of the participant within the simulation; must either beEthernetWriter
orEthernetReader
.[RegistryUri]
Thesilkit://
URI of the registry to connect to; defaults tosilkit://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
sil-kit-system-controller (not needed for unsynchronized execution)
sil-kit-monitor (optional)
SIL Kit Network Simulator (optional)
- Parameters
<ParticipantConfiguration.yaml>
File name of the participant configuration to be used; useDemoLin.silkit.yaml
for an example configuration.<ParticipantName>
The name of the participant within the simulation; must either beEthernetWriter
orEthernetReader
.[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
SIL Kit Network Simulator (mandatory)
sil-kit-monitor (optional)
- Parameters
<ParticipantConfiguration.yaml>
File name of the participant configuration to be used; useDemoFlexRay.silkit.yaml
for an example configuration.<ParticipantName>
The name of the participant within the simulation; must either beNode0
orNode1
.[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
sil-kit-system-controller (not needed for unsynchronized execution)
sil-kit-monitor (optional)
- Parameters
<ParticipantConfiguration.yaml>
File name of the participant configuration to be used; useDemoPubSub.silkit.yaml
for an example configuration.<ParticipantName>
The name of the participant within the simulation; must either bePublisher
orSubscriber
.[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
sil-kit-system-controller (not needed for unsynchronized execution)
sil-kit-monitor (optional)
- Parameters
<ParticipantConfiguration.yaml>
File name of the participant configuration to be used; useDemoRpc.silkit.yaml
for an example configuration.<ParticipantName>
The name of the participant within the simulation; must either beServer
orClient
.[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 theAdd100
andSort
functions on theServer
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. WithDemoBenchmarkTCPNagleOff.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; useDemoNetSim.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.