Is it possible to add timers for packet generators in dataplane?

Hello,
I am wondering whether it is possible to add/delete timers for packet generation in data plane. For example, can the switch start a timer when receive some specific packets and generates another packet when timeout?

Hi @asdwerrtyyui,

Last time I read about the timers (which is a very interesting feature), it was in the p4 dev mail list. I found the conversation:

Isaac Pedisich <iped@seas.upenn.edu>

“There are three pieces of functionality that these modifications implement. In brief, they are:
(…)
3) Periodic extern-helper execution: This allowed extern functions to register a callback and interval to the switch. If the extern is declared in the P4 code, the callback is called every time the interval elapses.”

and the response by Antonin:

Antonin Bas

"Also before submitting a patch, please ask yourself these questions:

  • does it belong in the core library (bm_sim) and can be used by several / most architectures, or is it architecture specific?
  • does it slow down packet processing for P4 programs that do not utilize the new feature?
  • if adding a feature to simple_switch, it is something that is required by the P4_16 v1model architecture - or at least compatible with it?

For example, 3) (timer) seems like a good candidate for the bmv2 core library, providing that it is implemented in such a way that there is no penalty for programs that do not require it."

You should probably mail Isaac and ask if he has implemented it and, possibly, shared a public fork. You particular feature about a timer and generating custom packets to be sent out (different to the one that triggered the timer) might not be implemented yet. Or not exatly like Isaac thought about imeplementing the functionality.

Maybe someone more involved on testing bmv2 can confirm if this is currently in work/merged. I believe this feature is currently not present in bmv2. However, I have not seen any reference to timers in v1model.p4 or bmv2/psa.p4. When I checked the bmv2 repository, I found the timerFired function, but it seems to be related to reading PCAP files and scheduling a packet. See my search here.

There might be other targets that have similar features in place, but this is only a guess. You will have to ask Intel, Napatech, Pensando, Netronome, etc.

If anyone else has more information please let us know :slight_smile:

Have a nice week !

Thanks a lot for your information! I’m currently working on TNA architecture, and I found some relevant description on its doc, but I cannot find the detail of implementation :thinking:.

Hi,

If you are working with a Tofino-based switch then you have to ask this question in their forum.

One thing I learnt from @vgurevich is that you should apply to be a member of “Intel Connectivity Research Program (ICRP), please use ICRP Forum for all Tofino-related questions”. :slight_smile:

Cheers,

1 Like

Thanks a lot for your reply!

In addition to @ederollora excellent recommendation, I would also like to point you to this YouTube video, that @andyfingerhut and I recorded for 2021 P4 Workshop. We discuss Tofino packet generators starting at time mark 42:18.

Happy hacking,
Vladimir

Your reply did help me a lot, thanks!