Reputation: 201
I'm new to P4, and I'm trying to understand how packet counters are implemented.
In the documentation, it is quite clear how counters are defined and then incremented. But I cannot see how one would be able to view the counter using the control plane.
I'm using Mininet and the BMV2 software switch - how would I be able to view my counter values?
Upvotes: 2
Views: 502
Reputation: 431
The interactions between the data and the control plane are defined in the P4Runtime specification, which can be found at https://p4.org/specs/. This is a general document not specific to BMv2 switches.
There are two ways to manage BMv2 software switches.
When manually reading the switch state (e.g. counter value) is sufficient, you may use the Thrift-based simple_switch_CLI
command. It gets installed as part of BMv2, together with the simple_switch
command. In the CLI you will be able to use the counter_read
command.
To read the values from a Python script, you can use e.g. the nsg-ethz/p4-utils which contains Python bindings for both the Thrift and the P4Runtime APIs. The repository contains usage examples.
Make sure you use the simple_switch_grpc
command to start your switch if you wish to use the P4Runtime API.
Upvotes: 1