4ward¶
A glass-box P4 simulator — trace every decision your packet makes.
4ward is a spec-compliant P4₁₆ reference simulator that produces trace trees: a complete record of every parser transition, table lookup, action execution, and branch decision a packet encounters. At non-deterministic choice points (action selectors, clone, multicast), the trace forks — showing all possible outcomes in a single pass.
Prefer to get your hands dirty?
Jump straight to the hands-on tutorial — compile a P4 program, send packets, read traces, all from the terminal. Every command is CI-verified, so it always works.
Pick your entry point¶
| Entry point | Description |
|---|---|
| Web Playground | Edit P4 in the browser, install table entries, send packets, step through traces visually. |
| CLI | Compile a P4 program, run an STF test, read the trace — all from the terminal. |
| gRPC API | Load pipelines and inject packets programmatically via the DataplaneService and P4Runtime gRPC services. |
| C++ Library | Embed 4ward in a C++ project via Bazel, inject packets with designated-init call sites, assert with composable gtest matchers. |
Who is this for?¶
- Network engineers testing P4 programs — send a packet, see exactly what happened and why.
- Platform teams integrating a P4 simulator into test infrastructure (DVaaS, sonic-pins) via the gRPC API.
- Students and researchers learning P4 — the web playground lets you edit, compile, and trace P4 programs in the browser.
Key features¶
- Trace trees record every parser transition, table lookup, action, and branch — and fork at non-deterministic choice points to show all possible outcomes. Learn more.
- v1model, PSA, and PNA are fully implemented, with support for architecture modifications like translated port types. Learn more.
- A spec-compliant P4Runtime server provides full arbitration, table management, PacketIO, and clone/multicast support.
- Actionable error messages tell you what went wrong, show the value you sent, and list the valid options — all 75 error paths are golden-tested. Learn more.
- Type translation lets
@p4runtime_translationtypes (string port names, translated IDs) flow through the entire stack, including traces. Learn more. - The web playground gives you visual pipeline diagrams, animated trace playback, and packet dissection right in the browser. Try it.