Generating new packets

Hello,

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

Thanks!

New packets can be generated with events. This is not specific to P4, but P4-programmable devices can support this functionality (e.g., https://dl.acm.org/doi/abs/10.1145/3365609.3365848).

@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.