Skip to content


Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?

Latest commit


Git stats


Failed to load latest commit information.
Latest commit message
Commit time

Speedlight BMv2

This repository contains a BMv2 adaptation of the Speedlight P4 dataplane, originally implemented for the Barefoot Tofino.


  • p4src/ -- The P4 source code of Speedlight.
    • includes/p4/ -- P4 includes that are shared amongst all variants.
    • primitives/ -- Stateful primitives for Speedlight.
  • snapshot_init/ -- Snapshot initiation program.
  • third_party/ -- bmv2 and p4v-bm submodules.

Naming Conventions

For file names:

  • *_W -- Contains code for handling wrapping of the snapshot ID back to zero.
  • *_C -- Contains code for capturing channel state, not just local processing unit state.

For function names:

  • t* -- match table
  • a* -- action definition
  • r* -- stateful register operation
  • i or e as a second letter indicates ingress or egress. None indicates it is used for both. For example, tiCheckRollover is a table used during ingress, reUpdateSnapshotId is a stateful operation used during egress, and aCheckSnapshotCase is an action used in both directions.

Compiling the dataplane

This release has been tested on Ubuntu 16.04 LTS, but should work on Ubuntu 14.04+. p4 simluator has a large memory requirement. We used it in 32gb RAM. The following instructions assume 3 windows: (1) switch behavioral model, (2) notification listener, and (3) snapshot initiation script.

  1. Setup.

    # Installs all prerequisites and compiles the Speedlight dataplane, including:
    # Also sets up the virtual network interfaces for BMv2
  2. Compile and run the Speedlight dataplane.

    # <VARIANT>            {Pkt, Pkt_W, Pkt_WC}
    # <NUM_PORTS>          Number of ports in the switch.
    # <MAX_SNAPSHOT_ID>    Highest valid snapshot ID. Without wraparound (*_W),
    #                      behavior above this value is undefined. With wraparound,
    #                      this number determines the maximum number of outstanding
    #                      snapshots.
    # Leave this window open
  3. In a new window, install the match-action rules and start listening for notifications.

    # <VARIANT>            {Pkt, Pkt_W, Pkt_WC}. Must match parameter given to
    ./ <VARIANT>
    # Leave this window open.  Notifications will output here.
  4. In a third window, initiate a snapshot.

    # <HH>                 Hour of snapshot according to the Unix date command
    # <MM>                 Minute of snapshot according to the Unix date command
    # <NUM_PORTS>          Number of ports in the switch. Must match parameter given
    #                      to
    # This will initiate a single snapshot with ID = 1 in a parallel fashion.
    # Port responsibilities are spread across available cores to increase the 
    # speed at which we can issue a sequence of snapshot initiations.
    # Example: ./start_snapshot 17 09 10
    # This will take snapshot for 10 ports at time 5:09 pm.
    ./ <HH> <MM> <NUM_PORTS>
    # You can also access the original, more flexible snapshot initiation 
    # that is compiled to the following program.  This one is required for
    # subsequent snapshots, etc.


  1. If the output includes the following:
Invalid table operation (DUPLICATE_ENTRY)

Please make sure to restart the switch between invocations of

  1. If prints nonsensical values, ensure that the VARIANT parameters of and match.

  2. If the crashes with:

lt-simple_switch: ../../include/bm/bm_sim/stateful.h:111: bm::Register& bm::RegisterArray::operator[](size_t): Assertion `idx < size()' failed.

Ensure that you are running with NUM_PORTS <='s NUM_PORTS


Note that this BMv2 version can only handle a small number of snapshot packets at a time---the behavioral model simply can't keep up with the pace of packets. At higher port counts, particularly with channel state notifications, initiation and notification drops occur. Our Tofino version does not have this limitation.


Source code for Speedlight, a system for Synchronized Network Snapshots








No releases published


No packages published