I was able to install the Stratum BMv2 switch as a standalone instance on a VM. I've attempted to clean up the instructions (i.e. these instructions have been updated and are not exactly what was was executed on the command line) for folks who would like to attempt the same (Note: There may be more elegant ways of setting this up :) )
# Create BMV2 package for a VM Running Debian 10
Note: "host>" is the host system which will be used to generate the Stratum
BMv2 Debian package. "stratum_dev>" is the Stratum development docker container.
"vm>" is a Debian 10 VM which will be converted into the Stratum BMv2 switch.
1. Clone the stratum repo on your host system:
host> mkdir repos && cd repos
host> git clone g...@github.com:stratum/stratum.git
2. Change dependency version for boost from libboost1.55-all-dev to
libboost1.67-all-dev (Since Debian 10 does not ship with libboost1.55-all-dev):
host> cd stratum
host> vim stratum/hal/bin/bmv2/BUILD
...
"libboost1.67-all-dev",
...
REF:
https://github.com/stratum/stratum/blob/main/stratum/hal/bin/bmv2/BUILD#L81-L983. Start the stratum docker development container and build the BMv2 package:
host> ./setup_dev_env.sh # You should now be in the stratum container.
stratum_dev> bazel build --stamp //stratum/hal/bin/bmv2:stratum_bmv2_debian
stratum_dev> mkdir stratum_bmv2_configs/libs && cd stratum_bmv2_configs/libs
stratum_dev> cp /usr/local/lib/libbmpi.so.0.0.0 ./stratum_bmv2_configs/libs
stratum_dev> cp /usr/local/lib/libsimpleswitch_runner.so.0.0.0 ./stratum_bmv2_configs/libs
Note: The package should exist at
~/repos/stratum/bazel-bin/stratum/hal/bin/bmv2/stratum_bmv2_debian.deb on the
host. Let's move the package to a common directory:
stratum_dev> mkdir stratum_bmv2_configs/bmv2_package && cd stratum_bmv2_configs/bmv2_package
stratum_dev> cp ~/repos/stratum/bazel-bin/stratum/hal/bin/bmv2/stratum_bmv2_debian.deb ./
4. SCP the package and associated libraries to the VM.
host> ssh <user>@<VM IP>
vm> mkdir stratum && mkdir stratum/bmv2_package
host> scp stratum_bmv2_configs/bmv2_package/stratum_bmv2_debian.deb <user>@<VM IP>:/home/<user>/stratum/bmv2_package
host> scp -r stratum_bmv2_configs/libs <user>@<VM IP>:/home/<user>/stratum
host> scp -r stratum_bmv2_configs/bmv2_config <user>@<VM IP>:/home/<user>/stratum
host> scp ~/repos/stratum/stratum/hal/bin/bmv2/dummy.json <user>@<VM IP>:/home/<user>/stratum
5. Install bazel 3.7.2 on the VM
vm> sudo apt install apt-transport-https curl gnupg
vm> curl -fsSL
https://bazel.build/bazel-release.pub.gpg | gpg --dearmor > bazel.gpg
vm> sudo mv bazel.gpg /etc/apt/trusted.gpg.d/
vm> echo "deb [arch=amd64]
https://storage.googleapis.com/bazel-apt stable jdk1.8" | sudo tee /etc/apt/sources.list.d/bazel.list
vm> sudo apt update && sudo apt install bazel-3.7.2
REF:
https://docs.bazel.build/versions/master/install-ubuntu.html3. Install dependencies and build stratum:
vm> sudo apt-get update
vm> sudo apt-get install apt-utils libjudy-dev libgmp-dev libpcap-dev mpi-default-dev libnl-3-200=3.4.0-1 libnl-route-3-200=3.4.0-1 libnl-route-3-dev libnl-3-dev libibverbs-dev libopenmpi-dev libboost-mpi-dev libboost-mpi-python-dev libboost1.67-all-dev -y
REF:
https://github.com/stratum/stratum/blob/main/stratum/hal/bin/bmv2/BUILD#L81-L984. Configure bmv2 associated libraries:
vm> cd stratum/libs
vm> sudo cp * /usr/local/lib/ && cd /usr/local/lib/
vm> sudo ln -s libsimpleswitch_runner.so.0.0.0 libsimpleswitch_runner.so.0 && sudo ln -s libbmpi.so.0.0.0 libbmpi.so.0
vm> sudo vim /etc/ld.so.conf
...
/usr/local/lib
vm> sudo ldconfig
5. Create links to older version of boost libraries:
vm> sudo ln -s /usr/lib/x86_64-linux-gnu/libboost_system.so.1.67.0 /usr/lib/x86_64-linux-gnu/libboost_system.so.1.62.0
vm> sudo ln -s /usr/lib/x86_64-linux-gnu/libboost_program_options.so.1.67.0 /usr/lib/x86_64-linux-gnu/libboost_program_options.so.1.62.0
vm> sudo ln -s /usr/lib/x86_64-linux-gnu/libboost_filesystem.so.1.67.0 /usr/lib/x86_64-linux-gnu/libboost_filesystem.so.1.62.0
vm> sudo ln -s /usr/lib/x86_64-linux-gnu/libboost_thread.so.1.67.0 /usr/lib/x86_64-linux-gnu/libboost_thread.so.1.62.0
6. Install the bmv2 package:
vm> cd ~/stratum/bmv2_package
vm> sudo apt-get install --reinstall ./stratum_bmv2_debian.deb
7. Add interfaces to config file and create the empty p4_pipeline.pb.txt which
is where your pipeconfig will be stored (i.e. after being pushed by the switch):
vm> cd ~/stratum/bmv2_config
vm> cp config.txt switch_ports-spine1.txt
vm> vim switch_ports-spine1.txt
description: "Spine1"
chassis {
platform: PLT_P4_SOFT_SWITCH
name: "bmv2-simple_switch"
}
nodes {
id: 1
slot: 1
index: 1
}
singleton_ports {
id: 0
name: "Eth0"
slot: 1
port: 0
channel: 1
speed_bps: 100000000000
config_params {
admin_state: ADMIN_STATE_ENABLED
}
node: 1
}
...
9. Create an empty "p4_pipeline.pb.txt" file (The P4 pipeline, pushed by the
controller, will be stored in there).
vm> vim p4_pipeline.pb.txt
10. Start the switch on port 50010:
vm> sudo stratum_bmv2 \
--persistent_config_dir=/home/<user>/stratum/bmv2_config \
--forwarding_pipeline_configs_file=/home/<user>/stratum/bmv2_config/p4_pipeline.pb.txt \
--chassis_config_file=/home/<user>/stratum/bmv2_config/switch_ports-spine1.txt \
--external_stratum_urls="
192.168.122.10:50010" \
--initial_pipeline="/home/<user>/stratum/bmv2_config/dummy.json" \
--bmv2_log_level=info
11. Attempt to connect to the switch from the P4R shell:
host> cd ~/repos
host> git clone g...@github.com:opennetworkinglab/ngsdn-tutorial.git
host> cd ~/repos/ngsdn-tutorial
host> util/p4rt-sh --grpc-addr
192.168.122.10:50010 --config ../stratum/stratum_bmv2_configs/bmv2_config/p4info.txt,../stratum/stratum_bmv2_configs/bmv2_config/bmv2.json --election-id 0,1
12. Use the gnmi utility to ensure that all ports are visible:
host> util/gnmi-cli --grpc-addr
192.168.122.10:50010 get / | util/oc-pb-decoder | less