Copyright (c) Microsoft Corporation. Licensed under the MIT license.
This example demonstrates a simple jrt-controller application that loads two codelets to a simple jbpf agent. The data_generator codelet increments a counter and sends the data to the jrt-controller app via an output map. The application aggregates the counter, prints a message about the aggregate value and sends this value to the simple_input codelet via a control_input channel. The simple_input codelet prints the received values.
This example assumes that you already have Jbpf and you have already built the Jbpf library without DPDK support (cmake option -DUSE_DPDK=off).
Also, it assumes that you are running all the below steps as root.
Steps to run the example.
Before running the sample apps build the project, see README.md for instructions to build bare metal or with containers.
cd $JRTC_PATH/jbpf-protobuf/jbpf
./init_and_patch_submodules.sh
source setup_jbpf_env.sh
mkdir -p build
cd build
cmake ../
make -jcd $JRTC_PATH
./init_submodules.sh
source setup_jrtc_env.sh
mkdir -p build
cd build
cmake ../
makecd $JRTC_PATH/sample_apps/first_example_c
source ../../setup_jrtc_env.sh
make -C ../jbpf_codelets/data_generator
make -C ../jbpf_codelets/simple_inputcd $JRTC_PATH/sample_apps/first_example_c
source ../../setup_jrtc_env.sh
make -C simple_agent_ipccd $JRTC_PATH/sample_apps/first_example_c
makecd $JRTC_PATH/sample_apps/first_example_c
source ../../setup_jrtc_env.sh
sudo -E ./run_jrtc.shcd $JRTC_PATH/sample_apps/first_example_c
source ../../setup_jrtc_env.sh
sudo -E ./run_simple_agent_ipc.shIf successful, one of the log messages at the agent side should report Registration succeeded:.
cd $JRTC_PATH/sample_apps/first_example_c
source ../../setup_jrtc_env.sh
sudo -E ./run_reverse_proxy.shcd $JRTC_PATH/sample_apps/first_example_c
source ../../setup_jrtc_env.sh
sudo -E ./run_decoder.shcd $JRTC_PATH/sample_apps/first_example_c
source ../../setup_jrtc_env.sh
sudo -E ./load_app.shUnload the yaml:
# Terminal 5
source ../../setup_jrtc_env.sh
./unload_app.shTo build the example from scratch, we run the following commands:
docker run --rm -it \
-v $(dirname $(dirname $(pwd))):/jrtc \
-w /jrtc/sample_apps/first_example_c \
jrtc-$OS:latest makeStart jrtc:
# Terminal 1
docker run --rm -it --net=host \
-v /tmp/jbpf:/tmp/jbpf \
-v /dev/shm:/dev/shm \
-v $(dirname $(dirname $(pwd))):/jrtc \
-w /jrtc/sample_apps/first_example_c \
jrtc-$OS:latest ./run_jrtc.shIn another terminal, run the Jbpf IPC agent:
# Terminal 2
docker run --rm -it \
-v /tmp/jbpf:/tmp/jbpf \
-v /dev/shm:/dev/shm \
-v $(dirname $(dirname $(pwd))):/jrtc \
-w /jrtc/sample_apps/first_example_c \
jrtc-$OS:latest ./run_simple_agent_ipc.shStart the reverse proxy:
# Terminal 3
docker run --rm -it --net=host \
-v /tmp/jbpf:/tmp/jbpf \
-v /dev/shm:/dev/shm \
-v $(dirname $(dirname $(pwd))):/jrtc \
-w /jrtc/sample_apps/first_example_c \
jrtc-$OS:latest ./run_reverse_proxy.shRun the local decoder:
# Terminal 4
docker run --rm -it --net=host \
-v $(dirname $(dirname $(pwd))):/jrtc \
-w /jrtc/sample_apps/first_example_c \
jrtc-$OS:latest ./run_decoder.shLoad the yaml:
# Terminal 5
docker run --rm -it --net=host \
-v $(dirname $(dirname $(pwd))):/jrtc \
-w /jrtc/sample_apps/first_example_c \
jrtc-$OS:latest ./load_app.shIf the codelets and the app were loaded successfully, you should see the following output at the jrt-controller:
App 1: Aggregate counter so far is 15
App 1: Aggregate counter so far is 55
...
Similarly, you should see the following printed messages on the agent side:
[JBPF_DEBUG]: Got aggregate value 15
[JBPF_DEBUG]: Got aggregate value 55
...
Unload the yaml:
# Terminal 5
docker run --rm -it --net=host \
-v $(dirname $(dirname $(pwd))):/jrtc \
-w /jrtc/sample_apps/first_example_c \
jrtc-$OS:latest ./unload_app.sh