P4 Sandbox
P4 Program:
#include
#include
header hdr { bit<32> a; bit<32> b; bit<64> c; } #ifdef _CORE_P4_ struct Headers { hdr h; } struct Meta {} parser p(packet_in b, out Headers h, inout Meta m, inout standard_metadata_t sm) { state start { b.extract(h.h); transition accept; } } control vrfy(inout Headers h, inout Meta m) { apply {} } control update(inout Headers h, inout Meta m) { apply {} } control egress(inout Headers h, inout Meta m, inout standard_metadata_t sm) { apply {} } control deparser(packet_out b, in Headers h) { apply { b.emit(h.h); } } #endif control ingress(inout Headers h, inout Meta m, inout standard_metadata_t sm) { action add() { h.h.c = (bit<64>)(h.h.a + h.h.b); sm.egress_spec = 0; } table t { actions = { add; } const default_action = add; } apply { t.apply(); } } V1Switch(p(), vrfy(), ingress(), egress(), update(), deparser()) main;
Single Port and Packet
STF file
Architecture:
V1model
EBPF
Run P4
Output: