Generating new packets


Has someone ever managed to emit new packets with P4 (not only editing incomming packets)?


New packets can be generated with events. This is not specific to P4, but P4-programmable devices can support this functionality (e.g.,

@TOKTOK – Welcome to the community!

As of today, P4 programs need an input packet to do anything useful. In fact, you can think of P4 parsers and controls as a kind of callbacks that are called in response to a packet being received.

Certain P4 targets fill in the gap by providing additional components, called packet generators that can generate packets even when the network does not send anything to us. Intel(r) Tofino™ is an excellent example of such a target.

To learn more about Tofino packet generators you can watch this video. This is how P4 events are implemented in practice today without anything extra in the language.