This tool replay P4Runtime write requests to a Stratum device with a given Stratum P4Runtime write request log.
Before using this tool, make sure you enabled logging for P4Runtime write requests and sets the pipeline config path flag.
By default, Stratum will use the following flags for P4Runtime write log and the pipeline config.
-write_req_log_file=/var/log/stratum/p4_writes.pb.txt
-forwarding_pipeline_configs_file=/etc/stratum/pipeline_cfg.pb.txt
If you override any flags above, make sure to use a non-empty and valid path.
Copy those files to your laptop/server so we can use it later.
Check step 1.1 below if you are running a containerized Stratum.
Go to step 2 if you already have those files.
To copy files from a docker container, we get the container ID so we know which container we should access.
$ docker ps | grep stratum-bf
4c615277261d stratumproject/stratum-bfrt:9.7.2-4.14.49-OpenNetworkLinux "/usr/bin/stratum-st…" 5 days ago Up 5 days
The 4c615277261d
is the container ID we need.
Next, we can use docker cp
command to copy files we need
$ docker cp 4c615277261d:/var/log/stratum/p4_writes.pb.txt .
$ docker cp 4c615277261d:/etc/stratum/pipeline_cfg.pb.txt .
You should be able to see those files in the current working directory.
$ ls
p4_writes.pb.txt pipeline_cfg.pb.txt
Copy those files to your laptop or the place you are going to run stratum_replay tool.
We provide a container image that includes a prebuilt stratum_replay binary.
To use it, you can run the following commands:
docker run \
-v $PWD:$PWD \
-w $PWD \
stratumproject/stratum_replay \
-grpc-addr="ip-of-switch-to-replay-on:9339" \
-pipeline-cfg pipeline_cfg.pb.txt \
p4_writes.pb.txt
You will see the following message if every P4Runtime write succeeded
Done
However, you will get the following messages if something goes wrong:
Failed to send P4Runtime write request: [Error detail]
This message means there is a P4Runtime error when the tool is trying to send a write request, but there is not error when writing the same request to the original switch.
You may also get some warning message such as:
Expect to get an error, but the request succeeded.
Expected error: [Error message]
Request: [Request body]
This means there is an error shown in the log, which means we should expect an error when sending the write request, but we don't get any error.
The third warning message you can get is:
The expected error message is different from the actual error message:
Expected: [Error message]
Actual: [Error message]
This message means there is an error in the log, and the replay tool also get an error after sending a write request, but the error message is different.
Errors and warnings above can be caused by the wrong software version (e.g., using a different version of stratum) or using the wring write request for a given pipeline config file.
bazel run //stratum/tools/stratum_replay -- --helpshort