I’m testing digest behavior in P4 and I’m seeing results that I don’t quite understand.
For testing purposes, the digest is triggered on almost every packet and it is configured with:
Based on this, I would expect each packet to generate a digest that is sent almost immediately and containing a single entry.
However, what I observe is:
-
Digests are sent 100–200 ms later, not after ~1 ms.
-
In the switch logs, it appears as if the digest is transmitted ~1 ms after being generated, but actually it is sent 100–200 ms later.
-
Some digests contain two entries even though max_list_size = 1.
-
Only two digests per switch reach the controller, after which it seems like some internal buffer becomes full and no more digests are sent.
Has anyone seen similar behavior or knows how digest batching/timing is actually handled internally in BMv2?
If you are comfortable modifying behavioral-model source code and recompiling it from modified source to get more debug output, I would recommend trying to add new debug print statements in your copy in the behavioral-model code that configures the max_list_size and max_timeout_ns (by different names in the source code by the time it reaches that layer of the implementation) and run your tests again to see if it helps analyze what is going on:
method in bmv2 source where the max_list_size is configured: behavioral-model/src/bm_sim/learning.cpp at main · p4lang/behavioral-model · GitHub
where the max_timeout is configured: behavioral-model/src/bm_sim/learning.cpp at main · p4lang/behavioral-model · GitHub
code called when your P4 program generates a digest message, and decides whether to send a new message to the controller immediately, or wait: behavioral-model/src/bm_sim/learning.cpp at main · p4lang/behavioral-model · GitHub
I did not isolate the precise code that checks when the max_time has elapsed and causes a transmission, but when the max_list_size is 1 it appears that should not matter.
If you have not build behavioral-model from source code before, hopefully these commands run starting from the top-level directory of a clone of the behavioral-model repo should work:
mkdir build
cd build
cmake -DWITH_PI=on -DWITH_THRIFT=on -DENABLE_MODULES=on ..
make
sudo make install/strip
sudo ldconfig