bmv2
Designing your own switch target with bmv2
Public Member Functions | List of all members
bm::Meter Class Reference

Public Member Functions

color_t execute (const Packet &pkt, color_t pre_color=0)
 

Detailed Description

Implementation of a general non-color aware N rate N+1 color marker. For P4 we will use 2 rate 3 color meters, as per this rfc.

Note that a Meter operates on either bytes or packets (not both, unlike a Counter).

Member Function Documentation

◆ execute()

color_t bm::Meter::execute ( const Packet pkt,
color_t  pre_color = 0 
)

Executes the meter on the given packet. Returns an integral value in the range [0, N] (where N is the number of rates for this meter). A higher value means that the meter is "busier". For a classic trTCM:

  • 0 <-> GREEN
  • 1 <-> YELLOW
  • 2 <-> RED You can optionally provide a pre-color for the meter. If the computed color is less than the pre-color, the pre-color will be returned instead.

The documentation for this class was generated from the following file: